Live data from Hacker News

Functional Reactive Programming

wiki.haskell.org

71–80 of 121 posts

Re: Functional Reactive Programming

#71

Angular is using rxJs which is a reactive programming framework, but I think it was an error to do so. The angular project I am working on is now 5 years old and the parts of the application that are the least understood are the ones with more rxJs in it. We even have custom rxJs operators that nobody understand anymore... The way we do things now is to transform everything we can into promises because it's more easy…

I understand this paradigm within the context of stream processing, but it seems like a weird way of modeling most REST api-based web applications.

I feel like a promise-based model makes way more sense for most simple web applications. Where you have a http request and response, a promise model seems to suffice for most applications communicating via http-requests to an API layer. Modeling as a stream doesn't make sense to me, and seems like it would over-complicate an otherwise simple mental-model.

In most of the simple web-applications I have encountered there is one or more requests made to unique endpoints for data after the document response has been completed. No need for handling multiple events from the same endpoint, debouncing, multi-casting, unsubscribing, back-pressure, or whatever else. These operations seem to make way more sense in the context of stream processing.

Re: Functional Reactive Programming

#72

Angular is using rxJs which is a reactive programming framework, but I think it was an error to do so. The angular project I am working on is now 5 years old and the parts of the application that are the least understood are the ones with more rxJs in it. We even have custom rxJs operators that nobody understand anymore... The way we do things now is to transform everything we can into promises because it's more easy…

Rx is a hot-shot, look what I can do, I am smarter than you, paradigm and not much more. Source: I did that to co-workers when I learned it.

Re: Functional Reactive Programming

#73
There's a lot of talk of Rx libs, but from https://reactivex.io/intro.html I see:

"It is sometimes called “functional reactive programming” but this is a misnomer. ReactiveX may be functional, and it may be reactive, but “functional reactive programming” is a different animal. One main point of difference is that functional reactive programming operates on values that change continuously over time, while ReactiveX operates on discrete values that are emitted over time."

At the same time, I see lots of references to FRP on https://reactivex.io/tutorials.html so I am not sure what the actual position of the project is, or the actual status of the technologies (maybe things have changed?).

Re: Functional Reactive Programming

#74

FRP is simply the true way to build real time application.

You mean interactive? I don't see how FRP helps with real time.

I expect the parent means having some portions of the output change without user input, which isn't either of those if we're being picky.

Re: Functional Reactive Programming

#75
post #67

Is it viable to build a traditional web product/company on top of Haskell? That sounds like a silly question - but I’m serious. I’m enamored by the beauty of FP, but I’m not sure if there’s enough tooling or libraries to get to market. For example - GraphQL. There are two packages (mu and morpheus), but neither clearly document their feature parity in relation to other packages for other languages - and things like d…

I have never tried, but my impression is basically "You could, but why would you?" Haskell had a big jump in popularity around a decade ago, but it didn't gain traction with the "i'll grind 17 hours a day to become a rockstar ninja whatever" demographic that every language seems to bootstrap itself off of. I won't speculate as to why, but the end result is that Haskell is missing a lot of "adapter"-style libraries and instead is just a bunch of building blocks. Yeah you can write great stuff in Haskell, but also you have no choice. No one else has written what you need so you'll be writing it yourself.

The benefits of Haskell don't even _really_ seem that useful when you're just writing yet another big ass crud app where the main goal is to convert json into some other json and then maybe render it. I could see it making more sense in specific domains where the main challenge is wrangling a complex mess of business logic into something you can be confident about. Not like "is my shopping cart correct" but "how can I optimize this PCB design to reduce trace length and total area?"

Re: Functional Reactive Programming

#76

For those of you interested in hearing the inventor of FRP talk about it, take a look at Conal Elliott’s retrospective talk in 2015: https://youtu.be/j3Q32brCUAI Especially useful for those whose only exposure to FRP is through frp-inspired libraries (they’re not the same thing).

This might be interesting from a CS perspective, but useless to developers who have to create real life messy business applications.

Re: Functional Reactive Programming

#77
post #67

Is it viable to build a traditional web product/company on top of Haskell? That sounds like a silly question - but I’m serious. I’m enamored by the beauty of FP, but I’m not sure if there’s enough tooling or libraries to get to market. For example - GraphQL. There are two packages (mu and morpheus), but neither clearly document their feature parity in relation to other packages for other languages - and things like d…

You absolutely can. Its a great platform for this.

There may not be as wide a variety of libraries as you would hope, but that's true of any smaller language.

The main thing you need to be able to do is have the wisdom to avoid the footguns. They're quite different from the footguns in other languages. in general, using Haskell well requires a good bit of experience with it, and knowledge of who in the community are selling false solutions.

Re: Functional Reactive Programming

#78
post #67

Is it viable to build a traditional web product/company on top of Haskell? That sounds like a silly question - but I’m serious. I’m enamored by the beauty of FP, but I’m not sure if there’s enough tooling or libraries to get to market. For example - GraphQL. There are two packages (mu and morpheus), but neither clearly document their feature parity in relation to other packages for other languages - and things like d…

Yes, it's possible to build a traditional web company with Haskell. We've made IHP exactly for that :) It's like Rails/Django but for Haskell. https://ihp.digitallyinduced.com/ We specifically try to be batteries-includes (like rails), so you don't have to think too much about what libraries to use, the core of IHP can get you very far without needing to manually decide between libraries.

IHP even won a G2 badge, which is kind of funny and ironic for a Haskell project :D https://www.g2.com/products/ihp/reviews

Re: Functional Reactive Programming

#79
post #56

Angular is using rxJs which is a reactive programming framework, but I think it was an error to do so. The angular project I am working on is now 5 years old and the parts of the application that are the least understood are the ones with more rxJs in it. We even have custom rxJs operators that nobody understand anymore... The way we do things now is to transform everything we can into promises because it's more easy…

Yes - totally the opposite. In fact, I think the issue with Angular is that they've not finished the work to make Angular RX-everywhere (for example, reactive components need to be manually plugged into Subjects at the moment). With RxJS you should use it everywhere (observing state, observing component inputs, side effects etc). It's when you use it half-heartedly that you get problems with merging different program…

> With RxJS you should use it everywhere (observing state, observing component inputs, side effects etc). It's when you use it half-heartedly that you get problems with merging different programming paradigms

Yes, yes ,yes! I have been working with angular professionally for five years and fell in love with rxjs. If you manage to use it for everything, it really shines. Your entire codebase becomes declarative and it works beautifully. The only downside is that it takes some time to get it started up from the ground up, but once you do making changes and adding features becomes trivial. Try making smallish pipes and comment their purpose. Break them modular pieces.

Re: Functional Reactive Programming

#80
post #23

As someone who had to maintain two applications written entirely using the FRP Paradigm (Rx in Kotlin/Swift with a heavy focus on FRP principles), I am fascinated the idea but I absolutely hated the experience. Writing behaviour flows can end in beautiful blocks of easy to understand operations. However, as these get more complex and you need to combine multiple data streams, logic is scattered all over a module. Ref…

> As someone who had to maintain two applications written entirely using the FRP Paradigm (Rx in Kotlin/Swift with a heavy focus on FRP principles), I am fascinated the idea but I absolutely hated the experience. I had a similar experience maintaining and reviewing an Angular+Typescript application at work. I was fascinated about RX and was looking forward to see it in action. In practice Angular exposes everything f…

>I made a renegade effort to eliminate all Observables and replace them with standard, well-understood Promises instead.

Wow. You would have been better off ditching Angular entirely, or sucking it up.

Post reply on HN