3 ms·
I think Erlang's pattern matching alone is a strong point for Erlang. Makes a generic server-client protocol parsing very trivial to implement. Eg: https://bra
by aloknnikhil 6y ago
I think Erlang's pattern matching alone is a strong point for Erlang. Makes a generic server-client protocol parsing very trivial to implement.
Eg:
https://bravenewmethod.com/2011/02/22/socket-binary-data-stream-parsing-in-erlang/ https://bravenewmethod.com/2011/02/22/socket-binary-data-str...
I don't know if any other language can do it this trivially.
- satvikpendem 6y agoRust can also pattern match the same, if I recall correctly.
- dnautics 6y agoYeah but what happens in rust if your match doesn't match the pattern? The compiler won't let you. In erlang, it throws an error, which you can let the runtime eat up. This can be a strategy for extremely lazy error handling.
- adwn 6y agoI'm not sure what you mean. In Rust, you can write: match msg { pattern1 => action1, pattern2 => action2, _ => {} // silently ignore }
- satvikpendem 6y agoI know about Erlang's let it fail philosophy but why would you want something to be caught at runtime when it could be caught at compile time? It doesn't seem to have any valid reasons.
- dnautics 6y agoNetsplits, for example. You don't want to keep track of every service that needs to be taken down with the dropped connection and notify them something bad has happened. Log, crash, cleanup the failure domain, restart, back off, reconnect later. Zero lines of code in erlang.