User blog:IAmAPersson/Why Javascript Sucks

Why Javascript SucksFrom a programmer's prespective Ok. So I'm a C# programmer. I've worked in C#, a small bit of C++, I used to work in VisualBasic, and occasionally use BASIC. Then I thought, "Javascript is popular. Let's learn it!" So I did. I immediately hated it. I'll explain in this article. First off, syntax is really weird. Say for example I wanted to see if 'myString' was "Potato". Here's how I'd do it: if (myString === "Potato") { } Why the flipping ===? Pointless. Javascript uses === and !== for basic comparison operators. In VB, they kept it simple, with a simple '=' to compare stuff. C/++/# etc. use '=='. As far as I know, '==' does nothing in Javascript. I have a saying. With syntax, KISS: Keep it simple, stupid. And indeed, the creators of Javascript have to be the most drunk and idiotic people on the face of the earth. This is just one example of 91873 with crazy syntax. Another thing. ALMOST EVERYTHING IS IMPLICIT. Look at this: var myInt;var myDouble;var myString; Seriously, why can't I define my own variables the way I want?! In C#, we'd do this: int myInt = 24;double myDouble = 83.263;string myString = "potato"; See? We have control. Now some Javascript defenders may be saying "well you just said KISS earlier, hypocrite!" Well, this IS simple. In Javascript, the implicitly defined variables make it slower and harder to use in my opinion. Also, THE SLOW NIGHTMARISH CONVERSION!!! It's a pain to deal with! Now that we've covered the very surface, let's dive deeper. Javascript claims to be an Object-Oriented language (a.k.a. OOP). Let's look at that, shall we? function iCallMyselfAnOOP { } That's a function. Tada. Woopdy flipping doo. A programming language can't call itself OO unless it has classes. Heck, classes and encapsulation are the CORES of OOP. Need a command group? Make a class. Need a subroutine-like-code? Program a method. In Javascript? Tough luck. You're screwed without classes. We'll keep going, shall we? Let's get into Javascript's purposes and the way it runs. Javascript, unlike Java, C/++/#, etc., is interpreted. This means slower code, and the code is more picky. After looking around the web for a while, I saw this from StackOverflow: "Problems with Javascript in a browser are absolutely awful to debug. You're running on a machine that's out of your control - the user may be running an obscure or ancient browser, they may be using anti-virus software that mucks with your Javascript, their browser plugins might muck with your Javascript. It's hard." However, with C# being compiled, most all browsers should compile it the same with no problems. Last thing I want to attack about Javascript: memory management. Oh hehehe. If you're a Javascript defender, you'd be better off closing this window right now. Not closed it yet? Well, let's have fun. First, memory leakage. It's not hard. Here's a basic program that'll leak memory: function LeakMemory{  for(i = 0; i < 5000; i++){    var parentDiv = document.createElement("");  }} Tada! You now have a memory leak. Well. Nicely done, Javascript. JS has automatic memory management. When a variable isn't needed anymore, it's released. JS appears to do poorly with this. Memory management is JS is a nightmare. Watch this: var s = "banana";function myFunction{  alert(s);} Well, I should get an alert saying "banana", right? Nope. When Javascript enters the new function, it erases string s. According to standard OOP encapsulation, this shouldn't happen. But this is JS, right? Who knows what kind of jacked up crap will happen? Now I'm not a master at Javascript, so I really can't go much further. To any of the Javascript defenders out there saying "Stop bashing on such a popularly used language", leave. I don't want you here. I couldn't give a crap about its popularity. I'm here to bash about the language itself. I hate Java as well, and it's widely used as well. Why are they popular if they're so horrible? Both of the languages are well known and widely used, so more people learn the languages, and it stays popular, a cycle that feeds on itself. If I owned all the websites on the internet, the new standard would be either C++ or PHP. Okay. I'm done bitching about Javascript. Next time: why HTML isn't a language.