JavaScript is the programming language that Pablo Picasso would have invented. "Broken" is the single word, describing JavaScript.
1. Broken behavior across competing implementations: it is virtually impossible to use JS to do anything robust on the client side. JQuery tries to amend this, but inconsistency is still there.
2. Broken type system: it is weak and its automatic coercion astonishes: "1"+"2"=="12" and "1"+1=='12', but "1"-2==-1, "2"*"3"==6, and (x="1",++x)==2; 0==-0, but 1/0!=1/-0; [123]==123, but [123][0]!=123[0]. Even worse: [0]==false, but ([0]?true:false)==true, so (a=[0], a==a && a==!a)==true; Following statements are also true: []==![], Math.min()>Math.max(), " \t\r\n"==0, ",,,"==Array((null,'cool',false,NaN,4)), new Array([],null,undefined,null)==",,,", Array()==false, ''!='0', 0=='', 0=='0', false!='false', false=='0', false!=undefined, false!=null, null==undefined, NaN!=NaN, []+[]=="", []+{}=="[object Object]", {}+[]==0, {}+{}==NaN, despite (typeof NaN)=="number", so ("S"-1=="S"-1)==false. Given function f(n) {return n&&+n|0||0;}, we have f("1")==1, f("1.2")==1, f("-1.2")==-1, f(1.2)==1, f(0)==0, f("0")==0, f(NaN)==0, f(1/0)==0. No numerical tower or even obvious integer types: the only numeric type supported is an IEEE754 double-precision float, allowing for 9999999999999999==9999999999999999+1. Hacks like `(x+y)|0` are employed to strip rational part.
3. Broken default value: whereas most languages have one universal singular value (null/nil/Void/whatever), JavaScript has four: "false", "null", "void" and "undefined", producing confusing and irregular semantics. Then `undefined` is not actually a reserved keyword, so undefined="broken" easily breaks code, although `void 0` can be used instead of `undefined`; jQuery uses kludge like (function (undefined) {...}()) to ensure that undefined is undefined. Other redefinable symbols are NaN, Infinity, and the constructors for the built-in types.
4. Broken lexical scoping: unlike C/C++/Java/C#/etc, where variables introduced in an anonymous block within a function are only valid within that block; in JavaScript such variables are valid for the entire function. JavaScript employs unintuitive process called declaration hoisting, in which all function and variable declarations are moved to the top of their containing scope. If a variable is declared and assigned in one statement then the statement is split into two, with only the declaration getting hoisted. This produces a lot of subtle bugs, like for example non-obvious hiding of outer variables or `f` in `var f = function() {…}` being present as undefined, while `function f() {…}` would always be defined. Every script is executed in a single global namespace that is accessible in browsers with the window object. The "with" statement is a benchmark example of bad design, because an innocent addition of a variable to a class breaks every place of its use, but the nightmare doesn't ends - the code using `with` is just unreadable, requiring hours to untangle the mess.
5. Broken syntax: semicolons are optional, but it only makes life harder, because newline can accidentally take place of a semicolon, in effect `return{a: "hello"};` and `return\n{a: "hello"};` (where '\n' is newline) mean completely different things: '\n' gets parsed as ';', resulting into just "return;" Finally, crippled syntax impedes functional programming: )}();)}();)}();)}();
6. Broken standard library: most built-in functions, given an invalid input, don't produce error or exception, but silently return some default, like new Date('garbage'), or even produce undefined behavior: parseInt("07")==7, but parseInt("08")==0 or parseInt("08")==8, because "the implementation may, at its discretion, interpret the number either as being octal or as being decimal". Even worse, parseInt('fuck') gives NaN, but parseInt('fuck', 16)==15 and parseInt(null, 34)==939407
7. Broken arrays: new Array() produces empty array; new Array(2,3) produces array with 2 and 5 as its elements; new Array(5) does not produce array with 5 as its single element; instead, it returns a 5-element array. In JavaScript an array with 2 elements can have length of 7, while an array with 7 elements can have length 2, because length property always returns the last numeric index, plus one. JavaScript has no out of bounds error: you can freely retrieve an element at any index and no error will be produced, even if element is undefined. JavaScript provides no reliable way to iterate array by index, instead for(var X in Xs) gives elements in completely undefined order.
I had to try some of the more absurd ones in a JS console and I can't believe even shit like []==![] works, as well as addition being non-commutative due to the shitty coercion.
I think the examples are still paramount to what a poorly designed piece of shit Javascript is for them to even be valid at all. You can't deny they are completely nonsensical behaviour.
Further, the rest of the post regarding everything apart from the bullshit == operator still stands. Especially the fact that no library functions or operators will produce exceptions, yet Javascript does have a throw/try/catch. The language silently producing bullshit on things like "{}+[]" is very poor.
Name:
Anonymous2013-09-01 7:08
>>8
I don't give a shit about javashit, but every time you idiots discuss it, you go like:
javascript is shit, here's my proof: [badly formatted essay]
also "1" != 1 LOL
Name:
Anonymous2013-09-01 7:11
State of the world, p?
State of the world, g?
State of the world, /g/?
State of the world, RICKAD STALL MAN INSTOOL <HARD G> ENT YOU AHAHAHAHAHAHAHAHHAA
Name:
Anonymous2013-09-01 7:37
>>1
The much-maligned Visual Basic language implements a 'with' keyword as well, but requires that you prefix members with a dot in order to distinguish them from similarly named variables:
Dim x as Integer = 10
Dim y as ObjType
With y
.x = x
End With
Now there's a lot left to be desired in the code above, but at least it isn't crazy.
>>13
I'm guessing you type like this: int really_shit_function()
{
int a, b = 4;
return 0;
}
Name:
Anonymous2013-09-01 9:55
The problem is that JavaScript tries to be C/C++ compatible, yet fails even basic operator semantics and scoping. It is hard to translate C/C++/C#/Java to JavaScript.
Name:
Anonymous2013-09-01 9:56
>>15 It is hard to translate C/C++/C#/Java to JavaScript.
Despite JS having richer features, like lambdas, eval and dynamic typing.
Name:
Anonymous2013-09-01 9:57
>>16 richer features
right lambdas
So what? eval
ok dynamic typing IHBT
Name:
Anonymous2013-09-01 10:09
>>17
A language without eval and dynamic typing is a defective language.
Name:
Anonymous2013-09-02 5:54
>>18
javashit developers abuse eval all the fucking time.