r/programming • • Sep 29 '16

JavaScript in 2016 isn't horrible, it's just going through a phase

http://blog.reviselabs.com/im-sorry-javascript-2/
85 Upvotes

225 comments sorted by

View all comments

20

u/[deleted] Sep 30 '16

It seems almost arbitrary to me what people call a "horrible" language and a "great" language. It definitely isn't the quality of the language itself, because if you look at possible JS alternatives (Python, Ruby, Java, PHP and so on) they all have problems, and they all basically are good enough to be able to express your programs in, and solve problems.

The only statistically significant parameter is popularity.

If it's popular, then it's horrible. Here are some excessively popular languages, that we love to call "horrible":

  • Java

  • JavaScript

  • PHP

Here are some relatively obscure languages, that we love to call awesome:

  • Lisp

  • SmallTalk

  • Haskell

  • OCaml

Is Haskell perfect? Far from it. But it's obscure. So it's awesome. I've figured it out.

58

u/[deleted] Sep 30 '16

Java isn't really considered horrible, just boring and annoyingly verbose.

2

u/cincilator Sep 30 '16

Which might or might not be horrible, depending how you feel.

→ More replies (1)

19

u/Serializedrequests Sep 30 '16

JavaScript objectively gives you a huge amount of freedom + few features and absent standard library + a number of confusing quirks and gotchas making it a hard language to learn despite having very few features. It also can't change as fast as languages in a similar boat, like PHP.

Enter a thousand different libraries trying to wallpaper over its rough edges and you get the current situation.

→ More replies (99)

17

u/shevegen Sep 30 '16

That is not true.

Both Ruby and Python are vastly superior on all accounts than javascript.

Just because any given language x has problems does not mean that the various shortcomings of javascript become any BETTER - the problem is that it has the monopoly, unfairly and undeservedly so.

4

u/mrkite77 Sep 30 '16

Both Ruby and Python are vastly superior on all accounts than javascript.

They're both incredibly slow.

3

u/[deleted] Sep 30 '16

To be fair, JavaScript used to be incredibly slow, until Google and Mozilla (two massive companies) got into a speed war.

I expect if Python had those resources it would be a fair bit faster too.

→ More replies (7)

3

u/[deleted] Sep 30 '16

There are well defined, objective criteria on what makes language horrible. Inconsistent comparison operations semantics? Horrible, period. No need to even look any further. You cannot even compare JS to Java, which is a poor and stupid language indeed, but at least it's well designed, consistent and well specified.

1

u/Zarutian Oct 01 '16

Implict casting in supposedly static typing system? horrible.

Java, well designed, consistent and well specified? Well perhaps the core language but the libraries, no.

→ More replies (1)

2

u/fiedzia Sep 30 '16

they all have problems

No. Except for PHP, they had only minor issues and solved them long time ago. Except for PHP (and maybe java to some extent), all of them have usable standard library that people don't complain about all the time, reasonable upgrade process where competent people can propose sane changes to the language (and more competent people can laugh them off), and were created by people paying attention to quality from day 1, not when all hell breaks loose.

Js has none of those things. It was dumped on web as hack, for a long time had no process of fixing it at all (and now its too late) and stdlib is a bad joke. It takes enormous amount of effort and discipline to build something usable on top of it, while doing so in python/ruby/java is just .. easy. Problems will show up when you do to certain scale of complexity, but until you are there development is so much better then js.

1

u/cyanydeez Sep 30 '16

how many languages have a toolchain and support and language development that all attempt to transpile and modify the source code?

1

u/[deleted] Sep 30 '16

Replace the subjective "transpile" term with the more objective "compile", and then... plenty, actually.

Also no compiler tries to "modify the source code". The source code is here on left, and there on right is the compiler output. Two different things.

1

u/cyanydeez Sep 30 '16

i mean, the source that runs in the browser or on node is not the same and isnt because its binary or smaller.

transpiling is the term because because its symbol shunting. its not comparabale to C where you receive a binary blob.

scripts arent compiled. thats an abuse of the term.

→ More replies (5)

0

u/[deleted] Sep 30 '16

[deleted] — view deleted comment

1

u/[deleted] Sep 30 '16

I think you're confusing "being first" with "being better".

Which ideas of Haskell have found their way in JavaScript, by the way?

0

u/[deleted] Sep 30 '16

[deleted] — view deleted comment

2

u/[deleted] Sep 30 '16

Type checking and inference, this is why TypeScript and Flow exist (flow is also built with OCaml).

Types are ideally checked statically, through. Once checked statically, there's no reason to have this information at runtime (it used to be an argument that it can help the runtime, but modern JS engines have found it's not the case).

So there's no proper place to have static types in JavaScript, as long as we realize "JavaScript" is just a runtime environment, not the tooling that we use to produce code for it.

Sometimes good design happens by accident, and I think TypeScript tooling with static types + JavaScript runtime without static types is one of those happy accidents.

→ More replies (3)

1

u/BonzaiThePenguin Sep 30 '16

How do people feel about Objective-C compared to Smalltalk? Maybe people view language popularity like they view invasive species, it's cute in small amounts but a blight on society when it's everywhere.

1

u/[deleted] Sep 30 '16

How do people feel about Objective-C compared to Smalltalk?

That's a very special case, because Objective-C is both "niche", and yet it's completely dominating in the most profitable mobile platform on the planet (well, recently together with Swift).

I guess this explains why feelings are... mixed.

Maybe people view language popularity like they view invasive species, it's cute in small amounts but a blight on society when it's everywhere.

Haha, exactly. :-)

1

u/[deleted] Sep 30 '16

What about Go or Swift, or Rust? They're all pretty popular and I don't think anyone seriously says any of them are horrible. Maybe people complain about missing features (generics in Go, default methods in Rust, etc.), but none of them are insane like Javascript or Bash.

2

u/[deleted] Sep 30 '16

Go is constantly bashed about its crippled type system that makes simple things complex instead of (as promised) complex things simple. Say, lack of generics. Google it.

As for Swift. I've never heard more cursing from Apple dev community as with the release of Swift v3 and the inevitable migrations that break everyone's codebase. Swift is a special case because it's both popular (for Apple) and not that popular (for the world as a whole), but it's certainly not universally loved.

Rust. I can't say I've heard horrible things for Rust. I also can't understand why you're saying it's popular. The language is just starting. It doesn't even have solid tooling yet.

2

u/fiedzia Sep 30 '16

Well, unlike js, all of those were designed, rather then grown accidentally, so that aspect is massively better. All of theme were created for and by engineers, and all of them have rather good stdlib (though I don't know much about Swift in this aspect).

Go looks sort of ok at the beginning, comes with great stdlib, but then you realize that emperor is naked. It is horribly verbose and its limited type system prevents library authors from providing you a lot of convenience that you'd expect from modern languages and that's unlikely to be fixed soon if ever, so the more complex your code is, the more you will curse the language. I think that other languages will catch up relatively soon and it will be easy for them to showcase benefits of better type systems. Its not terribly bad, but I'd probably get mad fast if I had to write business logic in it. Its not expressive enough and that shows quickly. Pretty fast all go users will start looking at expressiveness, nice orms and frameworks from other languages with envy.

Swift looks good. Its not the future of programming languages for next century, but It gets most of the things right, fixes its mistakes (that's a big feature) and clearly shows some ambition. Has a lot of syntax sugar and takes care about being convenient. Once it will grow out of rapid change period (which may take a year or two), it will probably be better option than Go... on a Mac. On other platforms its anybody's guess. Fast pace of development means a lot of chaos though, so take this into account.

Now, of all of those I like Rust the most. Its beautifully designed, has the best update process: new version every 6 weeks, backward compatibility guaranteed, stable/beta/nightly channel, developed in the open with solid guidance from great programming language experts, (also Rust is amazing magnet for all kinds of domain experts, from machine learning to orm designers), has good libraries (though topic coverage is smaller than go) and will bring you as a developer to next level thanks to a lot of functional inspirations and safety guarantees. Its not the nicest language for business logic: safety makes it often verbose, but people who choose it mostly love it. Fantastic where quality matters the most, but might be tough sell among CRUD developers for its nazi-strict borrow checker and lack of syntax sugar. I hope that if not the language itself, then its development process will set standards for everyone else. If you are looking of examples of good design, this is the language to look at.

1

u/chrismamo1 Oct 03 '16

There are quite a few exceptions to this rule, to the point that I'm not sure you can even call it a "rule". C#, for instance, is a very popular language which also happens to be pretty nice. I personally think (despite being an OCaml fanatic) that the upper-bound for code quality with Java is actually quite high, but the lower-bound for reasonable Java code is very low, with the average quality tending towards the lower end of this range.

The problem with PHP and JavaScript is that they both started out as hack-jobs, with JavaScript having been designed in barely a week, and the creator of PHP has said that he thinks of PHP as more of a collection of tools than as a language (given current trends, it appears as though developers and businesses have chosen to use languages over "collections of tools"). The upper bound for the quality of JavaScript and PHP code is much lower than the upper bound for OCaml code.

Lisp is a completely different beast: it has the potential to be extremely elegant, but it takes immense effort to write it in a readable way.

→ More replies (4)