Elixir for teaching programming

I propose to take a look at google sheets as an option for an absolute newbie.

Stage 1: Work with formulas in the cells - this is ‘functional programming’ I believe.
Stage 2: Progress to functional JS (which is Google Apps Script) to control the spreasheet (allows for side effect like writing to spreadsheet or to docs for that matter).

Whatever your pupil learns is probably immediately useful and transferable and keeps the whole chain right there in their hands. They will have complete independence and power immediately.

Stage 3: If their interest has piqued then they can move on to control spreadsheets (or docs or slideshows or forms etc), via the google suite APIs, from Elixir/Phoenix.

Stage 4: Supplement reading from/writing to the google suite via LiveView (and of course doing things wholly independent of google suite).

(To be fair, stages 3 and 4 are are what I would like to be taught! )

2 Likes

Thank you @John-Goff, I have the same idea, using Elixir to teach programming, obviously from a functional point of view, but there is no need to even mention it at this preliminary stage. I don’t want to introduce unnecessary concept. I dont want to teach Elixir itself, it will be a tool nor the goal. OTP, concurrency, are concept that will not find any place until one discover the problem they are meant to solve. And that requires times and a good amount of coding. Also, as you suggest, I’ll begin with iex and then exs scripts, there is plenty of things to learn before reaching for more advanced concepts. Thank you for you contribution.

Interesting approach, I can see the rationale of it, especially in producing early applicable results. But I will try to keep the teaching the most technology agnostic I can, and not focusing on real world specialized problems and solution. Steps 3 and 4 are too complex for the goals of this introductory course, we won’t get near web development yet. Before that I believe we will need a good intro to plain static HTML and some basic CSS. Only after that, I could think of introducing web dev, server rendering and the Phoenix framework; and I see many months of learning before reaching that point. Thank you for you contribution, I will keep it in mind to see if I could introduce it sooner than I expect.

I’m happy to see that people are (thinking about) using Elixir to teach programming!

We at UCLL at Belgium are using Elixir to teach the courses Internetprogramming Major and Distributed applications. The students already have a background of OO programming (and html, css, etc…). It is interesting to see the mistakes they are making, such as:

  • Even after a few weeks, some students still try to manipulate data instead of transform it
  • if statements. They’re everywhere!
  • pattern matching is a challenge
  • recursive functions seem to be a big hurdle to overcome.
  • They’re not used to solving things with higher order functions. Their most trusted tool (the for loop) is gone, and they try to use the for comprehension to manipulate data, which fails quite often. It is my personal opinion, but I try to forbid using that for comprehension and suggest them to use an higher order function as it only confuses them.
  • GenServer: messages (specifically cast messages) are used as setters, which results in messages everywhere! Invalid states and crashes are the result of this. Good thing they have a supervisor…

Those are just some of the more common ones. If I can help in any way, feel free to ask!

Regards,
Wannes

6 Likes

Thank you very much @WFransen, I’ve been there when I decided to learn FP and Elixir, coming from 10 years of Ruby OOP, and having started back when GOTO was not a bad word nor a horrible idea. I will put a lot of attention and efforts to make those points the natural way to go since the beginning. Then if my student will need to learn about for loops, well, she’ll take the responsibility for that :wink:
Thanks for your offer, I will remember to ask!

1 Like

Just a newbie perspective: I just started programming some months ago! Started with Javascript, but I got really annoyed with a course called “Object oriented Javascript”, because I didn’t see the logic in the way of organizing the code.

Then I discovered Elixir! I saw people saying it was a great language, but that it was difficult to shift mindset from a OO-language. So I decided to dive head first into functional programming with Elixir first, instead of the other way around.

I think Elixir has been supereasy to learn, and for me it seems like better tool to learn programming in general. When I look at other peoples javascript code, it seems like a big mess in my head – even though I know the basics. It’s way more easy to follow and read code in Elixir, especially with the pipe operator.

Most important, it’s fun! And that’s the most important thing when learning to program.

6 Likes

:smiling_face_with_three_hearts: Thank you for that! This is the hidden reason behind my choice of Elixir. Then when you love to program you can also stand the jayEssMess :wink: -if they pay you enough-

I have to say that I learned with Sinclair BASIC, there were not many other choices back then. It was the glorious time of spaghetti code, one liner functions and a hell of GOTO and GOSUB. But I had sooo much fun anyway, writing my programs on paper, waiting to get my hands onto a ZX80 microcomputer, at the local shop, to see if they worked or not!

2 Likes

I just know the existence of https://github.com/pprzetacznik/IElixir – but it might be worth to check. It’s a Jupyter kernel for Elixir

3 Likes

If I am not mistaken @adolfont teaches Elixir in universities (pardon the mention and if I remember not correctly :wink: )
I know you from twitter!

1 Like

I can imagine Elixir for a first take on programming, but not to learn how to build software.

Elixir is too easy, too good actually. Soon enough the student will hear about JDK/JRE or have to deal with webpack/rollup/babel and figure out how to get something out of that hell of an ecosystem, figure out how to run them python 3 code with /usr/bin/python being v2 on most platforms, why does my website shows my PHP code, etc, etc.

Oh and why my unhandled node promise teared my whole app down …

1 Like

Yes, I have played with it some time ago, it could be a good learning tool indeed, but I’d like to start with a simple text editor at the beginning. Thanks for the suggestion!

1 Like

That is exactly the goal, a first take on programming aimed a total newbie with no prior experience of any kind. I’m not planning a course to build up professional skills, there are plenty of excellent resources for that, and it is beyond my capabilities. I’d like it to be a funny exploration of a new way to use a computer, and approach problem solving and analytical thinking.

1 Like

Lots of great insight here but I’d personally suggest getting them started on Racket with the free textbook How to Design Programs, written by the brilliant Matthias Felleisen (among others). I am biased since he was my university professor, but it’s a great introduction to programming from a functional perspective, and many language features from Racket (PLT Scheme) were borrowed for elixir, especially the metaprogramming features.

I second staying away from otp, but depending on the person, using raw message passing (spawn, send, receive, and friends) to “chat” between nodes can be a fun way to learn basics about concurrency, network addressing, distributed name lookup (and name authorities) and… Message passing. As long as you make sure “don’t do this for realz” is peppered throughout.

Iirc there was a teacher who did this with an elementary school class in erlang and they loved it.

3 Likes

The good news is that the js community is getting more and more functional and it is even possible to have a career in Js where you never write a class (though you should probably understand how they work).

2 Likes

I really loved the little time I spent with racket, but I fear it will be too intimidating. Anyway after a first period I’m planning to make an explorative tour of other languages, and I’d like to thank you for the suggestion (I was thinking of something like a bit of Js, SonicPi for ruby, Pharo’s smalltalk, a glance of swi prolog…) I will remember to include Racket/Scheme for a taste of lisp. Many thanks for the linked book too, I feel I could borrow lot of interesting material from it.

1 Like

I like the idea of aiming at a super simple distributed system with two nodes and processes implementing a sort of local network chat, I feel it could be a very funny final project for the course, the cherry to put on top of the cake! Thank you @ityonemo, I haven’t thought of that, knowing where I want to go makes the planning of the whole journey much easier!,

I found the video: https://www.youtube.com/watch?v=WT-dQ1jFSrg

1 Like

This is great! Works nicely!

Any way to get syntax highlighting there, though?

Hey @josefrichter I don’t know. I just knew its existence. Maybe you could open an issue in their github repo?

1 Like