Comment Write-once variables are useful (Score 1) 415
Whoops - the discussion (much of it) seems to being confusing three FP
related things: seas of parentheses, first-class functions, and
expression-orientation.
Not all functional languages use seas of parantheses - this is a
syntax choice made by the Lisp family of languages. Yep - it's
horrible, but it's not intrinsic to FP.
First-class functions are tricky beasts. Some procedural or OO
langauges have a similar power - for example, function-pointer
variables in C. Do you kow anyone who uses these regularly?
But FP languages are also expression-orientated. I've written a
compiler in Sisal (a pure expression-oriented language, but not FP). I
liked the pure expression-orientation, and it was easy to use.
Essentially, in a pure expression-oriented language, you have
write-once variables. You can only assign a value to a variable once -
and must do it once. This gives you great compile-time checking, and
makes variable-declaration comments even more useful.
Sisal's syntax is a typical procedural language syntax - hardly a
parenthesis in sight, and normal looking variable declarations, if
statements, loops, etc. There is a slight price - you declare more
variables, and loops have an extra construct to distinguish between
this-iteration and last-iteration variables - but this is easy to get
the hang of.
In summary ... The nasty syntax isn't intrinsic to FP, and if you
don't like first-class functions you don't have to use
them. Write-once variables are a great idea from FP, which can be
adapted into procedural programming as a stylistic thing, or
incorporated into procedural-seeming language design.
related things: seas of parentheses, first-class functions, and
expression-orientation.
Not all functional languages use seas of parantheses - this is a
syntax choice made by the Lisp family of languages. Yep - it's
horrible, but it's not intrinsic to FP.
First-class functions are tricky beasts. Some procedural or OO
langauges have a similar power - for example, function-pointer
variables in C. Do you kow anyone who uses these regularly?
But FP languages are also expression-orientated. I've written a
compiler in Sisal (a pure expression-oriented language, but not FP). I
liked the pure expression-orientation, and it was easy to use.
Essentially, in a pure expression-oriented language, you have
write-once variables. You can only assign a value to a variable once -
and must do it once. This gives you great compile-time checking, and
makes variable-declaration comments even more useful.
Sisal's syntax is a typical procedural language syntax - hardly a
parenthesis in sight, and normal looking variable declarations, if
statements, loops, etc. There is a slight price - you declare more
variables, and loops have an extra construct to distinguish between
this-iteration and last-iteration variables - but this is easy to get
the hang of.
In summary
don't like first-class functions you don't have to use
them. Write-once variables are a great idea from FP, which can be
adapted into procedural programming as a stylistic thing, or
incorporated into procedural-seeming language design.