News for hackers. Stuff that matters.
Re:JavaScript web apps considered valuable by falcolas on Thursday January 21, 2016 @10:06AM (#10945629)
I agree that Javascript web applications have a place. The problem is that the pendulum has swung too far, and folks are using Javascript everywhere. Static content generation on the client side, rendering non-interactive content, on the backend, in the build process, as a generic scripting language... the list goes on.

We're watching programming and design concepts which played out back with Windows 95 being hailed as "the future of programming". We're being told "worse is better" as Javascript is being used to turn our computers against their users by serving as a vector for malware, ads, and bots.

It's a mess, and it's going to take pushes from the far side of the pendulum's swing to bring it back to a sane place. If the pendulum was actually stalled too far towards "server side only", I'd agree that "server side only" articles would be too much - but we're not there.

> We can only improve the user experience with the front-end technologies we have.

No, we are more than capable of degrading the user experience with the front end technologies we have. There's a lot of proof of that on the web today. Delayed full page ads, pop-overs for every third word, hijacked scrollbars, malware installs...

Re:JavaScript web apps considered valuable by Wintamute on Thursday January 21, 2016 @10:20AM (#10945736)
JavaScript has grown up; it's got one of the best package managers anywhere, rapidly improving syntax and semantics, a large passionate community, loads of great tooling and a well maintained cross-platform binary in the shape of Node. It's no less deserving than any other language to be run on a server, as part of a build, generic scripts, whatever. Browser security issues arise because it's hard to resolve total user security across the public web coupled with highly interactive scriptable web pages ... its got nothing to do with the JavaScript language per se. It's fair enough to argue against the level of control scripts happen to have over the browser, but web page scripting could be implemented in <insert some other language here> and the same issues would be present. Your comment comes across as ignorant and prejudiced I'm afraid.
Re:JavaScript web apps considered valuable by donatj on Thursday January 21, 2016 @10:22AM (#10945749)
NPM and the community that surrounds it is a nightmare. I guess you could be talking about Bower but either way they are far from good,let alone best.
Re:JavaScript web apps considered valuable by Wintamute on Thursday January 21, 2016 @10:44AM (#10945929)
I was talking about npm. And I find the JS community welcoming, friendly and passionate and for the more serious npm modules out there highly technically literate, but hey it's a subjective thing I suppose :/
Re:JavaScript web apps considered valuable by kuschku on Thursday January 21, 2016 @07:51PM (#10949894)
So, the package manager that doesn’t do proper deduplication and, thanks to nested dependencies, runs over the file path length limit on multiple platforms?
Re:JavaScript web apps considered valuable by Silhouette on Thursday January 21, 2016 @09:23PM (#10950345)
FYI, the nesting and deduplication were fixed in NPM 3. It uses a flat structure now.

Unfortunately, in their place the version resolution algorithm is now subject to order dependency: the same package.json file, run at the same time with the same packages available in the NPM repository, can give different results on different machines depending on what had already been installed.

Re:JavaScript web apps considered valuable by paulddraper on Thursday January 21, 2016 @11:03PM (#10950679)
Yep. Solved long file paths. All we had to give up was determinism!
Re:JavaScript web apps considered valuable by its2complicated on Thursday January 21, 2016 @09:31PM (#10950380)
Ha ha, the effing path length limit drove me crazy! There'd be 50 node_modules folders and Windows wouldn't let you delete anything; It was nuts! I had to start renaming directories to "a", "b", "c", and so on until I cut the size down. I like JS for quick personal projects, but I'm glad I don't use it professionally anymore.
Re:JavaScript web apps considered valuable by overcast on Thursday January 21, 2016 @11:07AM (#10946130)
Can you give me examples of this? Everything I've used regarding NPM has been awesome. Stupid easy to use and integrate.
Re:JavaScript web apps considered valuable by Silhouette on Thursday January 21, 2016 @01:23PM (#10947153)
OK, here's an everyday example. Suppose you and I are working on a front-end project, all neatly set up with package.json and so on in place. We've been working on different new features, adding in a new package or two from NPM in the process. We both fetch each other's latest changes to in-house code from source control. What NPM command do we run to make sure we also have the same packages installed and are actually running the same code?
Re:JavaScript web apps considered valuable by overcast on Thursday January 21, 2016 @01:28PM (#10947191)
package.json version control and npm update? npm install --save will install the package you want, and add it to package.json

Why wouldn't your repo merge package.json between your changes? I'm doing the same thing when I merge changes to production. I add packages as I work on things at the desktop, and sync changes to production server.

Re:JavaScript web apps considered valuable by Silhouette on Thursday January 21, 2016 @01:45PM (#10947298)
Unfortunately, the regular package.json and related npm commands are built around semver, and typically also only specify direct dependencies. Either of those alone is enough to violate the simple condition I gave many times over on a real project, because it means you can't in practice guarantee that two developers are even running the same code. It's actually worse with the latest NPM changes that flattened the tree in node_modules, because now there are order dependencies affecting which versions of things you get as well.

The closest NPM has to an answer for this is shrinkwrap, but that adds a lot of complexity of its own, and still has limitations. In fact, there's a note at the bottom of the npm shrinkwrap documentation page suggesting that if you really want to control your dependencies robustly, you need to check everything into source control -- which is obviously the sensible thing to do, except that because npm does magic in node_modules that can involve all kinds of funky build steps, you're not checking in just the source for the modules you depend on, but might have all kinds of other artifacts that may or may not be portable as well.

In short, it is all but impossible in practice to use Node and NPM to satisfy the most basic of development requirements: getting all of your developers (or production systems, for that matter) to actually run exactly the same code. If that's not a catastrophic failure to meet the requirements for a package management system, I don't know what is.

Re:JavaScript web apps considered valuable by Wintamute on Thursday January 21, 2016 @02:09PM (#10947496)
Personally I don't find using npm shrinkwrap a chore at all. If npm 3+ notices a shrinkwrap file in the project it'll update it automatically, so most of the time you don't even have to think about it.

We've been using npm 3 on multiple large projects spanning frontend and backend, being worked on by many developers, pushing code through CI into production many times a day and npm installing fresh in every environment. There are probably many thousands of nested dependencies in some projects. It works, nothing bad happens, it's fine.

Npm comes with some trade offs, true, but also a long list of plus points as well. No system is perfect, but you're painting some calamitous disastrous picture here which simply isn't reflected in reality.

Re:JavaScript web apps considered valuable by Silhouette on Thursday January 21, 2016 @04:52PM (#10948694)
You've been using NPM3 on many large projects with many developers, many commits, thousands of nested dependencies, and not run into a single problem? If so, that is a remarkable achievement, and I hope you'll write up how you've done it somewhere.

In particular, I envy whatever combination of dependencies and development platforms you get to work with, because I haven't seen a single project with no problems due to updates since NPM3 arrived, never mind all of them. (Edit: This is not intended to imply NPM3 is the only reason for the problems, only to define a comparable time frame.)

Even if you're in an environment where shrinkwrap is working well, we seem to find transitive dependencies of installed packages that introduce bugs or break something without correctly updated semver with alarming frequency. As some of us were discussing here on HN the other day, this has happened so often with Gulp plugins over the past few months that one project I work on dumped the entire Gulp ecosystem (and instantly and dramatically improved developer productivity as a direct result).

Re:JavaScript web apps considered valuable by Wintamute on Thursday January 21, 2016 @06:53PM (#10949556)
> and not run into a single problem?

I didn't say not a single problem: I said "its fine, nothing bad happens, it works". Of course there are issues, and bugs, some of them due to dependencies breaking, but nothing calamitous or actually bad, and nothing out of the ordinary compared to other stacks and tools imo.

Npm module churn can be annoying sure, but on the flip side its good to be getting incremental patch updates sometimes too. And with exact versions in package.json and shrinkwrap you can eliminate enough uncertainty that to all intents and purposes its really not a problem.

> dumped the entire Gulp ecosystem

Amen to that. Gulp plugin eco-system has been messed up for a year or more. We do all our frontend builds with npm scripts now, running the bare cli tools where possible, and reducing dependencies as much as possible (e.g. Gulp and all its plugins).

Re:JavaScript web apps considered valuable by Silhouette on Thursday January 21, 2016 @09:21PM (#10950335)
I suppose we just have different amounts of tolerance for unexpected breakage.

It sounds like we do have a similar philosophy as far as tooling goes: simple scripts, minimal dependencies. But I add to that a strong preference for tools like build systems and package managers and source control systems to have completely deterministic behaviour and therefore provide reproducible results by default.

In practice, trusting semver has caused real world problems for some projects I've worked on with non-dev dependencies too. For example, a few weeks ago, Facebook pushed a bad update to React that completely broke dev builds on IE. It was fixed a few days later, but during that window NPM considered the broken version just as good as the version we'd been developing and testing with for the past couple of weeks. Tracking that one down wasted a few hours in our office as we tried to figure out why tests were failing on our new build/CI machine but whenever the developers tried it everything seemed to be working fine.

I guess I just don't understand the decision to make ambiguity the default with NPM, particularly with the Node/NPM culture of using very many small dependencies. It's not as if it's difficult to issue a message if a newer version of something relevant is available, or to provide a command or option to deliberately change to newer versions of packages -- pretty much every package manager in every language I've ever used does these things -- so introducing unnecessary variability just seems like asking for trouble.

Re:JavaScript web apps considered valuable by Matachines on Thursday January 21, 2016 @11:03AM (#10946098)
Agreed. The JS community has some great people but in general it's very immature.
Re:JavaScript web apps considered valuable by smt88 on Thursday January 21, 2016 @10:40AM (#10945890)
> ignorant and prejudiced I'm afraid

Relax. You're talking about someone's opinion of a programming language.

That said, all of your comments come across as ignorant to me. I don't think you're ignorant, though. I think you know JavaScript really well and like it.

I personally found it unusable on the server until TypeScript became mature enough to use. Have you tried TypeScript or some other static-typed, better-defined language (Flow, Clojure, etc.)?

You may love JavaScript, but there's a good reason Facebook, Google, and Microsoft all find it to be unusable and have created compile-to-JavaScript languages so that their companies can be JavaScript-free someday.

Re:JavaScript web apps considered valuable by todd3834 on Thursday January 21, 2016 @10:55AM (#10946029)
I doubt the goal is to be JavaScript free. The compilers typically enhance the language or give you access to functionality that is destined to land in the future JavaScript. ES6+ shows a lot of promise and thanks to Babel we can use those features now.
Re:JavaScript web apps considered valuable by smt88 on Thursday January 21, 2016 @11:05AM (#10946116)
Let me clarify what I mean by "JavaScript-free": they don't want any of their employees writing JavaScript by hand anymore, whether it be ES6, ES2015, or ES2020. TypeScript and Flow are supersets, but Clojure (and many other compile-to-JavaScript languages) are completely different.
Re:JavaScript web apps considered valuable by danneu on Thursday January 21, 2016 @11:09PM (#10950702)
No, they just want some static tooling on top of a dynamic language.

We use Typed Clojure where I work. To say it's because we "don't want to write Clojure by hand anymore" would be nonsense.

Reading your comments in this thread, I think you'll find out one day that people just have different appetites for different trade-offs and that's really all there is to it. No need to wheedle, condescend, or link Paul Graham essays.

Re:JavaScript web apps considered valuable by Wintamute on Thursday January 21, 2016 @12:33PM (#10946785)
Your insider knowledge of the technical policies of Facebook, Google, MS, etc is truly impressive. And ES2020 too? Somebody write this down quick!
Re:JavaScript web apps considered valuable by smt88 on Thursday January 21, 2016 @01:02PM (#10946995)
I understand what it's like to be emotionally invested in a particular language or technology. It's usually a result of not having used something better[1] or just having invested a lot of time into that technology.

The good news is that a lot of programming skills are fungible, and you (like me) will eventually use things you like more than you expected -- perhaps even more than you like JavaScript. The time you invested won't be wasted.

1. http://www.paulgraham.com/avg.html

Re:JavaScript web apps considered valuable by Wintamute on Thursday January 21, 2016 @02:13PM (#10947520)
You assume a lot about me! Don't worry ... I'm 35, I've been around the block, dipped in and out of a few languages and platforms :)

And if we're talking about emotional investment in technology ... I think that's where most of the JS shaming comments we're seeing on this thread are coming from. People feel a bit threatened by it because it seems like it's eating a lot of things at the moment. They'd be better off following your advice and stop sniping at it and take an interest.

Re:JavaScript web apps considered valuable by falcolas on Thursday January 21, 2016 @10:39AM (#10945879)
Javascript has grown up. It's past its infancy, and at a point where it starts to be really good at what it was designed to be good at. However, like any adolescent, since it's good at one thing, it thinks it is the best at everything.

I'm anthropomorphizing Javascript somewhat here, attributing the feelings of its community to the language itself. But from the point of view of someone whose first programming language was not Javascript, the trend is pretty apparent: We can run Javascript anywhere, so we will run it everywhere.

Re:JavaScript web apps considered valuable by Wintamute on Thursday January 21, 2016 @10:51AM (#10945995)
> However, like any adolescent, since it's good at one thing, it thinks it is the best at everything.

The only thing that's happening here is that a community has formed around an evolving language and is taking advantage of some great tooling and open source projects to do some interesting stuff. That community isn't formed exclusively of wet-behind-the-ears web developers. It's comprised of developers of all skills levels with experience in a multitude of platforms and languages, just like any other. These people chose JS because it works for them and their problem set. To suggest otherwise is condescending to say the least. Stop trying to paint the whole community with a single brush, you sound ridiculous. If JS isn't your bag fine, move on, but less of the JS shaming please.

Re:JavaScript web apps considered valuable by EvanPlaice on Thursday January 21, 2016 @12:13PM (#10946620)
Atwood's law.

They're building operating systems with it now.

See, NodeOS and Runtime.js.

The "Birth and death of Javascript" talk is beginning to look less like satire, and more like moderately accurate prediction.

Re:JavaScript web apps considered valuable by Silhouette on Thursday January 21, 2016 @01:13PM (#10947073)
JavaScript has grown up; it's got one of the best package managers anywhere, rapidly improving syntax and semantics, a large passionate community, loads of great tooling and a well maintained cross-platform binary in the shape of Node.

I'll give you the passionate community point. I almost completely disagree with everything else.

JavaScript is a very immature platform.

JavaScript has probably the worst packaging ecosystem of any major programming language. The fine-grained packages, indirect dependencies, and frequently broken versioning cause endless problems in real world systems. Recent attempts to fix the package manager have unfortunately swapped one set of problems for another, while still leaving some of those fundamental weaknesses involving transitive dependencies and excessive trust of version numbering conventions unaddressed.

It does has rapidly evolving syntax and semantics, but at the expense of stability, portability and future-proofing. The only reason 99% of JS programmers use most of the new syntax and semantics is a combination of a transpilation tool written primarily by one (remarkable) person and a polyfill written primarily by one other (remarkable) person in their free time. Browser, tool and Node support for many of those new features is patchy, which is why that transpilation and polyfilling is necessary.

Tooling for JS is at least two decades behind the industry best-in-class. It's a dynamic language that now has such a huge mess of build tools associated with it that seasoned veterans of web development weep at the prospect. You can't reliably debug real world JS code in its natural form, even on the level of setting break points and examining local variables and call stacks, without jumping through all kinds of hoops, and in some browsers even then. Profiling also relies almost entirely on browser magic. There are lots of testing tools, but setting them up is often a chore and they have widely varying degrees of power and flexibility. We've only recently got a style checking tool that can actually cope with ES2015 reasonably well. Refactoring, auto-completion, documentation, navigation in your editor? What are those?

As for Node... I've seen experienced developers spend months trying to get basic stuff working in a cross-platform way with Node, and then seen other experienced developers do more in a week or even a day using C. Using Node is saying "I know, let's throw out a few decades of experience building reliable client-server systems and all the other tried and tested languages and tools and libraries we've developed over that time, and instead transfer all of those negative aspects of JS to the server side as well, even though unlike front-end developers we don't have to".