5 ms·
My problem with Elixir is that the syntax is too noisy: defmodule Math do def sum(a, b) do a+b end end Compare that with P
by TekMol 3y ago
My problem with Elixir is that the syntax is too noisy:
defmodule Math do
def sum(a, b) do
a+b
end
end
Compare that with Python:
def sum(a, b):
return a+b
Having the name of the file be the name of the module and whitespace defining the blocks is the perfect approach for me.
- h0l0cube 3y agoThis is a fairer example for Elixir (if comparing succinctness)... def sum(a, b), do: a+b
- sph 3y agoOn the other hand, dealing with dependencies, deployment, even containerisation is a breeze in Elixir, so it balances out.
- Cthulhu_ 3y agoUnfair comparison, your Elixir example includes a module definition. That said, code volume is never the issue, code clarity is. Right now you're comparing trivial examples, but what does in this case Pinterest's high volume spam detection code look like? I wouldn't judge a language on microscopic code snippets, or disregard them as "too noisy" when it usually isn't a deciding factor in programming languages.
- thaumasiotes 3y ago> Unfair comparison, your Elixir example includes a module definition. Huh? TekMol explicitly points out that the python code also includes a module definition. It's just that the python module definition takes up zero characters in the source file. (Note that this is not always true, but in this case it is.) It takes more than that, in the name of the file, but the Elixir file will also have to have a name, and the comparison ignores both of those equally.
- kungfooguru 3y agoOr Erlang for even less noise ;) -module(math). sum(A, B) -> A + B.
- deleted 3y ago[deleted]
- dns_snek 3y agoYou're not seriously complaining about 2 extra lines of code in what would typically be a 100+ line file, are you? Besides, the equivalent of Elixir's module (a struct with functions) is Python's class, not a plain file.
- sharts 3y agoI'd take noisy syntax over the noise that is Python API docs any day.
- adamauckland 3y agoYes, but they were moving from enterprise JAVA which is considerably more verbose
- conradfr 3y agodef sum(a, b), do: a+b Sure, if you don't like having the name of a module/class at the top of a file that excludes a lot of language.