Functional Programming

wantedSpidy

Senior member
Nov 16, 2006
557
0
0
I'm about to start studying hardcore, cuz I'm bored of OOP and Java.

Insights as to what language to start with, general reading to understand functional programming?
 

Cogman

Lifer
Sep 19, 2000
10,283
134
106
Reading, I don't know. But the language I see as almost the defact functional programming recommendation now-a-days is haskell.

Others I've seen are Lisp, OCaml, and F#. YMMV on which one is "best" to learn.
 

tatteredpotato

Diamond Member
Jul 23, 2006
3,934
0
76
Haskell is a good choice if you want to go "Purely Functional", however I find Scala to be a more interesting language. Scala lets you use classes and other OOP constructs if you like, while still providing FP constructs. Also Scala compiles to Java bytecode, and as a result allows your Scala code to be called from Java and vice versa (which means Scala has access to existing Java libraries).

That said you might want to stick to "Pure Functional" while learning to keep you from regressing to an OOP/Procedural way of programming.
 

brandonb

Diamond Member
Oct 17, 2006
3,731
2
0
What does functional provide that OOP doesn't provide?

What is the difference? I had a coworker talking to me about it one day, and it seems to be loosely typed, dynamic type stuff, which to me usually only makes things harder to write. (Atleast large apps, maybe one of those single page web apps thats another story).

--- Not trying to start a flame war here, just curious what it offers because from my very limited knowledge, it wouldn't be something I would ever invest in ----

What would functional programming's target audience be?
 

Cogman

Lifer
Sep 19, 2000
10,283
134
106
What does functional provide that OOP doesn't provide?

What is the difference? I had a coworker talking to me about it one day, and it seems to be loosely typed, dynamic type stuff, which to me usually only makes things harder to write. (Atleast large apps, maybe one of those single page web apps thats another story).

--- Not trying to start a flame war here, just curious what it offers because from my very limited knowledge, it wouldn't be something I would ever invest in ----

What would functional programming's target audience be?

Functional programming is much more closely related to mathematical functions than it is to procedural functions. Functional programming prides itself in being short and concise. It is less "do this, then do this, then do this" and more "These are a bunch of functions, this is how they relate".

I'm not a functional programming master by any stretch of the imagination, but this is my gleaning from what I've read about it.
 

wantedSpidy

Senior member
Nov 16, 2006
557
0
0
Functional programming is much more closely related to mathematical functions than it is to procedural functions. Functional programming prides itself in being short and concise. It is less "do this, then do this, then do this" and more "These are a bunch of functions, this is how they relate".

I'm not a functional programming master by any stretch of the imagination, but this is my gleaning from what I've read about it.
This is pretty accurate. We use it for implementing trading strategies, and its definitely a lot lighter then any other language we could have used for the same purpose.

Its funny when I was growing up I learnt how to develop by thinking along the lines of functional programming, and then I had to unlearn my methods so I could adapt to OOP.

As for languages I'm right now deciding between Haskell, Scala and OCaml. I'll do some more research and then post here. Thanks for the input.
 

tatteredpotato

Diamond Member
Jul 23, 2006
3,934
0
76
What does functional provide that OOP doesn't provide?

What is the difference? I had a coworker talking to me about it one day, and it seems to be loosely typed, dynamic type stuff, which to me usually only makes things harder to write. (Atleast large apps, maybe one of those single page web apps thats another story).

--- Not trying to start a flame war here, just curious what it offers because from my very limited knowledge, it wouldn't be something I would ever invest in ----

What would functional programming's target audience be?

OOP and Procedural languages are both in the family of "imperative" languages. This family of languages are in essence a series of statements that transform your program state (usually by manipulating memory). Functional on the other hand treats everything as evaluation of expressions. In a language like C, you would consider an "expression" is something that has a value (like variables or constants), while "statements" have side effects (assignment operators, 'for', 'while', etc). Functional languages abhor side effects and "program state", and therefor don't have for/while loops, but instead use list operations like maps and folds.

The nice thing about functional programming is that without side effects, some things are much easier to understand. A function does the same thing every time you call it with the same arguments. Also some algorithms can be expressed much more tersely in functional languages because in my experience functional languages use much less "boilerplate" code.
 

humanure

Senior member
Dec 28, 2005
441
0
0
The only one I've used is Lisp. Not sure what reading to suggest, used it in a course in school and then only in a limited way using car, cdr, list, cons, cond, mapcar and a few operators. It was strange at first, no variables, no for, while loops, or if statements just recursion. Some algorithms like quick sort, depth or breadth first search are really elegant in Lisp. If I remember right quicksort is 3 or 4 lines. Just use an editor that does parentheses balancing like notepad++.
 

KIAman

Diamond Member
Mar 7, 2001
3,342
23
81
Although not a purely functional language, I enjoyed scheme, which is a type of stipped down Lisp. I remember having some fun with scheme.
 

ioni

Senior member
Aug 3, 2009
619
11
81
What does functional provide that OOP doesn't provide?

What is the difference? I had a coworker talking to me about it one day, and it seems to be loosely typed, dynamic type stuff, which to me usually only makes things harder to write. (Atleast large apps, maybe one of those single page web apps thats another story).

--- Not trying to start a flame war here, just curious what it offers because from my very limited knowledge, it wouldn't be something I would ever invest in ----

What would functional programming's target audience be?

I've only used Lisp and it was for AI programming. One feature Lisp has that no other imperative language that I know of has is the ability to dynamically generate functions to run at runtime. Although, I don't know if this is an exclusive feature to Lisp or a feature of all functional languages.
 
Apr 10, 2011
40
0
0
OOP tends to send you down one particular route of 'abstraction'. Learning to program functionally lets you learn how to do 'abstraction' in different ways,

I wouldn't say that the abstractions that you do OOP are 'better' or 'worse' than what you can do with functional programming: I think it's a very confrontational way of thinking about things. The ways of doing abstraction that you pick up doing FP are just as valid as anything you might do in OOP, and you can use them in all sorts of situations... There's no real reason why you'd want to avoid them, IMO. They're never going to make you a worse programmer

Ioni: Are you talking about lambda expressions? If so, then there are some nonfunctional languages which use them, but it's in FP where they really do shine
 

degibson

Golden Member
Mar 21, 2008
1,389
0
0
I've only used Lisp and it was for AI programming. One feature Lisp has that no other imperative language that I know of has is the ability to dynamically generate functions to run at runtime. Although, I don't know if this is an exclusive feature to Lisp or a feature of all functional languages.

A number of scripting languages allow this as well (actually, so does any language that allows manipulation of byte arrays -- just not as a first-class syntax element).
 

dinkumthinkum

Senior member
Jul 3, 2008
203
0
0
A functional programming language is a language which focuses on the idea of using and composing "functions" as the fundamental tool of abstraction. A function is a piece of code with parameters and produces a result based solely on those parameters. A function is also a first-class value in these languages and may be provided as the argument to or result of another function.

Now there is a broad spectrum of functional programming languages from there. Some adhere strictly to the notion of a function, and others are less restrictive. In addition, many functional programming languages are designed with advanced static type and module systems, but not all of them are. There is a clever correspondence connecting functional programs using parametric polymorphic types to proofs and propositions in intuitionistic logic. If you are interested in writing computer-verified logical proofs, then this is an area to explore further.

Of the dynamically typed functional programming languages, the recommended starting point is Scheme, as mentioned above. There are many excellent resources, such as this book online: http://www.htdp.org. How to Design Programs. You should always use a Lisp-aware editor for writing Lisp-like languages such as Scheme (emacs, vim, etc... have very good support).

Of the statically typed functional programming languages, most people start with either ML or Haskell. OCaml is the most widely used ML, and Standard ML is mostly used for teaching these days, but is very powerful. Haskell is a very interesting language because it is considered "pure" FP and tries to take advantage of that. This includes using so-called "lazy evaluation" instead of the typical call-by-value, and also there are many advanced type system experiments being conducted in the real-world high-performance compiler, GHC. The Haskell community is probably the largest of the FP languages as well, there is a lot of support. Start at http://www.haskell.org/.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |