News for hackers. Stuff that matters.
Re:Writing my own init with Go by lmm on Tuesday February 09, 2016 @10:19AM (#11065811)
Is there even any concurrency in this case? Wouldn't e.g. OCaml be a better choice?
Re:Writing my own init with Go by pjmlp on Tuesday February 09, 2016 @11:07AM (#11066173)
Personally I would use OCaml over Go, as I prefer expressive languages.

However given Oberon's influence on Go, I find positive other devs that like Go, do use it for such purposes.

OCaml already has MirageOS advertising it for system level coding. :)

Edit: Regarding concurrency, even systems programming languages older than C have built in support for concurrency. C and C++ are probably the outsiders in terms of built-in support for concurrency, language or std libs.

Re:Writing my own init with Go by JoachimSchipper on Tuesday February 09, 2016 @12:54PM (#11067193)
If you want to build a system that can survive out-of-memory conditions, you need to implement init so that it doesn't allocate memory at semi-random moments. Both Go and OCaml will fight you on that requirement. (IIRC, Go is designed to allocate memory the moment your stack grows too deep - which is usually a good idea, but not here.)

Of course, very few Unices actually survive out-of-memory - Linux runs an OOM killer by default, OpenBSD tends to crash the kernel, etc. Apparently Solaris does have a good story here. (Of course, you'd have to ensure that the system doesn't spend all its time swapping, regardless.)

Re:Writing my own init with Go by commentzorro on Tuesday February 09, 2016 @10:38AM (#11065953)
What benefit would adding the overhead of learning OCaml be to this project? It's not like a functional or immutable language would add any value here, would it?!
Re:Writing my own init with Go by davexunit on Tuesday February 09, 2016 @12:00PM (#11066712)
Using high-level languages for init systems is a great idea. In fact, we do this for the Guix System Distribution. Our init system is called GNU Shepherd, and it's written in Guile Scheme. It's great because you write services as Scheme code. For example, I have a number of Ruby web servers that I run for development at work that are nearly identical. Since services are first-class Scheme objects, I wrote a simple function that returns a service object for running a Ruby web server, specialized for a given application. For this workflow, I run Shepherd as an unprivileged user and additionally manage all of my user services like gpg-agent, emacs daemon, offlineimap, etc. No crappy external domain specific language to learn; data is code. Highly recommended.

http://www.gnu.org/software/shepherd/

Re:Writing my own init with Go by jerf on Tuesday February 09, 2016 @10:46AM (#11066009)
When C is taken as the baseline, there's a very long list of languages that look better for this sort of program. I don't see a huge reason that init has to be C, or even particularly benefits from it. (Specific init implementations may have the advantage of being battle-tested, but that's a characteristic of the program and time, not implementation language per se.)
Re:Writing my own init with Go by lmm on Tuesday February 09, 2016 @10:43AM (#11065986)
Even at this 3-line stage, the stateful log.SetOutput construct is ugly and error-prone. So I'd say a functional/immutable language would already be adding value, and that would only increase as the amount of code grows. At a minimum an init is going to involve parsing config and something similar to a state machine, both good use cases for functional languages.
Re:Writing my own init with Go by groovy2shoes on Tuesday February 09, 2016 @12:18PM (#11066902)
Init's job is to start the init scripts and then hang around to foster orphan processes. Ideally, it should not be parsing configs, but should spawn another process to do that sort of work. A good PID 1 is very, very minimal.
Re:Writing my own init with Go by lmm on Wednesday February 10, 2016 @03:46AM (#11071460)
This project isn't just a PID1 though, it's a full system. (Well at the moment it's a hello world, but that's the intent)
Re:Writing my own init with Go by rakoo on Tuesday February 09, 2016 @02:40PM (#11068122)
Erlang would look be a very interesting choice here, seeing how any Erlang system is basically a miniature OS. It even has an init already.