Live data from Hacker News

For modern development Javascript indeed is a shit language

live.julik.nl

161–170 of 243 posts

Re: For modern development Javascript indeed is a shit language

#161
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.

Generally speaking, in the JS world at least, if you're passing more than a few parameters into a function you might have code complexity problems. If you need to pass in a bunch of data to a function you tend to do it in a single options object with some runtime checking to work out what to do with it. Any remaining problems should be caught with good test coverage. Being able to flexibly and clearly handle variable…

>>How do you handle Javascript ignoring wrong numbers of function arguments?

>if you're passing more than a few parameters into a function

I didn't know you had to have "more than a few parameters" before you could make a coding error related to the number of parameters you pass something.

Re: For modern development Javascript indeed is a shit language

#162
post #153

Earlier quoted context omitted.

Firefox Nightly [1,10,5,-15,-2,4].sort ((a, b) => a-b).toString(); "-15,-2,1,4,5,10"

People dont write JS just for Firefox Nightly.

I didnt say they should (some people do), it is code which works with a JavaScript console though

Re: For modern development Javascript indeed is a shit language

#163

Earlier quoted context omitted.

>"JS is slow." In comparison to what? JS is one of the faster script languages out there. V8 is way faster that Ruby and outperform python a lot of time as well. It's regex is blast fast as well.

It outperforms Python at everything except where Python just calls a C function. Ruby (especially the recent releases) is on par with Python speed, if not faster. But neither is close to JS.

"My pet is fast because it can beat a turtle and a slug in a race"

Re: For modern development Javascript indeed is a shit language

#164

Earlier quoted context omitted.

The reason alot of people like dynamicly typed languages is that they don't have to babysit the compiler. Small example, in JS, if you have a function that works on a "age" property of an object, it doesn't matter what kind of object you send in, as long as it has an "age" property. You can do this easily in staticly typed languages as well, but you have to write more code (generics, class/struct-definitions, interfa…

> "Small example, in JS, if you have a function that works on a "age" property of an object, it doesn't matter what kind of object you send in, as long as it has an "age" property." Shouldn't you just pass the 'age' property then?

Depends what operation you are performing. increaseAge function would probably require the object to actually increase the age, not just return an increased age value.

This is a poor example, i know, but the point is that while both is simple operations in both static and dynamically typed languages, dynamically typed languages allow you to do this without writing an interface, generic function, abstract base class or whatever and restricting the function to that particular use case.

The tradeoff is flexibility vs safety. I personally prefer dynamically typed languages as I've found that with a combination of discipline and unit-tests (which, IMHO, you should have anyway) I never really miss the static type-checker. But I understand those people who prefer static typing very well.

Re: For modern development Javascript indeed is a shit language

#165
post #129
post #26

As someone who maintains old 1000+ KLOC projects I have to agree. Have look at some large old Perl projects to see how JS code will look&feel in 10 years. But on other side I see JS bytecode as great alternative to Java and JVM. Modern languages usually include JS as compilation back-end.

>But on other side I see JS bytecode as great alternative to Java and JVM. Exactly how is javascript a better byte code than JVM byte code?

Obviously install base is huge.

Re: For modern development Javascript indeed is a shit language

#166

Earlier quoted context omitted.

Safari/Chrome: SyntaxError: Unexpected token '>' Firefox: SyntaxError: syntax error In a discussion about Javascript maybe it would be a good idea to give examples of Javascipt that actually run in a Javascript console?

Firefox Nightly [1,10,5,-15,-2,4].sort ((a, b) => a-b).toString(); "-15,-2,1,4,5,10"

You have responded to my pointing out that '->' syntax doesn't work in current browsers with an example of a different bit of syntax, '=>', that works in a single development browser. I don't follow your point.

Re: For modern development Javascript indeed is a shit language

#167
post #158

Earlier quoted context omitted.

It's still a programmer error when they accidentally call a function with 2 arguments when they meant to call it with 3. The fact that the language can't inform them of the error doesn't change that.

So do some error checks. The first unit test I write for any function is that it handles arguments correctly.

That's great if it's your function that's the problem. Less so if it's someone else's.

And it's not only these kinds of errors that can cause silent failure. I've had it on missing brackets, on missing commas, on failure to include/require the right source file etc, etc. No error message, no warning, no log entry, no nothing. Just silence. And a blank output. Not overly helpful.

Re: For modern development Javascript indeed is a shit language

#168
post #158

Earlier quoted context omitted.

It's still a programmer error when they accidentally call a function with 2 arguments when they meant to call it with 3. The fact that the language can't inform them of the error doesn't change that.

So do some error checks. The first unit test I write for any function is that it handles arguments correctly.

But you do see why people are complaining, right? You are having to manually write thousands of tests to check something that is trivial for a compiler to check.

Re: For modern development Javascript indeed is a shit language

#170
Agree. JS = gavno. It's faster than Ruby only because Ruby is slow like gavno as well.

The fact that many are eating gavno and are feeling happy about it does not make it healthy or tasty. The problem is when there are no other food to choose (browsers).

That's why I love backend development. I can choose a decent, compiled, strongly typed language and well-supported framework.

Post reply on HN