The Art of How To Program A Computer — Concurrently

Ardhi
2 min readSep 4, 2017
For the sake of read worthiness

Fuzzy, I wish I remember what is the first programming book I read. A book that has changed my life forever, those simple and easy examples of how to print an output to console using C.

Nowadays I work with much higher level languages where they hides so many details that (arguably) actually matter. Then today I reached a new level of clueless code that cost the life-hood of many.

Checkout Go code below and guess what could go wrong with that?

Have you realized what could go wrong? No? I’ll tell you the output then, it’s all 10. Not 0 to 9, just 10 ten times.

Compare with the following Elixir code below:

Above code will prints 0 to 10 in an unordered manners, which is expected.

Now, what will happen if an unexperienced Go programmer (me) found that code and never get a warning that it will be disastrous? Deploy it to production. But.. why you don’t have a test? Ever tried to create a test of primitive goroutine? Any success story?

Cool, we can use WaitGroup. Not really, that code meant to be a fire and forget, giving it under Fork/Join alike will be inappropriate.

Yeah, then what next? Ranting about having no direct memory access?

It comes to my personal opinion, that a I now prefer working with a higher level language where all those low level and unsafe details were hidden for me. Hence I can focus on writing a productive and non-idiomatic but safe code.

I will never say a low level (system) language is bad, but it’s just there for you to create what it meant to be in the first place. This is from Go FAQ:

Why are you creating a new language?

Go was born out of frustration with existing languages and environments for systems programming.

Compare to Elixir’s:

Elixir is a dynamic, functional language designed for building scalable and maintainable applications.

Two different views of what the language purpose is. This also reflected into its tooling, documentation, and the language directions.

For the sake of more debates and rants, I’ll share the snippets of comparable and minimal source code to run a Hello Concurrent World.

--

--