13 ms·
Writing a Unix clone in about a month
- lupusreal 2y agoMissed opportunity to call it Drewnix.
- jrpelkonen 2y agoFun fact: Linus Torvalds originally named his fledgling OS as “Freax”, but it was an FTP site admin who came up with “Linux” and the rest is history. So perhaps the opportunity is not completely missed…
- davisr 2y agoNo he didn't. "I called it Linux originally as a working name. That was just because "Linus" and the X has to be there--it's UNIX, it's like, a law--and what happened was that I initially thought that I can't call it "Linux" publicly because it's just too egotistical. That was before I had a big ego." https://yewtu.be/watch?v=kZlOCHYu1Vk https://yewtu.be/watch?v=kZlOCHYu1Vk
- andsoitis 2y agoImpressive, super cool, and inspiring! Example of “creating something impressive in X days” requires a lot of experience and talent that is built over years.
- ezconnect 2y agoHe only have Helios so he just integrated a few missing parts.
- PaulDavisThe1st 2y ago... and also a previously kernel implementation called Helios to provide a lot of the lowest level code. Not trying to knock down the accomplishment, but DD is pretty open about the fact that a lot of the speed of this project was dependent on having done Helios first (and reusing code from it).
- palata 2y ago...which is part of the "experience and talent built over years", I guess? :-)
- pushedx 2y agoAlso the creator of KnightOS, written entirely in Z80 assembly, more than 12 years ago! https://www.ticalc.org/archives/files/fileinfo/463/46387.html https://www.ticalc.org/archives/files/fileinfo/463/46387.htm...
- ruined 2y agoholy shit. they're already a living legend but somehow i didn't make this connection
- lupire 2y agohttps://drewdevault.com/2020/01/27/KnightOS-was-interesting.html https://drewdevault.com/2020/01/27/KnightOS-was-interesting.... Sadly defunct. I guess the real OS was the syscalls we made along the way.
- beryilma 2y agoVersus now... I changed the text on a button with an internationalized string. It only took me about a week. I put the English string in the catalog, updated a number of tests, run the tests on the local system, pushed the change to staging cluster, fix unanticipated test failures, push the change to production, contact the translators to have the string translated to a number of languages, and have documentation updated.
- Muromec 2y agoSo... It goes to production before you get translations to all the languages?
- beryilma 2y agoIn my case, the "production" does not really become visible to users right away. Perhaps, I should have called it "pre-production".
- lupire 2y agoI suggest you use translation management tools, so the translator gets the strong as soon as you add it to the catalog. Buy anyway there's no "then vs now" when you are really comparing "prototype" to "deliver to users". It took Unix decades to get those strings translated.
- saagarjha 2y agoDrew is smart and his timeline is short but I think it’s the wrong way to look at it if you just put him on a pedestal for it. Making a UNIX clone is a typical undergrad project at most universities. Extending that to something that is complete is something that requires perseverance, not special genius.
- bjoli 2y agoI think it is a matter of how you are exposed to programming. I started with pascal at 9, and I wrote my first (VM-)bootable OS in junior high school (around the age of 14). Not as fancy as this of course, but it booted into an environment not unlike r4rs scheme - based on SIOD. A scheme error was handled but any C errors would immediately lead to a kernel panic. I am not a programmer today, but I can still wrap most of my head around many low level concepts. I can't, however, write anything resembling a modern web page. Nor can I understand how any larger JS application works.
- smugma 2y agoNachOS was developed at Berkeley and maintained at UW. Both are top-ranked CS programs. Undergraduates are expected to add features to the core OS e.g. virtual memory, not build it from scratch. https://en.wikipedia.org/wiki/Not_Another_Completely_Heuristic_Operating_System https://en.wikipedia.org/wiki/Not_Another_Completely_Heurist... https://homes.cs.washington.edu/~tom/nachos/ https://homes.cs.washington.edu/~tom/nachos/
- 8organicbits 2y agoCode is here: https://git.sr.ht/~sircmpwn/bunnix/tree/master https://git.sr.ht/~sircmpwn/bunnix/tree/master GPLv3 license.
- pjmlp 2y agoQuite cool, by making use of Hare instead.
- samatman 2y agoI was interested in Hare until I found this immensely self-defeating FAQ item: https://harelang.org/documentation/faq.html#will-hare-support-windows-or-macos https://harelang.org/documentation/faq.html#will-hare-suppor... As a baseline, I support developers using whatever license they would like, and targeting whatever operating systems, indeed, writing whatever code they would like in the process. That doesn't make this specific policy a good idea. Even FSF, generally considered the most extreme (or, if you prefer, principled) exponents of the Free Software philosophy, support Windows and POSIX. They may grumble and call it Woe32, but Stallman has said some cogent things about how the fight for a world free of proprietary software is more readily advanced by making sure that Free Software projects run on proprietary systems. They do at least license the library code under MPL, so merely using Hare doesn't lock you into a license. But I wonder about the longevity of a language where the attitude toward 95+% of the desktop is "unsupported, don't ask questions on our forums, we don't want you here". Ironically, a Google search for "harelang repo" has as the first hit an unofficial macOs port, and the actual SourceHut repo doesn't show up in the first page of results. Languages either snowball or fizzle out. I'm typing this on a Mac, but I could pick up a Linux machine right now if I were of a mind to. But why would I invest in learning a language which imposes a purity test on developers, when even the FSF doesn't? A great deal of open source and free software gets written on Macs, and in fact, more than you might think on Windows as well. From where I sit, what differentiates Hare from Odin and Zig, is just this attitude of purity and exclusion. I wish you all happy hacking, of course, and success. But I'm pessimistic about the latter.
- stonogo 2y agoSounds like you and the Hare people have different definitions of success. As for "languages either snowball or fizzle out," I feel like that's pretty dismissive of a lot of languages that have been steadily marching on for decades even without this rockstar status. Not every band has to hit the Billboard charts to be worth listening to.
- jampekka 2y ago"The goal of Hare is not to achieve the broadest possible reach, but to be a part of a broader system which effectively achieves Hare’s goals."
- anta40 2y agoVery cool. Most of these Unix clones are usually written in C. This one is written in a new programming language.
- balder1991 2y agoI only read part of the FAQ. I find the desire to keep the complexity low by limiting the compiler lines of code and not using LLVM interesting, but I wonder how practical it is. The FAQ admits that because of this, it generates slower code. So it shifts the complexity to the software codebase, by telling the users to “use assembly where needed”. Seems a bit like Python’s philosophy of not introducing too much optimizations to prevent the runtime complexity from spiraling out of control.
- PhilipRoman 2y agoI doubt it is a real problem for anything other than number crunching. I like to use tcc during development (which does very little, if any optimizations) to speed up compilation and I never noticed any regressions in performance, even for GUI software. Throughput just isn't that big of a deal for most applications (although latency and resource usage is, but that's not affected by choice of compiler).
- fuzztester 2y agoYou are using C (with TCC) for GUI apps? with what GUI framework or library?
- PhilipRoman 2y agoI used SDL2. Not actively working on that project anymore, but I picked it due to requirements - fast startup, low latency, low memory usage, portability anywhere (linux on multiple distros, CPU architectures and multiple rendering backends, any Windows version from XP to 11...). C fits that very well IMO and I don't regret choosing it.
- nickcw 2y agoHare looks like an interesting language. Though this limitation will limit its adoption in this multicore age I think: From the FAQ https://harelang.org/documentation/faq.html https://harelang.org/documentation/faq.html .... Can I use multithreading in Hare? Probably not. We prefer to encourage the use of event loops (see unix::poll or hare-ev) for multiplexing I/O operations, or multiprocessing with shared memory if you need to use CPU resources in parallel. It is, strictly speaking, possible to create threads in a Hare program. You can link to libc and use pthreads, or you can use the clone(2) syscall directly. Operating systems implemented in Hare, such as Helios, often implement multi-threading. However, the upstream standard library does not make reentrancy guarantees, so you are solely responsible for not shooting your foot off.
- senkora 2y ago> multiprocessing with shared memory if you need to use CPU resources in parallel This is actually pretty powerful. I personally prefer it for most purposes, because it restricts the possibility of data races to only the shared memory regions. It's a little like an "unsafe block" of memory with respect to data races.
- pjmlp 2y agoI changed from a strong threads believer and dynamic libraries plugins, exactly because of attack vector and host program stability.
- packetlost 2y agoI just wish it had closures
- guenthert 2y ago> However, the upstream standard library does not make reentrancy guarantees, so you are solely responsible for not shooting your foot off. Well, that not only rules out multi-threading, but also usage in interrupts. Quite a limitation for a "systems programming language" methinks.
- throwaway0- 2y ago[flagged]
- mtillman 2y agoThis is really cool. Reminds me of the original Unix was invented in a couple weeks while Ritchie's family went on vacation to CA to visit his in-laws. Source: UNIX: A History and a Memoir Paperback – October 18, 2019 by Brian W Kernighan (Author)
- balder1991 2y agoBut I think it’s relevant to say that before writing Unix he was working on Multics for a long time already. Unix was a “simplified” version of it, if I remember well. So it didn’t “spring out of thin air.”
- trollerator23 2y agoAbsolutely.
- fuzztester 2y ago>So it didn’t “spring out of thin air.” Right. Almost nothing does. You see, it's https://en.m.wikipedia.org/wiki/Turtles_all_the_way_down https://en.m.wikipedia.org/wiki/Turtles_all_the_way_down
- eichin 2y agoMmm, even early versions ended up being more the "anti-multics" than actually simplified-from, despite the name pun...
- DiggyJohnson 2y agoWhere did the quoted text come from? Something might have gotten edited.
- teleforce 2y agoUnix was a kind of play word for Unique as an anti-thesis for Multics that latter was originally designed for modern multi-user and multi-process OS. Ironically as any real-world OS Unix eventually becomes multi-user system similar to Multics but the name stucked. Granted Unix has a very simple (as in simple as possible but no simpler) multi-user permission and security system that work reliably for many decades until now. Of all the organizations NSA actually even come up with a better replacement for the modern Unix permission and security model with SELinux, but most users just ignored and disabled SELinux although it's installed by default by many major Linux distros [1]. [1] SELinux is unmanageable; just turn it off if it gets in your way: https://news.ycombinator.com/item?id=31176138 https://news.ycombinator.com/item?id=31176138
- LightFog 2y agoIt was really cool watching the ~daily updates on this on Mastodon - seeing how someone so skilled gradually pieces together a complex piece of software.
- herodoturtle 2y agoLink to the mastodon thread (from Drew’s article), for those that are interested: https://fosstodon.org/@drewdevault/112319697309218275 https://fosstodon.org/@drewdevault/112319697309218275
- kpw94 2y ago> I also finally learned how signals work from top to bottom, and boy is it ugly. I’ve always felt that this was one of the weakest points in the design of Unix and this project did nothing to disabuse me of that notion. Would love any resources that goes in more details, if any HN-er or the author himself knows of some!
- palata 2y agoI wanted to say the exact same thing! I would love to get more details about that.
- eterps 2y agoWould love to read a blog post about that.
- retrac 2y agoSignals are at the intersection of asynchronous IO/syscalls, and interprocess communication. Async and IPC are also weak points in the original Unix design, not originally present. Signals are an awkward attempt to patch some async IPC into the design. They're prone to race conditions. What happens when you get a signal when handling a signal? And what to do with a signal when the process is in the middle of a system call, is also a bit unclear. Delay? Queue? Pull process out of the syscall? If all syscalls are async (a design principle of many modern OSes) then that aspect is solved. And if there is a reliable channel-like system for IPC (also a design principle of many modern OSes) then you can implement not only signals but also more sophisticated async inter-process communication/procedure calls.
- Joker_vD 2y agoAs I wrote in some older discussion about UNIX signals on HN, the root problem (IMHO, of source) is that signals conflate three different useful concepts. The first is asynchronous external events (SIGHUP, SIGINT) that the process should be notified about in a timely manner and given an opportunity to react; the second is synchronous internal events (SIGILL, SIGSEGV) caused by the process itself, so it's basically low-level exceptions; and the third is process/scheduling management (SIGKILL, SIGSTOP, SIGCONT) to which the process has no chance to react so it's basically a way to save up on syscalls/ioctls on pidfds. An interesting special case is SIGALRM which is an asynchronous internal event. See the original comment [0] for slighlty more spellt out ideas on better designs for those three-and-a-half concepts. [0] https://news.ycombinator.com/item?id=39595904 https://news.ycombinator.com/item?id=39595904
- amelius 2y agoWaiting for an OS that treats GPU(s) as a first class citizen ...
- eterps 2y agoThat wouldn't be too hard if GPU's would have a stable interface. Try programming a GPU in Assembly language and see how that goes. The experience sucks, but that's the level that needs to be targeted in case of an OS.
- eterps 2y agoFor example, in the past Amiga computers had a 'GPU' (although much less powerful than todays GPUs) with a stable interface. It was a first class citizen in its OS. It also was incredibly easy to target in Assembly language.
- saagarjha 2y agoWhat should this OS do?
- sph 2y agoIf programming GPU drivers was not something only a handful of employees with NVIDIA or AMD badges could do (because of NDAs, non-public documentation and immense complexity), somebody would have tried.
- 2y ago
- calvinmorrison 2y agohey drew! did writing this project give you any Hare-y situations you hadn't run into before, or maybe - reached into corners not yet probed by Hare and gave you ideas for a new feature or edge case that was scary?
- thefaux 2y agoImpressive work but I feel this approach is the hard and brittle way to write an os. The easier and more portable way is to write the os as a guest in a host language. You start with a simple shell with the print command and build from there.
- AtlasBarfed 2y agoAre there "waypoint" commits for major milestones? Id really like to see those. Like PC bootstrap, basic kernel action loops, process forking, yada yada
- westurner 2y agoFrom "Linux System Call Table – Chromiumos" https://www.chromium.org/chromium-os/developer-library/reference/linux-constants/syscalls/ https://www.chromium.org/chromium-os/developer-library/refer... https://news.ycombinator.com/item?id=33395777 https://news.ycombinator.com/item?id=33395777 : > google/syzkalleR > Fuschia / Zircon syscalls: https://fuchsia.dev/fuchsia-src/reference/syscalls https://fuchsia.dev/fuchsia-src/reference/syscalls
- westurner 2y agoAnd a new one, a new syscall this year: mseal() "Memory Sealing "Mseal" System Call Merged for Linux 6.10" https://news.ycombinator.com/context?id=40474551 https://news.ycombinator.com/context?id=40474551
- userbinator 2y agoThe userspace is largely assembled from third-party sources. That answered my initial surprise of clicking on the ISO and getting a 60MB download. For comparison, Linux 0.01 was a 71k download, but contained only the kernel source.