Specifically, I'm interested in BEAM, but I'm not sure if I should go for Elixir or Gleam. What seems cool about Gleam is that it has static typing.

I have no experience with functional programming at all btw

top 40 comments

sorted by: hot top controversial new old
[+] 21 points 1 year ago (7 children)
  • [–] 4 points 1 year ago

    Haskell isn't the best venue for learning currying, monads, or other category-theoretic concepts because Hask is not a category. Additionally, the community carries lots of incorrect and harmful memes. OCaml is a better choice; its types don't yield a category, but ML-style modules certainly do!

    @thingsiplay@beehaw.org and @Kache@lemmy.zip are oversimplifying; a monad is a kind of algebra carried by some endofunctor. All endofunctors are chainable and have return values; what distinguishes a monad is a particular signature along with some algebraic laws that allow for refactoring inside of monad operations. Languages like Haskell don't have algebraic laws; for a Haskell-like example of such laws, check out 1lab's Cat.Diagram.Monad in Agda.

  • source
  • parent
  • [–] 2 points 1 year ago (2 children)

    When I read about Monads, it looks like to me like generic Rust struct with a generic trait and a (more complex) result as a return value. I have no idea if this is what a Monad basically is or not. For context, I never learned Haskell properly (just tried hello world and read a few topics).

  • source
  • parent
  • hideshow 2 child comments
  • [–] 6 points 1 year ago (1 child)

    You should think of Monad as basically giving you a way to provide your own implementation of the semicolon operator so that you can dictate what it means to sequence computations of a given type.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 3 points 1 year ago

    I think the mistake I do (and many others) is trying to compare existing mechanisms from other languages, without the full picture around that mechanic. Every time I think to understand what a Monad is, its wrong. :D Guess I have to dive deeper to understand what that actually means, not just as an explanation. Just out of curiosity.

  • source
  • parent
  • [+] 14 points 1 year ago (2 children)
  • [–] 10 points 1 year ago (1 child)

    Clojure always seems to be more popular than I expect it to be. Though I have no experience with it myself. It benefits from access to the JVM ecosystem as well I believe.

  • source
  • hideshow 1 child comment
  • [–] 4 points 1 year ago

    I love clj. in general it takes more of a pragmatic approach to functional programming than others. you get most of the purity for way less effort. same with specs over proper static types. it just ends up being a very enjoyable and productive language

  • source
  • parent
  • [–] 8 points 1 year ago (1 child)

    I'd go with Erlang over elixir, but it sounds like you already have an interest in gleam.

    FWIW: just pick one and get started. There are some major axes to consider: pure versus impure, lazy versus strict, static versus dynamic typing, but to kick off if you've done no FP before it's probably better to just go for it.

    There are some really intriguing "next steps": SICP, the ML module system, the Haskell ecosystem, the OTP approach to state, but to begin with it's just worth getting used to some basics.

  • source
  • hideshow 1 child comment
  • [–] 6 points 1 year ago (1 child)

    I assume this suggestion will get me torched for reasons I don't understand, but why not a multi-paradigm language like JavaScript/Typescript, or C#?

  • source
  • hideshow 1 child comment
  • [–] 5 points 1 year ago
    [–] 5 points 1 year ago

    Elixir is quite amazing to write and read, the major libraries (Pheonix, Ecto, etc.) have excellent documentation, the tools are generally excellent and it is built on to BEAM which is amazing. But it is a dynamically typed language with all the pain that can incur. Of course, there are tools (such as Dialyzer) to give some amount of static type checking but they were not very good when I tried them some years ago. Using things that need mutation can also be a pain. Programming Elixir 1.6 Functional |> Concurrent |> Pragmatic |> Fun was the book I used to learn functional programming and Elixir and it served me well.

    There are other good languages you can look into such as Ocaml (that has good free resources for new programmers) and Racket with the amazing free course you can find on OSSU.

  • source
  • [–] 4 points 1 year ago

    I think it doesn't matter in what language you start, as long as it is the paradigm you are learning. You can still pick and choose the language later. Maybe start with a pure functional language, just to learn its concepts. Haskell comes to mind, but it kind of is not the best usable language in every day programming; its more academical nature in my opinion. I personally find Closure also interesting, but I'm not the biggest Java fan at all. At least the language is for practical usage.

  • source
  • [–] 4 points 1 year ago (1 child)

    My ₹1. It may depend on what you plan to write in it (for fun). The BEAM sounds great for long-running processes, but not as much for point tools; Erlang and co supposedly run slower than Python, which isn't fast either.

    My other ₹ ;-) if you stick to the BEAM: OCaml sort of runs on it, as there is the Caramel project to replicate it (https://caramel.run/). One of the Erlang creators also ported Prolog to the BEAM (erlog), as well as Lua (erlua) and Lisp (LFE). Elixir is probably great, as it is inspired by Ruby (I found Ruby very pleasant, other languages have so much semantic noise).

    Freebie! The BEAM inspired an inspirational design for parallel programming, the Pony language. I am somewhat sad development slowed down, it is a Rust killer.

  • source
  • hideshow 1 child comment
  • [–] 2 points 1 year ago (1 child)

    I love functional programming and hate object oriented. It's just how my brain thinks, I can and regularly do OOP, but I have to force myself to do it. Why not python? You can do BEAM in python, it's pretty easy to learn, and it's incredibly versatile, and you can program functionally in it too.

  • source
  • hideshow 1 child comment
  • [–] 1 point 1 year ago

    Python has OOP but basically no ergonomic support for FP? It doesn't even support tail recursion or currying, lambdas are very limited and there is no nice way to compose functions. Most of the python ecosystem heavily relies on OOP and in many cases global state. Not hating on python but even compared to other mixed paradigm languages like javascript it's on the less-functional side of things.

  • source
  • parent
  • [–] 2 points 1 year ago

    If you’re interested in BEAM anyways, Gleam is just a lovely language to work with. It makes many functional principles easy to work with rather than mathematical. Although I don’t have any experience in Elixir, so I can’t judge how it compares in detail.

  • source
  • [–] 2 points 1 year ago*

    Clojure is simple, is a lisp (huge plus since they are super simple and you gain access to a whole realm of languages), and practical. You can do anything from backend to frontend dev with it, and the philosophy and community are lovely.

    Scheme is less practical but easier to start with.

    Haskell is the least practical but isdefinitely beautiful and helps you understand things better.

  • source
  • [–] 2 points 1 year ago

    F# is a decent introduction into functional programming. You can use .NET libraries and occasionally fall back to imperative code when needed.

  • source
  • [–] 2 points 1 year ago

    gleam feels cozy.

  • source
  • [–] 3 points 1 year ago* (last edited 1 year ago) (2 children)

    Rust is not fully functional. But I am legally obligated to recommend it any time I can.

    Jokes aside, this doesn't apply to you, since you seem to actively learn functional programming. But for people that are scared of it, rust looks like "normal" languages, but has tons of features that can be attributed to functional programming. Even more so if you avoid using references. You can easily "mutate" objects the functional way, by passing the object to the function, and the function creates a new object with just some value changed.

    It has algebraic data types. Function pointers. Iterators. Pattern-based match statements. Don't have class inheritance. Inmutable by default. Recursion. Monads. And probably other FP features that I'm missing.

    It has basically every functional feature while having familiar syntax.

    It's also extremely easy to install. Which I didn't use to appreciate, but then I tried to learn OCaml and had to give up because I couldn't set up a proper dev environment on windows.

  • source
  • hideshow 2 child comments
  • [–] 5 points 1 year ago* (last edited 1 year ago) (1 child)

    Rust certainly is an interesting language and very worth learning but, as you already pointed out, can hardly qualify as functional. It has some functional features and a rich type system for sure, but the way you solve problems in rust is mostly just imperatively and very different from the "FP-way" imo. If OP wants to get into FP specifically, I'd suggest picking a different language first.

    On another note: Not quite sure why you're saying OCaml ist hard to install, since the setup has been incredibly easy for me. Maybe the process has changed lately (they've been working on improving the tooling with opam and dune) but you can just follow the official installation instructions under https://ocaml.org/install and get it running in like 5 mins. If that doesn't work, there's always wsl.

    Personally I'd suggest OCaml, as it's a statically typed, expressive and pragmatic language with a decently sized and mature ecosystem. For learning resources there's the wonderful Cornell book. Elixir is another hot contender and a pleasure to work with, as others have already pointed out. Pick Haskell if you're interested in getting freaky later on and have built some foundational knowledge (personally I enjoyed the haskell mooc but there are other great resources like learn you a haskell for great good too).

  • source
  • parent
  • hideshow 1 child comment
  • [–] 2 points 1 year ago

    It was years ago. So I don't remember what exactly the problem was.

    I believe ocaml has a shell interpreter and a compiler right? I managed to get the shell interpreter to work, but I couldn't get one of these to work:

    • Compiler
    • LSP

    The reason I prefer windows is because things just work. But it was a frustration with ocaml. Meanwhile rust was a single command for the compiler, and a single extension install for the LSP.

  • source
  • parent
  • [–] 1 point 1 year ago

    I've only used one, and I'm only mentioning it since nobody else has, but I recommend Lean; moreso as a second functional language if you want to build stuff as opposed to just learn the paradigm. It's mostly used in maths because it supports dependent types, but it was fine for writing simple scripts, and it can be easily compiled to binary formats. I don't like the package management system and toolchain complexity, but most languages kinda suck at that, imo.

  • source
  • [–] 1 point 1 year ago

    I'd start with logo.

  • source
  • [–] -1 points 1 year ago* (1 child)

    Erlang https://learnyousomeerlang.com/ If you know golang and recurrence it should be easy, google basically stole channels from Erlang and syntax from Swift. Like everything else, they just stealing stuff and claiming they're great. Fucking rich script kiddies.

  • source
  • hideshow 1 child comment
  • [–] -3 points 1 year ago* (last edited 1 year ago) (4 children)

    Rust. It has all the good bits of functional programming but basically none of the bad bits.

    Good bits:

    • Strong type system (though not quite as sophisticated as Haskell or OCaml).
    • Map, filter, etc.
    • First class functions (though lifetimes can make this a bit awkward)
    • Everything is an expression (well most things anyway).

    Bad bits:

    • "Point free style" and currying. IMO this is really elegant, but also makes code difficult to read very quickly. Not worth the trade-off IMO.
    • No brackets/commas on function calls. Again this feels really elegant but in practice it really hurts readability.
    • Global type inference. Rust requires explicit types on globals which is much much nicer.
    • Custom operators. Again this is clever but unreadable.
    • Small communities.
    • Poor windows support (not a fundamental thing but it does seem to be an issue in practice for lots of functional languages).
  • source
  • hideshow 4 child comments
  • [–] 2 points 1 year ago

    I would advise going in the opposite direction, learning a purely functional language first to then being able to appreciate functional parts

    That is beside the point of an opinionated list of the good and the bad, that will differ for others

  • source
  • parent
  • [–] 1 point 1 year ago (2 children)

    The only things on the bad list that I agree with are top-level type inference and small communities. And ocamls windows support is terrible. Haskell's is more than ok now.

    In Haskell, any style guide worth its salt requires annotations on top level functions, and many of them also require annotations on local bindings. This pretty effectively works around the problem.

    Bad code will be unreadable in any language of course. But the other things don't themselves make code unreadable once you're actually familiar with the language and its ecosystem.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 1 year ago (1 child)

    Bad code will be unreadable in any language of course.

    Yeah I'm talking about good code, or at least not bad code. Let's not "no true Scotsman" this.

    Even for good code you don't need syntax highlighting to easily see which identifiers are function names and which are their parameters in Rust.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 1 point 1 year ago*

    I don't need syntax highlighting for that in Haskell either. My usual highlighting just leaves them both in the default text color.

    And I'm specifically arguing that the other things on your list do not inherently make code bad.

  • source
  • parent