5 ms·
And for non-functional languages? Not everybody wants to spend next 5 years learning thinking bottom-up, mastering category theory, monads and all that for suc
by bitL 9y ago
And for non-functional languages?
Not everybody wants to spend next 5 years learning thinking bottom-up, mastering category theory, monads and all that for such a task like writing a silly webpage you wouldn't rather be doing.
[rant] Frankly, I am not sure why is functional paradigm considered a savior and better approach for inherently non-concurrent web frontend technology. I program in Haskell/Scala but pushing functional programming everywhere is IMO just insanity and everybody is silent about many warts and weirdness of purely functional programming. [/rant]
- dbrgn 9y agoElm is the opposite. From this article: https://medium.com/@eeue56/why-type-classes-arent-important-in-elm-yet-dd55be125c81 https://medium.com/@eeue56/why-type-classes-arent-important-... "Right now, any Elm developer can examine Elm code that another developer has written, and fully understand what is going on. I consider this a major thing that Elm has got right." And "Elm is targeted at the main source of users it has — Javascript developers. Javascript developers may be familiar with typeclasses, but it is less likely that they are than Haskell developers. Alternatives like Purescript provide more abstractions and powerful type systems suited to those from the Haskell community. There are many of us Haskell users who sit happily with Elm too." Elm favors simplicity and pragmatism over academic FP lingo. You need to change your way of thinking a bit, true, but it benefits the architecture. And it'll take weeks, not years! You will not find the words "monad" or "category theory" or "algebraic datatype" used in the Elm docs.
- bitL 9y agoThanks! Do you know any good (Udemy?) course in Elm that won't take too much time and gets into important parts quickly and thoroughly?
- machiaweliczny 9y agoI don't get why you need udemy course. Just read official tutorial with open sandbox/project.
- csmiller 9y agomaybe this? https://pragmaticstudio.com/courses/elm https://pragmaticstudio.com/courses/elm
- dbrgn 9y agoThe guide is probably the best resource to get started: https://guide.elm-lang.org/ https://guide.elm-lang.org/ It introduces you to the language as well as the concepts / architecture.
- mafribe 9y agoI'm surprised that you think FP requires mastering category theory. Au contraire. It's perfectly possible (and indeed easier for programmers) to understand the abstractions that Haskell and Scala pioneer (higher-kinded types, and things like type-classes as well as monads which are basically enabled by HKTs) without category theory. It is true that monads were discovered via category theory, but in retrospect programmers could have discovered them -- after all they are (simplifying a bit) merely a way of generalising composition. Scala and ML-variants like Ocaml, F#, Reason.js are perfectly good imperative languages. They don't force you to go purely functional. I always recommend that my students (whose first language is Java) start by treating Scala as a "nicer Java", and then slowly explore Scala's more powerful features. Indeed, I'd argue that Scala and the aforementioned ML-variants are (slightly) better general-purpose imperative languages than the Javas, Pythons, PHPs and Javascripts of this world, because they are more consistent, they have types/type-inference, and their statefulness fully supports higher-order state and powerful modularisation without restriction, not to mention pattern matching. Being able to use functional idioms without compromise if and when desired (including, but not restricted to, pure functional programming) is another benefit of Scala and ML-variants.
- seanmcdirmid 9y agoMonads existed before their connection to category theory was discovered (by Wadler and company), they just didn’t have an elegant way of describing or naming but. them, and definitely the connection allowed them to push them more. The biggest problem of very functional code on the web is simply debugging it. So much control flow is buried in compositions that there isn’t much to grab on in terms of break points or variable inspection. Pure languages exacerbate this problem by making state more difficult to dig out and pin down at run-time.
- bitL 9y agoExactly. Debugging is one of the biggest problems with FP, and when you hear some prolific Haskell hackers talking about no longer being capable of understanding code they produced 10 years ago at the peak of their mental performance, it's difficult to commit to it exclusively.
- nickjj 9y agoIt's not that bad. I've been learning Elixir (a functional language) for a new project I'm working on and even with only being able to allocate 20-30 minutes a day on it, I don't feel like I need to relearn everything. This is with no prior functional language experience, just a bunch of general experience with Python and Ruby. I have no formal CS education and while I've heard the terms category theory and monads before I have no idea what they are. In my mind, monads are some Haskell related meme and category theory is thinking about whether or not to use categories on a blog engine. I found Elixir to be curiously easy to adapt to. I spent like 15 minutes glancing Elixir's documentation and now I'm running a Phoenix based web app (somewhat comparable to Rails but not really) following an "error based development" work flow. This is where you try to do something, completely fail at it, look up the answer and figure out how to apply it. I don't even know how most of Elixir / Phoenix works yet I'm able to accomplish real things. After spending 15 minutes reading Phoenix's docs on routing, I actually feel like I understand Phoenix's routing system better than other frameworks in different languages that I've worked with for years. This is partly because it's so easy to just trace a function call back to another function call and understand what's going on (plus their docs are badass).
- pka 9y ago> And for non-functional languages? I would recommend Typescript then. > Frankly, I am not sure why is functional paradigm considered a savior and better approach for inherently non-concurrent web frontend technology. True, FP excels at concurrent programming, but that's far from its only strong point. I'd propose that React-like architectures (which are based around a pure Model -> View function) and functional languages are a match made in heaven.
- bitL 9y ago> I would recommend Typescript then. Funny, all people using Typescript I know use it in functional way (computer vision/AR in a browser).
- ptx 9y agoIf you want an imperative and statically typed language, try Kotlin: https://kotlinlang.org/ https://kotlinlang.org/ ...which targets JavaScript in addition to the JVM (and being an officially supported language for Android development): https://kotlinlang.org/docs/reference/js-overview.html https://kotlinlang.org/docs/reference/js-overview.html
- mmargerum 9y agoImmutable dats structures in CLJS pairs well with react type frameworks. Trying to make js pretend it supports immutable structures is what turned me off the most about react/js I ended up going with vue which uses mutations instead of having to return structure copied from functions. Just made more sense to me. Maybe MobX does this for react? Idk