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 @03:39AM (#12342026)
>Really? There is no more "problem" with Node.js than there is a "problem" with any other platform.

Javascript's type system really doesn't stand up well to scrutiny. That's more crucial than you'd think - the type system is the foundation the rest of the language is built upon.

I suspect this is partly why javascript cycles through technologies so often. The foundations are shaky.

Re:“Node.js is one of the worst things to happen to the soft... by nostrademons on Tuesday August 23, 2016 @03:55AM (#12342073)
It's dynamic typing with a prototype-based object model. This type system tends to be very good at iterating quickly and testing out many alternative approaches to solving a problem without committing to a data representation up-front. It tends to be pretty bad at communicating invariants to other programmers or nailing down APIs for other subsystems to build off.

Small wonder, then, that the Node.js ecosystem tends to very good at iterating quickly and testing out many alternative approaches to solving a problem, and pretty bad at communicating invariants to other programmers or providing a stable API for other programs to build off. You tend to get what you ask for.

Re:“Node.js is one of the worst things to happen to the soft... by cmrdporcupine on Tuesday August 23, 2016 @08:05AM (#12342988)
The problems with the JS type system has nothing to do with its dynamic typing or its prototype model.

JS has unfortunate implicit type coercions, bad scoping rules (not type system related but still crappy), and annoying tri-value silliness (NaNning all over).

I'm a big fan of prototype OO. JS not so much.

Re:“Node.js is one of the worst things to happen to the soft... by crdoconnor on Tuesday August 23, 2016 @05:07AM (#12342329)
There exist strongly typed dynamic languages that are good at both.
Re:“Node.js is one of the worst things to happen to the soft... by nostrademons on Tuesday August 23, 2016 @05:17AM (#12342369)
Examples?

If you're about to say one of SmallTalk/Lisp/Python/Ruby, then no, they are good at prototyping but have all the pitfalls of Javascript when used on large teams. If you're about to say one of Java/Go, then no, you give up a lot of prototyping flexibility for their explicitness.

Re:“Node.js is one of the worst things to happen to the soft... by discreteevent on Tuesday August 23, 2016 @07:54AM (#12342930)
This is exactly the intention of optional/gradual type systems. You can prototype away just as freely as with a purely dynamic language. Then when you have learned enough to be more definitive you can start putting in types. Dart is a good exponent of this (I think). Its a fully dynamic language but the compiler will catch the majority of static type errors (for types you define) and you can run it in checked mode during testing to catch other type errors. Typescript also has optional types (without runtime checking) but when I tried it it seemed to be harder to mix and match dynamic/static.
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.

Re:“Node.js is one of the worst things to happen to the soft... by soulbadguy on Tuesday August 23, 2016 @10:18AM (#12343892)
dart , typescript, typed/racket ,julialang ?
Re:“Node.js is one of the worst things to happen to the soft... by jasode on Tuesday August 23, 2016 @07:54AM (#12342927)
>There exist strongly typed dynamic languages that are good at both.

What concrete examples were you thinking of? (You didn't mention any strongly-typed-dynamic languages in your replies to the others.)

Re:“Node.js is one of the worst things to happen to the soft... by vertex-four on Tuesday August 23, 2016 @05:29AM (#12342425)
I really don't think that people have been coming up with new frameworks because you can add [1] to 5 and get nonsense.

Javascript cycles through technologies quickly because web developers cycle through technologies quickly, and they do that because they get to work on greenfield projects with minimal expectation for them to be around in 5 years a lot. Check out all the different server side frameworks and infrastructure components that have been in vogue with web developers over the last decade.

In comparison, people who aren't writing consumer-facing websites and webapps tend to have much more clearly-defined goals, longer lifespans of their apps, and don't often get the choice to use anything but industry standard technology. Because of the slower cycle, there's less opportunity to redesign frameworks and core technologies even when it's allowed.

Re:“Node.js is one of the worst things to happen to the soft... by crdoconnor on Tuesday August 23, 2016 @06:36AM (#12342639)
>I really don't think that people have been coming up with new frameworks because you can add [1] to 5 and get nonsense.

There's plenty more nonsense where that came from. That's just an easy to understand, concrete and obviously stupid example.

>Check out all the different server side frameworks and infrastructure components that have been in vogue with web developers over the last decade.

In python it's mainly been django and flask for a decade. In Ruby it's mainly been Rails.

Why do they have sticking power? It's partly cultural but it's largely because they were built on far more stable foundations.

Re:“Node.js is one of the worst things to happen to the soft... by vertex-four on Tuesday August 23, 2016 @08:27AM (#12343113)
In web frameworks, over the past decade, we've had various PHP frameworks, Zope, Ruby on Rails, Django, a variety of microframeworks in various scripting languages, Play, node.js+express in a handful of configurations (though generally MVC-ish), and Phoenix. There's very likely more that I'm forgetting.

In deployment, we've gone from SFTP scripts to Fabric-like software to PaaS to configuration management software to Docker, and then it seems every 6 months there's a different preferred way to make Docker do something useful. And of course there's the eternal argument over whether to deploy to VPSes, cloud platforms, or bare-metal hardware.

The "hip" web companies at any given moment - the ones who need the latest and greatest components to impress investors and attract "rockstar" "10x" developers - aren't tied to any specific language. They'll pick whatever was the most popular at the time they needed to pick something. Hence, right now, you have a whole lot of companies building on Golang and node.js, where they'd've been building on RoR five years ago.

Re:“Node.js is one of the worst things to happen to the soft... by nickpsecurity on Tuesday August 23, 2016 @01:22PM (#12345459)
Great comment illustrating the big picture of a few years. Now we just have to figure out which of those is the best for arbitrary, use cases with easy maintenance, unlimited scaling, and high availability. Whoever figures that out will finally be "Right." ;)
Re:“Node.js is one of the worst things to happen to the soft... by lootsauce on Tuesday August 23, 2016 @03:43AM (#12342038)
Is it a tradeoff or idiocy (bad idea)? Clearly you are in the "bad idea" camp. No worries, you can use TypeScript. Enjoy! (edited for clarity)
Re:“Node.js is one of the worst things to happen to the soft... by Noseshine on Tuesday August 23, 2016 @04:04AM (#12342101)

    > with Babel you can use TypeScript
Be careful with throwing "idiocy" at otehrs when it seems you yourself don't even know what you are talking about. To write TypeScript you use... TypeScript (their compiler).
Re:“Node.js is one of the worst things to happen to the soft... by lootsauce on Tuesday August 23, 2016 @04:08AM (#12342124)
Thanks the Babel thing was incorrect, Typescript is separate.

To clarify, I'm certainly not implying this person is an idiot. I'm saying, they lean toward thinking that the typing system is more of a bad idea (idiocy) than a valid tradeoff.

Re:“Node.js is one of the worst things to happen to the soft... by crdoconnor on Tuesday August 23, 2016 @07:12AM (#12342758)
Yes, that's accurate.

I don't think typescript is necessarily the answer though. You don't fix the problems caused by weak implicit type casts with static typing, you do it by turning off weak implicit type casting and raising a lot more type errors.