Re:What the web platform can learn from Node.js: The Darwini...
by dham on Wednesday December 16, 2015 @01:24PM
(#10746134)
Web development is in truly a sad state. Having worked on a larger Node project I'll never do it again. The only thing you can do is npm shrinkwrap and never update your dependencies ever again. If you update you are f'ed. It's a nightmare. Semvar doesn't help at all. For instance Bookshelf added a method called count. Co worker was on .4 and using count. Everyone else was on .3. 0_0. https://github.com/tgriesser/bookshelf/issues/888
If you want things to just work like in the Ruby community, make sure you shrinkwrap.
I don't think most people run into this because most backend node programmers have moved to Go at this point, so they're not aware of the upgrade problems.
On the front end, people are probably re writing the front end every 3 or 4 months. Moving from javascript framework to javascript framework. Never dealt with upgrading 6to 5 to Babel to Babel 4 to 5 to 6, and npm from 2 to 3. Or browserify, browserify react hot reload, react-proxy v1 only, gulp. Ugh.
I'm not sure it's possible to move a project using Babel 5, async/await, generators and react to upgrade to Babel 6. I've spent hours on it.
Sometimes I think it's all some kind of cruel joke. Look at Babel. I mean a library that doesn't do anything without installing a plugin. At least support transpiling ES 6 and 7 to 5 out of the box and everything else with a plugin. I have to install like 4 plugins to get anything running.
Re:What the web platform can learn from Node.js: The Darwini...
by bkurtz13 on Wednesday December 16, 2015 @02:38PM
(#10746681)
> I don't think most people run into this because most backend node programmers have moved to Go at this point
Comments like this are what make it difficult for me to take HN seriously anymore. It's just an example of the hivemind at work, assume that an entire industry has the same ideas as you about what technology to use.
The Node/JS ecosystems are experiencing a Cambrian explosion in technology, with all that implies. If you don't like it, don't worry. It probably won't take 20 million years this time to settle in on the "best" ways of doing things.
Re:What the web platform can learn from Node.js: The Darwini...
by rpedela on Wednesday December 16, 2015 @02:39PM
(#10746690)
Cant speak for Babel, but the rest of it does not mirror my experience. I have had either no trouble or minor trouble upgrading Node versions. I always hard-code versions for dependencies, and then periodically upgrade which usually takes a few minutes. Once in awhile an API changes, and I have to spend a couple hours (gasp!). You make it sound like upgrading in Node is completely broken, but that doesnt appear to be the case in my experience.
Re:What the web platform can learn from Node.js: The Darwini...
by mnutt on Wednesday December 16, 2015 @06:10PM
(#10748103)
I also hard-code versions, but many dependencies float their own dependency versions, so you occasionally end up with broken sub-dependencies unless you shrinkwrap. Plenty of other package managers suffer from this type of issue as well, though.
Re:What the web platform can learn from Node.js: The Darwini...
by cozuya on Wednesday December 16, 2015 @03:52PM
(#10747248)
I use Node on both OSX and Windows and its definitely broken in Windows or maybe just not a priority to work well. Getting a full stack modern application working on localhost on a Windows machine is really painful and typical requires hours of googling obscure npm i errors.
Re:What the web platform can learn from Node.js: The Darwini...
by curun1r on Wednesday December 16, 2015 @04:46PM
(#10747602)
Or it requires conceding that Windows isn't an appropriate platform for developing unix-focused technologies and running something like Docker or Vagrant to better mimic the environment where the code will eventually be deployed.
Most of the developers where I am are running OS X, which is significantly more similar to our Linux production environments than is Windows and yet we determined that it was just easier to always run our node applications on Linux guest VMs. On Windows, I wouldn't even have the gall to try to make it work without this kind of setup.
Re:What the web platform can learn from Node.js: The Darwini...
by tracker1 on Thursday December 17, 2015 @01:40AM
(#10749984)
There are times on windows, where I just have a linux VM setup, where I can SSH into that in a couple of consoles, and map my home directory in windows via CIFS so I can use a gui editor in windows... VS Code is surprisingly good with node code, though they really should include most ES6/7 features for syntax highlighting at this point.
Re:What the web platform can learn from Node.js: The Darwini...
by tracker1 on Thursday December 17, 2015 @01:43AM
(#10749993)
You can set that globally... Many windows devs already have a version of VS installed. Though less common than say build-essentials in ubuntu, or xcode in OSX. You're likely to see the same issues there if you don't have them.
Python 2.x is the bigger oddity to me... seems like python's role with gyp should be replaced with something self-bootstrapped at this point.
Re:What the web platform can learn from Node.js: The Darwini...
by paulddraper on Wednesday December 16, 2015 @08:20PM
(#10748812)
Sure.
"Run anywhere" is really only descriptive of languages (e.g. Java), not implementations (e.g. Dalvik). You can't have a "run anywhere" implementation, unless you are grouping a bunch of implementations together...one for ARM, one for x86, one for FreeBSD, one for Windows, one for Minecraft, etc... because even under the same name the implementations would very significantly internally.
"Run anywhere" is a function of (1) the language spec (i.e. how much machine dependent behavior is permitted) and (2) the actual real-world support across platforms.
JS has the first, but the second is often conceeded, per the earlier comment.
Re:What the web platform can learn from Node.js: The Darwini...
by mAritz on Wednesday December 16, 2015 @04:43PM
(#10747583)
We run a good-sized app API using Typescript with Node.js. Our developers use Linux or Windows. The only real trouble we have with windows are some rare native add-ons like memwatch.
We keep our dependencies up-to-date by occasionally running "npm outdated", checking the packages for their Changelog.md (or equivalent) and then enjoying the new stuff.
From my perspective you were just unlucky with your packages, or you might be doing something else wrong.
Re:What the web platform can learn from Node.js: The Darwini...
by bronson on Wednesday December 16, 2015 @04:08PM
(#10747349)
That's also true of Ruby, Python, Perl, ... Ultimately, if you're on Windows and you want a smooth development experience, you need to use made-for-Windows technologies (notably C# and friends). Hopefully that changes one day.
Re:What the web platform can learn from Node.js: The Darwini...
by tracker1 on Thursday December 17, 2015 @01:37AM
(#10749979)
I remember it was that way for a long while.. but other than Python 2.x, and having a recent VS (Community Edition works) installed, haven't had many issues... at least no more than I've typically had with Linux.
I spend about equal parts of my development time between OSX, Linux and Windows... they all have had pain points for me. The only difference is in OSX dev you're likely to have XCode & homebrew. In windows, you may have VS, and probably won't have Python ^2.7.0 installed.
Part of why I've at least participated enough to raise a possible bit of help with the situation[1]. There are times when all you can reasonably do is raise the issue, and suggested fix... there are others where you should proactively fix it.
Node/npm's community is very open-source driven, and very diverse. I don't liken it as much worse than any other platform, and far better than most.
Re:What the web platform can learn from Node.js: The Darwini...
by rpedela on Wednesday December 16, 2015 @04:06PM
(#10747331)
I bet. Even though Node claims to work on Windows, most dependencies are built and tested for Linux (or OSX). Just curious, what are the use cases for Node on Windows?
Re:What the web platform can learn from Node.js: The Darwini...
by cozuya on Wednesday December 16, 2015 @04:47PM
(#10747603)
I'm probably the rare developer who prefers the UI and feel of Windows to OSX.. though I am probably a prototypical use case to switch to Mint, but haven't got around to it.
Re:What the web platform can learn from Node.js: The Darwini...
by krisdol on Wednesday December 16, 2015 @06:34PM
(#10748254)
I feel comfortable with all the UIs, but essentially I want to be as close to my application's production environment as possible, while still being productive. I've never worked on a team where that environment was windows, and setting up node/ruby/docker/vim/bash/nginx in a windows environment has always been a total pain compared to either linux or OS X (still kind of a pain for docker, but slightly less so).
For some of these core tools, authors explicitly state that windows is a second class citizen. It's just not worth the expense to support something that has so few comparative users, in some cases (ruby). It's a lot of work for something that will never feel "native".
Re:What the web platform can learn from Node.js: The Darwini...
by tracker1 on Thursday December 17, 2015 @02:14AM
(#10750079)
I feel that Windows 7 was really the pinnacle UI for desktops... I kind of dig Unity, as it's similar enough for me. I do prefer a bash prompt to CMD though.
I don't think node on Windows is so bad these days once you've got Python 2.x and VS 2015 Community installed... When I started with node (0.6-0.8 era), it was pretty bad in Windows. These days most popular modules just work, or work once you have gyp prereq's installed.
Re:What the web platform can learn from Node.js: The Darwini...
by sanderjd on Wednesday December 16, 2015 @06:41PM
(#10748292)
Maybe we're both rare, but I think Windows 7 and Windows 10 are both really nice, as is the Edge browser. I've been considering switching from OSX. It seems like it should be relatively convenient with tools like Vagrant to develop on Windows but run, test, and deploy on Linux. But I haven't tested this hypothesis yet.
Re:What the web platform can learn from Node.js: The Darwini...
by tracker1 on Thursday December 17, 2015 @02:16AM
(#10750083)
As long as you get Windows 10 Pro, you get Hyper-V... I have an always-on linux VM that I SSH a few terminals to and map a drive via SAMBA on the VM to my desktop, so I can edit in a windows GUI, but interact in Linux... it works pretty well, and tbh is usually easier than the odd edge case with windows, unless you're a C/C++ guy.
Re:What the web platform can learn from Node.js: The Darwini...
by tracker1 on Thursday December 17, 2015 @10:49PM
(#10756501)
Hyper-V is just a VM environment that comes with some versions of windows... It's not really too much different than VMWare, Parallels or VirtualBox... It does have an option to start in the background on machine start on the desktop version.
So I installed Ubuntu Server (latest) in a Virtual Machine via Hyper-V... set it to auto-boot.. setup OpenSSH, setup Samba ... I kind of just muddled through it, to be honest.. after that, I setup Docker, build-essentials and nvm, which covered my needs there.
On the windows side, I use Clover as an explorer replacement (file explorer, not the desktop), and use ConEmu for tabbed shell interfaces. It works pretty well for me. I use GUI stuff in windows, and the linux side via SSH.
Re:What the web platform can learn from Node.js: The Darwini...
by lobster_johnson on Wednesday December 16, 2015 @02:49PM
(#10746763)
I've also had a bunch of cases where old versions of packages (looking at you, esprima!) suddenly disappear from the official npmjs.com repository.
We have apps that are stable and have been running for many months, until suddenly we need to add a small feature. With a missing package deep in the tree — not one we were depending on directly — we have to waste several hours being forced to upgrade packages to newer versions, just to work around the missing version. It's insane.
(It's possible to unpublish NPM packages, which is what happened here. That in itself is terrible, especially since all you get is a 404 from NPM — no reason for the unpublish provided.)
The NPM tool itself is a mess:
* It suffers from sporadic bugs (the dreaded "npm ERR cb() never called") and isn't resilient against network issues (e.g., timeouts).
* It can't use its own cache for packages that have compiled artifacts.
* npm-shrinkwrap.json isn't stable. Adding a package tends to rewrite the whole file depending on whether it has resolved packages from the network or locally.
* Lots of surprising disconnect between shrinkwrap and node_modules. For example, "npm i package" does nothing if it's in the shrinkwrap file, but "npm i package@latest" upgrades (but doesn't, obviously, modify the shrinkwrap file).
* It uses a lot of files. We've had inode issues on some boxes because the sheer size of the NPM cache + deploys use so many files. Production deploys includes all sorts of artifacts (tests, documentation, readme, etc.) that you can't exclude.
* The nested tree (fixed, I hear, in NPM 3.0) is really unmanagable.
The microscopic, mutating nature of NPM packages is chaotic. There's no practical way to do upgrades in a controlled manner. (My wish list item: A command that prints out all upgradeable packages and a complete changelog for each version bump.)
Re:What the web platform can learn from Node.js: The Darwini...
by sotojuan on Wednesday December 16, 2015 @02:06PM
(#10746432)
It doesn't have to be this way. At least stuff like Elm forces semver on your projects. It detects if your new version has breaking changes and won't publish it unless you bump it up a version. That said, Elm is super niche and will probably never be popular. But my point is, there's people doing it right.
I too am confused about Babel 6... but to be fair I haven't looked too much into it. I just think it's weird that something as "simple" as doing ES2015 -> ES5 now has plugins and a whole ecosystem around it. I understand the creator's ambitions, but I'd prefer to just install it and plug it to my build system.
I don't know much about Go, but I am personally looking into Elixir as another backend choice.
Re:What the web platform can learn from Node.js: The Darwini...
by tracker1 on Thursday December 17, 2015 @02:20AM
(#10750095)
It's not just ES6/7 transpilation though... there are a lot of ES6 features that are in node, and modern browsers, so not everything needs to be translated all the time... let alone more advanced options like flow and jsx (more than just for react, but mercury and others).
That's why the change, I do think they pulled the gun a bit soon though, but many would have jumped to it just the same.
Re:What the web platform can learn from Node.js: The Darwini...
by matt2000 on Wednesday December 16, 2015 @01:48PM
(#10746304)
I could not agree more. The rapid versioning and huge quantity of dependencies in Node and javascript development in general is just a recipe for disaster. This will become more obvious as large legacy node projects start transitioning to new teams and the true scope of the downsides will become obvious. However, I'm not sure it will be obvious here because the focus is almost exclusively on green field new development with the latest tools.
The legacy of node will be nothing but sadness. (Sort of a joke, but also kind of true)
Re:What the web platform can learn from Node.js: The Darwini...
by nostrademons on Wednesday December 16, 2015 @02:55PM
(#10746817)
Isn't that the legacy of every programming system in existence? I've never known a programmer to take over maintenance of another programmer's code and say "Wow, this is a joy to work with." You always end up with a big ball of mud that grew really rapidly under the pressures of customer demands (because the ones that don't grow really rapidly and respond to customers don't survive to attract maintenance programmers), that you then have to untangle and understand.
It seems like you have two choices if you'd like to work in the software industry: you can put up with shitty code and boring maintenance work in exchange for a steady, risk-free paycheck, or you can take on the risk that your code will fail outright and the certainty that it will be grumbled about and ultimately replaced in exchange for the intellectual thrill and potential financial rewards of working on a green-field project.
Re:What the web platform can learn from Node.js: The Darwini...
by revelation on Wednesday December 16, 2015 @05:02PM
(#10747685)
Frankly, the dependency trees in other languages are pretty shallow. You'll have trouble to find anything three plus levels deep for something like C++.
Meanwhile in node, and I'm just picking a random path here:
Re:What the web platform can learn from Node.js: The Darwini...
by ry_ry on Wednesday December 16, 2015 @03:17PM
(#10746982)
Every language has it, but because JavaScript is evolving so rapidly the problem is amplified. We've seen more change in the last couple of years than some more mature languages have seen in the last decade - js isn't finished, and I don't think it ever should be.
On the plus side, it keeps us employed as long as we are prepared to keep learning the new stuff, or earn a spectacular exit.
Re:What the web platform can learn from Node.js: The Darwini...
by tracker1 on Thursday December 17, 2015 @02:23AM
(#10750101)
Even without JS there's been a lot of changes over the years... in ASP.Net from 1.0 was a big mess, by 3.x it was nice, then came MVC, paradigm shift... that coupled with additions to C# and VS. There's been similar changes to Java, Python and others over the years too. Let alone Ruby which would never have gained ground if it weren't for Rails.
I will say for a 20 year old language, JavaScript has grown more in the past 6 years than it's first 14, and a lot of that is thanks to Node/npm.
Re:What the web platform can learn from Node.js: The Darwini...
by iends on Wednesday December 16, 2015 @01:43PM
(#10746258)
I too have switched from Node.js to Go in my own projects. However, Node.js (and Angular 1.x) still pay the bills. I tried to convince my previous company to write some of their microservices in Go but it was a hard sell. In fact, I introduced a minor piece of go code that would only run once and politics exploded. I was asked to rewrite it in Node.js.
Obviously, I'm not longer with that company, but still writing Node in the day job. As you mention, packages have minor updates with breaking changes, so if you don't shrinkwrap things explode. There is a huge number of JS packages that do a lot of interesting things but the average quality leaves a lot to be desired.
I've found people get something working very quickly with Node.js but then after a year...or three it's very hard to maintain the Node.js system. Especially when the original author is no longer on the team. This is the problem TypeScript tries to solve, and TypeScript is really nice in my opinion...but its 2015 and my computer has four cores and 4 virtual cores. Languages that do not enable developers to easily take advantage of these cores are not interesting and not something I want to invest too much time in for fear they are out of favor in the next few years when cores increase even more...
Go has this solved, but people don't quite trust Google yet. For one, they seem to have a history abandoning things (or completely rewriting from scratch them like Angular 2). Go is missing a few needed features that are preventing more wide spread adoption (things like better package management), but these features are not things that the core team is prioritizing at this time.
Re:What the web platform can learn from Node.js: The Darwini...
by politician on Wednesday December 16, 2015 @02:18PM
(#10746521)
> This is the problem TypeScript tries to solve.
If your development methodology collapses when an original developer leaves, then the problem was that they were carrying tech debt by force of will rather than building a robust architecture. This isn't something TypeScript can solve.
> Languages that do not enable developers to easily take advantage of these cores...
Single-threaded runtimes, like Node, aren't intrinsically problematic, and multi-threaded solutions aren't a panacea.
If you have multiple cores and a single-threaded application that you'd like to scale, then assuming the other resources are plentiful, just spawn multiple instances and pin them to those extra cores.
> Go ...
I like Go, and its goroutines, but working with them still requires an understanding of locking and concurrency to get it right. If the plan is to throw a random front-end developer at Go and expect magic, I think that's wildly optimistic.
Re:What the web platform can learn from Node.js: The Darwini...
by troncheadle on Wednesday December 16, 2015 @04:08PM
(#10747347)
> If you have multiple cores and a single-threaded application that you'd like to scale, then assuming the other resources are plentiful, just spawn multiple instances and pin them to those extra cores.
Re:What the web platform can learn from Node.js: The Darwini...
by tracker1 on Thursday December 17, 2015 @01:49AM
(#10750010)
I was going to comment on TypeScript as well... I find that it's when modules become too big, ill-named or just hard to follow that is when things get hairy. TypeScript (and Angular, while I'm at it) tend to favor larger class-style modules. It's harder with a dynamic language, and TypeScript doesn't inherently make it better. As for Angular, mentioned before, I really don't like their DI system and really favor Node's CommonJS or ES6 module references.
Agreed on single-threaded runtimes... you can get around them, as far as robustness goes, you bring in the same techniques used to scale to multiple servers, you're just doing it a little sooner.
I haven't done enough in Go to really comment, it looks cool, though I haven't had a use case that I really needed more performance than what I already have with the other tools available.
Re:What the web platform can learn from Node.js: The Darwini...
by Touche on Wednesday December 16, 2015 @03:16PM
(#10746976)
> Go is missing a few needed features that are preventing more wide spread adoption
For me it's that Go is purely an imperative language and is not ashamed of it. That's fine, it's a good imperative language, but I don't like them, so I won't use it. I don't care how great goroutines are (or are not, I really don't know), I'm not using a non-functional language again in my career.
Re:What the web platform can learn from Node.js: The Darwini...
by Touche on Wednesday December 16, 2015 @04:15PM
(#10747395)
I don't (yet), it's very appealing to me though. The main thing blocking me is that it seems well suited for long-living servers but I also write a lot of things like cli programs and I'm not sure if it's suited for that.
Re:What the web platform can learn from Node.js: The Darwini...
by tjholowaychuk on Wednesday December 16, 2015 @02:45PM
(#10746742)
Yep haha, it's easy to be blind to all this if you haven't switched to something else. I knew it was bad but I didn't realize how much better platforms like Go were until really making the move. Too many people have grown used to transpiling etc, IMO it's not acceptable that we transpile pretty much everything server and client for usability.
Re:What the web platform can learn from Node.js: The Darwini...
by Touche on Wednesday December 16, 2015 @03:52PM
(#10747249)
I think this is a temporary problem. What is now called ES2015 (or ES6) was largely part of ES4 that got abandoned. Once most of ES2015 is in browsers and current versions of Node, especially modules, I think the need to transpile will be much less. Eventually JavaScript will syntactically be close to "done" and we won't need transpilers any more.
Re:What the web platform can learn from Node.js: The Darwini...
by tjholowaychuk on Wednesday December 16, 2015 @03:55PM
(#10747261)
Agreed, it'll get there eventually. It's just unfortunate that this critical stuff wasn't done earlier, could have been huge for the community. Things like async/await should be top priority IMO. I'd almost rather just start from scratch so there's not a ton of weird legacy baggage.
Re:What the web platform can learn from Node.js: The Darwini...
by fidget on Wednesday December 16, 2015 @07:13PM
(#10748502)
A lot of the GP's concerns are around libraries breaking compatability, and upgrading deps being hard, but Go doesn't exactly have all the answers in that regard.
Re:What the web platform can learn from Node.js: The Darwini...
by tjholowaychuk on Wednesday December 16, 2015 @07:37PM
(#10748616)
Yeah certainly. I've found that in practice it's not a big problem with Go, you can easily vendor your app's deps, of which there are typically fewer (not 500mb+). Keeping them updated for security reasons is the only drawback of that approach really. I vastly prefer Go's technique compared to a central registry.
Re:What the web platform can learn from Node.js: The Darwini...
by tolmasky on Wednesday December 16, 2015 @02:41PM
(#10746708)
There are a number of really good (separate) points here:
1. Shrink-wrapping: yes, of course. Semver ranges never made sense to me. All changes are breaking changes. The idea that we could safely auto-upgrade a project is insane. A semver range is an open invitation to allow people not on your team to arbitrarily change your code at any time in the future. If it was up to me, npm install -save would just shrink-wrap. The idea behind semver ranges is fundamentally flawed since it relies on a human making a determination of whether the change is patch or major or what have you. Even if you automate it and tie it to tests you can't know for sure: Even in a magical world where a "patch" upgrade could be guaranteed to not actually break behavior, it could still have dire perf consequences (which in an async world could absolutely change the behavior of your running program by surfacing new race conditions or what have you). That's why this is the behavior on tonicdev.com: when you require a package we magically shrink-wrap it at that point in time. Reproducibility should be the default. All changes are breaking changes.
2. The quickness of change is definitely also an issue. This may just be a price of progress thing though. I certainly wouldn't want to give up amazing rewrite the world changes like the development of React for a "stable" environment. I can also see the flip side to this though.
Re:What the web platform can learn from Node.js: The Darwini...
by cjhveal on Wednesday December 16, 2015 @03:34PM
(#10747101)
For what it's worth, w.r.t. your first point you can get part of the way there by creating a .npmrc in your project with "save-exact=true". Even if it doesn't protect you from higher order dependencies that violate semver, it will peg all saved dependencies to an exact version (even by other engineers). But alas, even that sometimes doesn't give you any guarantees with the (albeit rare) force publish. Better than nothing, though.
Re:What the web platform can learn from Node.js: The Darwini...
by bahmutov on Wednesday December 16, 2015 @01:34PM
(#10746195)
Well, consider that you have not paid anything for these packages, can you complain that authors do not follow the semver?
If you want to protect yourself and upgrade reliably - there are tools, like my https://github.com/bahmutov/next-update - runs your tests and only keeps upgrades that don't break stuff.
Re:What the web platform can learn from Node.js: The Darwini...
by dham on Wednesday December 16, 2015 @01:37PM
(#10746213)
Nope, you are a 100% correct. That's why I made sure I praised/thanked the author/contributors for their work on the project and suggested to them how fix the issue.
Re:What the web platform can learn from Node.js: The Darwini...
by tracker1 on Thursday December 17, 2015 @01:30AM
(#10749956)
Seems like the author's coworkers didn't follow semver, a feature/method was added in a minor release, they should have bumped the minor/minimum when bumping... locking to x.x.* is the new npm default iirc.
Re:What the web platform can learn from Node.js: The Darwini...
by codeshaman on Wednesday December 16, 2015 @02:20PM
(#10746531)
Yes.
I loved node when it came out. I did a lot of experimental projects with it.
I also liked npm and the ability to use modules...
But at some point, this all turned into dependency insanity.
It didn't bite me as much, because i've never used node for production apps, but I imagine it has the potential to be a serious issue, when
your bread-and-butter app depends on 694 other libraries.. who knows what lurks in them...
What did bite me was the apparent "infinity" of possibilities at each step of the development process.
Whenever I need a feature - there's 20 different libs there to help you. Which one should I pick ?
Re:What the web platform can learn from Node.js: The Darwini...
by krisdol on Wednesday December 16, 2015 @06:29PM
(#10748216)
>It didn't bite me as much, because i've never used node for production apps, but I imagine it has the potential to be a serious issue, when your bread-and-butter app depends on 694 other libraries.. who knows what lurks in them...
The problem is this approach that somehow finds a monolith with 694 dependencies acceptable, yet turns around and praises node.js modules for being so "bite-sized".
>What did bite me was the apparent "infinity" of possibilities at each step of the development process. Whenever I need a feature - there's 20 different libs there to help you. Which one should I pick ?
This kind of choice paralysis used to bite me too. What totally fixed it for me was really weighing the consequences of adding a dependency every time I'd consider one. Most of my production services are a couple hundred lines and have fewer than 5 dependencies (of which, half are boilerplate that every other service has).
Rails is great at big CRUD MVC applications. If you want a Rails-like app in Node.js, you should start with an opinion "skeleton" MEAN/MVC framework rather than re-implementing rails and all its dependencies with every application.
Re:What the web platform can learn from Node.js: The Darwini...
by phpnode on Wednesday December 16, 2015 @01:42PM
(#10746250)
> I'm not sure it's possible to move a project using Babel 5, async/await, generators and react to upgrade to Babel 6. I've spent hours on it.
Well, you're actually right. Babel 6 has had a lot of problems, particularly with async functions, but they are slowly being worked out. I think it's pretty clear at this point that it was released too early, and they really need smoke tests to prevent this kind of problem in future. If you've already built a significant project using Babel 5, definitely consider holding off the upgrade for another month or two.
Re:What the web platform can learn from Node.js: The Darwini...
by Swizec on Wednesday December 16, 2015 @02:06PM
(#10746427)
The funniest problem I ran into is that in Babel 6 using `typeof` does not work. Had to rewrite all our code to use Lodash type helpers because it is an external dependency and doesn't go through our build stack. We need our shit to work in production and don't have time to wait for forever.
Re:What the web platform can learn from Node.js: The Darwini...
by wdmeldon on Wednesday December 16, 2015 @02:32PM
(#10746624)
It's kinda funny actually. I remember the oft quoted maxim regarding very mature static languages: "It's never the compilers fault". This was obviously a hyperbole, but it held true most of the time. These days, the definition of "compiler" has gotten extremely loose on the web side, and it seems like correctness has gone by the wayside.
Re:What the web platform can learn from Node.js: The Darwini...
by nostrademons on Wednesday December 16, 2015 @03:04PM
(#10746884)
That's always been the case with fast-growing technologies. I remember finding a disturbing number of bugs in Java 1.3 c. 2000; if you ask Swift programmers today about the stability of the compiler, they could tell you all about compiler crashes & bugs.
If you want stability, use a technology that was popular 10 years ago. If you want to work on the bleeding edge, you will be bleeding. Decide what's appropriate for your project. The reason people worked in Java in 2000 or Swift/Babel today is so they can take advantage of temporary market opportunities where other people get deterred by the pain of capitalizing on them. This can be very financially lucrative if you yourself are willing to put up with that pain.
Re:What the web platform can learn from Node.js: The Darwini...
by Scarbutt on Wednesday December 16, 2015 @01:48PM
(#10746293)
I don't think most people run into this because most backend node programmers have moved to Go at this point, so they're not aware of the upgrade problems.
Re:What the web platform can learn from Node.js: The Darwini...
by lobster_johnson on Wednesday December 16, 2015 @02:15PM
(#10746504)
Go's static typing goes a long way in helping catch breakage due to things like adding or remove symbols. (However, it does have some warts where incompatible versions may silently compile, like initializers.)
While Go doesn't have package management, it does have a framework (go get) for automatically fetching and compiling dependencies. However, people quickly realized that there's no way to pin dependencies; it will always fetch the master branch's HEAD, so if you "go get" a project, it will fetch some arbitary version depending what time of day it is. The community has devised various ways around it, and recent versions of Go have a way of resolving packages to a local "vendor" directory, but it's not a solved problem. There's no solution that stands out from the rest as particularly good or feature-complete when you look at the historical alternatives (Ruby's Bundler in particular).
Re:What the web platform can learn from Node.js: The Darwini...
by muraiki on Wednesday December 16, 2015 @08:39PM
(#10748905)
As far as I understand it, always fetching HEAD was the default because Go was developed with Google's giant monorepo full of vendored dependencies in mind, where doing this is both safe and sane.
FWIW, I've been using Go 1.5's vendoring alongside govendor and it seems pretty nice. While this situation is a bit of a disappointment given the generally awesome tooling in Go, it's hopefully something that will be resolved soon.
Re:What the web platform can learn from Node.js: The Darwini...
by kashif on Wednesday December 16, 2015 @10:32PM
(#10749317)
This is the kind of reasoning which bothers me about Go. How can you write a language that you expect the world to use based on assumptions which are only true within 'Google'
Re:What the web platform can learn from Node.js: The Darwini...
by muraiki on Thursday December 17, 2015 @08:23AM
(#10751296)
Well, I think that it is reasonable to say that the practice of vendoring dependencies is not limited to Google alone. It might not be as common in dynamic languages, but it's fairly common in static languages like C++, which Go was designed to replace. `go get` is basically a better curl for _getting_ dependencies, not _managing_ them. The language authors and the community are addressing the problem of management right now.
Before dismissing Go, please try to understand its history and the fact that it is changing.
Re:What the web platform can learn from Node.js: The Darwini...
by phillmv on Wednesday December 16, 2015 @01:50PM
(#10746313)
Last time I checked Go didn't really have a package manager, so I think the joke here is that most web apps are semi disposable and people haven't hit the upgrade cycles for their Go apps either.
Re:What the web platform can learn from Node.js: The Darwini...
by Keats on Wednesday December 16, 2015 @04:21PM
(#10747434)
I agree with pretty much everything you said minus the Go one: if you are doing a CRUD app and you don't expect a huge traffic something like Python works well. Go shines for microservices though.
I can't talk about Node on the server since I don't use that - already doing way too much javascript for the frontends - but the frontend side is hard to keep up with as well.
Between all the Babel and Webpack plugins it's hard just to get a working setup and the `do one thing and do it well` should not be a bigger thing than user experience.
TypeScript makes writing JavaScript less painful but doesn't solve the ecosystem for me: I do rm -rf node_modules/ && npm install semi regularly to make sure everything works (not using shrinkwrap yet) on a fresh install and I get install errors way too often (peer dependencies etc).
To save you time, don't bother with npm3 for now as it is extremely slow.
Re:What the web platform can learn from Node.js: The Darwini...
by 20years on Wednesday December 16, 2015 @07:29PM
(#10748582)
"On the front end, people are probably re writing the front end every 3 or 4 months. Moving from javascript framework to javascript framework."
That seems crazy! Maybe I am out of touch but how is that even viable or smart? Seems like a time & money suck both of which can be spent on so many other valuable areas. Does the consumer or whoever the site services really care about what front-end framework is being used? No, they just want a decent user experience so why not focus on that rather than the latest shiny framework. I just don't get it.
I feel like some devs have lost site on what's really important with developing software. It is not about the latest shiny thing. It is about the target customer.
Re:What the web platform can learn from Node.js: The Darwini...
by dalore on Thursday December 17, 2015 @06:45AM
(#10750895)
To paraphrase: "If you don't freeze your dependencies, you're going to have a bad time".
This is the case in any environment. This is the case for your OS, for python requirements, for java jars, everything. Your versions should be part of the source control (not necessarily the dependencies in your source, but at least a project file that has the versions listed).
Python has a requirements.txt. It's best practice to pin your versions in it.
I've been trying out jspm recently. It's quite nice and teaches you this out of the box. You pull down a npm package, it will put the version into your package.json so everyone can use the same version.
Re:What the web platform can learn from Node.js: The Darwini...
by drinchev on Wednesday December 16, 2015 @02:07PM
(#10746434)
HN why all the hate agains NodeJS? It's still ( IMHO ) amazing.
Yes the versioning is sad and breaks almost every time. Also some modules look fragile and what was good yesterday is not good today anymore.
But still. Those are the reasons why I still stick with NodeJS :
1. Electron. Simply awesome - I copied 90 % of my app, changed Sequelize ORM to have it's storage to sqlite and boom. I have a webapp as a OS-packaged app.
2. Isomorphic code - I'm rendering React / Flux applications on the server-side and on the client-side. Reusing code, storage and syncing logic between them. Even my logger module works on client-side / server-side.
3. Front-end / back-end needs very similar skills - This is one of my top reasons to tell my clients ( I work as a freelancer ). There will not be a big deal for a front-end guy to write / understand backend code and vice-versa. Also it's javascript. The most popular language.
4. Libraries for most popular services - There is always something, someone wrote that is NodeJS or at least javascript.
P.S. I'm heavily using TypeScript nowadays. I think this solved a lot of NodeJS syntax/compiler problems.
Re:What the web platform can learn from Node.js: The Darwini...
by pikzen on Wednesday December 16, 2015 @03:45PM
(#10747175)
>1. Electron. Simply awesome - I copied 90 % of my app, changed Sequelize ORM to have it's storage to sqlite and boom. I have a webapp as a OS-packaged app.
And your users get to enjoy awful performance and insane resource usage for their app. How generous of you.
Also, the hate for NodeJS is because Javascript is a terrible language, no matter how many things you put on it (TypeScript, Babel, etc.). It's also because V8 performance is laughable.
Everything you mentioned is also mentioned in http://notes.ericjiang.com/posts/751 , which I believe does a nice job of explaining why NodeJS is terrible.
Re:What the web platform can learn from Node.js: The Darwini...
by drinchev on Wednesday December 16, 2015 @04:03PM
(#10747311)
I usually answer "Javascript is bad" statements with "English is not the most declarative language too, but ... it's the most common". Anyway I think JS is not a part of my statement, so I'm not going to agree on why JS sucks. It's opinionated. And contrary to logic it works good when you get used to it.
About Electron. I think nobody will build Photoshop or 3D Games ( at this point ) using it as a platform. I would personally decline if I have an assignment like this. But for apps like Slack, Visual Studio Code, Atom, etc, it works pretty good. Something more. I'm actually working on my own accounting app that suits my needs, which I would not be able to do for that limited spare-time I have these days If I used Objective-C / Swift.
Re:What the web platform can learn from Node.js: The Darwini...
by pikzen on Wednesday December 16, 2015 @04:49PM
(#10747624)
>But for apps like Slack, Visual Studio Code, Atom, etc, it works pretty good.
I won't get into a long rant, but aside from on OSX, Slack and Atom are slow, resource hogging and unstable piles of crap. Atom couples that with bad architecture and engineering choice, but that's not Electron's fault.
(Also, your comparison with English is bad. English naturally evolved to the state it is in today. Javascript was designed from scratch, and it still manages to be awful. Also, sorry, Javascript isn't the most common language, thankfully.)
Re:What the web platform can learn from Node.js: The Darwini...
by tracker1 on Thursday December 17, 2015 @02:02AM
(#10750047)
I have an i7 desktop with 32gb of ram.. a recent rMBP i7/16gb-ram for my personal labtop, and another work issued one... I also use VMs with Linux frequently... VS Code is one of the better code editors I've used. Given, I'm on fast machines with plenty of ram... I really haven't had a serious problem with it... hell, my browser typically uses up way more ram than any other single application on my computer... it still does the job well enough...
Re:What the web platform can learn from Node.js: The Darwini...
by porker on Wednesday December 16, 2015 @06:23PM
(#10748178)
> I won't get into a long rant, but aside from on OSX
Ah, so they're better on OSX? On Windows 7 all the slack.exe processes are currently using 780MB RAM in total, and I'm only signed into 3 Slack communities.
Re:What the web platform can learn from Node.js: The Darwini...
by vdaniuk on Thursday December 17, 2015 @04:03AM
(#10750331)
>Slack and Atom are slow, resource hogging and unstable piles of crap
Atom is my primary editor and I am extremely satisfied with it. Your self-righteous arrogant attitude is strange and has nothing to do with objective, rational criticism.
Re:What the web platform can learn from Node.js: The Darwini...
by drinchev on Wednesday December 16, 2015 @03:02PM
(#10746874)
Yep, but environments also change. Microservices are so popular nowadays and I see so many libraries written by Yahoo, Microsoft, Airbnb, etc., which are NodeJS oriented.
And no. Things break all the time and still give value to customers. Things break for A reason and still give value to customers.
Yep it would be cool and more non-breaking if 20-years of Java experience was injected into NodeJS, but I bet in 20-years NodeJS will be even better than the popular alternatives these days.
Re:What the web platform can learn from Node.js: The Darwini...
by xemdetia on Wednesday December 16, 2015 @03:49PM
(#10747229)
I think the point trying to be raised is that node seems to be built on a mindset of endless churn where some of us need to be able to write software that we aren't going to be able to CI and develop on for a year and expect it to work the same time next year without further development. Also like some have mentioned a high severity CVE that comes out turns into 'how fast can I move to fix it and then go back to something else.'
Sometimes the value to customers is just a system that works without downtime or failures, and the next increase in value is not even related to something that was built on this bleeding-edge packaging model. The only types of development projects that seem to benefit from it are the kind of project that can dedicate a full-time or mostly-full-time developer to it forever (forever being the lifetime of the product/service).
If dependency issues crop up every few months for a perodically updated project that could almost be a death knell, if you have to pivot or do major work on the backend all of a sudden you could come back to just a broken set of shambles. So the only thing it fits is a really strange gap between hobbyist/side project and stable production which ends up being just plain risky for a technology choice.
Re:What the web platform can learn from Node.js: The Darwini...
by drinchev on Wednesday December 16, 2015 @04:09PM
(#10747355)
Upvoted your comment. I mostly agree.
IMHO Node isn't built on this mindset ( endless churn ). I think it's just rapidly evolving. It's just enthusiasm by the community.
As far as my experience goes, I just put more effort in finding the right module rather than finding >any< module that will do the work. Afterwards I can usually npm-shrinkwrap, upload to DigitalOcean and leave forever.
Re:What the web platform can learn from Node.js: The Darwini...
by klodolph on Wednesday December 16, 2015 @08:41PM
(#10748910)
TypeScript is awesome, and using the same code client and server is also a great benefit. However, I would like to inject a little bit of skepticism. JavaScript is not the most popular language. TIOBE, for example, ranks it #8. It's a great language for you, but last time I checked, the Java and Ruby shops were still hiring. And it's a bad sign when your community isolates itself by creating its own jargon, like "isomorphic". "Isomorphic" means that something has the same shape, but the term we're really looking for is "portable", "runtime agnostic", "environment agnostic", or something like that. Java called it "write once, run anywhere" and it's clear that the terminology used here is more driven by marketing than by actual technology.
But don't take it personally. HN truly has hate for every language (name a language it doesn't hate!), and the internet supports sharing your hatred with others more than it supports sharing love.
You've found a system that earns you money by writing software, and that itself earns you some respect here.
Re:What the web platform can learn from Node.js: The Darwini...
by tracker1 on Thursday December 17, 2015 @02:04AM
(#10750053)
And these Java and Ruby shops never touch JS code? I'd bet at least half of them do.. same for .Net shops for that matter, even some Python shops... it may not be the primary language for the job, but almost every job with a web interface will contain at least some JS... no other language is as pervasive.
Re:What the web platform can learn from Node.js: The Darwini...
by tlrobinson on Wednesday December 16, 2015 @01:46PM
(#10746278)
I've run in to so many npm errors over the past couple weeks, some due to npm bugs, some due to buggy packages, that I'm not very confident in npm or the package ecosystem any more.
First of all, most people don't actually follow semantic versioning, but npm's default version ranges assume they do, so unless you lock down your dependencies with `npm shrinkwrap` you'll find your app occasionally breaks because some deeply nested dependency broke something in some package you don't know anything about.
But shrinkwrap has a bunch of problems itself (so many that Uber wrote a separate tool to try to fix it: https://github.com/uber/npm-shrinkwrap). npm-shrinkwrap.json files are huge, in part due to the nature of npm, but it also contains a bunch of unnecessary information. The bigger problem is it's non-deterministic, resulting in huge diffs every time you run it, even if nothing has changed.
Re:What the web platform can learn from Node.js: The Darwini...
by matthewtoast on Wednesday December 16, 2015 @02:54PM
(#10746810)
I'll share a thought or two while I wait for $ npm install to finish.
I agree that other ecosystems could learn a lot from the Node philosophy. And in general I enjoy working with the technology. But it's not all roses. In an ecosystem of small modules, you often find yourself wading through many -- equally small -- annoyances which can add up to a lot of friction. Here's a contrived fake example:
Your app needs ABCXYZ. So you go shopping for a module. The most popular one looks good, but when you Browserify it your bundle ends up with 1,000s of extra lines of code for the Buffer shim. So much for keeping that footprint small. So you keep looking and find another one that has a good footprint, but a weird API and it hasn't been updated by the maintainer since 2011. The next one you find looks great, but the maintainer decided they were tired of ES5 and didn't feel like adding a distfile, so you would have to install a bloated transpile toolchain to use it. You're getting annoyed but you keep going. The next one's author inexplicably decided to implement everything with streams. But you're too busy to spend a day grokking streams and reworking your entire API to be compatible. The next one is packaged as a jQuery plugin. The next one doesn't have a license. The next one uses Web Workers for no reason you can see. Etc. etc. etc. Repeat.
Any of these could be problems with a monolith (and monoliths certainly come with their own pile of frustrations), but monoliths are less likely to hit these problems simply because they consolidate effort and personal emotional investment around a certain set of techniques and standards, which leads to more consistency overall.
Re:What the web platform can learn from Node.js: The Darwini...
by tracker1 on Thursday December 17, 2015 @02:11AM
(#10750072)
Or, fork the light library, and work around the troubling bits? Many (most?) npm modules are ISC, MIT or something equally permissive.
There are several times I've found something close to what I want, I fork it on GH, change the bits I want, update the name everywhere and publish it... many times they continue to work as-is without much grief. Of course that's part of why there are so many options for any problem.
I usually look at the following, when was the last commit, and how many issues have been sitting stale for over a month... if the last commit was several months ago, but there aren't any recent issues, I'll check through the backlog issues.... some libraries reach maturity and don't change much, if the issues aren't recently curated, I move on...
Re:What the web platform can learn from Node.js: The Darwini...
by matthewtoast on Thursday December 17, 2015 @08:50AM
(#10751406)
I agree and that's what I like to do too when these issues come up (time permitting). Still, I hope my basic point came through: the small modules approach isn't a panacea; it can add its own set of problems; "monoliths" can be a good choice, not always, but sometimes.
Re:What the web platform can learn from Node.js: The Darwini...
by matthewtoast on Wednesday December 16, 2015 @03:52PM
(#10747246)
Correct and I shouldn't have mentioned XHR -- it was just a fake example for the sake of my point. I just went back and ninja-edited my original comment above to call it "ABCXYZ" so that it's clear I didn't intend to call out any specific package/author.
Re:What the web platform can learn from Node.js: The Darwini...
by Osiris on Wednesday December 16, 2015 @02:05PM
(#10746418)
I work on a fairly large node.js project with over 100k LOC, and I rarely run into issues where a minor update to a dependency breaks the application.
thrift is the only module where I've locked the version number in package.json.
Maybe it's easier because I don't shrinkwrap, I also get the latest version when CI runs and that allows me to make sure that my application is always compatible with the up-to-date releases of all the dependencies. Shrink wrapping has the downside of actually making it harder to upgrade dependencies because you can get further and further behind on updates.
Re:What the web platform can learn from Node.js: The Darwini...
by tjholowaychuk on Wednesday December 16, 2015 @02:09PM
(#10746450)
Not being able to create something useful out of the box on the web is pretty painful. I have the same problem with node, you need 1000 modules with ridiculous names to do anything.
Fundamental core patterns like streams are still broken and suffer from huge UX issues. I hope future versions will use promises and async/await in core and redo streams to utilize this more like Go's reader/writers. Just by punting that stuff to core the UX without third-party modules would improve drastically, and encourage better practices throughout third-party code as well.
I'm not bashing Node I'd love for it to do great. I'd love to use Lambda out of the box with no callbacks and not worry about which streams are missing which handlers or does this third-party module implement them correctly or will it explode on me :D.
Re:What the web platform can learn from Node.js: The Darwini...
by homulilly on Wednesday December 16, 2015 @01:56PM
(#10746360)
While npm and semver are far from perfect, I've personally found them to make dependency management a lot less of a headache in node than, for example, python which is an absolute nightmare to deal with. You still have to make sure you're using fairly stable, well written packages by people who actually understand semver and best practices but the same applies everywhere and I've found the node community's to this kind of detail better than most other ecosystems.
Re:What the web platform can learn from Node.js: The Darwini...
by BinaryIdiot on Wednesday December 16, 2015 @02:01PM
(#10746387)
I don't know as a very heavy user of node I absolutely hate the hundreds and thousands of dependencies. A vast, vast majority of modules never maintain an LTS version of their module so when one module has a security update you better have the latest of everything (especially if it's a very common dependency) otherwise now you're stuck back porting security patches.
I've had to back port security patches far more than I would ever like to admit.
The node community is still pretty immature. Sure it's nice to rush ahead releasing version after version without having a LTS version but when I want to build something serious with it it can be downright frustrating.
Re:What the web platform can learn from Node.js: The Darwini...
by phillmv on Wednesday December 16, 2015 @01:48PM
(#10746294)
I've heard this claim before and it feels like a mixture of stockholm syndrome and wishful thinking.
In my experience, it's a bit of a shit show. You end up with libraries that are subtly incompatible, or have overlapping functionality, or strangely large holes of functionality that require overlapping combos of libraries and therefore nobody's written.
If you get your socks off writing shims and glue and maintaining it against a thousand moving targets, power to you.
In my opinion, what you really want is someone to bundle composable libraries for you. That bundling has incredible value. You know that everything more or less works, in ways that you'd expect, because someone else managed to test it.
You have all the functionality basics down pat. The shims you do have to write work at higher levels of abstraction. Etc, etc.
Re:What the web platform can learn from Node.js: The Darwini...
by Swizec on Wednesday December 16, 2015 @02:09PM
(#10746447)
> In my opinion, what you really want is someone to bundle composable libraries for you. That bundling has incredible value. You know that everything more or less works, in ways that you'd expect, because someone else managed to test it.
Sooooo a big monolithic framework like Rails or Django? I thought we said those are bad.
Re:What the web platform can learn from Node.js: The Darwini...
by spo81rty on Wednesday December 16, 2015 @01:15PM
(#10746070)
One app with 1,000 package dependencies? Sounds like a nightmare to me when it comes time to update them and ensure they didn't break anything... especially in a language without a compiler to help.
Edit: I know this doesn't solve the problem completely, but comparing, for instance, a typical CPAN module's versioning scheme with what you get in npm, I'm far more confident in a lack of breakage in the npm case. :)
Edit2: For downvoters: I program in Perl and Javascript professionally. I'm speaking from experience (my boss just ran into this exact problem with a cpan module in production yesterday), not picking on Perl.
Re:What the web platform can learn from Node.js: The Darwini...
by BinaryIdiot on Wednesday December 16, 2015 @01:46PM
(#10746282)
When you're looking at modules individually yeah semver is useful. When you're looking at modules that include other modules that include other modules? When one person makes the decision to upgrade then everyone either has to upgrade or not upgrade and I rarely see even big projects start a LTS version where they keep updating it; no most of them move on the second the next big version is released.
This can be painful when you're dealing with a really big project and someone provides a security update but it's only for the newer version that has lots of breaking changes.
Re:What the web platform can learn from Node.js: The Darwini...
by muraiki on Wednesday December 16, 2015 @02:25PM
(#10746575)
Yes, I agree that this is a problem. You might be using foo in your project which gets a security update, and two things that depend on foo, where one of those things is using the still-vulnerable-foo. So you now have two versions of foo, including one that is vulnerable.
I'm curious to know how other dynamic languages handle this. In Perl I think you generally can't safely load >1 version of the same module, so while you could end up with breakage on an update, you can't end up with the above security problem.
Re:What the web platform can learn from Node.js: The Darwini...
by jondubois on Wednesday December 16, 2015 @05:13PM
(#10747760)
I'm pretty unhappy with the current state of software development. Developers who have a voice are often extremists with very strong ideas (and sometimes very bad ideas).
The idea that you should use a module to check if a number is -0 is just insane.
Developers need to wisen up and accept the reality that there is no right or wrong way to do anything. The problem is that people like radical thoughts. No one wants to hear the word 'sometimes' - Which is actually the right word to use 99% of the time.
Question:
- Should you use as many small modules as possible?
Answers:
- Famous developer: Yes, always break everything into small modules because it encourages code reuse, composability, collaboration. That's the Unix philosophy.
- Moderate developer: Small modules are great sometimes but in some cases you just want a wholesome tool that just works and takes care of all the edge cases (and gives you operational guarantees). Having too many separate modules increases management complexity and can make the upgrade/deployment process more complicated and time consuming. Sometimes having too many small modules can make your code difficult to read because people are forced to read through pages of documentation on GitHub every time they encounter a new module.
Question:
- Is Microservices always the right approach to software development?
Answers:
- Famous developer: Yes, always break up your system into separate services - This promotes separation of concerns which makes your system easier to manage.
- Moderate developer: Sometimes. If you have a small team, you don't want to be managing too many different services and having too many code repos - Sometimes it's better to start out with one service, but build it in a way that it can easily be split out later on.
Question:
- Should you use Docker?
Answers:
- Famous developer: Yes, you need to Dockerize your whole stack from the beginning if you want fast deployment.
- Moderate developer: Sometimes. You should be selective about which technologies you use within your project and try to keep the deployment process as simple as possible. If you can keep your technology count to a manageable level, you may end up not needing Docker.
Question:
- Should you use promises in JavaScript?
Answers:
- Famous developer #1: No, promises are evil, they are slow, they swallow your errors and they make your logic impossible to follow.
- Famous developer #2: Yes, promises should always be used. Callbacks make code difficult to read and cause callback hell.
- Moderate developer: Promises are good sometimes but you have to be careful how/when you use them. You don't want to have really long chains of promises spread across multiple files. Sometimes callbacks are more appropriate if you design your system in such a way that nesting is minimal. Ultimately is comes down to what makes your team happy.
Re:What the web platform can learn from Node.js: The Darwini...
by falsedan on Wednesday December 16, 2015 @12:54PM
(#10745924)
Reminds me of the plethora of packages on CPAN; juxtapose with PyPI & trying to convince python devs that releasing a distribution that only does one thing/has one package wasn't a waste of time…
Re:What the web platform can learn from Node.js: The Darwini...
by substack on Wednesday December 16, 2015 @04:01PM
(#10747297)
I think that's preferable to remembering whether any given method is in List::Moreutils, List::Util, List::AllUtils or some other package entirely. You already know the name of the method you want, why can't that be the name of the package?
Re:What the web platform can learn from Node.js: The Darwini...
by riffraff on Wednesday December 16, 2015 @06:04PM
(#10748070)
that is only true if you know the name in advance.
Considering List::Util I can look at the module documentation for a function that returns the first element for each pair in a list and fine "pairkeys" but I would probably not make the name up and match what the package author thought.
If you want things to just work like in the Ruby community, make sure you shrinkwrap.
I don't think most people run into this because most backend node programmers have moved to Go at this point, so they're not aware of the upgrade problems.
On the front end, people are probably re writing the front end every 3 or 4 months. Moving from javascript framework to javascript framework. Never dealt with upgrading 6to 5 to Babel to Babel 4 to 5 to 6, and npm from 2 to 3. Or browserify, browserify react hot reload, react-proxy v1 only, gulp. Ugh.
I'm not sure it's possible to move a project using Babel 5, async/await, generators and react to upgrade to Babel 6. I've spent hours on it.
Sometimes I think it's all some kind of cruel joke. Look at Babel. I mean a library that doesn't do anything without installing a plugin. At least support transpiling ES 6 and 7 to 5 out of the box and everything else with a plugin. I have to install like 4 plugins to get anything running.
Comments like this are what make it difficult for me to take HN seriously anymore. It's just an example of the hivemind at work, assume that an entire industry has the same ideas as you about what technology to use.
The Node/JS ecosystems are experiencing a Cambrian explosion in technology, with all that implies. If you don't like it, don't worry. It probably won't take 20 million years this time to settle in on the "best" ways of doing things.
Most of the developers where I am are running OS X, which is significantly more similar to our Linux production environments than is Windows and yet we determined that it was just easier to always run our node applications on Linux guest VMs. On Windows, I wouldn't even have the gall to try to make it work without this kind of setup.
You need to install the proper prereqs for node-gyp, but those are clearly explained on the node-gyp docs.
It still didn't work until I stumbled upon the --msvs_version flag for npm i. And this is for a dependency in mongodb!
Python 2.x is the bigger oddity to me... seems like python's role with gyp should be replaced with something self-bootstrapped at this point.
"Run anywhere" is really only descriptive of languages (e.g. Java), not implementations (e.g. Dalvik). You can't have a "run anywhere" implementation, unless you are grouping a bunch of implementations together...one for ARM, one for x86, one for FreeBSD, one for Windows, one for Minecraft, etc... because even under the same name the implementations would very significantly internally.
"Run anywhere" is a function of (1) the language spec (i.e. how much machine dependent behavior is permitted) and (2) the actual real-world support across platforms.
JS has the first, but the second is often conceeded, per the earlier comment.
We keep our dependencies up-to-date by occasionally running "npm outdated", checking the packages for their Changelog.md (or equivalent) and then enjoying the new stuff.
From my perspective you were just unlucky with your packages, or you might be doing something else wrong.
I spend about equal parts of my development time between OSX, Linux and Windows... they all have had pain points for me. The only difference is in OSX dev you're likely to have XCode & homebrew. In windows, you may have VS, and probably won't have Python ^2.7.0 installed.
Part of why I've at least participated enough to raise a possible bit of help with the situation[1]. There are times when all you can reasonably do is raise the issue, and suggested fix... there are others where you should proactively fix it.
Node/npm's community is very open-source driven, and very diverse. I don't liken it as much worse than any other platform, and far better than most.
[1] https://github.com/nodejs/node/issues/3694
For some of these core tools, authors explicitly state that windows is a second class citizen. It's just not worth the expense to support something that has so few comparative users, in some cases (ruby). It's a lot of work for something that will never feel "native".
I don't think node on Windows is so bad these days once you've got Python 2.x and VS 2015 Community installed... When I started with node (0.6-0.8 era), it was pretty bad in Windows. These days most popular modules just work, or work once you have gyp prereq's installed.
So I installed Ubuntu Server (latest) in a Virtual Machine via Hyper-V... set it to auto-boot.. setup OpenSSH, setup Samba ... I kind of just muddled through it, to be honest.. after that, I setup Docker, build-essentials and nvm, which covered my needs there.
On the windows side, I use Clover as an explorer replacement (file explorer, not the desktop), and use ConEmu for tabbed shell interfaces. It works pretty well for me. I use GUI stuff in windows, and the linux side via SSH.
We have apps that are stable and have been running for many months, until suddenly we need to add a small feature. With a missing package deep in the tree — not one we were depending on directly — we have to waste several hours being forced to upgrade packages to newer versions, just to work around the missing version. It's insane.
(It's possible to unpublish NPM packages, which is what happened here. That in itself is terrible, especially since all you get is a 404 from NPM — no reason for the unpublish provided.)
The NPM tool itself is a mess:
* It suffers from sporadic bugs (the dreaded "npm ERR cb() never called") and isn't resilient against network issues (e.g., timeouts).
* It can't use its own cache for packages that have compiled artifacts.
* npm-shrinkwrap.json isn't stable. Adding a package tends to rewrite the whole file depending on whether it has resolved packages from the network or locally.
* Lots of surprising disconnect between shrinkwrap and node_modules. For example, "npm i package" does nothing if it's in the shrinkwrap file, but "npm i package@latest" upgrades (but doesn't, obviously, modify the shrinkwrap file).
* It uses a lot of files. We've had inode issues on some boxes because the sheer size of the NPM cache + deploys use so many files. Production deploys includes all sorts of artifacts (tests, documentation, readme, etc.) that you can't exclude.
* The nested tree (fixed, I hear, in NPM 3.0) is really unmanagable.
The microscopic, mutating nature of NPM packages is chaotic. There's no practical way to do upgrades in a controlled manner. (My wish list item: A command that prints out all upgradeable packages and a complete changelog for each version bump.)
NPM could learn a lot from Ruby's Bundler.
I too am confused about Babel 6... but to be fair I haven't looked too much into it. I just think it's weird that something as "simple" as doing ES2015 -> ES5 now has plugins and a whole ecosystem around it. I understand the creator's ambitions, but I'd prefer to just install it and plug it to my build system.
I don't know much about Go, but I am personally looking into Elixir as another backend choice.
That's why the change, I do think they pulled the gun a bit soon though, but many would have jumped to it just the same.
The legacy of node will be nothing but sadness. (Sort of a joke, but also kind of true)
It seems like you have two choices if you'd like to work in the software industry: you can put up with shitty code and boring maintenance work in exchange for a steady, risk-free paycheck, or you can take on the risk that your code will fail outright and the certainty that it will be grumbled about and ultimately replaced in exchange for the intellectual thrill and potential financial rewards of working on a green-field project.
Meanwhile in node, and I'm just picking a random path here:
webpack -> watchpack -> chokidar -> anymatch -> micromatch -> extglob -> ansi-green -> ansi-wrap
(I might just write a tool to find the largest such path in all of npm.. accepting bets)
On the plus side, it keeps us employed as long as we are prepared to keep learning the new stuff, or earn a spectacular exit.
I will say for a 20 year old language, JavaScript has grown more in the past 6 years than it's first 14, and a lot of that is thanks to Node/npm.
Obviously, I'm not longer with that company, but still writing Node in the day job. As you mention, packages have minor updates with breaking changes, so if you don't shrinkwrap things explode. There is a huge number of JS packages that do a lot of interesting things but the average quality leaves a lot to be desired.
I've found people get something working very quickly with Node.js but then after a year...or three it's very hard to maintain the Node.js system. Especially when the original author is no longer on the team. This is the problem TypeScript tries to solve, and TypeScript is really nice in my opinion...but its 2015 and my computer has four cores and 4 virtual cores. Languages that do not enable developers to easily take advantage of these cores are not interesting and not something I want to invest too much time in for fear they are out of favor in the next few years when cores increase even more...
Go has this solved, but people don't quite trust Google yet. For one, they seem to have a history abandoning things (or completely rewriting from scratch them like Angular 2). Go is missing a few needed features that are preventing more wide spread adoption (things like better package management), but these features are not things that the core team is prioritizing at this time.
If your development methodology collapses when an original developer leaves, then the problem was that they were carrying tech debt by force of will rather than building a robust architecture. This isn't something TypeScript can solve.
> Languages that do not enable developers to easily take advantage of these cores...
Single-threaded runtimes, like Node, aren't intrinsically problematic, and multi-threaded solutions aren't a panacea.
If you have multiple cores and a single-threaded application that you'd like to scale, then assuming the other resources are plentiful, just spawn multiple instances and pin them to those extra cores.
> Go ...
I like Go, and its goroutines, but working with them still requires an understanding of locking and concurrency to get it right. If the plan is to throw a random front-end developer at Go and expect magic, I think that's wildly optimistic.
Not to mention, this is part of the core functionality of node. The cluster module is built in. https://nodejs.org/api/cluster.html.
Agreed on single-threaded runtimes... you can get around them, as far as robustness goes, you bring in the same techniques used to scale to multiple servers, you're just doing it a little sooner.
I haven't done enough in Go to really comment, it looks cool, though I haven't had a use case that I really needed more performance than what I already have with the other tools available.
For me it's that Go is purely an imperative language and is not ashamed of it. That's fine, it's a good imperative language, but I don't like them, so I won't use it. I don't care how great goroutines are (or are not, I really don't know), I'm not using a non-functional language again in my career.
Has it ever been better though? Technically, you could argue that webdev has never been as good as it is now.
Not that I like the current situation, I just think that things in webdevland are better now than ever before.
1. Shrink-wrapping: yes, of course. Semver ranges never made sense to me. All changes are breaking changes. The idea that we could safely auto-upgrade a project is insane. A semver range is an open invitation to allow people not on your team to arbitrarily change your code at any time in the future. If it was up to me, npm install -save would just shrink-wrap. The idea behind semver ranges is fundamentally flawed since it relies on a human making a determination of whether the change is patch or major or what have you. Even if you automate it and tie it to tests you can't know for sure: Even in a magical world where a "patch" upgrade could be guaranteed to not actually break behavior, it could still have dire perf consequences (which in an async world could absolutely change the behavior of your running program by surfacing new race conditions or what have you). That's why this is the behavior on tonicdev.com: when you require a package we magically shrink-wrap it at that point in time. Reproducibility should be the default. All changes are breaking changes.
2. The quickness of change is definitely also an issue. This may just be a price of progress thing though. I certainly wouldn't want to give up amazing rewrite the world changes like the development of React for a "stable" environment. I can also see the flip side to this though.
If you want to protect yourself and upgrade reliably - there are tools, like my https://github.com/bahmutov/next-update - runs your tests and only keeps upgrades that don't break stuff.
Thanks for the library.
I loved node when it came out. I did a lot of experimental projects with it. I also liked npm and the ability to use modules...
But at some point, this all turned into dependency insanity.
It didn't bite me as much, because i've never used node for production apps, but I imagine it has the potential to be a serious issue, when your bread-and-butter app depends on 694 other libraries.. who knows what lurks in them...
What did bite me was the apparent "infinity" of possibilities at each step of the development process. Whenever I need a feature - there's 20 different libs there to help you. Which one should I pick ?
The problem is this approach that somehow finds a monolith with 694 dependencies acceptable, yet turns around and praises node.js modules for being so "bite-sized".
>What did bite me was the apparent "infinity" of possibilities at each step of the development process. Whenever I need a feature - there's 20 different libs there to help you. Which one should I pick ?
This kind of choice paralysis used to bite me too. What totally fixed it for me was really weighing the consequences of adding a dependency every time I'd consider one. Most of my production services are a couple hundred lines and have fewer than 5 dependencies (of which, half are boilerplate that every other service has).
Rails is great at big CRUD MVC applications. If you want a Rails-like app in Node.js, you should start with an opinion "skeleton" MEAN/MVC framework rather than re-implementing rails and all its dependencies with every application.
Well, you're actually right. Babel 6 has had a lot of problems, particularly with async functions, but they are slowly being worked out. I think it's pretty clear at this point that it was released too early, and they really need smoke tests to prevent this kind of problem in future. If you've already built a significant project using Babel 5, definitely consider holding off the upgrade for another month or two.
Bug hasn't been fixed in almost a month: https://phabricator.babeljs.io/T6644
You'd think something like a basic language feature wouldn't break when you update your compiler. I did. I was wrong.
Thank the gods of software gardening that we were only using typeof in five or so places.
If you want stability, use a technology that was popular 10 years ago. If you want to work on the bleeding edge, you will be bleeding. Decide what's appropriate for your project. The reason people worked in Java in 2000 or Swift/Babel today is so they can take advantage of temporary market opportunities where other people get deterred by the pain of capitalizing on them. This can be very financially lucrative if you yourself are willing to put up with that pain.
How does Go solve this?
While Go doesn't have package management, it does have a framework (go get) for automatically fetching and compiling dependencies. However, people quickly realized that there's no way to pin dependencies; it will always fetch the master branch's HEAD, so if you "go get" a project, it will fetch some arbitary version depending what time of day it is. The community has devised various ways around it, and recent versions of Go have a way of resolving packages to a local "vendor" directory, but it's not a solved problem. There's no solution that stands out from the rest as particularly good or feature-complete when you look at the historical alternatives (Ruby's Bundler in particular).
But that may just be me. I think the same thing about generics, and others clearly don't.
FWIW, I've been using Go 1.5's vendoring alongside govendor and it seems pretty nice. While this situation is a bit of a disappointment given the generally awesome tooling in Go, it's hopefully something that will be resolved soon.
Brittle.
Before dismissing Go, please try to understand its history and the fact that it is changing.
I can't talk about Node on the server since I don't use that - already doing way too much javascript for the frontends - but the frontend side is hard to keep up with as well.
Between all the Babel and Webpack plugins it's hard just to get a working setup and the `do one thing and do it well` should not be a bigger thing than user experience.
TypeScript makes writing JavaScript less painful but doesn't solve the ecosystem for me: I do rm -rf node_modules/ && npm install semi regularly to make sure everything works (not using shrinkwrap yet) on a fresh install and I get install errors way too often (peer dependencies etc).
To save you time, don't bother with npm3 for now as it is extremely slow.
That seems crazy! Maybe I am out of touch but how is that even viable or smart? Seems like a time & money suck both of which can be spent on so many other valuable areas. Does the consumer or whoever the site services really care about what front-end framework is being used? No, they just want a decent user experience so why not focus on that rather than the latest shiny framework. I just don't get it.
I feel like some devs have lost site on what's really important with developing software. It is not about the latest shiny thing. It is about the target customer.
This is the case in any environment. This is the case for your OS, for python requirements, for java jars, everything. Your versions should be part of the source control (not necessarily the dependencies in your source, but at least a project file that has the versions listed).
Python has a requirements.txt. It's best practice to pin your versions in it.
I've been trying out jspm recently. It's quite nice and teaches you this out of the box. You pull down a npm package, it will put the version into your package.json so everyone can use the same version.
Node as npm, Perl has CPAN. Why are modules hard in Node, when modules in Perl work?
Yes the versioning is sad and breaks almost every time. Also some modules look fragile and what was good yesterday is not good today anymore.
But still. Those are the reasons why I still stick with NodeJS :
1. Electron. Simply awesome - I copied 90 % of my app, changed Sequelize ORM to have it's storage to sqlite and boom. I have a webapp as a OS-packaged app.
2. Isomorphic code - I'm rendering React / Flux applications on the server-side and on the client-side. Reusing code, storage and syncing logic between them. Even my logger module works on client-side / server-side.
3. Front-end / back-end needs very similar skills - This is one of my top reasons to tell my clients ( I work as a freelancer ). There will not be a big deal for a front-end guy to write / understand backend code and vice-versa. Also it's javascript. The most popular language.
4. Libraries for most popular services - There is always something, someone wrote that is NodeJS or at least javascript.
P.S. I'm heavily using TypeScript nowadays. I think this solved a lot of NodeJS syntax/compiler problems.
And your users get to enjoy awful performance and insane resource usage for their app. How generous of you.
Also, the hate for NodeJS is because Javascript is a terrible language, no matter how many things you put on it (TypeScript, Babel, etc.). It's also because V8 performance is laughable.
Everything you mentioned is also mentioned in http://notes.ericjiang.com/posts/751 , which I believe does a nice job of explaining why NodeJS is terrible.
About Electron. I think nobody will build Photoshop or 3D Games ( at this point ) using it as a platform. I would personally decline if I have an assignment like this. But for apps like Slack, Visual Studio Code, Atom, etc, it works pretty good. Something more. I'm actually working on my own accounting app that suits my needs, which I would not be able to do for that limited spare-time I have these days If I used Objective-C / Swift.
I won't get into a long rant, but aside from on OSX, Slack and Atom are slow, resource hogging and unstable piles of crap. Atom couples that with bad architecture and engineering choice, but that's not Electron's fault.
(Also, your comparison with English is bad. English naturally evolved to the state it is in today. Javascript was designed from scratch, and it still manages to be awful. Also, sorry, Javascript isn't the most common language, thankfully.)
That's the key right there "Well enough"...
How? (Other than choosing HTML and JS in the first place)
Ah, so they're better on OSX? On Windows 7 all the slack.exe processes are currently using 780MB RAM in total, and I'm only signed into 3 Slack communities.
Shocking!
Atom is my primary editor and I am extremely satisfied with it. Your self-righteous arrogant attitude is strange and has nothing to do with objective, rational criticism.
Compared to what? Objective-C? Dalvik? (JavaScript VMs generally achieve better performance than those for systematic reasons.)
And no. Things break all the time and still give value to customers. Things break for A reason and still give value to customers.
Yep it would be cool and more non-breaking if 20-years of Java experience was injected into NodeJS, but I bet in 20-years NodeJS will be even better than the popular alternatives these days.
Sometimes the value to customers is just a system that works without downtime or failures, and the next increase in value is not even related to something that was built on this bleeding-edge packaging model. The only types of development projects that seem to benefit from it are the kind of project that can dedicate a full-time or mostly-full-time developer to it forever (forever being the lifetime of the product/service).
If dependency issues crop up every few months for a perodically updated project that could almost be a death knell, if you have to pivot or do major work on the backend all of a sudden you could come back to just a broken set of shambles. So the only thing it fits is a really strange gap between hobbyist/side project and stable production which ends up being just plain risky for a technology choice.
IMHO Node isn't built on this mindset ( endless churn ). I think it's just rapidly evolving. It's just enthusiasm by the community.
As far as my experience goes, I just put more effort in finding the right module rather than finding >any< module that will do the work. Afterwards I can usually npm-shrinkwrap, upload to DigitalOcean and leave forever.
But don't take it personally. HN truly has hate for every language (name a language it doesn't hate!), and the internet supports sharing your hatred with others more than it supports sharing love.
You've found a system that earns you money by writing software, and that itself earns you some respect here.
First of all, most people don't actually follow semantic versioning, but npm's default version ranges assume they do, so unless you lock down your dependencies with `npm shrinkwrap` you'll find your app occasionally breaks because some deeply nested dependency broke something in some package you don't know anything about.
But shrinkwrap has a bunch of problems itself (so many that Uber wrote a separate tool to try to fix it: https://github.com/uber/npm-shrinkwrap). npm-shrinkwrap.json files are huge, in part due to the nature of npm, but it also contains a bunch of unnecessary information. The bigger problem is it's non-deterministic, resulting in huge diffs every time you run it, even if nothing has changed.
Here's another fun bug I encountered recently: https://github.com/npm/npm/issues/9642
Every time I think I've worked around some bug another pops up. I wish I've kept track of them all.
/rant
I agree that other ecosystems could learn a lot from the Node philosophy. And in general I enjoy working with the technology. But it's not all roses. In an ecosystem of small modules, you often find yourself wading through many -- equally small -- annoyances which can add up to a lot of friction. Here's a contrived fake example:
Your app needs ABCXYZ. So you go shopping for a module. The most popular one looks good, but when you Browserify it your bundle ends up with 1,000s of extra lines of code for the Buffer shim. So much for keeping that footprint small. So you keep looking and find another one that has a good footprint, but a weird API and it hasn't been updated by the maintainer since 2011. The next one you find looks great, but the maintainer decided they were tired of ES5 and didn't feel like adding a distfile, so you would have to install a bloated transpile toolchain to use it. You're getting annoyed but you keep going. The next one's author inexplicably decided to implement everything with streams. But you're too busy to spend a day grokking streams and reworking your entire API to be compatible. The next one is packaged as a jQuery plugin. The next one doesn't have a license. The next one uses Web Workers for no reason you can see. Etc. etc. etc. Repeat.
Any of these could be problems with a monolith (and monoliths certainly come with their own pile of frustrations), but monoliths are less likely to hit these problems simply because they consolidate effort and personal emotional investment around a certain set of techniques and standards, which leads to more consistency overall.
There are several times I've found something close to what I want, I fork it on GH, change the bits I want, update the name everywhere and publish it... many times they continue to work as-is without much grief. Of course that's part of why there are so many options for any problem.
I usually look at the following, when was the last commit, and how many issues have been sitting stale for over a month... if the last commit was several months ago, but there aren't any recent issues, I'll check through the backlog issues.... some libraries reach maturity and don't change much, if the issues aren't recently curated, I move on...
thrift is the only module where I've locked the version number in package.json.
Maybe it's easier because I don't shrinkwrap, I also get the latest version when CI runs and that allows me to make sure that my application is always compatible with the up-to-date releases of all the dependencies. Shrink wrapping has the downside of actually making it harder to upgrade dependencies because you can get further and further behind on updates.
Fundamental core patterns like streams are still broken and suffer from huge UX issues. I hope future versions will use promises and async/await in core and redo streams to utilize this more like Go's reader/writers. Just by punting that stuff to core the UX without third-party modules would improve drastically, and encourage better practices throughout third-party code as well.
I'm not bashing Node I'd love for it to do great. I'd love to use Lambda out of the box with no callbacks and not worry about which streams are missing which handlers or does this third-party module implement them correctly or will it explode on me :D.
I've had to back port security patches far more than I would ever like to admit.
The node community is still pretty immature. Sure it's nice to rush ahead releasing version after version without having a LTS version but when I want to build something serious with it it can be downright frustrating.
In my experience, it's a bit of a shit show. You end up with libraries that are subtly incompatible, or have overlapping functionality, or strangely large holes of functionality that require overlapping combos of libraries and therefore nobody's written.
If you get your socks off writing shims and glue and maintaining it against a thousand moving targets, power to you.
In my opinion, what you really want is someone to bundle composable libraries for you. That bundling has incredible value. You know that everything more or less works, in ways that you'd expect, because someone else managed to test it.
You have all the functionality basics down pat. The shims you do have to write work at higher levels of abstraction. Etc, etc.
Sooooo a big monolithic framework like Rails or Django? I thought we said those are bad.
Edit: I know this doesn't solve the problem completely, but comparing, for instance, a typical CPAN module's versioning scheme with what you get in npm, I'm far more confident in a lack of breakage in the npm case. :)
Edit2: For downvoters: I program in Perl and Javascript professionally. I'm speaking from experience (my boss just ran into this exact problem with a cpan module in production yesterday), not picking on Perl.
This can be painful when you're dealing with a really big project and someone provides a security update but it's only for the newer version that has lots of breaking changes.
I'm curious to know how other dynamic languages handle this. In Perl I think you generally can't safely load >1 version of the same module, so while you could end up with breakage on an update, you can't end up with the above security problem.
The idea that you should use a module to check if a number is -0 is just insane.
Developers need to wisen up and accept the reality that there is no right or wrong way to do anything. The problem is that people like radical thoughts. No one wants to hear the word 'sometimes' - Which is actually the right word to use 99% of the time.
Question:
- Should you use as many small modules as possible?
Answers:
- Famous developer: Yes, always break everything into small modules because it encourages code reuse, composability, collaboration. That's the Unix philosophy.
- Moderate developer: Small modules are great sometimes but in some cases you just want a wholesome tool that just works and takes care of all the edge cases (and gives you operational guarantees). Having too many separate modules increases management complexity and can make the upgrade/deployment process more complicated and time consuming. Sometimes having too many small modules can make your code difficult to read because people are forced to read through pages of documentation on GitHub every time they encounter a new module.
Question:
- Is Microservices always the right approach to software development?
Answers:
- Famous developer: Yes, always break up your system into separate services - This promotes separation of concerns which makes your system easier to manage.
- Moderate developer: Sometimes. If you have a small team, you don't want to be managing too many different services and having too many code repos - Sometimes it's better to start out with one service, but build it in a way that it can easily be split out later on.
Question:
- Should you use Docker?
Answers:
- Famous developer: Yes, you need to Dockerize your whole stack from the beginning if you want fast deployment.
- Moderate developer: Sometimes. You should be selective about which technologies you use within your project and try to keep the deployment process as simple as possible. If you can keep your technology count to a manageable level, you may end up not needing Docker.
Question:
- Should you use promises in JavaScript?
Answers:
- Famous developer #1: No, promises are evil, they are slow, they swallow your errors and they make your logic impossible to follow.
- Famous developer #2: Yes, promises should always be used. Callbacks make code difficult to read and cause callback hell.
- Moderate developer: Promises are good sometimes but you have to be careful how/when you use them. You don't want to have really long chains of promises spread across multiple files. Sometimes callbacks are more appropriate if you design your system in such a way that nesting is minimal. Ultimately is comes down to what makes your team happy.