Live data from Hacker News

Step-by-step tutorial to build a modern JavaScript stack from scratch

github.com

201–210 of 211 posts

Re: Step-by-step tutorial to build a modern JavaScript stack from scratch

#201
post #160

"This is a minimalistic JavaScript stack" "ES6, Babel, Gulp, ESLint, React, Redux, Webpack, Immutable, Mocha, Chai, Sinon, and Flow" brutal.

Minimalist python backend stack: Django, gunicorn, Django Rest, Postgres (psycopg2), celery, redis, requests, nose, factory_boy, freezegun, raven Building good applications for lots of people requires lots of stuff. Using vanilla JS to build web apps is as much fun as using vanilla python to build a backend.

I'd opt for flask if I were using python, but that's just me :)

the thing about the above-mentioned JS stack is that it's barely the tip of the iceberg. most of the dependencies in those python apps are built using standard libraries that simply don't exist in javascript. glazing over the whole "you're about to download a bunch of random stuff from npm that may be unmaintained or malicious" thing doesn't do a service to a junior dev.

it's also not a "modern" stack. gulp? webpack. npm? yarn. react? vue. and in another month it will be something else. what you would opt for in python, is well-established, built on libraries that are part of python's core, and maybe except for the testing stuff has been around for 100 javascript years.

I'm criticizing neither the article nor its author, simply remarking that javascript in 2016 is, in practice, completely fucking brutal.

Re: Step-by-step tutorial to build a modern JavaScript stack from scratch

#202

Ridicule me all you guys want but I still write using just html/css/js and sublime text (no jquery either). And I have written a 30k line project using just that and php. Being a filthy casual has it's upsides. I can do whatever I want insanely quick. Moving projects from machine to machine is quick as well. Only time I use command line is for git. I do have the advantage of having all my customers on a modern browse…

So just curious here -

How did you manage your js files ? Did you put everything in a single file ? If not, what scheme did you take up on to split the files ?

What about minification and obfuscation of js ? And since you are not using jquery, did you manually set event handlers (onclick, onchange) in the html ?

From my personal experience, I had once did a pretty big JS project without using the ES6, webpack flow. And beyond a point of time, it got pretty much out of control. In hindsight, using classes, require directives would have made life so much easier to understand.

Re: Step-by-step tutorial to build a modern JavaScript stack from scratch

#203

Ridicule me all you guys want but I still write using just html/css/js and sublime text (no jquery either). And I have written a 30k line project using just that and php. Being a filthy casual has it's upsides. I can do whatever I want insanely quick. Moving projects from machine to machine is quick as well. Only time I use command line is for git. I do have the advantage of having all my customers on a modern browse…

So just curious here - How did you manage your js files ? Did you put everything in a single file ? If not, what scheme did you take up on to split the files ? What about minification and obfuscation of js ? And since you are not using jquery, did you manually set event handlers (onclick, onchange) in the html ? From my personal experience, I had once did a pretty big JS project without using the ES6, webpack flow. A…

> How did you manage your js files ? Did you put everything in a single file ? If not, what scheme did you take up on to split the files ?

Since I have the benefit of having all my customers' systems on chrome/ff (evergreen variety) I can use latest js features that are stable. So most of my main project (a CMS for schools to manage date sheet, exams, result, attendance, homework, assignments, etc) is divided into features/modules.

There are a few project wide classes (es6) that are all in one file /main.js (about 1000 line file, nothing outrageous). Then every feature can have any number of individual pages (mostly two). So for example attendance has two pages take.php and view.php. Each page with it's own js file, an average of 300-500 lines per page, though a couple js files go as far as 1500.

At the end most pages have about 2 or in some cases 3 js files that are included in the header. It used to be kind of a mess when I wasn't using classes but now it's all pretty much as good as it will get at my current skill level.

> What about minification and obfuscation of js ?

My overall static page load is about 30kb to 50kb on average (excluding api/json calls) so minification is not something that I had to look into but I can easily do it with a babel flag. I mentioned babel in my original comment because some of the site is also exposed to parents that can be from any device/browser. So I use babel to compile (and if I want, minify/obfuscate) some of my code as well.

> And since you are not using jquery, did you manually set event handlers (onclick, onchange) in the html ?

I think even in jquery you would have to set manual event handlers. But I have a `Node.prototype.on = (e, f) => this.addEventListener(n, f);` somewhere in main.js. So setting event handlers is not as verbose but I never needed anything more than that. Not sure what other advantage jquery provides over `node.on('click', e => {})`. Inline event handlers are yuck. My html/js/css are strictly segregated.

I mostly keep my interface simple and focused on one single task so I never needed frameworks like react either. I keep DOM interaction to minimum. Only place where I think something is left to be desired in my work flow is generating DOM nodes from my json api responses. I have it down to as simple as I can but it's still pretty verbose. But I don't want to include and figure out an entire framework just to do this one task that I am not completely satisfied with but isn't that big of a trouble either.

Whew that turned out to be longer than I expected.

Re: Step-by-step tutorial to build a modern JavaScript stack from scratch

#204
post #200

Earlier quoted context omitted.

Again, you don't need to believe me, but shoving your head in the sand and pretending it's not useful isn't going to do you any good. Tons of companies are very successfully using javascript for long-running processes on the server side. And it's not exactly showing any signs of slowing down.

Mhm, they have been. Then they rewrote everything from scratch because as it turns out, javascript on the server side is still pretty damn awful performance wise.

Beats the hell out of Python or Ruby in that department. But regardless, absolute speed isn't the bottleneck in most situations, and in those cases trying to force JS will end you in a world of hurt.

Like most things in life, use it in moderation, and you'll end up much happier. But if you take absolute stances on things, you are only hurting yourself.

Re: Step-by-step tutorial to build a modern JavaScript stack from scratch

#205

Earlier quoted context omitted.

Yarn solve some problems that the npm folks were unwilling / unable to solve, and is backed by Facebook + Google (+ others) so it's likely to be here to stay. Unless npm wake up and smell the coffee and implement some of it themselves, but experience shows they are quite opinionated and not in a good way.

IIRC the yarn developers worked with NPM to get it out. It's not a lack of will or ability on the part of NPM that it can't be "fixed", it's that NPM has just so much baggage. They can't change how things are installed, because that would mean getting rid of features that many people rely on. For a while they didn't even have any documentation on how NPM worked, it was a bit tautological (npm worked in the way that n…

There is no reason why npm couldn't have a lockfile, for example.

Re: Step-by-step tutorial to build a modern JavaScript stack from scratch

#206
post #163

Earlier quoted context omitted.

Memory is still the number 1 limit I have to deal with, every day. Both on my laptop, and on the server side. It remains highyl relevant exactly because of that kind of attitude.

> Memory is still the number 1 limit I have to deal with, every day My raspberry pi has a node server deployed on it. I'm confident you can figure out how to manage it. > on the server side These are dev dependencies. If they are making it to your server, memory isn't the issue.

The issue isn't a single tool. It is when you have a lot of them, and it all starts adding up.

> These are dev dependencies. If they are making it to your server, memory isn't the issue.

Yet you above suggested deploying them somewhere else. Which is exactly what I do because otherwise my laptop is constrained by the heap of bloated tools I depend on.

Re: Step-by-step tutorial to build a modern JavaScript stack from scratch

#207

I feel like the people complaining about how many libraries there are in this stack don't know what these tools do. Most are small tools that do one thing very well. Yarn installs packages, much like Gem, NuGet, whatever. Pretty standard. React is a frontend framework. Not surprising that you'd use one. I suppose you could opt to write a giant pile of vanilla JavaScript instead (I'm assuming you're not using this kit…

I think what sets many people off -- including myself -- is that the "recommended" libraries change so often. It's like a joke: "You're still using npm for installing packages? That's SO 2015! Of course you should be using Yarn."

After 21 years of JavaScript, one would expect a little more stability, so that the web app you build in 2016 with cutting-edge technology wouldn't be scoffed at in 2017 and obsolete by 2018.

Re: Step-by-step tutorial to build a modern JavaScript stack from scratch

#209

Earlier quoted context omitted.

It took my 2 minutes to find a laptop under $500 with 8GB of RAM. My 2011 asus laptop has 8GB RAM. I'm not going to build software with my 2005 Inspiron in mind. Don't expect people to cater to 10 year old machines.

Not everyone has $500 of disposable income, either. Not to mention that very few phones and netbooks (like Chromebooks) have more than 4GB of RAM (in fact, I'm not aware of any in either category except for the Chromebook Pixel line). Lots of people in the real world are stuck with hardware with 2GB of RAM (or less!). I develop with those users in mind. I don't expect the average HN-reading programmer to do the same…

> I develop with those users in mind

I also develop with users in mind, which is why I don't care how large my development environment is as long as it brings benefit to them. My original comment was a response to a person who rhetorically asked how big the node_modules folder was after installing a list of dev tools. I don't install my IDE on your phone/netbook, nor do I install my JS dev tools. Who cares how much disk space it eats up on my developer computer? I couldn't fill my disk space unless I spent a week downloading porn. My laptop cost comment was one about developer contributions, based on the belief that we were still talking about dev tools. I won't design my dev environment so that a developer with a 10 year old computer can work with me. Everything in here has been about developer workflow. The user isn't impacted by any of it. In fact, all it does is improve their experience. For an example, I have a hobby app I'm working on in node/angular2, which is an image editing platform.

  $ du -sh my_app/
  483MB my_app/
  $ cd my_app && npm run build
  $ du -sh my_app.tar.gz
  3.7MB my_app.tar.gz
It unzips to 24MB, 20MB of which are the few node modules that don't play nice with my build system. Spinning it up, it takes ups 62 MB of RAM. I'd hardly consider that earth shattering to a user (the user doesn't download it anyway, it's an api deployed on a server). When I run it in dev mode, it takes up 400MB of RAM. I don't care, because that's what this computer exists for.

Re: Step-by-step tutorial to build a modern JavaScript stack from scratch

#210

Earlier quoted context omitted.

Just google "yarn vs npm" and you'll know the answer... the tools change because the technology is evolving, despite node the front end is still the driver, and mobile phones / browsers / etc are constantly being improved and evolved, and the ecosystem keeps up with it. Would you rather it all stayed static like in the C world and then you program a 2016 smartphone with a 2006 stack?

The answer to your question is yes. I would rather the stack, or at least most of it, stayed stable for 10 years. The problem seems to be that the JS community keeps re-discovering the wheel at every step, instead of actually looking at other ecosystems and learning from them. How log did it take for a sane build system to show up? Or a sane package manager (with dependency resolution, upgrades, checksums, signature…

> Why is Grunt/Gulp a thing when we have thinks like make/CMake?

What a ridiculous statement. It's like asking why .NET doesn't use the JVM or why Haskell doesn't use the C compiler. Grunt/Gulp solve web dev specific problems, make is a different kettle of fish.

Post reply on HN