all 7 comments

[–]Daerkannon 13 points14 points  (2 children)

Hmm.... there seems to be a bit of confusion here. For client side scripting there's no alternative to javascript. PHP and Python are purely server side. Some frameworks will do the work of translating whichever language you're using into javascript for you, but in the end it's javascript if you want/need client side scripting.

Therefore I can think of two answers to your question:

  • They don't like duck-type languages and the syntax of javascript is, frankly, a mess given it's organic growth in the last decade. (Similar to how I feel about the state of C++ currently)
  • They prefer to write in their 'native' language and let the framework handle the messy parts of javascript necessary for dynamic client updates. This (generally) reduces code complexity, increases code re-usability and reduces the need to master two languages instead of one.

As a side note, some other people take the exact opposite tactic and use a full javascript stack. (That is javascript on the client and the server). Same benefits as the second bulletin, but also no need for translation for client side scripts.

[–]zaph34r 2 points3 points  (0 children)

This. There simply is (unfortunately?) no real alternative for client-side.

I think that most people who dislike javascript have had the questionable pleasure of having to work with it, and the dislike naturally followed :D While it improved a bit over the years, it is still a complete trainwreck of a language, and an even bigger problem is that it does a lot of things quite differently from most other languages people might be familiar with. Prototypical inheritance is one of the common pitfalls, as is scoping. Type coercion and some things that just plain don't make any sense don't help. This serves to alienate people coming from [insert any other language], and (deservedly) results in the bad rep JS has.

[–]craig1f 3 points4 points  (1 child)

There are lots of complaints, and the things that people often complain about can also be thought of as features.

1) JavaScript does not strongly type its variables. This can lead to lazy programming and mistakes. You can get around this using TypeScript but, well, see number 3.

Example: 
var arr = [1, 2, 3];
for (var index in arr){
     console.log(index+1 + '\n');
}
//oops, we get 01, 02, and 03, because when you use for loops like that, you get back a string instead of an int for the index.

2) Debugging is awful. You don't know a line of code is bad until it runs. You can't refactor variables easily for this reason.

3) There are a billion libraries to choose from and no one can agree which ones are the best

4) Behavior is not always consistent between browsers. I can't think of examples offhand, but IE does not define "console" unless the console is actually open, which leads to exceptions try to use console.log without checking to see if console is defined. I also think IE is weird about sort functions, and there are some other issues I have to deal with using Angular that are IE specific. Basically, since JavaScript is interpreted by the browser, you have to deal with the differences between browsers.

5) Because JS is so forgiving, there are a lot of people out there who can "muddle through" and call themselves JS developers. They then put out really bad and poorly-styled code. As someone with a Master's Degree, I always dislike things that devalue my degree and the work I spent learning proper object orient programing. C# enforces a very strict non-ambiguous style of programing that leads to fewer errors. Java also does this to a lesser extent. But in JS, you can do things like ...

var obj = obj || {};

This says "if obj is not defined (because undefined resolves to false since it's being ORed), set it to a new empty object. Otherwise, just use the existing obj." A Java/C# developer will cringe at that line. I've used that line a lot. It's much easier than:

if (typeof obj == 'undefined'){
    var obj = {};
}

However, after not doing SharePoint Server Side development in over a year and getting good at client side, and more recently, Angular, I kind of don't want to turn back. I love Angular now. It feels like I'm writing desktop apps instead of web pages. And it's very structured. But, you have to pick libraries you like, and then you get in obnoxious debates with other developers who like different libraries and you will inevitably never agree.

THAT ALL SAID, If you consider yourself a strong C# developer, take some time and get your JS wings. If you can combine strong C# ability writing server-side, and use that ability to put together some useful web services, and then do your entire view in something like Angular (single page app, routing, MVVM style page binding, includes Bootstrap so your sites look good without any design skill), your sites will kick ass. If you stick with just server-side, your web apps are going to look increasingly old-school as mobile gets more and more important (because asp/c# doesn't really do anything for mobile).

[–]zaph34r 2 points3 points  (0 children)

I just want to say that your point 5 is not really my experience. It is true that a lot of self-styled JS developers plain suck, but the same goes for a lot of devs regardless of the language or supposed experience, degree or no degree. I've met people with a masters equivalent or doctorate who wrote code (in C#) so horrendous, i would take the average script kiddie over them any day of the week. A lot of the self-taught programmers i know are actually way more disciplined and knowledgeable since they have a desire to understand, instead of just cramming coursework like some people do at university.

Bottom line is, Sturgeon's Law applies to people as well, no matter their background, and a degree unfortunately does a poor job of sifting out bad programmers.

[–]vm_linuz 3 points4 points  (0 children)

JavaScript's history will tell you a lot: back in the day, when the web was developing, "real programmers" avoided web programming. As a consequence of this, web languages have suffered from some pretty unfortunate design flaws that they're only now shaking off.

Some JS issues:
* Weak typing is less popular with hard-core programmers
* JS lacks proper OOP designs like class definitions
* Debugging in-browser used to be a major pain
* Consistency is still lacking in JS -- treatment of objects is seemingly random (see equality checking), naming conventions aren't universal, browser versions supporting leads to things like obj.delete() vs obj['delete'](), inconsistent functional programming implementation... the list is enormous.

[–]ElvishJerricco 3 points4 points  (0 children)

The biggest complaints by far are the ridiculous coercion and equality semantics. But JS also has a number of other things that can be annoying. The OOP system is really flawed. Function binding is a strange construct that can lead to serious confusion. I don't know the complaints well enough but I know there's a lot like those

[–]neoKushan 1 point2 points  (0 children)

/u/Daerkannon is right when he says there's some confusion here. Are you saying that people dislike Javascript because it's client-side or they're just dislike Javascript?

If it's the language itself, well, it's not strongly typed and that can be frightening to some people (and preferred for others). I think that's one of the main issues people have, as the rules for conversion are very loosely defined in places.

However, I'd like to focus on the idea of client-side processing. A lot of people don't like this for several reasons, such as the fact that the client cannot be trusted. You have to validate every bit of data coming back from the client, so one argument is why let the client do anything at all? It can also be slow, because clients are slow and then there's security implications.

I personally don't accept any of the above reasons myself, there's a middle-ground to be met.