Computer Science
Algorithm
Data Processing
Digital Life
Distributed System
Distributed System Infrastructure
Machine Learning
Machine Learning Application
Operating System
Android
Linux
MacOS
Tizen
Windows
iOS
Programming Language
C++
Erlang
Why I Come Back to Erlang (2014)
Go
Scala
Scheme
Type System
Software Engineering
Storage
UI
Flutter
Javascript
Virtualization
Life
Life in Guangzhou (2013)
Recent Works (2013)
东京之旅 (2014)
My 2017 Year in Review (2018)
My 2020 in Review (2021)
十三年前被隔离的经历 (2022)
A Travel to Montreal (2022)
My 2022 in Review (2023)
Travel Back to China (2024)
A 2-Year Reflection for 2023 and 2024 (2025)
Travel Back To China: 2025 Edition (2025)
Projects
Bard
Blog
RSS Brain
Scala2grpc
Comment Everywhere (2013)
Fetch Popular Erlang Modules by Coffee Script (2013)
Psychology
耶鲁大学心理学导论 (2012)
Thoughts
Chinese
English

Why I Come Back to Erlang

Posted on 27 Apr 2014, tagged erlangnode.js

Some months ago, I learned Erlang and wrote a poker game with it. While I’m using it, its strange syntax drives me crazy. The sweetest syntax I’ve ever seen is in CoffeeScript. So in the next game I wrote (also a poker game), I tried to use Node.js with CoffeeScript. But after the basic features are implemented, I came back to Erlang. Here is why.

CoffeeScript Is Not Easy to Maintain

When the CoffeeScript project becomes large, it is very difficult to maintain. You don’t know what’s in an object because the members in it could be changed at any time. There are no declarations in the code, so you must write many comments if you want things to be clear.

CoffeeScript has no type. I thought the language without type was easy to use some months ago. But after that, I think languages with types are easy to maintain. And it is more friendly to IDEs and editors so that you can write code faster and find out your errors earlier.

Erlang is a dynamically typed language, too. But it comes with a very flexible type system and the code can be checked with Dialyzer. (Though I prefer to write type information in the code instead of in the optional -spec.)

Node.js Runs the Computation In A Single Thread

Yes, Node.js will fork some threads to do IO. But while you are computing things with the CPU, it only does things in one single thread. It is not a big deal if you are writing a web server since it doesn’t use CPU often. But it is not true in a game server. A game server has lots of things to compute so it will be very helpful if the computation could be run on multi-core. Erlang is known as scalable. It just does these things automatically.

If There Are Some Errors, Everything Fails In Node.js

If something has an error in the Node.js application, the whole application will fail. If you are using pm2 or something like that, it will restart the application for you if it fails. Again, it is fine in a web application since it is stateless. But the game has a state and many things will be lost after restart.

If an Erlang process fails, it won’t affect other processes. It will lose something, too. But it only affects few players if the bug is not easy to trigger (if it is easy to trigger then we’ve fixed it in development).

It Is Not Easy to Profile and Monitor Node.js Applications

I’ve reviewed many Node.js monitoring tools and found none of them are easy to use. Almost all of them use a third-party website to monitor or profile your application. I’m very confused with it. These things really suck.

On the other hand, Erlang has built-in profiling and monitoring tools. You can monitor each node, each process and so on.

The Killer Feature Of Erlang: Hot Code Deployment

If all of my reasons are listed until now, then there are many other choices such as Scala, Go and so on. But they lack the killer feature of Erlang: the ability of hot code deployment. We don’t want to stop the game server at any time. It will affect a lot.

Conclusion

After all, I’m not saying Node.js or CoffeeScript is such a bad platform or language that you should never use. But in this case, Erlang is more suitable. Erlang is a platform that provides many tools. I can be fine with its syntax with such a benefit.