Elixir syntax/ naming/ notation proposal

67 views
Skip to first unread message

Thiago Majesk

unread,
Apr 27, 2017, 8:25:16 PM4/27/17
to elixir-lang-core
Hello everyone,
First of all, I'd like to apologize if this is not the right place for this kind of question, please be patient :)

I'm finishing my reading through the Getting Started section and I have to say that I'm kinda amazed right now. 
Elixir feels complex and simple at the same time. I have to take off my hat to this remarkable project. 
Without further ado... I was wondering about Elixir syntax, and I'd like to know if there is a particular reason why to use some of the bellow notations: 

defmacro
defmodule
defstructure
defimpl
defprotocol,
hd() and tl()

instead of just

macro
module
structure
impl,
protocol,
head() and tail()

I know that sometimes I care too much about syntax and code aesthetics, but when I see thoose in particular, I have the impression that perfection was missed by a tiny bit.
IMHO, the first ones would look a lot more clean and the last two a little bit more verbose but a lot more explicit (don't looking like magic functions).
Would one gentleman consider change something like this in the future, maybe with somekind of "alias" for compatibility?

Greg Vaughn

unread,
Apr 27, 2017, 8:56:57 PM4/27/17
to elixir-l...@googlegroups.com
Thiago, thanks for your eye to detail, and I'm glad you see that complexity/simplicity balance that is Elixir. Your excitement is great to see and I hope it continues. If minor naming of 7 functions/macros is the only difference between Elixir and perfection, we are doing an awesome job! (Wait until you find out how list of integers are indistinguishable from Erlang strings. You might change your judgement on how close we are to perfection, but I digress...)

I love Elixir. I earn my living coding Elixir. Please be aware that while it is brand new to you, some of us have been dealing with it for 3, 4, even 5 years (I'm nearly 4 years, and José, of course, plus others were here ahead of me). These names are fairly fundamental. Sure, I can see how the 'def' part of those macros could be removed, but to be fair they really do represent a 'definition' of those concepts. The 'hd' and 'tl' come straight from our parent language of Erlang and are very convenient for those migrating from there (and I tend to use the [head | tail] syntax much more often anyway).

You might get better answers than mine concerning the reasons the names are as they are, but I don't expect there's going to be support for changing them due to aesthetics. There's been a lot of code written based upon them.

Since Elixir is so macro based, I suspect you could in fact perform that aliasing you want in your own projects, but I worry that sets you on the path into a special dialect of the language. Still, it's your choice to make.

-Greg Vaughn
> --
> You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/ccb62a31-5048-45db-a019-bc1215771713%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Thiago Majesk

unread,
Apr 27, 2017, 9:53:46 PM4/27/17
to elixir-lang-core
Wow, thanks for the quick response Greg.
I think that aesthetics play a big part on any programming language. Some may not care about this, but I think that it translates directly to productivity and satisfaction.

Although I have been hearing about Elixir for some time now, I regret that I've never bothered to look into it further. Now I'm just fascinated, as it shows :)

I think I've discovered the soft spot I've never found in the Ruby ecosystem/community. Mainly because of the bad experience outside *NIX platforms.
Coming from a traditional Java/C# background it's a breath of fresh air to see new possibilities. 

Thanks for the warm reception Greg. I hope in the future I can make some more substantial constribution to the community ;)

OvermindDL1

unread,
Apr 28, 2017, 10:48:22 AM4/28/17
to elixir-lang-core
Welcome!  Feel free to join us at https://elixirforum.com/ as it is the main community place nowadays.  :-)

As for why def on the front of macro and others I'd say (though I'm not the designer) that it is just a traditional thing for defining something that is callable in some form, that tends to be why I see it.  However if you do not like it then feel free to not include their names via include'ing Kernel without them or rename them via alias's.  :-)

As for the `hd` and `tl` that is because that is what Erlang calls them, and Elixir compiles to Erlang, so there are still Erlang'ism popping up (you can use anything in Erlang from Elixir and mostly vice-versa except macros).  :-)
Reply all
Reply to author
Forward
0 new messages