Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

functional programming  RSS feed

 
Randall Twede
Ranch Hand
Posts: 4680
8
Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not too hard I guess, but it's gonna take me a while. Not sure when to use it. The main points I have learned so far is:
All data is immutable
Functions are top level members
Everything is stateless
All functions require parameters and a return value
The article called the paradigm I'm used to imperative programming
I think this might take a while. Oh, and no loops. Recursion instead.
 
Piet Souris
Rancher
Posts: 1941
66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Randall,

I follwed the course 'functional programming with Scala' two years ago, at Coursera,
and I found it the most interesting course I can remember. Recommended!
 
Randall Twede
Ranch Hand
Posts: 4680
8
Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scala is certainly on my list of things to learn about.
 
Tim Holloway
Bartender
Posts: 18661
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Randall Twede wrote:
Functions are top level members


Well, I think it depends. In languages like LISP, functions are actually second-class citizens in a manner of speaking. The top-level members are Lambda Expressions, and in LISP, functions are simply lambda expressions which have been associated with a name.

I've only lightly skimmed over other languages such as Haskell, so I don't vouch for their use of terminology.

I can count at least 4 levels of programming:

1. Declarative programming. This is the most foolproof, since the rules are limited in both syntax and semantics and must be parsed and executed by an external engine (Finite State Machine). In the simplest declarative languages, such as those used by Maven, Ant, lexers and compiler-compilers/ such as bison and yacc, there is little or no scope for conditional execution or looping. Or even secondary calls/recursion.

2. Functional programming. As you mentioned. Logic functions are again constrained and looping is cheating, but functions can invoke other functions and the arguments to function calls may themselves be function calls.

3. Imperative programming with tightly-constrained datatyping (such as Java). Here you have the ability to do conditions and loops freely (and thereby introduce bugs via wrong turns), but the data usage is constrained. May be subdivided into free-for-all, structured and Object-Oriented techniques.

4. Imperative programming with loosely-constrained datatyping (many of the scripting languages, such as JavaScript). The main difference here being that instead of discovering data type violations at compile time, you get the joy of learning about at random inconvenient intervals out in the field.

Functional and declarative languages usually don't enforce strong datatyping, but on the other hand, they often define abstract functions, where the actual datatypes of the arguments and results are (mostly) immaterial. Some branches of mathematics like this.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!