HACKER Q&A
📣 freedomben

Elixir as a First Language?


I was recently asked, "Is Elixir a good first language for someone to learn who has never done (serious) programming before?" After thinking for a minute, I realized that at some point in the last 20 - 25 years I really lost touch with this area.

My first language was C, and I did and still do think that was a fantastic first language because you can start very simply and don't have to learn a ton of programming concepts prior to writing some code. In my experience, learning to code is much more likely to succeed if you can write something (even hello world) and iterate on it. For example, working with people learning Java as their first language, they really struggle because you can't really do a hello world without encountering objects, classes, static keyword, public/private, and other things.

I love functional programming and Elixir, but I do worry that it has a few things like that to learn that might be a barrier to entry for a brand new programmer. Since I started procedurally and years later learned OOP, and then after that learned functional, I have so much baggage that I'm not sure I can weigh Elixir as a first language.

There's also the obvious, "what do you want to do with it?" question that matters. For example if you want to write frontend SPAs or mobile apps you have less flexibility. In this case however, that's largely irrelevant.

Is there anyone here who learned Elixir as their first (or first serious) language who can comment on this? Or is there anybody who started with a functional language and/or a lisp or similar who can comment?


  👤 thatha7777 Accepted Answer ✓
Excellent question! In choosing a first programming language, I think the most important things are (1) acquire generic knowledge, (2) have help along the way.

(1) The most important thing to keep in mind while learning a first programming language is that it should teach you the abstract notions of programming, without entrenching your mind into a particular programming paradigm. (When I say paradigm, I mean procedural, functional, object-oriented, message passing---I'm sure I'm forgetting a lot.)

I have seen countless _very good_ software engineers struggle when switching but from one paradigm to another, but not between languages of similar paradigms.

In that respect, a multi-paradigm language is the ideal first programming language. Elixir's origins are functional, but it's evolved to be a multi-paradigm language [1].

(2) To have help along the way, you either need a strong/active community, OR a very helpful compiler. Elixir's compiler isn't particularly helpful, and the community is nascent, so in that regard Elixir isn't the best first programming language.

At the end of the day, I think someone's pre-existing mental model of computers should be the tie-breaker (for example, if it's someone with a strong mathematical background, I think they'd enjoy Elixir more than someone who'd get a kick out of making a cute website-based game.)

[1] I'm guessing the Elixir community would consider purely-functional Elixir as the most-aesthetically pleasing Elixir, keeping true to its Erlangian origins.


👤 minute_forest
Yeah, why not? My first language was JS but i use Elixir daily and it definitely made me a stronger dev. What hooked me into Elixir was seeing it for the first time and getting really excited by being able to read the code line by line without knowing the syntax and getting a good sense of what was happening.

But three things i think that really matters for someone to pick their first language are: 1. Is syntax and data types easy to grok right off the bat? 2. How fast are they able to make a mental map of the flow and transformations of data only by reading the code? 3. Are the docs easy to read and navigate, and do they instill understanding?

Elixir definitely is for someone that wants to learn it, and are okay with the fact there might not be many resources to learn from. But what i gathered so far is most of the resources and the community really seek to help someone get a deeper understanding of the language and think about the things that go beyond languages like system design and code quality. Yeah there isn't many packages and libraries out there like the more popular languages to put stuff together, but that's where the fun begins. It's like being in uncharted territory where one is forced to engage with what they're doing and learn how to really build stuff from scratch.

For someone thinking about elixir as a first language, hacking around a basic module and testing it out in the repl to building a web app with Phoenix is a great way to learn.


👤 t-3
My unpopular opinion: start as low-level as possibly, preferably with assembly. A hello world in assembly is ~7-8 instructions on x86_64, provides easy introduction to debuggers, OS internals, and architecture, and will help understanding higher level abstractions.

Starting with high-level is fine if they just want to get a job (in which case they should probably just go straight to JS, Java, or C++), but if they want to really learn and understand, start with low-level.


👤 nh23423fefe
I can't say you made a great point by saying java is worse than c. Seems trivially identical to me.

    #include 
    int main() {
        printf("Hello, World!");
        return 0;
    }

    class HelloWorld {
        public static void main(String[] args) {
            System.out.println("Hello, World!"); 
        }
    }

what is stdio, printf? whats f? return 0? The important thing is that actually all those questions are irrelevant. programming is complex, it can't be simplified, the steepness of the on ramp is irrelevant. if you want to climb the mountain you will. the climbing is the value the grade of the hill is irrelevant its a constant factor. People dont stop programming because java is verbose. They never really get past tutorial hell and build something they care about.

learning to programming isn't made easy by a language. learning calculus isn't going to be easy if you choose infinitesimals vs episilon-delta. Building understanding in your mind is the process of seeing the important structure through the fog of syntax.


👤 cribbles
Let me start by saying that I really like Elixir as a language and ecosystem. That said, I don’t think it’s a good choice for a first language.

Elixir excels for building highly available networked backend applications. Not that it can’t be good for other things, but I personally tried my hand at it as a scripting language (as a complete newcomer to programming might). For this purpose I had to learn things like Erlang interop, module composition, setting up a mix project, etc. — just to get a small project off the ground. Even as a seasoned developer familiar with syntactically and conceptually comparable languages (Ruby, OCaml…) I found the self-instructional overhead to be atypically high for a programming environment.

This is a bit of a tangent, but I’ve noticed that whenever “best first language” discussions come up, responses tend to be biased toward whichever language people first scrapped something together in for fun. For me that was TI-BASIC. By no means do I think that was a “good” first language - it’s just what was around. But it passed the litmus test of letting me quickly iterate from writing calculator-crashing output loops to making little games for my friends.

For its virtues, Elixir was originally developed to serve a community of experienced web devs trying to solve problems most newcomers don’t know about and won’t encounter — and it shows. I think most novices would be better served by a more “mainstream” scripting language like Python, Ruby, JS, etc.


👤 weatherlite
No. There could be two ways to teach programming - one by doing - e.g building stuff. In that case all the popular web dev languages are good (javascript/python/ruby) because they are comfortable and it is relatively easy to build an app. Try doing that in C for instance. The other way of teaching is less by building a functional app and more by deep diving into computer science concepts like how arrays are implemented, what are pointers etc. C is usually used for that and I'm not a big fan of this style of teaching though many universities do it.

As for Elixir - going functional with your first language will just be confusing - the student will probably have to learn JS and other OOP languages soon. It makes more sense to me to do this transition when you are an established programmer.

And finally Elixir is not considered an easy language. Your first language ideally will let you get things done in the easiest way possible. For me that also puts typed languages as not ideal but I'm a minority there.

When you've never ever written code everything is hard - I see no point in making it harder so no I see no point in choosing Elixir as a first language.

Finally there's the job market of course, that small thing. Elixir in general is more suited for senior devs who are called to work on super scaley problems and the amount of jobs is small, that's not ideal for a beginner. However I will concede there are way fewer people who know it so maybe it could work out when applying to jobs.


👤 pawelduda
It really depends on the purpose of learning the language. If it's the first one, I would assume a general lack of broader perspective. As I remember how clueless I was - PHP, Ruby, Python, etc. didn't mean too much to me except having some cool logos and different syntax, from which, well, it was also hard to tell anything because I didn't know all these building blocks.

If the main purpose is to find a job, then I would check if there are local Elixir communities/companies nearby that could guide along the way. Elixir is a niche compared to other options out there, so I would recommend doing this ONLY knowing that there would be a strong support available on the way, from start to finish (landing an entry-level job).

On the other hand, if the main driver is curiosity to get into programming and that person feels drawn towards Elixir the most, I would say "just do it". The sheer will to tinker and build cool stuff that works can inflict a very positive feedback loop, which IMO is one of the strongest drivers to bettering oneself at coding. Even if that attempt turns out to be a failure, it's better to fail fast and give something else a try. I believe that in such case, the time spent on tinkering with Elixir will pay off anyway!


👤 Tabular-Iceberg
I started out with Common Lisp and David S. Touretzky's book[1]. The great thing with Lisp or Scheme as a first language is that it requires learning very few concepts and very little little syntax to get started. Lisp isn't terribly functional, but the functional style feels natural to use.

I like the idea of starting with pure functional programming. With procedural programming you have to teach two concepts, functions and side-effects. With pure functional you only have to teach one of those concepts. That is until you need to interact with the world, ideally you'd start out with a framework that papers over all of this. Maybe Elm would be good option for this reason? It helps that you can easily produce something graphical that can be interacted with from the very beginning, and building web apps is probably the most common application for programming these days.

1. https://www.cs.cmu.edu/~dst/LispBook/book.pdf


👤 linkdd
Erlang/Elixir is best suited for large, long running, distributed system.

Why? Because it has all the tools to handle such complexity, but you still need to understand it.

Someone who has never developed anything serious, or does not know programming, surely don't want to start with implementing such a system because they would not know what is the complexity, what is required, what are the footguns, etc...

By following the principle "use the right tool for the job", elixir is not the right tool to write "hello world".

My subjective answer to your question is: no it's not a good first programming language.

My bonus point: But down the line, you can only benefit from learning it.


👤 i-make-memes
i haven't even learned anything yet but a microscopic amount of java and lua but i might try elixir