3 ms·
Functional programming best matches web development because the web page is basically a static container that sends messages back and forth to a farm of servers
by DanielBMarkham 16y ago
Functional programming best matches web development because the web page is basically a static container that sends messages back and forth to a farm of servers. The server that gets the message may know nothing about what the web page is doing.
FP fits nicely because in FP you're always "threading the state" -- keeping everything you need around to make the program work. Functions can sit on a server, or on a million servers, and seamlessly process messages from clients. This is easily being done in the OOP-world, but on the FP side it's trivial, whereas with OOP there can be a lot of hoops to jump through.
WebSharper is very cool -- takes F# and makes it run as javascript. So you write one script module, annotating methods as running either on the client, server, or both, and then you just code as if all the methods were in the same spot. It figures out how to write the javascript and how the methods can talk to each other.
I'm also seeing some cool stuff with functional-reactive programming, which, if taken to its logical extreme, could rewrite large parts of the web server stack. In my opinion, because of the architectural nature of the web, in a lot of ways, functional code maps much more closely with web operations than OOP does.
Having said all of that, programming is programming, and if you know what you're doing, you can make things happen. Choice of languages and brands can be vastly overrated. The important part is knowing how to use the tools.