Live data from Hacker News

Is functional programming relevant to web development?

stackoverflow.com

11–20 of 27 posts

Re: Is functional programming relevant to web development?

#11
post #9
post #2

Just make sure you don't pointlessly store continuations when you don't need to, like on Hacker News.

Indeed. The language of implementation does not matter much, what matters is what sort of data structure you use. When you can just read a piece of text from a database, it makes little sense to create an opaque state-carrying object dependent on the memory space of one process. news.arc is about as far from "functional programming" as you can get. People often use Darcs as an example of why functional programming is…

You know what would knock the planet's socks flat on their asses? If the Haskell and Erlang people got together.

I definitely fall on the Erlang side, but (especially if you shrug off the fanatic outliers) the differences are actually quite minor.

Re: Is functional programming relevant to web development?

#12
post #9

Earlier quoted context omitted.

Indeed. The language of implementation does not matter much, what matters is what sort of data structure you use. When you can just read a piece of text from a database, it makes little sense to create an opaque state-carrying object dependent on the memory space of one process. news.arc is about as far from "functional programming" as you can get. People often use Darcs as an example of why functional programming is…

You know what would knock the planet's socks flat on their asses? If the Haskell and Erlang people got together. I definitely fall on the Erlang side, but (especially if you shrug off the fanatic outliers) the differences are actually quite minor.

Like strict vs. lazy evaluation by default...?

Re: Is functional programming relevant to web development?

#13

Earlier quoted context omitted.

You know what would knock the planet's socks flat on their asses? If the Haskell and Erlang people got together. I definitely fall on the Erlang side, but (especially if you shrug off the fanatic outliers) the differences are actually quite minor.

Like strict vs. lazy evaluation by default...?

This is not really an insurmountable issue. $ is the lazy function application operator. $! is the strict function application operator. Use the one you mean and it will all work out.

Re: Is functional programming relevant to web development?

#14

Yes. The HTTP lifecycle is a perfect example of purely functional interaction. You get a request object. You produce a response object. Done.

If it was a purely functional interaction, shouldn't the same request always get the same response?

In reality a lot of non-pure IO stuff tend to be the main part of what goes on in-between the request and the response in most web-apps...

Re: Is functional programming relevant to web development?

#15
post #14

Yes. The HTTP lifecycle is a perfect example of purely functional interaction. You get a request object. You produce a response object. Done.

If it was a purely functional interaction, shouldn't the same request always get the same response? In reality a lot of non-pure IO stuff tend to be the main part of what goes on in-between the request and the response in most web-apps...

If it was a purely functional interaction, shouldn't the same request always get the same response?

Yes. This is why things like Rail's "flash" breaks the Internet... or at least your web app.

Re: Is functional programming relevant to web development?

#16
post #3

The reason why functional programming is popular with web programming is that it explicits shared and changing state and allows the programmer to express the purely functional parts as pure functions. Pure functions have the advantage of being very simple to run in parallel - as they have no side-effects. At least that's my reason.

... but it's not popular? ...

I agree. It's not popular. But some would consider it as the next great thing.

Re: Is functional programming relevant to web development?

#17
post #14

Earlier quoted context omitted.

If it was a purely functional interaction, shouldn't the same request always get the same response? In reality a lot of non-pure IO stuff tend to be the main part of what goes on in-between the request and the response in most web-apps...

If it was a purely functional interaction, shouldn't the same request always get the same response? Yes. This is why things like Rail's "flash" breaks the Internet... or at least your web app.

Well, each time I go to twitter.com I hope to see something slightly different than last time and that's not part of the internet being broken.

Re: Is functional programming relevant to web development?

#18
post #14

Earlier quoted context omitted.

If it was a purely functional interaction, shouldn't the same request always get the same response? In reality a lot of non-pure IO stuff tend to be the main part of what goes on in-between the request and the response in most web-apps...

If it was a purely functional interaction, shouldn't the same request always get the same response? Yes. This is why things like Rail's "flash" breaks the Internet... or at least your web app.

Each request should get the same "logical" response. There is nothing wrong with the content varying with each request. A resource that represents "The last 10 items processed" will always contain just that, even if the response is different at the html level. This is why cache-invalidation is important.

A resource can also be composed of parts of other resources. For instance, you can have an order resource which is composed of item resources that each have their own url.

I think the rails flash is usually used to send a user a message which will only be seen once on the very next request. Think of the message as a resource that isn't important enough to get it's own url, and every resource as a composite of the actual item they are looking for and an optional "message" resource. The message resource isn't important enough to store into permanent storage. It could be stored into the db backend and then loaded up on the next request, and then deleted once the user has seen it. In practice that's not practical so it's kept in memory.

I don't think it breaks the internet at all.

Re: Is functional programming relevant to web development?

#19
You can already do functional web programming with Scala/Lift. Be prepared for a real mind-bender of a web framework though. For instance, each form field specifies an in-line closure that gets called when the form is submitted. When you define an ajax button that is inserted into a form, clicking on that button invokes a server-side closure that's provided with the definition. There aren't any servlets, json parsing, ajax client library or anything like that in between. It's really quite nice. Just really really different.
Post reply on HN