Category talk:JavaScript: Difference between revisions

→‎Is JavaScript functional?: Isn't it nice when things lead to new tasks? :-)
No edit summary
(→‎Is JavaScript functional?: Isn't it nice when things lead to new tasks? :-))
 
(5 intermediate revisions by 2 users not shown)
Line 36:
::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 9590% prototypal 8% procedural and 52% 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)
Line 44:
:::: On the other hand, it is undeniable that JavaScript is completely side effect ridden and therefore non-declarative.
:::: It just so happens that declarative programming is probably the most important part of ''effective'' FP. By telling the computer what to do rather then how to do it, you free up the compiler to optimize and parallelize at will. –[[User:Jhuni|Jhuni]] 01:42, 2 Janurary 2010 (UTC)
:::: Since we aren't really talking about JavaScript anymore, and I have made basically all my points about the language itself, we may as well move this to [http://rosettacode.org/wiki/Category_talk:Programming_paradigm/Functional Talk:FP]. –[[User:Jhuni|Jhuni]] 01:49, 2 Janurary 2010 (UTC)
::::: Unless a paradigm is fundamentally impossible in a programming language (perhaps it's made so by some feature of the VM), a programmer can employ that paradigm, regardless of how convoluted or tricky it might be. What all this tells me is that templates and language-page modifications are the ''wrong'' way on Rosetta Code to associate langauges with paradigms, and that a "show me the code" approach is really what's necessary. To that end, tasks would be needed in order to provoke demonstrations of aspects of a given paradigm. --[[User:Short Circuit|Michael Mol]] 02:12, 2 January 2011 (UTC)
:::::: I would like to see a "enforce immutability" task that shows what means languages have to enforce immutability on values, parameters, methods, and other things. –[[User:Jhuni|Jhuni]] 03:12, 2 January 2011 (UTC)
::::::: I see that you've been working on such a task. Cool! –[[User:Dkf|Donal Fellows]] 12:32, 2 January 2011 (UTC)
Anonymous user