instead, which is much closer to what python/java et al runs, then at least I get around 2850 syscalls.
The constant ppoll:ing is because erts spins looking for new work from any fd. Specifically "/sys/devices/system/node/node0" is in order to check for cpu topology updates by the operating system, i.e. if for some reason a core/cpu is taken offline of something like that. This is limited in my example above by "+sbwt none"
IIRC the bind is an UDP socket to talk to the local nameserver. This is removed in my example with "-mode minimal".
Maybe some analogy -
C is like riding a very fast bike.
Python, Java - Starting a truck which will move what you want.
Erlang - starting a railway system.
Erlang is like another system inside your system, it's more akin to booting a system inside a vm just to echo some hello world.
Erlang isn't a bare programming language like C, or even a high level, but still fundamentally simple language like Python.
It isn't just an intermediary bytecode running in a VM, like Java, that maps bytecode instructions to OS instructions.
It is instead more like a Smalltalk environment or similar; an entire ecosystem running for the specific purpose of providing you a very particular kind of programming environment.
Terry Davis describes his TempleOS† as a motorbike, Windows a car and Linux a semi truck with a huge gearbox. In TempleOS, you'll crash if you lean over too far. The solution? Don't lean over, then!
† ring-0 only, no memory protection, exploratory dev/art focused
To put it another way, if you run code on a system with concurrency units sharing the memory (the heap), your code is running on DOS or Windows 3.1 which was cool in 1990s.
Erlang/Elixir is like running your code on a modern OS with a process memory separation, preemptable concurrency (processes don't have to yield by hand to others). Built in tracing and monitoring facilities (tracing, observer, dbg). Built in networking (distribution, global process registration, in memory distributed db) etc.
By default, the erl interpreter starts up the otp app, which loads lots of modules (50+?) and multiple (5?) different processes. It takes a second. To get things running faster, you can use the -boot argument to erl. There is a appendix in Joe Armstrong's book that steps you through it.
A quick suggestion for the author based on the "dude I can't debug anything on OS X" line - take a look at DTrace, which is shipped with MacOS (albeit an old version).
Compared with strace on Linux it is like night and day.
Good advice, on Windows it's really a nightmare though..
Investigating why the OS seems to 'freeze' a process for 10s once in a while (threading issue?) is really mysterious..
> I wanted to debug something
> I've analyzed Erlang strace
> "Erlang is complicated"
If you want to debug Erlang program then Erlang/OTP already includes tools to help you do that: http://www.erlang-in-anger.com/ - 92 page manual that includes:
- tracing functions called with defined parameters
- analyzing crash dumps, memory leaks, cpu scheduling
This is great, if you're planning to do many things with erlang, our you have a lot of time. If your friend has a weird problem and comes to you because you have a reputation for figuring things out that you've earned by using strace, then you use strace. Incidentally, I'm reading this because I use erlang, but it took about a minute to see the problem (tcp port exhaustion) from the strace.
cross posting what I wrote as a comment in the article:
epmd is a separate process, yes. But an erlang node connects to epmd in order to register it's name on it. It will bind a socket to talk with epmd (probably among other things)..
See also: http://erlang.org/doc/apps/erts/erl_dist_protocol.html
Would it make sense to do a large number of iterations (in the millions) of the basic "Hello, World\n" print statement in all the languages to amortize the cost of the BEAM/JVM setup/initialization system calls out?
Isn't it the case that in Java and Erlang we have a large VM environment that also needs to be launched before the first line of the trivial print statement is executed?
One last thing -- erlang runs bind once when it starts. Why does it need to listen on a TCP socket to run hello world?
My first thought: "So this guy is investigating Erlang with strace, but he couldn't be bothered to Google articles on its design!?" Then I tried Googling this myself. Uh, yeah. I happen to know this stuff, even though I don't use Erlang, but it's not exactly easy to find packaged conveniently in one place.
erl -noshell +sbwt none -smp disable +A 0 -mode minimal -eval 'io:format("Hello world~n").' -s init stop
instead, which is much closer to what python/java et al runs, then at least I get around 2850 syscalls.
The constant ppoll:ing is because erts spins looking for new work from any fd. Specifically "/sys/devices/system/node/node0" is in order to check for cpu topology updates by the operating system, i.e. if for some reason a core/cpu is taken offline of something like that. This is limited in my example above by "+sbwt none"
IIRC the bind is an UDP socket to talk to the local nameserver. This is removed in my example with "-mode minimal".