Live data from Hacker News

For modern development Javascript indeed is a shit language

live.julik.nl

71–80 of 243 posts

Re: For modern development Javascript indeed is a shit language

#72
I'm so tired of hearing how bad JS is as a language - guess what, it doesn't metter. The ecosystem and community is absolutely amazing and that's something you just can't beat - all the well documented, polished and maintaned libraries, frameworks etc, the amount of books, guides, conferences and so on, the ability to use JS everywhere, tools, services, cloud based solutions and much, much more. That's why people create all the amazing stuff and all of this results in one of the most important things - development speed. Sure, JS has a lot of quirks you need to be aware of and it's easy to write bad JS, but with some experience, you can rapidly write a maintainable, easy to read, flexible and modular code.

Re: For modern development Javascript indeed is a shit language

#73
> a function is not an object, not a datastructure that can carry data

Wait, what? That's the definition of a closure.

Most of this seems to boil down to the author saying "my programming brain was hardwired by Ruby, and I'm annoyed JavaScript is different." OK, I feel your frustration. As a reader, though, I'd far rather see a post from someone who has spent the time to become proficient in both ecosystems and can offer more considered pro/cons.

On one point, I'll agree: I wish Javascript had an easy way to say "referencing an undefined property of this object should throw an error."

Re: For modern development Javascript indeed is a shit language

#74
post #70

Earlier quoted context omitted.

> The correct answer is it has to do with weak types. No, it does not. You could define the exact same default function in Java, Haskell (requiring that the sorted type be a Show instance) or Python (hell, getting the exact same behavior in Python could hardly be simpler: `ar.sort(key=str)`. There, I broke it. That is near literally how the ECMAScript spec very explicitly defines the default comparison function. The…

> That might well be, but the default sort comparison function is not a demonstration of it. Yes it is. It demonstrates weak typing which I also think is broken. If I wanted to sort a string, I would have done this: > ["1","2","3"].sort() > (hell, getting the exact same behavior in Python could hardly be simpler: `ar.sort(key=str)`. There, I broke it. You broke it by writing more code. That's good. Javascript is brok…

> Yes it is. It demonstrates weak typing which I also think is broken.

For the third time, no. There is no implicit conversion process during the comparison, the default comparison is explicitly specified to convert both of its arguments to strings before doing the comparison.

Javascript does not trigger conversions to compare two numbers, so relying on the type system would actually do exactly what you want.

> You broke it by writing more code.

Meanwhile you completely missed the point of posting the snippet.

> Javascript is broken __unless__ you write additional code.

And as I replied the first time around, I have no objection with the assertion that the default sort comparison function is garbage, I have an issue with your assertion that it is a consequence of weak typing because it is not.

Re: For modern development Javascript indeed is a shit language

#76
post #17

Personally, I disagree. I find JavaScript to be the most "write-able" language, and switching to Node + frontend JS as my main language (I've done Python, Ruby, PHP, Java and C++ as jobs) has been the best thing I've done in a long time. Express and Angular are amazing. Sure, it has a bunch of quirks. Sure, it's not good for everything (I do mostly relatively simple CRUD apps). Sure, in the browser, it gets slow when…

I see this all the time. JS is slow because of the dom. No. JS is slow because JS is slow. Yes, I know V8 makes it faster than it used to be. Yes I know it is neck and neck for computation, but because of the way memory is handled it is slow for loading large dictionaries. But I could forgive all of that. JavaScript is not well designed for work in a team environment, nor is it well designed for Large Code Bases. But…

> JS is slow because JS is slow.

JS is the fastest dynamic language next to SBCL's Common Lisp implementation.

> JavaScript is not well designed for work in a team environment, nor is it well designed for Large Code Bases.

Why is this a problem? Most web problems don't need a large code base. A small, dynamic language is suited to web problems. And judging by the amount of things being built with Javascript, enough people have figured out its quirks.

> All the best languages have a group of scientists that have chosen that language to be their defacto language. That is why we see Python, LISP, Fortran (yes still), MatLab, all living on long beyond the "trendy" languages.

To a certain degree I agree, at least about LISP and Fortran. You should add Haskell to the list. One language has also lived long beyond most of the trendy languages: COBOL. Take that for what it's worth.

> but JS for backend is like writing in Visual Basic. These days you can do anything in it, it will be fast, but that doesn't make it the right choice.

Why this is even an issue is beyond me. Nodejs is good for people writing a small backend to interact with a single page app on the client side. If you're writing giant Nodejs apps you're doing it wrong.

Besides, with pretty much every language having web frameworks and every language compiling to JS, you have plenty of choices.

Despite all of JS' quirks, people still write amazing things in it. That should tell you something.

Re: For modern development Javascript indeed is a shit language

#77
post #17

Personally, I disagree. I find JavaScript to be the most "write-able" language, and switching to Node + frontend JS as my main language (I've done Python, Ruby, PHP, Java and C++ as jobs) has been the best thing I've done in a long time. Express and Angular are amazing. Sure, it has a bunch of quirks. Sure, it's not good for everything (I do mostly relatively simple CRUD apps). Sure, in the browser, it gets slow when…

I see this all the time. JS is slow because of the dom. No. JS is slow because JS is slow. Yes, I know V8 makes it faster than it used to be. Yes I know it is neck and neck for computation, but because of the way memory is handled it is slow for loading large dictionaries. But I could forgive all of that. JavaScript is not well designed for work in a team environment, nor is it well designed for Large Code Bases. But…

>> JS only picked up steam because Flash died. Not because it was a great language. If it were a great language people would have started optimizing it 5 years ago. It isn't. So they didn't. The new optimizations are out of necessity. And because it lets front end pretend to be backend. That may sound snobby, and it is, but JS for backend is like writing in Visual Basic. These days you can do anything in it, it will be fast, but that doesn't make it the right choice.

Very much ^this.

I never cease to be amazed by the defensive attitude and excuses coming from JavaScript developers. Usually the premise is "I can get shit done in it, so it must be good", which isn't a particularly strong argument.

If you would make up 20 completely different metrics to rank programming languages on, and score every popular language using each of them, JavaScript would be near the bottom of almost all of them, and near the top of none. It's not terrible in every way imaginable (it would score reasonably well on 'productivity' for example), but it's not great in any of them either, which frankly makes it a shit language that only exists as a historical accident.

Re: For modern development Javascript indeed is a shit language

#78
post #67
post #7

Earlier quoted context omitted.

How do you handle Javascript ignoring wrong numbers of function arguments? Do you use a linter to catch this sort of thing? This part of Javascript sounds the most absolutely insane to me: Silencing an error like that is catastrophic.

In JS, sending the "wrong" number of arguments is frequently a feature. There's no concept of language-level function overloading, and it allows for the authorship of functions that take a variable or unbounded number of arguments (useful when coding in a functional paradigm).

That "feature" would be better with an explicit language construct such as *args or params args[], though. As with so many complaints about JavaScript, it's the default behaviour that is a problem.

Re: For modern development Javascript indeed is a shit language

#79

Despite most of the points in this post being debatable — there's one bit that caught my eye: "Being nice will not help it, and CoffeeScript is not radical enough." As the guy who started CoffeeScript, I agree. It's an intentionally very conservative approach. But there's more than one good way to skin the JavaScript cat. I think it would be fun to take another run at the same problem — attempt to find a minimal, rea…

CoffeeScript was obviously inspired by Ruby. While CS is great, I've never gotten over the usage of "->" or "=>" to signify a function. To me, Ruby's "def" or "do" reads so much better. Especially with "end", to signify a barrier, as opposed to whitespace. Have you considered porting Ruby directly to JavaScript? By the way, thanks for your work on _ & Backbone!

    > Have you considered porting Ruby directly to JavaScript?
No. It's been attempted before, and it doesn't turn out to be terribly useful in the end, because of the vast semantic mismatch between the two languages. See: https://github.com/jashkenas/coffee-script/wiki/List-of-lang...

    > I've never gotten over the usage of "->" or "=>" to signify a function.
Give it a try, perhaps. It's critical not to use "def" and "do" when your functions are first-class values that can be passed as arguments, or assigned to variables. It's for this reason that Ruby 1.9 has a new lambda syntax that looks a great deal similar to CoffeeScript's. For example:

    request(url, def callback(response) do
      ...
    end)
... that kinda thing is no good.

The reason it's an arrow is because in any decent function, the input determines the output, eg. input points to output. And therefore, the CoffeeScript syntax: (input) -> output

Re: For modern development Javascript indeed is a shit language

#80

Despite most of the points in this post being debatable — there's one bit that caught my eye: "Being nice will not help it, and CoffeeScript is not radical enough." As the guy who started CoffeeScript, I agree. It's an intentionally very conservative approach. But there's more than one good way to skin the JavaScript cat. I think it would be fun to take another run at the same problem — attempt to find a minimal, rea…

Keep up the good work! I still think the main point around javascript is the type system or the lack thereof. I don't mind dynamic typing, but the javascript data types are central to all HTML5 APIs and most existing libraries. CoffeeScript gets this right, many others don't.

TypeScript & Dart are offering optional typing. ASM.js is seeing big performance gains through utilizing the numeric types, and avoiding the GC monster.
Post reply on HN