BrokenIcarus
Member
Javascript can be a rough transition especially if you come from traditional languages like Java or C++ as you'll have to throw out some of what you had previously thought was best practice and use some different patterns. Though I imagine it'll grow on you over time, certainly I felt the same way when I started but I really like it now.
What don't you like about JS? I wouldn't count on it going away anytime soon. It's only getting more popular.
The language is just full of pitfalls.
Warning big rant incoming:
Arrays can be used as Lists, as well as Associative Arrays, but what actually happens when you call:
Code:
var arr = [];
arr["key"] = value;
So it's the same as
Code:
arr.key = value;
This causes problems when sorting arrays.
Code:
[1,3,20,10].sort(); // returns [1, 10, 20, 3]
The generally scope is a mess.
There are virtually zero name spaces and I've seen at least 3 different ugly work around hacks to simulate the feature (such as wrapping everything in a huge anonymous function for the closure).
You can declare global variables inside a function or something similar if you forget the "var" keyword.
You can declare Instance and class members of a "class" just about anywhere in your code and the "this" reference is utterly confusing as to what it actually points to.
For private instance variables and inheritance, you have to jump through huge hoops to actually get what you want. There is no standardized way to do such a simple thing.
Without interfaces, the only way to know what methods you can call from other classes is to use external documentation, or to actually look at the src code.
I've worked in other dynamically typed languages like Python and even they have interfaces with which you can easily work.
In JavaScript there is no such thing as constants or readonly values, again you have to jump through a lot of hoops and hacks to get this to work.
If you've worked with Regular expressions in js you probably know how ugly the code can get by using them.
Other pitfalls I've written down:
Code:
typeof foo === "object" //returns true if foo is null
typeof NaN === "number" //returns true
NaN === NaN //returns false
return
{
bar: "hello"
};
//this actually returns "undefined" because in JS, Semicolons are optional, yay!
var a = b = 3;
//this creates var a like you would expect, but also creates the global variable b
I've written these things down, so they never happen to me again, but it's just awful that these things CAN happen.
And I haven't even really gotten started yet about Dynamic vs Static Typing.