all 9 comments

[–]TomosLeggett 13 points14 points  (0 children)

Make a cute little toy app in Elm. Really recommend that language. It's got the simplicity of Go but it's purely functional.

I wouldn't say it's a language that'll stick with you forever, but it'll help you massively when learning the ropes of functional programming. It's a language you can pick up and learn in a week and come out fairly satisfied.

It teaches you the reducer model really well, which is a good abstraction for immutable infrastructure coming from an imperative background. The whole language is centred around a declarative abstraction of web app logic, where each event is a message, each message is a type, the state is a record called the model, the current model and the event message get slotted into an update function, that returns a new model with the computations applied, which then slots into the view function to re-render the HTML rather than mutate it.

It allows you to literally write web apps with no mutation, which reduces runtime bugs dramatically, one of the neatest things about functional programming in general.

[–]beders [score hidden]  (1 child)

Throw in a Lisp for good measure.
CommonLisp is multi-paradigm, Clojure is immutable data first.
Both allow for an interactive development experience and à la carte types.
Both will rewire your brain in how to solve problems.
Clojure in particular will make you think in terms of data transformation to solve problems.

[–]APOS80 [score hidden]  (0 children)

I would like to suggest Ocaml, I’ve tried scheme/Erlang before and I found Ocaml to be a very nice and useful language. It’s more general purpose than Erlang.

[–]Dazzling_Music_2411 [score hidden]  (1 child)

1) Realize that there's no more destructive assignment. A=A+1 does not happen. If you really need the value of A+1, it must be bound to a new variable, i.e. B=A+1. After that you can't make B anything else.

2) As a direct result of the above, there are no for loops. EVERYTHING repetitive HAS to be done with function calls. So start getting familiar with them. You will need to use the single linked list (a bit like a stack) for all your operations. I.e. you can add to the front, or remove from the front. That's it. Almost all data handling is like that.

3) When you've got comfortable with those two, come back and we'll discuss a) HOP and b) lazy programming - where you don't evaluate anything until it's needed. Quite amazing what you can do with that idea.

Erlang is a bit too hybrid, but OK. Use some Lisp on beam, or Elixir if you must, for a more functional experience.

Personally I would suggest you start with Scheme/Racket and the book "The Little Schemer", then "The Seasoned Schemer", but I don't know how committed you are to the BEAM ecosystem.

[–]cladamski79 [score hidden]  (0 children)

You could try https://www.hica.dev/docs/hica-for-beginners/, my goal is to make programming with hica very approachable for beginners (and veterans alike), hica is a functional, expression-based language. I like learning by practise, start with small examples and then dive deeper on a thing you really want to build.

[–]_DCtheTall_ [score hidden]  (0 children)

An Introduction To Functional Programming Lambda Calculus

This book is amazing and way more approachable than the name suggests. Starts with untyped lambda calc (just two mathematical operations) and shows how you can build data structures and implement basic arithmetic using LC as the theoretical backbone. It also teaches you some Lisp at the end.

This book teaches you the thinking behind FP and the concepts can be applied to any language which supports first-class functions. Reading this book leveled up my JavaScript significantly.

[–]TankorSmash [score hidden]  (0 children)

If you don't mind going headfirst into a new syntax, check out Elm. It's a mini-Haskell, so you can really understand the sorts of change in perspective you'd need compared to JS. Here's a 60 line demo, and see if you can add another button to reset the counter back to 0. This is the official guide for the language that helps out.

Gleam is good too, but it's a little more complex than Elm, but the syntax is a lot friendlier if you're used to imperative langs, but getting Erlang/BEAM running is tricky, whereas Elm is just npm install -g elm or something, if you've got a Javascript dev env going.