Programming Erlang Book Club

Still reading…
Finished chapter 13 about how to seperate working code from error handling, again a very good concept I think, as I don’t like all the defensive code I’m used to write in C#.

At the moment I’m hyped about the OTP 24 release, Erlang just got so much better :smiley:

I really wanna use Erlang more, just I don’t know how i can achieve that. At least I had the opportunity to introduce Akka in my company, which brings some Erlang concepts to C#:slight_smile:

3 Likes

I really need to get back into this book Rainer! :see_no_evil:

The Erlang team have been doing a great job - I think out of all of our portals, Erlang has the most releases recorded :sunglasses: (no idea why it got a reputation for not being as actively developed as other languages!)

2 Likes

So I was looking into a large Erlang codebase yesterday. My flow stuttered a lot, despite full understanding of the syntax and design patterns. I have no problem writing Erlang, but readability isn’t there yet. On the other hand, I can understand F# or Ocaml fairly we despite not having much knowledge of the syntax.

Is it just me? Or does Erlang demand a bit more practice to gain fluency in terms of reading code? I think, Pascal cased variables and lower cased atoms play trick on my mind?

2 Likes

What was the code Mafinar?

1 Like

A friend wrote a server for Vehicle GPS tracking devices (ones that you plug in a car). So it gets data from various devices, parses the sentences and sends them to a server, along with receiving server sent events (i.e. stop the car engine, take photo, call 911 etc) and react accordingly.

2 Likes

Ah… I thought it might have been a public project (just wanted to have a nose, haha!) :smiley:

1 Like

It will be public soon though.

2 Likes

It’s arrived, my copy of the book! :nerd_face:

4 Likes

Ooo exciting! And I like what you did with your arm there Herminio :sunglasses:

I’ll look forward to reading your updates :smiley:

2 Likes

It’s more because of prolog syntax, lol. ^.^

Also more prolog.

Eh, an atom is most close to, say, a global variant, which is common stuff in a lot of languages like OCaml (which is technically OOP-capable though no one really does that in it), or an enum in most other languages (though those are namespaced!).

Which is why I’m still sad about the removal of value typed modules just a few versions ago… :frowning:
It had so many useful abilities, especially in regards to emulating higher typed modules (by just putting a module inside a modules values!)!

Dialyzer is always a must use! ^.^

2 Likes

I have a special trepidation and positive attitude bordering on love for the author of this book (Joe Armstrong). What a pity that he was not destined to write the continuation of the chapters of this wonderful book. Well. We will be glad that we have! Several years ago I translated this second edition of this book into Russian. Unfortunately, due to the plight of the publishing industry in Russia and the small community (I develop one of them), I was never able to release this translation of mine.

I have an idea how to continue to improve this wonderful book. I will make rebar3 projects based on the examples of the book as I re-read this book. What do you think of this way of rereading a book? I would be interested to know your opinions.

I am now doing similar creative work, reading a book “Erlang Programming”. I will definitely share the results with you if you are interested in it.

2 Likes

Awww :orange_heart: I miss Joe too :cry:

I’ve been trying to get @rvirding to write one for a few years now - I’m hoping he might change his mind one day :blush:

Have you thought about approaching PragProg? Last time I spoke to @Dave he mentioned they actually translate many of their books to German… so who knows maybe Russia is also on their radar :smiley:

I’d probably read it from the beginning and post an update here once per chapter… that way you won’t miss anything important It’ll help keep you (and the rest of us!) motivated too :sunglasses:

2 Likes

@rvirding has a lot of stories to tell and something to share by book I hope. He recently gave an interesting interview (via smartlogic podcast).

Super! It is goo for you. I prefer active reading: “reading + coding + thinking” circle. Thus, I better perceive new educational material and find my own approaches and solutions.

2 Likes

Yep I am sure he does - I reckon he could provide a really good opinion/insight on Erlang and how it and the BEAM world has been expanding these past few years :sunglasses:

Awesome, keep us posted!

PS, I noticed you’ve put you’re interested in the #zotonic framework - any particular reason why? (I wonder if we need a dedicated thread to chat about it!)

2 Likes

I think it can be right tool when you would like to develop web app with thick client part (Angular framework). For instance merging Erlang power with Angular. I think it would be useful stack of technologies.

#zotonic has all I need at backend part.

If you prefer Erlang for web #zotonic is handy tool. Its API actively developed - (zotonic news).

2 Likes

I’ve never heard of #zotonic but I’ve tested #nitrogen !

Already bought the “Build it with Nitrogen” book which his kinda…thick.

3 Likes

You’ll have to start a thread (or Journal) about it @Maartz - I am sure loads of us will be interested in hearing your thoughts about it :nerd_face:

4 Likes

That’s a terrific idea!

4 Likes

Chapter 1 - Introducing Concurrency

About concurrent and parallel:

  • Distinguish between concurrent and parallel.
  • Computer with only a single-core, it can never run a parallel, but it could be possible to run concurrent, because the computer use time-share between the different tasks and give the parallel illusion to run these tasks.
  • Concurrent program is a program written in a concurrent programming language.
  • Concurrent Programming Language is a language that has explicit constructs for writing concurrent programs. These constructs are an integral part of the language.
  • Parallel Computer is a computer that has several processing units(CPUs or Cores) that run at the same time.

PS: Concurrency has to do with software structure; parallelism has to do with hardware.

Module declaration:

  • Syntax -module(). The first line -module(some_module_name) and should be the same as the filename without the .erl extensions.

  • Module name, it’s written with a small letter.

  • Module name is an atom.

Public functions:

  • Syntax -export(). E.g. -export([FunName1/N1, FunName2/N2,]).
  • The square brackets [...] mean “list of”, list of public functions and arity(e.g. /1).

The spawn it is an Erlang most primitive way to create a concurrent process and returns a process identifier(pid).

spawn(ModName, FuncName, [Arg1, Arg2, ..., ArgN])

And with the process identifier, it how to interact with this process.

In Erlang, processes share no memory and can interact only with each other by sending messages. It’s an actor model.

John ! {self(), "Hello World"}

The syntax Pid ! Msg means send the message Msg to the process Pid. The self() argument in the curly brackets identifies the process sending the message.

How to receive messages where are sent?

receive
  {From, Message} ->
    ...
end

Benefits of Concurrency:

  • Improve performance
    • running in concurrent and parallel based on the numbers of CPUs the computer had to improve performance. It’s necessarily to write concurrent programs. The sequential code doesn’t fit with a multicore computer to run parallel.
  • Create scalable
    • concurrent programs are made from small independent processes, and help to scale easily to increase the number of processes and add more CPUs.
  • Fault-tolerant
    • it means processes will run independent, and if any error occur in one process cannot accidentally crash another process, its protect against the failure.
  • Clarity, be more reliable
    • use sequential language to write real-world, made things run in parallels more difficult, because it necessarily uses another services and solutions where the language is native support, but Erlang can map the real-world parallelism more clear and easily to understand.
2 Likes

A post was split to a new topic: What do you use to read Erlang docs?