8 ms·
Gopher-OS: A Proof of Concept OS Written in Go
- infogulch 9y agoThis seems to be in very early development with the first commits in late March and a single line readme. Interested to see where it goes and what problems they encounter.
- Numberwang 9y agoI've never really understood OS:es. Why are so many people creating them, yet so few have any success? I've must have seen a dozen OS:es over the past two years on HN, most developed by people having no confidence in calling it a serious effort. Why care about OS:es when there is no room for anyone on that level of abstraction apart from a handful developers at MS, Apple and Google?
- castis 9y agoMost of the ones I've seen were learning experiments. A really really good way to understand something is to build it.
- nkozyra 9y agoIf you think of an OS as solely something that sits on your desktop, then sure, but this is fairly myopic (and defeatist). There are lots of small, proprietary and often embedded operating systems that rely on the same principles established by present and past OS. Writing operating systems is also a great way/introduction to work on operating systems, and it's a fairly distinct area of development. It's hard to get day-to-day overlap if you're working on things that don't have the constraints and operating system does.
- kajecounterhack 9y agoIt's usually a learning project. The same way tons of people implement web servers but ultimately use something out of the box in production. https://github.com/klange/toaruos https://github.com/klange/toaruos << example of a hobby OS taken farther than most I've seen.
- xj9 9y agoever heard of fun? or learning? not everything needs to have the potential for monetization to be worthwhile; it can just be interesting. this is actually something that has been difficult for me to internalize, but i am much happier for it. no less ambitious, but i've found that there are a lot of nice (pointless) things that contribute to my happiness in addition to success.
- infogulch 9y agoOperating systems' success is fundamentally based on their popularity. Popularity resembles an exponential distribution, therefore there can only be a small number of popular ones with a long long tail of less and less popular ones. Here, popularity is a positive feedback loop, where the more popular it is the more developers target it, and the more it's targeted the more it's developed internally, which makes it better and therefore more popular. That doesn't mean it's useless to develop them. If you set your sights low (playing around, learning, academic) you can still benefit from them without them being a huge success by popularity standards.
- skocznymroczny 9y agoHaving no confidence in the project is part of the path to success "I’m doing a (free) operating system (just a hobby, won’t be big and professional like gnu)"
- Numberwang 9y agoHey, good luck with it! I'm thinking maybe I'm just wired differently. If I have a side project or hobby I still want to feel maybe not success but a sense of completion. An OS project I suspect will always end when you no longer have time for it or are stuck somewhere. I'd be annoyed by that.
- bradyd 9y ago@skocznymroczny was actually quoting a post from Linus Torvalds when he first released Linux.
- garfij 9y agoIt might have been helpful for GP to note that the quote comes from Linus Torvalds. He said it while he was first developing Linux
- AdamJacobMuller 9y agoYour reply, while I'm sure it is genuine, couldn't be more on-point by being more wrong. You really don't know, and cannot know, where the next Linux is going to come from. I don't know if this will be it, just by considering probabilities, it probably won't be, but it could. Even at the worst case, the author of a project like this is going to learn A LOT from it, and the people who read through the source code are also going to learn a lot. Writing an OS in a higher-level language absolutely is beneficial to people who want to learn more about how hardware works and interacts with the OS, without needing to delve into something as complex as the Linux/BSD kernels. At a minimum, I think projects like this directly create contributions to other "real" kernels by teaching developers how to do kernel/OS programming.
- 0xdeadbeefbabe 9y ago> Why care about OS:es when there is no room for anyone on that level of abstraction apart from a handful developers at MS, Apple and Google? There is as much room as there are people frustrated with the "state of the art." Edit: Have you seen this apple commercial https://www.youtube.com/watch?v=OYecfV3ubP8 https://www.youtube.com/watch?v=OYecfV3ubP8. Yes it is from 1984 and you might think it doesn't apply.
- mcbits 9y agoThe reasons aren't so different from the reasons for writing any other software. 1. Even if the project never replaces the other software you use, you gain a better understanding of that other software by solving some of the same problems, making the same mistakes, learning the same lessons. 2. You may have special requirements that don't make sense to add to an existing project aimed at a broader audience. This is where a lot of niche microcontroller OSes come from. 3. You have a crazy idea that would be hard to explore within the architecture of an existing project. If it turns out to be crazy enough to work, then maybe people will do the work to migrate it to the mainstream. 4. Everyone has a little dream that the masses will find great value in their work and flock to it, supplanting the status quo. Like becoming a billionaire, it essentially never happens, but you can't blame people for trying.
- laumars 9y ago5. fun. A lot of people -myself included- enjoy solving puzzles for fun. So I often set myself weird or obscure challenges to solve with code.
- bitwize 9y agoWhy care for computers when there's a worldwide market for maybe five, tops?
- weberc2 9y agoThat's not a good comparison. The original quote was made in reference to the total number of machines, not to the number of models.
- lkdjalsdjfasdf 9y agoLookup Redox
- eberkund 9y agoProbably should have let this develop a little further before posting it.
- edoceo 9y agoNo way, raw stuff on HN, moar please. Lots of learnding for all
- weberc2 9y agoI don't know anything about OS development, but how do you implement an OS in a language whose runtime depends on an OS?
- bpicolo 9y agoLooks like it's a matter of not importing almost any libraries other than "unsafe".
- weberc2 9y agoNot only that, but you'd have to take care not to do anything that would trigger an allocation, since you don't have memory management.
- pjmlp 9y agoJust on the very lowest layer, then GC is just yet another kernel service. There are lots of GC enabled OSes and research papers to learn from.
- nickpsecurity 9y agoOn the lowest levels only. The rest of the OS can be GC'd. See Oberon, JX OS, and House in Haskell for instance. That Go has a low-latency GC makes it even better for that usage. http://programatica.cs.pdx.edu/House/ http://programatica.cs.pdx.edu/House/
- dullgiulio 9y agoWell, the Go runtime is written in Go itself. And you can write Go without the runtime, the same way the compiler is. The hard part is that the runtime is indeed build on OS primitives (syscall mostly), that you have to implement yourself. You have to forgo all the niceties of having a runtime but you can do it. Definitely not the most productive use of Go, but it's fun and you learn a lot.
- weberc2 9y ago
- pjmlp 9y agoGood luck with the project, nice to learn about it.
- fenwick67 9y agoWith the S not capitalized in "Gopher-Os" I read it like a cereal (like Cheerios).
- achilleasa 9y agoHi, I am the author of gopher-os. It started as a fun research project to learn more about the Go runtime internals and I didn't really expect it making it to HN. If you take a look at the Go runtime sources you will notice that all the low-level arch/os-related bits have been split into separate files which usually invoke some syscalls (e.g. the memory allocator eventually calls mmap) The idea I am currently investigating is to first provide an implementation for things such as physical memory allocation and virtual memory mapping which would ultimately allow me to bootstrap the Go allocator. From that point onwards the plan is to incrementally add more features and gradually initialize the rest of the runtime. This is much more difficult than it sounds as all code must be written in such a way to prevent the compiler from calling the runtime allocator (no variables allowed to escape to the heap).
- driusan 9y agoI started writing a kernel in Go a while ago (and since abandoned it due to not having time.. I got as far as having a simple built in shell that let you do ls and cat on a FAT filesystem). The part about memory allocation and virtual memory wasn't much more difficult than it would be if you were implementing your kernel in C or some other low level language. The hard part is once you get memory and paging working, you'll need a syscall interface. If you want to be able to run Go userspace programs, that means you need to implement the syscall interfaces for an OS that's already supported, and can't just go out and design your own, and at that part it starts getting a lot less fun.
- laumars 9y agoCould you instead write your own syscalls but also your own $GOOS target for the compiler? That's possibly more work but it's the approach I would have taken as it seems more fun than just replicating Linux (or whatever) syscalls.
- driusan 9y agoSure, you could, but then you need to fork the Go compiler too (and hopefully eventually get your GOOS target mainlined, which seems unlikely unless your OS gets popular) or you could do your userspace in something other than Go and implement what you need for that. My point was just the memory allocation and paging isn't significantly different than it would be writing an OS in any other language, it's once you get to the part where you need to implement other people's interfaces/standards to make a viable product that it starts bogging down (if you go that route. If you go your route, then you have two major projects instead of one: writing an OS, and adding a new OS target to an existing toolchain.)
- josteink 9y agoMaybe I'm old, but I immediately assumed this was an OS built around the Gopher-protocol[1], whatever that would mean in practice. Gopher is already an established name, so the naming seems a bit unfortunate. [1] https://en.m.wikipedia.org/wiki/Gopher_(protocol) https://en.m.wikipedia.org/wiki/Gopher_(protocol)
- Jaruzel 9y agoThe subsummation of the word 'Gopher' into the Go language eco-sphere irritates me also. I believe it has something to do with the Language having adopted the Gopher (animal) as their mascot? Just because something is no longer in common/widespread use, does not mean you can come along and use its meaning or name on your shiny new product. Gopher the protocol maybe niche these days, but it's not dead. The continued use of the term 'Gopher-XYZ' by the Go language people will only accelerate the death of the Gopher protocol, which although inevitable it does not mean it should be erased from history by something else.
- canes123456 9y agoThere a tons of name conflicts for things that are more popular than the gopher protocol. If the creators wanted to avoid this they need to pick a unique name.
- treve 9y agoMy pet peeve is Atom the protocol and Atom the text editor. They're obscuring a format and a protocol that's much more important for the web than another text editor is, and they're doing the world a disfavor as a result.
- elinchrome 9y agoEven worse is when Justin Timberlake did that song "Cry Me A River", when there was already an excellent song by the same name. It just obscures the existing song, and does the world a disservice.
- mhh__ 9y agoIs Go suitable for OS/Systems development? Inline Assembly would be nice to have. I'm guessing a project like this will need to implement the Go runtime given that (I'm assuming) it uses posix (Or windows etc.) system calls.
- lloeki 9y agoGo has an assembler, but its goal is not to build, say, a bootloader: https://golang.org/doc/asm https://golang.org/doc/asm
- driusan 9y agoThe Go assembly language is actually one of the things that make doing something like this difficult. Go uses the Plan9 assembly syntax but doesn't support GNU asm syntax. gccgo uses GNU asm syntax but doesn't support Plan9 assembly. The Go linker doesn't allow you to not link in the Go standard library runtime, which means you need to use gccgo to write a kernel. The end result is that you can't do something that's buildable with the standard Go toolchain, and even if Go were to add a "don't link the runtime" option there'd be no way to incrementally port your ASM over one bit at a time. It's all or nothing.
- pjmlp 9y agoJust like C in the 80's and 90's, and it wasn't a problem for its adoption.
- achilleasa 9y agoI take a slightly different approach for my implementation that allows me to use the standard go toolchain. I use nasm for the early ASM code and patch the go build tool's output (see: https://github.com/achilleasa/gopher-os/blob/master/Makefile#L39 https://github.com/achilleasa/gopher-os/blob/master/Makefile...) to bypass the link step and replace it with a manual call to ld that links the go object files with the output from nasm. I will be talking about this approach in more detail in GolangUK '17.
- barsonme 9y agonice! btw, wrt the `Memset` function, if you have something like func foo(b []byte) { for i := range b { b[i] = 0 } } the compiler turns it into a `memclr` call which can be pretty fast: https://github.com/golang/go/commit/f03c9202c43e0abb130669852082117ca50aa9b1 https://github.com/golang/go/commit/f03c9202c43e0abb13066985... Perhaps there could be a performance boost to a simple for-range loop if `value == 0`?
- solidsnack9000 9y agoPerhaps it can have a JS shell? And store data in HTML elements instead of files?
- ungerik 9y agoA lightweight Go OS would be nice for virtualization environments. Deploy your Go server/service with the minimal needed OS into the cloud...
- saintfiends 9y agoInteresting project. What's all this voodoo inside Makefile, I would love more comments in there. I think that would be the first step for anyone wanting to contribute, to understand the Makefile. @echo "[go] compiling go sources into a standalone .o file" @GOARCH=$(GOARCH) GOOS=$(GOOS) go build -n 2>&1 | sed \ -e "1s|^|set -e\n|" \ -e "1s|^|export GOOS=$(GOOS)\n|" \ -e "1s|^|export GOARCH=$(GOARCH)\n|" \ -e "1s|^|WORK='$(BUILD_ABS_DIR)'\n|" \ -e "1s|^|alias pack='go tool pack'\n|" \ -e "/^mv/d" \ -e "s|-extld|-tmpdir='$(BUILD_ABS_DIR)' -linkmode=external -extldflags='-nostartfiles -nodefaultlibs -nostdlib -r' -extld|g" \ | sh 2>&1 | sed -e "s/^/ | /g" edit I think I understand what's happening here, funny how writing it down helps one understand. It's just building up a build script with sed and executing it. The thing was I didn't know sed could do that. TIL