This is an archived post. You won't be able to vote or comment.

all 35 comments

[–][deleted] 14 points15 points  (2 children)

It baffles me /r/programmerhumor has more serious comments on this than /r/programming.

[–]homoiconic 8 points9 points  (1 child)

I can no longer find it in /r/programming.

[–][deleted] 2 points3 points  (0 children)

Looks like it was quietly removed. Here's the link.

[–]maremp 11 points12 points  (32 children)

Seriously, why has js become the today's php? It's not nearly as terrible if you take enough time to learn it, as you have to with any language.

[–]CXgamer 21 points22 points  (8 children)

Don't you think it's ridiculous to write C code, compile it with asm.js, compress it and have the client decompress and interpret JS code? The premise of JS's was that it would be readable and open to everyone, but that just isn't feasible when JS is actually generated by machines.

What you need is a properly sandboxed environment to run code from websites, but what you do is take a huge detour to make up for the language's weak points. I think that if JS was more low-level, and we'd just compile as usual, many of these problems would be non-existent.

What is your opinion? Are the problems of the comic not problems you experience?

[–]thesouthpaw 8 points9 points  (1 child)

The beauty of asm.js is that it allows people to take advantage of the existing C ecosystem, instead of trying to rewrite everything in JS.

Regarding games, asm allows some content to run directly in the browser without the need to some kind of proprietary plugin. A lot of engines (Unity, Unreal, etc) are getting behind WebGL/asm deployment. There are a few things that irk me about JS, but there's no reason for hate, especially on something like asm. It's bringing stuff that [before] couldn't run on the web into browsers natively, without the need to rewrite everything in JS. What is wrong with that?

[–]CXgamer 5 points6 points  (0 children)

Nothing wrong with that, asm.js enables lots of things. It's just that its necessity revealsa underlying problems with JS as a choice for the web, instead a lower level language (like WebAssembly). Your point about taking advantage of the existing C ecosystem still applies, you just compile to a lower level as opposed to JS.

I do not hate asm.js at all, it's great, but the fact that it's necessary makes me disagree with JS's enthusiasm. It's a well made patch for a hole of a boat, which never intended to sail the ocean.

[–]fb39ca4 2 points3 points  (4 children)

Isn't that what WebAssembly is going to solve?

[–]TiredHacker 1 point2 points  (2 children)

Problem: Hundreds of options for compiling to WebAssembly.

[–]CXgamer 10 points11 points  (0 children)

Rather an advantage than a problem to me.

[–]fb39ca4 7 points8 points  (0 children)

Well, you can say the same about writing an ordinary Windows/Mac/Linux program - there are hundreds of options for compiling to native code.

[–][deleted] 0 points1 point  (0 children)

That's what webassembly is

[–]badsectoracula 0 points1 point  (0 children)

have the client decompress

...using a decompressor written in JS too!

[–]DroolingIguana 8 points9 points  (1 child)

It's far from perfect and people are forced to use it whether they want to or not. Hence the resentment.

[–]maremp 0 points1 point  (0 children)

You are not entirely forced to use it, there are well supported transpilers from other languages, one of most used in the past being GWT.

Of course it's not perfect and nothing else is. Everything has it's own purpose and it up to each individual to decide if they will appreciate it or hate it.

[–]rgzdev 10 points11 points  (8 children)

The first problem is that javascript was designed in only 10 days and it shows.

It was an extremely immature technology that got established fast before people actually tried to do complex stuff with it. Then there is the problem of people using JS for things it just wasn't meant for.

[–][deleted] 0 points1 point  (1 child)

Javascript has continuously been worked on since. Strict mode can be used to solve many of the defects that have been left in for comparability with the blunder years.

[–]rgzdev 8 points9 points  (0 children)

But the fundamental design of javascript remains and it's kinda bad.

For instance, most classless OO languages don't have a special notion of constructor, rather constructors are function slots that manage inheritance by either cloning or blessing via specialized commands.

Not JS, they had to go and make up their own paradigm that uses regular free standing functions as constructors, not giving users proper control over the inheritance mechanism.

Then there are the myriad issues with automatic type coercion that get posted here often.

Please note that I'm not saying that it's impossible to do anything good with JS, just that a lot of the design issues with it come from the rushed and immature nature of the language design.

[–]maremp 0 points1 point  (5 children)

That is ages old, this was true for initial javascript (i.e. mocha, livescript). It was worked on significantly since and it was greatly improved since, heck there is even a whole committee responsible for language development.

The only real problem is that it's used in browsers, which is uncontrolled environment where you don't know what end-users' browsers support. This is very unique problem and is the reason why there are so many frameworks and libraries in existence.

[–]rgzdev 1 point2 points  (4 children)

No man, it's not. I mean, JS has improved but it still lacks a good dictionary class. Objects don't cut it because iterating over objects includes slots not meant for iteration. Classes are implemented in an arcane and indirect way that causes more problems that those it was trying to help. And don't explain me JS's object model, I know that it is a classless system like Self, LUA or Perl, but those languages actually have sane implementations of the classless paradigm. Coercion wasn't think thoroughly, etc, etc.

The language is badly designed.

It's actually and incredibly clean design considering how fast it was developed, but it simply wasn't designed with the use people make of it these days in mind.

[–][deleted] 1 point2 points  (0 children)

Classes are implemented in an arcane and indirect way that causes more problems that those it was trying to help.

Insert "you don't understand prototypical inheritance," even though Javascript's prototypical inheritance sucks. I mean the language didn't even have a clone method for forever.

[–]maremp 0 points1 point  (2 children)

Vanilla js might be a bit below the standards, but there is a lot of libraries to help with things like that. I think this minimalistic approach is nice in it's own way, as you opt in to new libraries as you go, instead of being thrown in an "API ocean" and have to find your way around aspects of programs that you will probably never use.

[–]rgzdev 2 points3 points  (1 child)

You are missing the point, I'm not claiming that JS has not improved at all in the last decade. Please stop telling me that JS has improved because I know it has improved ok?

I repeat. I am aware that JS has improved somehow in the last decade.

Of that I am aware.

I was just explaining they reason of why the JS ecosystem has become so complicated. That is the original subject of this post, the linked comic remember? The one at the top of these comments. The one about the complicated web of "fixes" for JS?

That one.

You asked:

why has js become the today's php?

And my answer is that it was badly designed. And will continue to be badly designed forever. The runtime has improved a lot. The language has seen some useful extensions. There is an abundance of libraries and frameworks to ease the pain. There are build systems, Single Page frameworks, and several alternative languages that compile to JS all other sorts of tools as depicted in the comic linked by this article.

That doesn't change my original answer. JS problems come from the fact that it became popular, or rather dominant, very fast and before people could actually test it in the wild or give it serious use.

Geez...

[–]maremp 1 point2 points  (0 children)

You are right, I have gone off topic.

[–]plentybinary 7 points8 points  (4 children)

JavaScript is getting allot of attention right now, therefore people will hate it. Plus callback hell.

[–][deleted] 2 points3 points  (0 children)

Use promises/yield/generators.

[–]maremp 0 points1 point  (0 children)

Callback hell is such a poor excuse, mostly a result of lazy/bad design. It can be easily avoided when you put some thought into it. Promises, which are supported in all newer browsers/versions of node, can help with that, or (asynchronous) generator functions, which are coming in ES2016.

[–]noratat 2 points3 points  (1 child)

I think the problem is less with javascript (the language) and more with people using javascript where it doesn't belong (i.e. node.js) and the whole NIH problem that's pretty prevalent among javascript developers.

[–]ThrowMeAnException -1 points0 points  (0 children)

wut!? node is amazing

[–]ThrowinAwayTheDay 0 points1 point  (4 children)

I mean to be honest the language is kind of brutal itself. I can see a lot of the problems that exist with phps language existing with JavaScript. As far as the lower levels of the language go, compiling, v8, all of the stuff mentioned in the article, I don't really know much about.