Category talk:JavaScript: Difference between revisions

I can't find a reason for saying that JS isn't functional
No edit summary
(I can't find a reason for saying that JS isn't functional)
Line 1:
== Is JavaScript functional? ==
 
Javascript is a functional language? --[[User:Short Circuit|Michael Mol]] 10:45, 29 May 2010 (UTC)
: It seems it is (too), according to several sources. --[[User:ShinTakezou|ShinTakezou]] 17:42, 29 May 2010 (UTC)
 
----
 
'''Effects System''':
Line 34:
:To me, the key marks of a functional programming language are that it allows functions (or references to them) as values, that it allows recursion, and that it doesn't require the use of side-effects to produce the results of a function. That is admittedly a loose definition that permits ''lots'' of languages to claim that they support it, but so what? There's also a class of strict functional programming languages that are far more restrictive (e.g., by being side-effect free) but they're much less useful; even Haskell doesn't make it to that level of purity (due to the IO Monad, a requirement for participating in an outside world that has state). –[[User:Dkf|Donal Fellows]] 01:28, 1 January 2011 (UTC)
 
::Lots and ''lots'' of programming languages support first class functions. If you put basically every language into the functional category it is going to become a basically meaningless word. So rather then making the word functional meaningless I set a bit of a higher standard. Functional languages should have immutable data structures and some good way to avoid side effects.
----
::JavaScript is one such language that lacks immutable data structures. Static typing allows you to limit what an object can mutate to. For example, with static typing you can prevent somebody from replacing a function with a number. Since JavaScript doesn't have immutability or static typing you can replace any value with any other value. To add fuel to the fire JavaScript puts everything in a global name-space so that anyone can overwrite things and cause a collision. Furthermore, all properties are late-bound. All these things compounded make JavaScript worse off in terms of side effects then any language I know of.
::Perhaps it shouldn't be a black and white thing that you are either functional or you are not. Perhaps it should be said that JavaScript is 95% prototypal and 5% functional or something along those lines. Prototypal programming is a community practice for a reason. The language makes it hard to get away with anything else. --[[User:Jhuni|Jhuni]] 03:41, 1 January 2011 (UTC)
 
::: Well, ultimately the functional paradigm's been pretty successful, though the strict functional less so (precisely because so many problems are very coupled to their state). That's an indication of a reasonable degree of success for the paradigm. (We probably ought to take this part of the discussion somewhere more general.) For my money, the fact that authorities outside of RC say that JS is functional is sufficient evidence for me to admit its description as such here. –[[User:Dkf|Donal Fellows]] 10:56, 1 January 2011 (UTC)
:Lots and ''lots'' of programming languages support first class functions. If you put basically every language into the functional category it is going to become a basically meaningless word. So rather then making the word functional meaningless I set a bit of a higher standard. Functional languages should have immutable data structures and some good way to avoid side effects.
:JavaScript is one such language that lacks immutable data structures. Static typing allows you to limit what an object can mutate to. For example, with static typing you can prevent somebody from replacing a function with a number. Since JavaScript doesn't have immutability or static typing you can replace any value with any other value. To add fuel to the fire JavaScript puts everything in a global name-space so that anyone can overwrite things and cause a collision. Furthermore, all properties are late-bound. All these things compounded make JavaScript worse off in terms of side effects then any language I know of.
:Perhaps it shouldn't be a black and white thing that you are either functional or you are not. Perhaps it should be said that JavaScript is 95% prototypal and 5% functional or something along those lines. Prototypal programming is a community practice for a reason. The language makes it hard to get away with anything else. --[[User:Jhuni|Jhuni]] 03:41, 1 January 2011 (UTC)
Anonymous user