Category talk:JavaScript: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 1:
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 31 ⟶ 33:
:Static typing is nothing to do with functional programming. It's an independent feature axis. You can't say that namespaces are a feature of functional programming; they're just naming features (as is your point on Scheme's <code>!</code> suffix). Moreover, a great many languages that are functional actually support mutable state; it cannot be a feature that allows a decision to be made on whether a language is functional. The only thing that you might ''possibly'' have a point about is “functional purity” but you're beginning to sound to me like you're making a No True Scotsman argument, which is a logical fallacy. What I ''can'' agree though is that community practice with JS is not to program in a functional manner. –[[User:Dkf|Donal Fellows]] 01:17, 1 January 2011 (UTC)
: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, which are a cornerstone of functional programming. 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 dynamicstatic 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]] 0103:2841, 1 January 2011 (UTC)
:At least Scheme allows you to avoid side effects in various ways, such as by making it clear that side effect causing functions are suffixed with a !
: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 get away with anything else. --[[User:Jhuni|Jhuni]] 01:28, 1 January 2011 (UTC)
Anonymous user