News for hackers. Stuff that matters.
Re:“Node.js is one of the worst things to happen to the soft... by crdoconnor on Tuesday August 23, 2016 @05:53AM (#12342504)
>Python/Ruby, then no, they are good at prototyping but have all the pitfalls of Javascript when used on large teams.

No, they absolutely don't.

>>> "1" + 1

Javascript: 11

Perl: 2

This is the kind of approach works ok for small programs. Where the code that does these implicit type casts isn't too buried.

When it's buried 3 layers down in a dependency used by a dependency used by a dependency, you want this to happen instead:

Python/Ruby: Type error

Re:“Node.js is one of the worst things to happen to the soft... by Terr_ on Tuesday August 23, 2016 @06:20AM (#12342586)
... And? That's simply "not having unpredictable type-juggling."

It does nothing to communicate invariants or guide API usage at design-time.

Consider PHP, which does have some of those bizarre and frustrating conversions, yet at the same time it also has stuff like type-hints and interfaces that can be used for design-time checking.

Re:“Node.js is one of the worst things to happen to the soft... by crdoconnor on Tuesday August 23, 2016 @06:33AM (#12342629)
>... And? That's simply "not having unpredictable type-juggling."

Literally what this entire thread is all about.

Lots of languages have this issue and it manifests in the instability and indeterminacy of large scale applications in Perl and PHP much as it does in javascript.

Type hinting is, honestly, a pretty poor way of dealing with the problem of turning "1" + 1 into 2, but that's a separate issue.

Re:“Node.js is one of the worst things to happen to the soft... by Terr_ on Tuesday August 23, 2016 @12:31PM (#12345012)
> [type juggling is] Literally what this entire thread is all about.

No it isn't, that's just what you've been fixated on. Please re-read nostrademons' post, because you aren't actually addressing the issues they brought up, namely:

> It's dynamic typing with a prototype-based object model. This type system [...] tends to be pretty bad at communicating invariants to other programmers or nailing down APIs for other subsystems to build off.

While it's true that Python "fails nicer" than JS, it addresses neither of those two issues about preventing failures.

Re:“Node.js is one of the worst things to happen to the soft... by nostrademons on Tuesday August 23, 2016 @11:58PM (#12349575)
While I think that JS's loose typing is a little annoying and certainly isn't what I'd build if I were designing the language from scratch, it just isn't much of a problem for me in practice. Type errors in general (either of the implicit coercion variety or the dynamic typing variety) aren't much of a problem. They rarely happen, and when they do, they usually take all of 5 minutes to track down and fix.

I find that the big benefit of types are in documentation. They are executable, explicit, compiler-checked documentation of the programmer's intended usage. Without this, it becomes much harder to read through and comprehend a large codebase that was mostly written by other people. It becomes even harder to change it.

I like Python, I like Javascript - but they have their uses, and those uses don't include large-scale mature software engineering. I actually argued otherwise for my first couple years at Google (where both are used extensively, though the JS is largely statically typed), but eventually saw the wisdom of more experienced engineers in this, and relegated my Python to exploratory coding.

Re:“Node.js is one of the worst things to happen to the soft... by oliverkyss on Tuesday August 23, 2016 @11:51AM (#12344687)
Java: 11

I guess companies should stop using Java for big enterprise applications with tons of dependencies. Or this isn't a problem because programmers usually know the basics of the language they are using. And if they don't, then that is the problem, not the language.

btw, Python: '1' * 3 -> '111'

Re:“Node.js is one of the worst things to happen to the soft... by crdoconnor on Tuesday August 23, 2016 @01:52PM (#12345775)

   Main.java:17: error: incompatible types: String cannot be converted to int
    int z = x + y;
>btw, Python: '1' * 3 -> '111'

In theory I agree with this but in practise I see this so rarely used it barely matters.

Re:“Node.js is one of the worst things to happen to the soft... by oliverkyss on Tuesday August 23, 2016 @02:15PM (#12346036)
Sorry, I meant "11" (String), same result as with JS.

see here: https://repl.it/Cqeq/0

Re:“Node.js is one of the worst things to happen to the soft... by Ar-Curunir on Tuesday August 23, 2016 @12:21PM (#12344937)
The python example is not an issue; you're going from string to a longer string, not to an integer.
Re:“Node.js is one of the worst things to happen to the soft... by oliverkyss on Tuesday August 23, 2016 @01:48PM (#12345741)
That's not true, you're going from string _and_ an integer, because '*' is a binary operator. (And it isn't communicative as shown here, which is another 'problem')

But that's not really the point, crdoconnor seems to think that languages should throw an error in cases like this, not just keep the type of the first argument.