Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Ha, ok so I gotta give one of these "that's a really strange thing to get hung up on" responses.

Erlang and Elixir don't overload the `+` operator. In fact, they don't overload ANY operators. If you can forgive the syntactic choice of the operator itself (which I think it pretty fair considering Erlang predates Postgres by a decade and F# by two decades), this allows them to be dynamic while maintaining a pretty high level of runtime type safety. For example, one of the "subtle bugs" people refer to when criticizing dynamic languages (even strongly typed dynamic languages) is the following would work when both args are given strings or numbers:

    function add(a, b) { a + b }
Erlang/Elixir eliminate this particular subtle bug (and it goes beyond strings and numbers) since:

    def add(a, b), do: a + b
will only work on numbers and raise if given strings.


ML (which is the precursor to OCaml/f#), pascal, basic, and sql use <>. If you consider that <, <=, etc are used as comparison operators it makes sense for <> to be in that camp. I actually never thought of it that way.

Interesting table here highlighting old programming languages https://en.wikipedia.org/wiki/Relational_operator#Standard_r...


It doesn’t predate sql and certainly not it’s use in mathematics. There are other options for concatenation so this is an unfortunate error.

Shouldn’t copy Erlang, otherwise might as well use it.


>It doesn’t predate sql and certainly not it’s use in mathematics.

What do you mean by "it's use in mathematics"? To my knowledge <> was invented by Algol language creators to use it for inequality. There was no previous use in mathematics. And to my opinion, that was an unfortunate error.


Interesting, must have learned it so long ago… Pascal? that I conflated it with math class. Still ~1958 is rather venerable.

The plot thickens, apparently ++ is used for erlang. So I still find it a poor choice.


++ is for concatenating lists, it's not the only functional language that uses this.

Really though who cares? `=` is already misused in most programming languages.


When looking at new languages, getting the basics right is the first thing I look at. Clumsy string concatenation is a blocker in my business, which is like 75% of the code.


Actually in Elixir when doing string building you want to use "improper" lists which lets you very efficiently build up a string without doing any copying.


Oh ha, duh me, I did not consider it wasn't invented by Postgres.


Oh really? What's the operator for adding two floating point numbers then?

The solution to type confusion is not separate operators for every type, it's static types!


Ha, I was going to mention this but there is none. `+` is for both ints and floats. OCaml, which is statically typed, has a separate operators for ints and floats, though.

I don't want to get into it but Erlang is dynamic by design. There have been several attempts to bring static typing to it over the years which have failed. People are still trying, though!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: