Live data from Hacker News

Gopher-OS: A Proof of Concept OS Written in Go

github.com

51–60 of 84 posts

Re: Gopher-OS: A Proof of Concept OS Written in Go

#51

Earlier quoted context omitted.

Having 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)"

Hey, 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.

It might have been helpful for GP to note that the quote comes from Linus Torvalds. He said it while he was first developing Linux

Re: Gopher-OS: A Proof of Concept OS Written in Go

#52

Earlier quoted context omitted.

Well, 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.

> Well, the Go runtime is written in Go itself. That's a bit of a stretch. The runtime uses special pragmas that are not available to normal programs. I don't think it would be possible to write Go's GC in Go unless these special pragmas existed: https://github.com/golang/go/blob/57df2f802f0417f08100ff8002... Also, there are magical variables in the runtime that the compiler knows about and special-cases: https://git…

That is the magic of cross compilation.

There is already a compiler that knows those special pragmas, one just needs to add a new bare-metal backed to it.

As for writing Go without a GC, just like in any other GC enabled systems programming language, by not using language features that require GC in the lowest layer, which the other packages then depend on.

Example in Oberon, https://people.inf.ethz.ch/wirth/ProjectOberon/Sources/Kerne...

Also even ANSI C requires some Assembly or compiler extensions to fully implement libc.

Re: Gopher-OS: A Proof of Concept OS Written in Go

#53
post #21

Earlier quoted context omitted.

Well, 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.

> And you can write Go without the runtime, the same way the compiler is. The compiler does depend on the runtime AFAIK > The hard part is that the runtime is indeed build on OS primitives (syscall mostly), that you have to implement yourself. This is what I was referring to. I don't know how you would do this without patching the language.

By using a mix of cross-compiling and some Assembly help, just like C needs some help beyond what ANSI C specifies.

Re: Gopher-OS: A Proof of Concept OS Written in Go

#54
post #44
post #28

Is 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.

Go has an assembler, but its goal is not to build, say, a bootloader: https://golang.org/doc/asm

The 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.

Re: Gopher-OS: A Proof of Concept OS Written in Go

#55
post #23
post #16

Earlier quoted context omitted.

Looks like it's a matter of not importing almost any libraries other than "unsafe".

Not 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.

Just 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.

Re: Gopher-OS: A Proof of Concept OS Written in Go

#56
post #54
post #44

Earlier quoted context omitted.

Go has an assembler, but its goal is not to build, say, a bootloader: https://golang.org/doc/asm

The 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…

Just like C in the 80's and 90's, and it wasn't a problem for its adoption.

Re: Gopher-OS: A Proof of Concept OS Written in Go

#57
post #54
post #44

Earlier quoted context omitted.

Go has an assembler, but its goal is not to build, say, a bootloader: https://golang.org/doc/asm

The 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…

I 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...) 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.

Re: Gopher-OS: A Proof of Concept OS Written in Go

#58
post #45

Hi, 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 investi…

Your project reminds me that I wish GOOS=efi to be a thing.

Ugh that would be completely amazing.

Re: Gopher-OS: A Proof of Concept OS Written in Go

#59
post #45

Hi, 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 investi…

Your project reminds me that I wish GOOS=efi to be a thing.

Wasn't there once a "tiny" runtime?

https://codereview.appspot.com/3996047/

Re: Gopher-OS: A Proof of Concept OS Written in Go

#60

Maybe 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)

Bikeshedding, we can also start discussing why `println` doesn't print anything on the printer, apple doesn't sell any fruits and their ipad is not really targeted to women during period, microsoft has no double glazed windows offers, oracle without cloud based prophecy api and why ml lang and machine learning are stealing established, widely deployed in most kitchens millilitres measure - nobody gives a crap.
Post reply on HN