4 ms·
If people want to move towards functional programming, I would recommend Elixir as the first step. There is a fantastic web framework called Phoenix built in E
by rkangel 8y ago
If people want to move towards functional programming, I would recommend Elixir as the first step.
There is a fantastic web framework called Phoenix built in Elixir. This provides a way that you can immediately build something useful, and it teaches you how to use Elixir well: the documentation is good, the generated code that you start working with is a great example of how to use the language properly, and when you start understanding the design of the framework it's a great example of functional systems design (e.g. the Plug.Conn structure that gets passed around).
Not having to deal with a full ML (or Haskell) like type system takes away a large barrier to entry, but you still have to change your mindset about how you implement things. And then the dialyzer is there, when you later want to start using gradual typing.
- proaralyst 8y agoElixir is not statically typed. Thus you lose a lot of what makes OCaml great; a whole class of errors caught by the compiler before you run your program. I'd say the type system isn't that much of a barrier to entry. You're likely used to one from any existing statically typed language; the only new things are sum types, polymorphic types & type inference. These aren't _that_ hard to get your head round but really improve the safety of your program.
- rkangel 8y agoMy point was about barrier to entry. My experience is admittedly with Haskell rather than OCaml, but while I did get my head round these things to some degree, I was still a long way from being productive. And this is despite having come from a background of C++. The debate on static vs dynamic is a far from settled one, but I think you would be hard pressed make the case that Python has no place. In this case, I'm suggesting that Elixir is a great way of getting people into functional programming and learning the value, while being immensely useful in its own right. Learning that value is a good first step. I now find it immensely depressing every time I go from my Phoenix web-app back to the Android app. Kotlin is better than Java, but it's still a mess of objects and interfaces, and having to construct 5 things when it could just be passing a map to a function. The result is that I will now more aggressively pursue FP options when I'm looking at technology decisions (e.g. bucklescript is on my 'to investigate' list).
- proaralyst 8y agoHaskell has a famously high barrier to entry that has little to do with its type system or functional nature. As a pure lazy language you have to learn a lot of concepts (What does pure mean? What does lazy mean? What is a monad?) before you can be productive. Extending this into intermediate usage is difficult too; how do I begin to combine these monads I now understand? I see your argument. If your aim is to get into functional programming then Elixir/Erlang, even Lisp/Scheme is fine. I don't think it's the functional nature of OCaml and Haskell that make them powerful; I think those parts of the language are great, yes, but the type system (static, algebraic, inferred) is the real secret sauce.
- progman 8y agoIf you want to teach FP you should use the very first and most simple FP languages --- Lisp and Scheme. Despite their extreme simplicity, they provide an extremely expressive power (through their macros) which is still unmatched in most other languages.
- drb91 8y agoI wouldn’t characterize either as FP, though—both of them still actively encourage maintenace of mutable state and use of macros. They may be “simple” in that they are very analyzable but you’re teaching a whole bag of skills, and the most FP part of lisp/scheme is just the closure.
- baby 8y agoThese languages are horrible, filled with parenthesis and not fun. I had to learn these in school, like many other people, and I stayed away from FP languages for a long time because of that (like most people). Try to learn Erlang or Ocaml, it's fun.