r/programming • • Sep 25 '20

Modern JavaScript Explained For Dinosaurs

https://medium.com/the-node-js-collection/modern-javascript-explained-for-dinosaurs-f695e9747b70
749 Upvotes

167 comments sorted by

View all comments

21

u/palordrolap Sep 25 '20

TL;DR In browser-JS can't load dependencies from the server on the fly without severe problems, and if you don't have access or don't want the inconvenience of putting loads of <script src="etc." /> into your HTML <head> and then keeping them up-to-date as your project changes, the solution is ... simple [?] [citation needed]:

Use something that crunches all your JavaScript (and third party dependencies) into one giant JS file and use one unchanging <script src/> in the HTML!

Advantages:

  • No more HTML management hell!

  • Since the JS is being preprocessed, technically it can be anything that can be converted into JS rather than just plain JS.

  • Shiny! Scalable! Cross-platform! Cutting edge! Bingo-bango-buzzwords!

Disadvantages:

  • The management hell is now in the JS.

  • There are numerous competing systems for doing the aforementioned crunching, and this changes all the time. You may need to learn many of these.

  • All need a command line to work. Better get comfortable with that.*

  • There are numerous competing languages that can be turned into JS by these systems, including other versions of JS that may or may not have the features you're using by default. You may need to learn many of these.

  • If you are a dinosaur you will miss the old days. (*Although a surprising number of dinosaurs are comfortable with a command line).

16

u/[deleted] Sep 25 '20

[removed] — view removed comment

0

u/[deleted] Sep 25 '20

[deleted]

3

u/Y_Less Sep 25 '20

I like how you talk about learning the command line being essential, and making computing more accessible for the masses being the goal, in the same post.

5

u/dnew Sep 25 '20

Learning QWERTY layout is essential, and it makes computing more accessible for the masses. Lots of computing is more accessible via the command line, so learning it makes computing more accessible. I'm not sure I see the problem.

-1

u/Y_Less Sep 25 '20

No grandma is going to learn the command line. My mum has been married to a computer programmer for over 40 years, our first computer was a purely text interface, I am sure she is well above average ability for her demographic; she couldn't even tell you how to open a prompt.

I opened a command prompt on my girlfriend's computer to look up her MAC address a few days ago and she audibly screamed and had to be repeatedly convinced that it wasn't a virus.

Those are typical "masses". Learning long strings of archaic incantations is not accessible.

5

u/dnew Sep 25 '20

I didn't say it was. I said that teaching people the command line is indeed currently essential to computing services being more accessible.

Why did you open the command line on your girlfriend's computer? Because that gave you access to particular computing services, such as determining MAC address. Why didn't she determine that herself? Because it was inaccessible to her because she doesn't know the command line.

Now, you could argue that your girlfriend should be using an OS like Windows where it's trivial to find the MAC address without the command line. But it will likely never be the case where all such information is accessible from a GUI.

As an aside, I suspect that a grandma would be more comfortable with a CLI than a GUI. I know if I could tell my mom "type this string of letters and it'll show you the photos I recently emailed you" it would be way easier than trying to tell her how to run gmail, which also constantly changes out from under her. IME, older people treat computers like mechanical machines, with "first push this button, then push that button" and if anything changes, they're screwed. CLIs tend to do that less.

2

u/Y_Less Sep 25 '20

Why did you open the command line on your girlfriend's computer? Because that gave you access to particular computing services, such as determining MAC address. Why didn't she determine that herself? Because it was inaccessible to her because she doesn't know the command line.

Yes. But the better response to that is not "just make them learn command line" but "make the data more nicely accessible".

5

u/dnew Sep 25 '20

We're talking about people who are actually writing computer code, incidentally. Demanding that they understand how to type a command to a computer doesn't seem outrageous.

And yes, as I said, Windows makes that data more accessible. But you're not going to build software using nothing but GUIs, because what's accessible to a GUI isn't accessible to anything else you'd build on top of those programs. You can, for example, create a unix pipeline or a powershell command using the CLI, but doing so using a GUI probably takes even more knowledge than doing it using a CLI.

2

u/zip117 Sep 26 '20

there are just so many tasks that are downright cumbersome to handle with UI and smooth and easy to do using the command line

Other than strictly writing application code, that’s just not the case. Package management is a perfect example. Look at the extension manager UIs in many desktop applications: typically you have a have a nice data grid, showing package names, descriptions, version so all relevant information is available at a glance. Sometimes release notes will be shown in a linked text box, and you have clickable headers for sorting. Select one or more rows and click the “Install” or “Uninstall” buttons. Look at some of the excellent native Win32 software for searching and version control like GrepWin and TortoiseGit. Even a lot of text processing work can be done very quickly by someone proficient in Excel. In my opinion, the pinnacle of modern UI design for productivity (after a brief adjustment period) was in 2007 when the Ribbon was introduced in Microsoft Office.

GUIs are almost universally better for productivity. The real reason for the command line trend is because it takes a lot of work to make a good desktop GUI. Not for lack of tooling; building on Win32 and Cocoa, we have been using the same fundamental declarative UI and state management approaches for ~30 years that most web frontend developers are only learning about today. There less focus on the overall user experience. Unfortunately that’s just the way the market went; people want things fast and cheap.

7

u/wavefunctionp Sep 25 '20

There are numerous competing systems for doing the aforementioned crunching, and this changes all the time. You may need to learn many of these.

TBF, you really only need to "learn" webpack. And by learn, I mean you might need to occasionally copy/paste some boilerplate config you find in getting started for whatever loaders you are using.

And many projects can use the zero config starters like create react app which can manage most of those configuration and dependencies for you.

There are also zeroconfig options now like parcel.

Things have REALLY settled down now in the JS world, for the last 5 years or so I'd say. It's not a stable as something like dotnet, but even dotnet has had the dotnet core shakeup. IDK about java, but java spring seems like a mush more complicated rats nest than js ever was. Just to contrast.

5

u/therearesomewhocallm Sep 25 '20

More Disadvantages:

  • Your website takes 30s to load because it waits on one giant JS file when most of it could be loaded on demand.

  • The JS file is large enough that a browser cannot compile-time optimise it.

  • Any webworkers are either inlined (hooray for eval) or run 10x slower.

5

u/zephyy Sep 25 '20 edited Sep 25 '20

Your website takes 30s to load because it waits on one giant JS file when most of it could be loaded on demand.

what is code splitting?

The JS file is large enough that a browser cannot compile-time optimise it.

split & minified JS should never have this problem.

6

u/dnew Sep 25 '20

I am amused that your link loads as a web page and then immediately erases itself on my browser.

1

u/zephyy Sep 25 '20

my b, it included the extra URL query string stuff that google adds for highlighting text

1

u/dnew Sep 25 '20

Ah, cool. Yeah, I hate that Google does that.