Help me decide a language for Advent of Code

rhymes on December 01, 2018

I haven't given it much tought the past few days but I would like to try doing Advent of Code this year. I'm way past the middle of the day but ... [Read Full]
markdown guide
 

Elixir will become handy on the future as Rust, both are in demand right now and hard to find developers for them. Just depends in what part of the globe you live or if you are a remote developer.

Elixir is the language of choice for distributed, concurrent, parallel and fault tolerant systems. Elixir is a functional programming language that makes very easy to write software that runs concurrently in a fault tolerant way across several machines(distributed), their philosophy is "Let it crash...". Elixir is not suitable for heavy number crunching, but here we can interface with Rust, C to get the ultimate performance while benefiting the fault tolerant features of running a system in Elixir.

Elixir runs on the BEAM, that has more than 20 years of development and continues to be used on telephony exchange systems and in Cisco routers. The BEAM as nine nines of availability while AWS achieves only five nines.

Rust shines for being as fast as C while memory safe, due to the borrow and ownership model that guarantees at compile time that the code is memory safe, thus not needing garbage collection at run-time. Rust have a hard learning curve, thus I do not recommend you to use it to learn while doing the advent of code challenge.

Rust is powering now the new versions of Firefox and have strong foundations to replace C in the future.

Clojure I cannot comment on, but I would recommend you to go with Elixir for the advent of code challenge and afterwards you can challenge yourself to solve them again with Rust or Clojure and then you will have a good view what suites best your code style and the problems you need to solve.

Please remember that the hard part of doing Elixir is to shift to functional programming mindset, because developers more often than not will write OOP code while coding in a functional programming language and this is often without themselves realizing that they are doing so.

 

Clojure I cannot comment on, but I would recommend you to go with Elixir for the advent of code challenge and afterwards you can challenge yourself to solve them again with Rust or Clojure and then you will have a good view what suites best your code style and the problems you need to solve.

That's a great point. I can redo it in the future with the other two languages I didn't choose :-)

Please remember that the hard part of doing Elixir is to shift to functional programming mindset, because developers more often than not will write OOP code while coding in a functional programming language and this is often without themselves realizing that they are doing so.

Yeah I can see that happening, I'm definitely spoiled by imperative languages :-)

Thanks for the advice!

 

Let me know if you need some good resources to start with functional programming in Elixir.

Have fun in your advent of code challenge.

Please let us know what was the language that you decided to use.

I've posted my broken solution in Elixir but it's not working: github.com/rhymes/aoc2018/blob/mas...

Keep in mind I haven't even read the tutorial yet :D

Basically it's supposed to iterate on infinite stream of numbers, add one to the previous and if the sum is already known (hence the set), quit

Try to follow the advent of code in Elixir forum elixirforum.com/t/advent-of-code-2..., they are sharing their solutions there. The solution from member Sneako seems a good one, check it elixirforum.com/t/advent-of-code-2....

They are very nice people and will help you in your journey.

I am not doing the advent of code... unfortunately I don't have spare time to dedicate to it.

TIP: while if else exists in Elixir is barely used by a functional programmer. Instead try to use pattern matching in the function heads. See here an example dev.to/flatironschool/pattern-matc...

they are sharing their solutions there. The solution from member Sneako seems a good one, check it

yeah, I ended with a similar solution github.com/rhymes/aoc2018/blob/mas... - though you can see how more imperative is my code

They are very nice people and will help you in your journey.

Nice to know! I still haven't completely ruled out Clojure :D

I am not doing the advent of code... unfortunately I don't have spare time to dedicate to it.

It's perfectly fine, it's my first time ever!

TIP: while if else exists in Elixir is barely used by a functional programmer. Instead try to use pattern matching in the function heads.

Thanks for the tip. I'll surely read it. I tried to use pattern matching with MapSet.member? as a guard but it wasn't allowed, so I switched to a recursion first and then the if + reduce_while version.

I hope I'll have time to study the language a little better, not just try to butt my head on the wall until I get a decent solution :D

Nice you have been able to figure it out.

Not everything can go in guard clauses. Try to read about them.

I am seeing some doing the advent of code in 2 languages at same time. So why not Elixir and Clojure for solving each day challenge?

No matter what language you want to use for the advent of code would have been good that you had time to prepare for it before, like going through the basics of it.

What worked better for me to left the imperative thinking and adopt the functional programming way was this video course and this book. They are paid but totally worth every cent I paid for them. The author spent a lot of time ensuring that we understand the functional programming paradigm. By the end we have built something useful that we can use in our day to day as developers.

Thank you :-) You're right, I should have gone through at least the tutorial before, but I totally forgot about it :D

 

If you've never done a lisp, then go for Clojure for sure. It's refreshingly fun and different, plus you can read my totally helpful post to get started

 

I second that, it's radically different from most languages so if you're not familiar with LISP-y languages already then it could enlightening to work through the "wizard book".

Structures and Interpretation of Computer Programming:
web.mit.edu/alexmv/6.037/sicp.pdf

 

Oh the SICP book, brings back memories of reading Paul Graham's essays on Lisp and Arc

 

Ah ah thanks I read it, and it helped. I studied Common Lisp a bit many years ago (using SBCL) but I don't remember much.

 

If you go clojure, and I recommend it too, this template is what I used for AoC last year

 
 

I've tried coding AoC day 1 with Clojure but I'm unsure about what's wrong with this: github.com/rhymes/aoc2018/blob/mas...

🧐

any ideas?

 

I'm going to do Python/JS since it's my first year and I really want to complete it!

 

Makes sense, I want to complicate the stakes 😅

 
 

Among those you listed, I would pick Clojure. Simply because I have never used a Lisp dialect. Of course, I would suggest F# if you haven't tried it already.

 

I thought about F# too.

Don't know if I prefer ML or Lisp syntax :D

 

I'm a huge proponent of Rust, but I'd actually advise against it in this case.

It's got a moderate learning curve that might be frustrating to start immediately solving different problems every day. It's more of a "marathon" language, when you're trying to do sprints.

 

I'm a huge proponent of Rust, but I'd actually advise against it in this case.

Yeah, I noticed. Although the day one was easy enough for me to find a solution to in Rust, I can sense it's going to be harder and harder if I don't know the language at all.

It's more of a "marathon" language, when you're trying to do sprints.

Great analogy. I'll also try today, then I'll remove it from the list (I haven't decided yet between Clojure and Elixir hahaha)

code of conduct - report abuse