4 ms·
I'm at a very similar place to you at this point. It make sense for FP to be good at "describing relationships of actions" since the base unit of reasoning is a
by stepbeek 5y ago
I'm at a very similar place to you at this point. It make sense for FP to be good at "describing relationships of actions" since the base unit of reasoning is a function, or an action.
The beauty of modern programming is that we don't have to stick to a pure example of either paradigm. We can use FP techniques where it makes sense and turn to imperative otherwise.
In you example, we could have a nice, purely functional model of an LED that enforces the invariants that make sense. We could then "dispatch" the updated led entity to an imperative shell that actually took the action. All without using the M-word!
I'm probably - unfairly - treating your example more seriously than you intended it, but I think I'm leading to the same conclusion as you at a slightly different place. I want to have a purely functional domain that I wrap in an imperative shell. Trying to model side-effects in a purely functional manner using something like applicative functors just doesn't give the productivity boost that I want.
> I use a purely functional language every day: it's called SQL
This is my favourite way to annoy FP advocates (despite probably being one myself). Every one is a closet mathematician in FP-land but no one wants to admit how beautiful relational algebras are.
- TuringTest 5y ago> I want to have a purely functional domain that I wrap in an imperative shell. Trying to model side-effects in a purely functional manner using something like applicative functors just doesn't give the productivity boost that I want. Funtional Reactive is a very good way to create that mix. Web Front developers have realized that, and that's the reason why most modern frameworks have been veering towards this model slowly, with Promises and Observers everywhere. When you represent state as an asynchronous stream that you process with pure functional methods, you get a straightforward model with the best of both paradigms.
- stepbeek 5y agoI like FRP, but prefer to imitate it in a synchronous manner now - I mainly work on the JVM and I've personally found debugging to be too painful when working asynchronously. If I need async then FRP is definitely the first tool in the toolchest that I'd reach for. Elixir's pipe operator is a brilliant tool that I wish every language had. I mainly use kotlin day-to-day and definitely abuse the `let` keyword to try to get closer.
- TuringTest 5y agoTrue, FRP doesn't need to be asynchronous; it's just a very good paradigm to support multi-process computation and module composition. As I said above, it just happens to also be a very good at handling state without a fear of side effects.
- WastingMyTime89 5y ago> I want to have a purely functional domain that I wrap in an imperative shell. Like you, I too think the ML-side of functionnal programming got it right. Sadly, their most popular language commited the unforgivable sin of not being written by Americans and is therefore condamned to never be as popular as Haskell. I console myself by using F# when I can.
- stepbeek 5y agoMy FP experience has mainly been with Scala (with haskell on side projects). Is OCaml the ML language de jure?
- WastingMyTime89 5y agoYes, it's the most actively developed and the most featurful. F# is another interesting ML. It has less of the features which makes Ocaml interesting but it runs on .NET so you have access to a ton of library. SML seems more niche. I don't think it sees much use outside of academia.
- gpderetta 5y agoInterestingly, a lot of very popular languages are not authored by Americans: - Guido of Python fame, is Dutch - Stroustrup (C++) is Danish - Lerdorf (PHP) is Danish - Anders Hejlsberg (author of both C# and TypeScript) is also Danish - Ruby is not as popular as it used to be, but Matz is Japanese. - Java's Gosling is Canadian, but I'm not sure if that is the kind of American you had in mind That covers a big chunk of Tiobe top 10. If anything Denmark is over-represented! edit: - Wirth (too many languages to list) is Swiss
- WastingMyTime89 5y agoIt's not about the nationality of author. It's about where they worked from and with whom. Except Ruby which failed, all the languages you are talking about where developed in the USA. Van Rossum moved to the USA in the 90s, got funds from DARPA and went to work at Google quite quickly. Stroustrup developed C++ while at Bell Labs in New Jersey. Lerdorf moved to Canada as a teenager before going to work in the USA. Hejlsberg made C# and TypeScript at Microsoft in Seattle. Yukihiro Matsumoto could be an exception but as you rightfully pointed Ruby always remained somewhat niche even after its move to Heroku in San Francisco. James Gosling is Canadian but did his PhD in the USA before developing Java at Sun. Wirth did its PhD at Berkley before moving to Standford where he did most of the work on ALGOL W what would become Pascal and did multiple sabbaticals at Xerox PARC.