3 ms·
I think the sytnax of Erlang is much more elegant, because it was build around the fundamental idea of pattern matching as a core feature of the language. When
by dschiptsov 14y ago
I think the sytnax of Erlang is much more elegant, because it was build around the fundamental idea of pattern matching as a core feature of the language.
When you have a few good ideas put together, you could get an elegant solution. When you just stuff everything inside (like Clojure) or went to extremes (like Haskell) all you got is just a mess.
Erlang syntax, however, is noisy due to all those punctuation, but it is elegant nevertheless.
map(Fun, [H|T]) -> [Fun(H)|map(Fun, T)];
map(Fun, []) -> [].
member(H, [H|T]) -> true;
member(H, [_|T] -> member(H, T);
member(H, []) -> false.
This is intuitive, readable, but noisy.)
- pohl 14y agoI'm not sure I follow you. Is the pattern-matching in Haskell somehow not 'core' enough? Both qsort examples linked in this thread use pattern matching.
- dschiptsov 14y agoAll I'm trying to say that Erlang syntax is much more intuitive and readable, being derived from Prolog. I honestly can't see why should I use Haskell (except for being so clever) when I have Erlang, or at least one real advantage.
- mwotton 14y agowell, let's look. map f (h:t) = f h:map f t map f [] = [] member x (h:t) = x == h || member x t member _ [] = False I think the only difference is that you can't match for equality directly in the pattern.