When comparing Scheme vs Erlang, the Slant community recommends Scheme for most people. In the question“What is the best programming language to learn first?” Scheme is ranked 4th while Erlang is ranked 37th. The most important reason people chose Scheme is:
Scheme syntax is extremely regular and easy to pick up. A *formal* specification of the syntax fits onto just a few pages; it can be introduced informally in a paragraph or two. Students are not distracted by remembering how to write if statements or loops or even operator precedence because every syntactic follows the same pattern. Ultimately, everything looks something like this: (func a b c) This includes not only user-defined functions but even control flow: (if cond then-clause else-clause) or even primitive operations like `define` and `set`: (define foo 10) (set! foo 11) This means that nothing really has special syntactic treatment in the language. There are essentially no weird edge-cases to memorize, and different concepts are given a more equal weight in the language. (Unlike Algol-like languages which tend to given undue weight to loops and assignment statements, for example.)
Ranked in these QuestionsQuestion Ranking
Pro Simple syntax
Scheme syntax is extremely regular and easy to pick up. A formal specification of the syntax fits onto just a few pages; it can be introduced informally in a paragraph or two. Students are not distracted by remembering how to write if statements or loops or even operator precedence because every syntactic follows the same pattern.
Ultimately, everything looks something like this:
(func a b c)
This includes not only user-defined functions but even control flow:
(if cond then-clause else-clause)
or even primitive operations like
(define foo 10) (set! foo 11)
This means that nothing really has special syntactic treatment in the language. There are essentially no weird edge-cases to memorize, and different concepts are given a more equal weight in the language. (Unlike Algol-like languages which tend to given undue weight to loops and assignment statements, for example.)
Pro Great at teaching fundamental programming ideas
Scheme teaches the important, fundamental ideas immediately without the distraction of unnecessary syntax or language features.
Pro Great, well known textbooks
There is a set of very strong textbooks introducing CS and programming using Scheme. These books are available for free online.
The most famous example--and one of the most famous CS books full stop--is Structure and Interpretation of Computer Programs usually known as SICP. This book introduces fundamental ideas in computer science and covers an incredible amount of material quickly and clearly without requiring any prior knowledge.
However, some people find SICP a bit challenging as a first text. Happily, there are other more introductory texts as well. Simply Scheme is a book designed to be read before SICP, easing beginners into the language as well as CS and programming in general. How to Design Programs is another text used in introductory college courses.
Pro No Magic - it's clear how everything works
Scheme has far less built into the language itself, helping students see that things like OOP are not magical: they are just patterns for organizing code. Everything in Scheme is built up from a very small set of primitives which compose in a natural and intuitive fashion.
Having a language that does not accord many things special status helps keep students open minded. This will help students later go between different languages and paradigms from procedural to object-oriented to functional.
Pro Robust metaprogramming
The quotation functionality of Lisp allow for extremely powerful, yet syntactically straightforward metaprogramming via macros. This is more powerful than the C preprocessor while being less involved than something like Template Haskell or F# quotations.
Using macros to properly decompose a problem domain teaches new developers good habits, improving composibility and reliability when tackling large programs. Scheme metaprogramming also serves as a gentle introduction to domain specific languages.
Unlike most languages, Scheme actually accords both functional programming and imperative programming roughly equal status. Many other languages like Python and Java are staunchly imperative while SML and Haskell are primarily functional; Scheme is a nice middle ground.
Additionally, since Scheme syntax is extremely flexible, it can easily be re-purposed for teaching non-deterministic and logic programming. There is no need to learn a new language like Prolog when the same ideas can easily be expressed with Scheme syntax.
This gives students a good perspective on different ways to think about and organize programs, which makes it much easier to move forward to other languages and technologies.
Pro Built from the ground up with concurrency and distributed computing in mind
Erlang has strong roots with the telecom industry in which concurrent processes are normal. It's designed to be concurrent, to be used for distributed computing and to be scalable.
Fault tolerance means that a system has the property to continue operating even though one or more components have failed.
For Erlang systems, this means that the system is kept running even if for example a user has to drop a phone call rather than forcing everyone else to do so.
In order to achieve this, Erlang's VM gives you:
- Knowledge of when a process died and why that happened
- The ability to force processes to die together if they depend on each other and if one of them has a fault.
- A logger that logs every uncaught exception
- Nodes that can be monitored so that you find out when they go down
- The ability to restart failed processes (or groups of them)
Pro Upgrade code without stopping the system
In a real-time system it may not be possible to stop the system in order to implement code upgrades. For these cases Erlang gives you dynamic code upgrade support for free when using OTP. The mechanism is very easy to understand and works as follows:
- Start the app
- Edit the code
That's all that is needed, the app updates with the new code while it's still running and tests are run automatically.
Pro Great for writing distributed applications
Erlang is made to be parallel and distributed. Because it's very easy to write code that uses multiple processor cores, it's also very easy to write applications that span multiple servers.
Pro Battle proven
Erlang has been used in production for more than 20 years now. During that time it has proven itself over and over again that works great in both small startups and large-scale enterprise systems.
Erlang has been used extensively by Ericsson themselves. For example, the AXD301 ATM, which is one of Ericsson's flagships is probably the largest Erlang project ever with more than 1.1 million lines of Erlang code.
Pro Light processes
Erlang's processes have very little overhead (about 500 bytes per process). This means that a huge amount of processes can be created, even on older machines.
Pro Consistency across platforms
Erlang's processes run in a complete independent way from the OS (they aren't managed by the OS scheduler neither). This means that programs written in Erlang will run exactly the same way regardless of the operating system or platform.
Con Little Market Search
There are little to none jobs searching for a Scheme programmer. The ones that exist are more related to Research in Maths or Artificial Intelligence.
Con Fragmented ecosystem
Scheme is an IEEE standard, not an implementation. Unfortunately, the standard is too minimal and practical implementations have diverged--they had to expand on the standard to get anything done, but did so in incompatible ways.
The later de facto standard R6RS tried to correct this, but lost Scheme's minimalist elegance in the process. The newer R7RS standard takes the best of both worlds with an elegant minimalist core and a practical standard library.
Con Eccentric syntax
Erlang's syntax may feel very strange to 99% of programmers who have never used it. This is because it does not share any similarities or common syntax definitions that are found in all the other languages that are used today.
Con Useful in only one niche
Erlang is not really a general purpose language. It has a very special and well-defined niche where it towers above everything else. It's specialized in scalability and in distributed applications. Which is not necessarily a bad thing per se, but it still lacks and falls behind other languages when it needs to do things outside it's niche.