Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Functional programming?

Name: Anonymous 2012-07-26 22:47

I've always avoided functional programming because of the following:

-It's pretty slow, FP by it's nature is slower than imperative because machine code is imperative and FP is implemented as an abstraction on top of machine code.  An optimized imperative C program(with splashes of assembly if needed) will always be significantly faster than anything else.

-Pure FP is very limiting.  It doesn't handle algorithm implementation, input/output, or complex data structures very well

-I don't understand the usefulness of meta-programming.  Lispers say it's bad practice to use macros when they aren't needed.  Normal programming styles never need macros at all, what gives?  From what i've heard it usually leads to convoluted programming flows, slow programs, and difficult to debug code.

-Languages designed for FP don't seem designed for real-world use. LISP doesn't even have normal math syntax.  Standard libraries are usually poor or non-existent.  Development tool-chains usually suck. 

Languages not designed for FP like Java require tons of boilerplate to program in a FP style.


Anyway, those are my gripes.  Do your thing /prog/ , tell me why i'm wrong and FP is amazing.

Name: Anonymous 2012-07-26 22:49

It is a different paradigm, that alone makes it worth investigating

Name: Anonymous 2012-07-26 23:03

>>2

What's different about it? To me it just seems like FP rewrites everything to be a nested function.  It may make for more concise code, but it doesn't seem that novel or useful.

Name: Anonymous 2012-07-26 23:51

>>3

Rewriting for loops and such as calling of nested functions isn't that useful. But declaring nested functions and passing them as arguments to other functions gets advanced very quickly. You can get a similar effect in Java by passing instances of nested classes, although it can become verbose.

-It's pretty slow, FP by it's nature is slower than imperative because machine code is imperative and FP is implemented as an abstraction on top of machine code.  An optimized imperative C program(with splashes of assembly if needed) will always be significantly faster than anything else.

That really depends on the architecture. If a functional program is written in a way that can be implicitly parallelized, it likely that it could outperform a single threaded program written in C if the architecture has multiple cores. And there are ways to represent some operations you'd expect to be imperative using functional style. That's kind of what I'm working on at the moment.

-Pure FP is very limiting.  It doesn't handle algorithm implementation, input/output, or complex data structures very well

True. Many algorithms require the use of mutable data structures to get their asymptotic bounds.

-I don't understand the usefulness of meta-programming.  Lispers say it's bad practice to use macros when they aren't needed.  Normal programming styles never need macros at all, what gives?  From what i've heard it usually leads to convoluted programming flows, slow programs, and difficult to debug code.

This isn't really related to functional programming. Meta programming could be used for C and seeples if you wanted to employ the right set of tools. All it takes is one experience of applying it well. Then giving it up will feels like becoming crippled.

-Languages designed for FP don't seem designed for real-world use. LISP doesn't even have normal math syntax.  Standard libraries are usually poor or non-existent.  Development tool-chains usually suck. 

Ocaml is an example of a practical functional programming language. Lisp style is actually pretty convenient for dealing with large formulas in text form. Especially if you need to define and extend the syntax of the formulas. But the standard libraries do suck. It takes a large user community to get a feature loaded set of maintained libraries.

Languages not designed for FP like Java require tons of boilerplate to program in a FP style.

Meh, the only think preventing me from using functional style in Java is the absence of tail call elimination. Well, that and that closures aren't succinct. Also,

>boilerplate

that's what macros are for.

Anyway, those are my gripes.  Do your thing /prog/ , tell me why i'm wrong and FP is amazing.

No, it is still shit. Just like everything else. But it is some what interesting shit.

Name: Anonymous 2012-07-27 0:49

Functional programming is for programmers to masturbate over how ``elegant'' their code looks and reads. All engineering issues, like CPU usage, are out of the question. This is art.

Name: Anonymous 2012-07-27 0:49

>>1
FP is by design more limited, thats the whole point. In exchange, some benefits emerges. This is why Erlang is used in Facebook.

meta-programming
This is strictly a LISP thing. Why? Because most of the language structural features (like loops, switch, etc) can be put inside libraries instead of baked into the language. Is it done? All the time... use the macro stepper in DrRacket to see your fibs program turn into COBOLISP before your eyes.

Name: Anonymous 2012-07-27 0:54

FFP

Don't change these.
Name: Email:
Entire Thread Thread List