Hacker News new | ask | show | jobs
by kenko 4105 days ago
"More specifically, empathy for the user.

This empathy is demonstrated in a variety of ways. Many have been extensively discussed: the natural syntax, ... "

I guess the author means "empathy for the user of Ruby"?

2 comments

What Drew is talking about is the syntax is natural in its representation. Things that we think of as keywords in most languages, ie `def`, `if`, `unless`, `defmodule`, etc are all just macros in Elixir which accept arguments. The syntax is incredibly natural when you see how Elixir is represented internally and built up using macros from a tiny base. This is what Drew is talking about, not some Ruby similarities.
How did you arrive at any of those conclusions?

That doesn't strike me as a very straightforward interpretation of the offhand reference to the syntax's being natural, made without any further comment. Nor do I see why "def" being a macro makes the syntax "natural in its representation" (or even what you mean by that).

Just as a test: if that is what he meant by the syntax's being natural, he should be willing to claim that the syntax of Scheme is at least as natural.

Usually, when people talk about Elixir's syntax being natural, they go on to contrast it against either Erlang, which is known for having some odd syntax quirks such as having to end lines with different punctuation marks depending on context (something that can make changing or refactoring code difficult -- although, tbf, Erlangers have tooling that does help with this), or Lisps like Clojure, from which Elixir takes many ideas (it's macro system and the idea of the AST being normal language data types, it's protocols, etc). In fact, I've seen "natural syntax" defined as something like: functions are called like this: `my_function(arg1, arg2)`, and with operators so that numbers are used naturally, as in mathematics, like: `1 + 2` in contrast with lisps where function calls are like `(my_function arg1 arg2)` and math becomes `(+ 1 2)`. I do not know if this is any kind of technical definition, or just one that's been internalized by the Elixir community to some extent (I've seen it repeated in at least two or three places) but that's my guess as to what the author meant.

While Elixir may appear similar to Ruby syntactically, because of it's `do, end` blocks, that similarity is actually somewhat superficial. In reality, a Rubyist will only feel slightly more comfortable with Elixir's syntax than someone coming from another imperative language, for a couple reasons. One, Elixir's usage of do/end is far more regular than in Ruby, where `do/end` have a very specific meaning, and two, the differences from Ruby syntax (defmodule, defstruct, fn -> end, |>, calling anonymous functions) are actually greater than the similarities. But I think both the Rubyist and the (Javascript, C, Go, Python) programmer will find Elixir's syntax more natural than they would find the syntax of many other functional languages.

Of course, at the end of the day, our intuitions and feelings about syntax are quite subjective, and syntax is a very tricky thing because of this.

I can't say for sure what the author meant by natural syntax of course, but this would be my guess, based on how I've seen the term used in other descriptions of the language.

I'm curious what language background you come from, and whether there are particular things about elixir's syntax you found unnatural, difficult or uncomfortable?

It looks like you skipped all examples given next, which do not seem to be Ruby related at all: the inviting community, the extraordinarily involved creator and the tooling.
I ... well, yes, obviously? Since all I was concerned to address was the claim that the syntax is "natural", I didn't feel any need to include anything else. That's why used ellipses, which mean "the sentence continues, but I'm not quoting the rest".