top | item 21860713

Lilith: x86-64 OS written in Crystal

542 points| hootbootscoot | 6 years ago |github.com | reply

251 comments

order
[+] jchw|6 years ago|reply
Wow. Preemptive multitasking, graphical window management, POSIX-like, in a programming language that to my knowledge it hasn't yet been done in... and in just several months of work.

There's no smoke and mirrors as far as I can tell. I dug back to the initial commit: https://github.com/ffwff/lilith/commit/c9fa1053dc6a22d630ee6... - and it's just bootstrapping to VGA.

Very well done, and inspiring. Makes me want to try OS dev again.

[+] ffwff|6 years ago|reply
Sorry for the late reply (being rate limited)

Thanks! Originally it only started as an experiment to see how far I could go making an OS in a high-level (higher than C at least) language, I was only planning to build a monotasking DOS system. Around this time, Andreas Kling started to show us his SerenityOS, which was one of the factors propelling me to reach this point. So shout outs to AK!

Yeah! It's pretty fun to develop an OS, albeit time consuming. You should check out the osdev wiki and the Intel/Seagate manuals, they should hopefully get you to the point where your OS can read/write/execute files, you should also take a look at how other kernels do things as a reference and actually implement them in your OS in a way that fits.

[+] onlyrealcuzzo|6 years ago|reply
Maybe it's just because I come from Ruby, but Crystal seems like an amazing language. I'm interested why it seems to be getting little attention compared to Go, Rust, & Julia. It seems in the same league to me.

Kotlin and Swift have more obvious reasons for their adoption.

[+] mberning|6 years ago|reply
Agreed. Super impressive. I really like Crystal and hope it continues to get traction.
[+] ffwff|6 years ago|reply
Oh wow someone actually posted this! Thanks a lot for the comments and criticisms guys, really means lot to me. Before I go I'll answer some questions, so ask them away!
[+] nlh|6 years ago|reply
I’ll echo what everyone else said - SUPER IMPRESSIVE and awe-inspiring work. Thanks for sharing it with the world.

I have one question: While I can read and understand each individual line of code you wrote (go Crystal!) and what each method does, etc., I’m at a total loss for how you knew what and how to build - big picture wise. Can you share a bit about your process for building the mental model of this? How do you know where to start, what modules to build, what’s needed / what’s already there, etc? What roadmap (if any) are you using?

I’m just amazed at how something like this comes together and would love to learn a bit more about the process a single dev uses to build it.

Thanks in advance!

[+] martinesko36|6 years ago|reply
How/when did you get started with coding? How did you learn your skills and how do you stay so productive?
[+] GordonS|6 years ago|reply
I just wanted to say, to build such a fully-featured OS on your own, and in such a short time frame, is an incredible achievement!

I very much look forward to reading through the code and learning more about it.

[+] kburman|6 years ago|reply
- What are the things that you have patched in crystal and libc?

- Any plan to release ISO for us to quickly run it in our local system?

[+] ssivark|6 years ago|reply
1. Would you consider this project "mature", or still rapidly evolving? Any particular aspects you are actively working on?

2. Any other project ideas you are toying around with?

Kudos and cheers!

[+] mscasts|6 years ago|reply
How old are you?
[+] martinesko36|6 years ago|reply
Is the dev a high school student? From their blog: https://fw.neocities.org/blog/5.html

If so, this is crazy impressive.

[+] ssivark|6 years ago|reply
If so, it is definitely mind-bending. Makes me wonder what people mean about not being over-ambitious, "avoiding NIH", "worse is better", "minimizing technical risk", etc. Somehow one is made to feel (by no particular person, but by the composite emergent vibe) that there are a hundred and one reasons to be more conservative. I wonder how many people have the audacity to re-imagine their software ground-up, and the technical chops to actually implement it. The verve is refreshing. Kudos to the author, and also thanks.
[+] tndl|6 years ago|reply
Apparently they've also written a language, a static site generator in that language, a brainf*ck interpreter, and a markdown parser, among other things. Super impressive stuff. https://github.com/ffwff?tab=repositories
[+] hota_mazi|6 years ago|reply
Two things that I immediately respected about Crystal's landing page [1]:

- It shows numerous code snippets covering various functionalities. Not just "Hello world" but code samples that give you a very solid flavor of the language.

- Its spinning logo can be manipulated with the mouse.

[1] https://crystal-lang.org/

[+] andrekandre|6 years ago|reply
i really like that spinning crystal; its a small thing really, but i find it very endearing
[+] kick|6 years ago|reply
This is really impressive! Crystal was just barely on my radar until now: it's a lot higher up now.

For anyone unfamiliar:

https://crystal-lang.org/

[+] sergiotapia|6 years ago|reply
Crystal has the most badass color on Github. Solid black.
[+] maxpert|6 years ago|reply
I've been following Crystal for long time (Shameless plug I've been running a geo-location service in production for years now https://gitlab.com/maxpert/crlocator and it works flawlessly). Despite the setbacks in past Crystal has continued to evolve and I am waiting for fully baked version 1. I am not surprised that Crystal can pull of something like running a complete operating system. Modern language landscape is getting populated and brings novel ideas (Rust, Zig, Golang, Julia); and Ruby's nice syntax with efficiency of compiled language IMOH still remains desirable for a lot of us.
[+] pjmlp|6 years ago|reply
Lovely, very inspiring to see "not yet another UNIX clone in C", in a language like Crystal.

Wishes of a successful long term project.

I will be adding it to my OS list.

[+] ksrm|6 years ago|reply
Is your OS list public?
[+] lykr0n|6 years ago|reply
Wow. That's impressive.

Crystal is a solid alternative to Go. I gave it a solid look when figuring out which language I should learn. The only reason Crystal didn't make it is because it's just missing some core features. The one that sticks out is there is no way to get the length of a channel last time I looked.

But this is impressive and I can't wait to see what's next

[+] todotask|6 years ago|reply
I have the same feeling as yours. I wish Crystal web server could be customisable, and lack of gRPC, HTTP/2 (only separate repo) and QUIC going to take more time to implement.
[+] Thaxll|6 years ago|reply
It's missing many things that make it a viable language:

- libraries

- community

- support

The language itself is not even finish or properly tested.

[+] skocznymroczny|6 years ago|reply
How does memory management work in Crystal. Is it RC or GC or manual?

As a D user, I've been curious about Crystal for a while, but until it gets proper Windows support I won't be playing with it too much.

[+] ffwff|6 years ago|reply
Out of the box, Crystal does garbage collection through the boehmgc library, however if you pass in some compiler flags you can get application to not use GC.

As for my OS, I wasn't gonna port libgc, and since I have prior knowledge of building a GC in rust (very badly!) I decided to make a tri-color concurrent, mostly precise (through compiler patches), garbage collector, in Crystal.

[+] bbmario|6 years ago|reply
This is one of the most fun things I've seen in a while. Congrats.
[+] xbhdhdhd|6 years ago|reply
Just this morning I was pondering the same thing in Elixir.

I wonder if Elixir and Crystal compete for ruby developers to pick up

[+] abhijat|6 years ago|reply
Interestingly apart from the ruby like syntax they seem to be quite different languages from my limited exposure, in terms of the domains they target (elixir - distributed systems, crystal - whatever go/rust are known for minus distributed systems?), the type system (dynamic vs static), deployment story (elixir - mix based, crystal - binary deployment), the standard libraries they leverage etc.

It seems the sum total of them covers a lot of ground from writing quick CLI apps to large distributed systems for developers familiar with Ruby.

[+] andykx|6 years ago|reply
I think Ruby developers are a lot more likely to switch to Crystal than Elixir. Elixir encourages a much more functional style than I think Ruby developers are used to.
[+] yellowapple|6 years ago|reply
¿Por qué no los dos? While I haven't tried it yet, Crystal seems like a viable candidate for writing NIFs/ports for Elixir apps.
[+] unixhero|6 years ago|reply
Crystal is soo good. I could read the code and understand it.
[+] lostgame|6 years ago|reply
What is that beautiful desktop wallpaper? any source?
[+] fsiefken|6 years ago|reply
So how would this compare performance wise to a lightweight linux with lxde? Can you run this on a raspberry pi and get good performance? What are the minimal memory requirements?
[+] saagarjha|6 years ago|reply
I doubt this is usable for general purpose work; many filesystem interfaces are unimplemented.
[+] gigatexal|6 years ago|reply
The name is great too! Just in time for co-marketing with Diablo 4 ;)
[+] fit2rule|6 years ago|reply
I wonder what the plan is for a media layer - audio and video streaming, etc?

Sure would be fun to write a content-creation app - i.e. DAW - for such an environment.