Anonymous user
Category talk:JavaScript: Difference between revisions
no edit summary
No edit summary |
No edit summary |
||
Line 2:
: It seems it is (too), according to several sources. --[[User:ShinTakezou|ShinTakezou]] 17:42, 29 May 2010 (UTC)
'''Effects System''':
Functional programming languages try to reduce side effects to a minimum, this usually involves immutable data structures and pure functions and then dropping down to something like Monads when side effects are needed.
What about JavaScript? What does JavaScript do to reduce or limit side effects in your program? Absolutely nothing
: No way of enforcing functional purity
: No way of creating immutable objects
: You can't statically type variables
: You can't even put things into namespaces
JavaScript has the weakest control over its side effects of any language I know of, there is even implied globals if you leave off the var keyword.
'''First Class Functions'''
JavaScript has first class functions. But so does Lua, Perl, Ruby, Python as of 1994, PHP 5.3, Visual Basic 9, C# 3.0, and even C++0x. If JavaScript's support for first class functions is all it takes to make it functional you should also add
What about parameter handling features? In C++ you can declare a parameter to be const to enforce const-correctness. In JavaScript you can't modify your parameters at all, they always come in as mutable variables. There is also no parameter types or default parameters.
Additionally, most functional programming languages have implicit return so that you don't have to write out a return statement. Although
'''How is JavaScript used?'''
JavaScript puts everything into a single mutable global namespace. There is no way to export functions into your module, or other features which would make functional programming a sane choice in JavaScript. As such, most of the time programmers use prototypal programming and object systems like Joose and JS.Class for code re-use purposes. As such JavaScript is mostly a prototypal programming language, or an OOP language, and not a functional programming language. ▼
▲JavaScript puts everything into a single mutable global namespace. There is no way to export functions into your module, or other features which would make functional programming a sane choice
As for Scheme, I do not think it is comparable to JavaScript, it has hygienic macros, homoiconicity, and an effects system (side-effect causing functions have a ! at the end of them in Scheme). These things together make JavaScript vastly different from Scheme. --[[User:Jhuni|Jhuni]] 0:15, 1 January 2011, (UCT)▼
▲As for Scheme, I do not think it is comparable to JavaScript
|