About me? ( if you have nothing better to do than reading about some random guy in the internet )
Hello all, this is my first post in this forum, so I apologize is something is off.
I am rather a direct person with strong opinions, but don’t be afraid of me, I don’t bite !
Recently I have been learning Elixir for a job offer ( yes, apparently you can find jobs using this thing! I mean, you have to sacrifice a virgin and a goat [ it can be a virgin goat ] to the Gods of Old and pray for 7 days, but hey, if it works it works right ? ) and I have been ramping up in my Elixir knowledge by watching as many conferences as possible.
I have a strong JS background where I do FP ( yes, it is possible ), and I got lured into this language becasue of it.
I have a lot of questions so I am giving this forum a chance!
This 1 hour video covers the main aspects of Elixir and makes sure you have a lot of questions after. Suffice to say you won’t learn Elixir in 1 hour, but it is a good start I guess.
The following points summarize what I learned.
- It has modules. Modules contain and organize functions, so it’s cool.
- It has a ton of data types, most notably: Int, Float, String, Atom, Tuples ( arrays ), Lists, Dictionaries, etc.
- Int type is not bounded. It has no maximum nor minimum value. If you ever had an overflow using Node ( like me ) you will really appreciate this feature.
- Has a native pipe operator !
|>JS is being left behind
- Has native String concat operator
- Has native List concat and diff operators ++`` and
- Has destructuring !
- Functions can have the same name as long as their signature is different !
- Has anonymous functions
- Has no for loop constructor. WHHHATTATATAGGAHHAHAGATIhvgdjfsAVSGBZ
- Creates child processes easily and sends messages between them easily as well
Not everything is nice with Elixir. It also has it’s technical shortcomings:
- No partial application and no currying. This is something I would expect from a FP language ( like Haskell ) to natively support. Huge disappointment.
- Currying and partial application via anonymous functions have a weird syntax. Yes, you can make a library to workaround this flaw, but the syntax you need to use is … weird at best: http://blog.patrikstorm.com/function-currying-in-elixir
- Being functional, Elixir has an horrible API. Most of it’s native functions are data first, instead of data last ( a basic concept of FP languages ).
- No Monads. Again very disappointing.
Elixir Weirdness ( aka, stuff you will eventually get used to )
- No return statements
- Elixir also has default values for parameters, but the syntax is anything but intuitive.
(x // 1, y // 2), this signature is saying that the default value for
xis 1 and for
yis 2. For most people, this would be a comment…
- It has a short syntax for functions ( like the arrow syntax for JS functions ) but it is super cryptic.
I know I am just starting. But aside from the data types ( that are immutable by nature ) JS actually has better support for the functional paradigm than Elixir. The native API ( String API comes to mind ) was designed using data first instead of data last ( a most basic flaw in an FP language ) and using currying with partial application feels clunky as all hell when compared to JS. And there are no Monads either … I mean Swift is not a FP language and even it has the Maybe Monad. How disappointing.
I must say I expected more from a newly designed FP language. The support for currying and partial application is rather atrocious but I can live with it.
I still didn’t get into error handling, but from what I have seen, it is extremely imperative with good old
try rescue blocks. It would appear that basic knowledge from Promises and Futures is missing.
Or perhaps I am missing something? Allow me to rephrase my noob rant in an organized manner:
- How does one use Monads in Elixir?
- Is it possible to use currying and partial application in Elixir using the function normal syntax, instead of the
- Are there any libraries widely used and publicly available to for the use of currying and monads?
- Are there any libraries that improve upon the mistakes of the native API?
- Is there a version of NPM or Ruby Gems for Elixir ( I understand there is none so far ) ?
Please let me know if I missed something. I have only seen a a couple of conference videos, I may very well be missing something brutal.