2 ms·
I've written a little bit of erlang, so I can offer a few reasons why it isn't used widely. Erlang does not have a string data type. All it has are lists of in
by yummyfajitas 17y ago
I've written a little bit of erlang, so I can offer a few reasons why it isn't used widely.
Erlang does not have a string data type. All it has are lists of ints smaller than 256.
1> [98, 114, 111, 107, 101, 110] == "broken".
true
If statements are just wrong.
if
X == 1 ->
io:format("you picked one\n");
X == 2 ->
io:format("you picked two\n")
end
If X == 3 an exception is raised. You also can't call functions in if statements. This won't compile:
if
p(X) ->
io:format("Predicate is true for X!\n");
true ->
ok
end
The syntax is unfamiliar (e.g., {} is tuple) and also fugly. You've got 3 separate line terminators, namely ; , . all of which are used at different times.
Records are also broken. In most languages, x.field addresses the field of a record. In erlang, x#ClassName.field is necessary, since records are actually just a macro which compiles down to tuples.
I actually rather like erlang. But make no mistake: it's a domain specific language for message passing. It's not a general purpose programming language, even if it is Turing complete.
- tobyhede 17y agoI think you are missing some of how Erlang views the world re:if statements. Erlang uses pattern matching rather than assignment, so the statements in the if are Guards. From Pragmatic Programming in Erlang: At least one of the guards in the if expression must evaluate to true; otherwise, an exception will be raised. Often the final guard in an if expression is the atom true, which guarantees that the last for m in the expression will be evaluated if all other guards have failed.
- yummyfajitas 17y agoPerhaps my "just wrong" was an overstatement. I guess my real objection is that they should use a different keyword than "if". Like in ocaml: match x with [] -> 0 | _ -> 7 Same semantics, but it doesn't look like a C/Python if statement. They could also use if, but require an else clause (like Haskell). Like it or not, syntax does matter to language adoption.