Elixir + Functional Programming in 9-12 High School

Hello All,

I don’t know how to ask this question or if I am asking it in the right place, but I need some suggestions/guidance. I am currently taking EDU courses in university that revolves around designing and assessing curriculum in K-12 gifted students.

On of the main projects is designing a curriculum that uses the CSTA K-12 Computer Science Standards and Core Standards (I am in Iowa, so I’ll be using Iowa standards for Technology Literacy).

There is already a plethora of information in Scratch and Python, so I am trying to design something for Elixir and Functional Programming.

My questions are:

If you had to teach functional programming in K-12:

Where would you start?
How would you do it?
What would you teach?
Would concurrency be better off taught in another semester of the course, say two courses one in the fall the other in spring?
If you were in high school, what would you have wanted to learn?

Here is a quick outline that I have going on:

Unit 1: Getting Started: Background, Tools, Brief CS Overview
Unit 2: Computer Science Fundamentals: Variables, Conditionals, Functions
Unit 3: Data Types: Integers, Characters, Boolean, Atoms, Structures
Unit 4: Organizing Data: Modules, Functions,
Unit 5: …
Unit 6: …

Each unit will have a project at the end.

Thanks in advance!

1 Like

For starters I think I’d leverage what they already know. For example, at lower levels they at least know what adding and multiplying are, so you can introduce the concept that you can have an “add” function that’s a bit like a box where you put in two numbers and get out a new one.

Higher grades have exposure to some algebra so you can work with that.

Anything that can be quickly used to solve real problems for them is also useful. For example just learning to use a REPL like iex as a fancy calculator already brings real value.

I’d show the absolute minimum in data structures and conditionals to get them writing code. So eg. you can start with just strings, numbers, lists, functions and if at the beginning. Bring in atoms, tuples, maps etc gradually, as a solution for a new problem.

I’d also try to introduce ideas of declarativeness vs imperative code for higher levels. This also fits with what they see in school, ie “let x = …”

Something a lot of educators miss is the importance of leaving mystery. If you can possibly get them to “hey, this is so complicated with all these if blocks I just wrote, is there a better way?” instead of pushing every conditional at them right away, I think it’s a better learning experience. So instead of “here are all the conditionals because this is the conditionals unit” I’d probably sprinkle them more.

It’s so tempting to be focused on making the order of modules look organized at the course plan level that it’s less fun. So eg. you could show them pretty early on how to bring in a dependency and use something like Req to access a fun API. They could do something like build a “what should I wear today based on the weather” project as one example.

Also obviously Elixir isn’t the only option for teaching FP – you could show them browser JS for example – but LiveBook seems like a no-brainer here for teaching Elixir.

Anything that can create games will get a lot of students excited. For concurrency maybe an early way to introduce it is “here’s how to do things in the background” and for higher levels you might even build a multiplayer game together or a messaging app.

Collaborating as a class on a bigger project could be interesting instead of everyone just doing smaller projects. It better reflects what building software looks like in the real world and you could build it on github/etc. too.

1 Like

Thank you for the suggestions!

I am planning on centering this curriculum around LiveBook. What I want to focus on is writing practical systems for the real world. As much as I think programming a robot is really cool and interesting, it’s not really practical. Not everyone wants to get into the technical side of things such as Robotics.

I want to design this with other aspects in mind such as marketing, business, etc. The focus being, building services or web apps that can be useful to a students goals or a problem they see around them. Allow them to start thinking about the world and problems they see around them and how they can leverage Elixir and Phoenix to address them.

I think teaching Software Development/Computer Science with Elixir is perfect in that it allows people to quickly prototype ideas.

I’ll be designing this curriculum until May 2025. I’ll post further developments if anyone else is interested.

I like the LiveBook focus and “real world” orientation a lot.

Based on my own learning path with programming – I started from a young age – I think something I’d focus on is getting them quickly to self-directed because it’s a maker space, more like creative writing than eg. pure math where you’re just learning and solving problems for years.

A training wheels metaphor could be useful, where as soon as they’re on the bike, as much as possible you’re letting them steer and pedal, but helping them stay up until they’re good on their own. The training wheels to me would be things like computer science concepts and language details. They’re useful but ideally should be learned alongside doing stuff.

You’re right not all kids will want to program robots–but some might–others might want to build art, some might want to create a discord bot, some might want to make games. Someone could hook up an LLM wrapper and make a “do my English homework for me” bot, or more appropriately a homework helper at least.

There’s a lot to be said for the “case study” approach to learning, where you could deliberately have a few small but cool projects that pair real-world stuff (eg. save to a file, connect to a REST API etc.) with computer science concepts. And then it only takes a few of those before they can do their own thing. I’d get to “individual project” or “group project” early if possible.

Also we have to admit Elixir isn’t the ideal choice for every problem, since it’s best suited for things with networks and servers, but that’s a lot of stuff these days.

1 Like

You’re absolutely correct but given that majority of the content that I have found is based on Python, Scratch or Minecraft I want to introduce another way of doing and approaching problems. Elixir might not be the right tool for every problem but it sure does make it easier to grasp the why and how something works.

I also program in C and Rust but that’s far more complex and I don’t want to bog them down with concepts such as the CPU, memory, pointer arithmetic and undefined behaviors. That will just put them off and stifle their creativity. I want them to have an idea, jot it down, and implement it.

My focus in CS is cloud computing and distributed systems and I find that working with Elixir I can express the ideas better.

Here are some projects that I want to implement — some might be complex:

  • HTTP Server/Client
  • TCP Server
  • WebSockets
  • Messaging App
  • Real-Time Interactions with PubSub (Drawing)
  • Kahoot-It Clone
  • Clinic/Coffee/Dentist Web App (Get them thinking on where they can implement elixir + phoenix)
1 Like

Nice. Depends a lot on the level. I think the younger they are the more you want to “make the thing” whereas older students might get a kick out of “let’s build a web server.”

Wish I learned programming at that age or earlier…