News for hackers. Stuff that matters.
Re:Interview with Ryan Dahl, Creator of Node.js by amasad on Thursday August 31, 2017 @12:53PM (#15141676)
The fact that Node survives as a platform for Fullstack JavaScript shows how serendipity works in invention: he set out to build a high performance network server and ended up building one of the largest platforms for building web applications.

The reasons it ended being very big are clear in hindsight but are hard to predict:

- Sharing code between server and client

- Server side rendering

- Lower barrier to entry than other platforms (learn once write anywhere)

- Well-designed package system

It was also helped by the fact that folks decided to write JS tooling in JS, be it minifier, transpilers, or test runners, without nodejs we would've built then on top of something else.

Re:Interview with Ryan Dahl, Creator of Node.js by thehardsphere on Thursday August 31, 2017 @01:06PM (#15141822)
What do people mean when they keep saying "server side rendering" in this specific Javascript/Node.js context? I ask because I've seen quite a few people tout that term as a recent innovation.

It was my understanding that "server side rendering" was the way the web worked since the beginning, with the server generating the markup that is provided to the browser to render the page. Nobody called it "server side rendering" until we had "client side rendering", where Javascript executed in the browser provided the markup instead of whatever program was running on the server.

I'm not trying to lecture or be snarky here; I'm genuinely confused as to what people mean when they say "server side rendering" as a new thing. Like, is there something novel that I'm missing because the term is overloaded with a definition I don't know?

Re:Interview with Ryan Dahl, Creator of Node.js by amasad on Thursday August 31, 2017 @01:08PM (#15141846)
It means you take your client side JavaScript code and render it on the server for performance and SEO.

Previously you had to either duplicate the code in different languages or pick one or the other (either use angular or rails).

Re:Interview with Ryan Dahl, Creator of Node.js by mbrock on Thursday August 31, 2017 @01:12PM (#15141870)
Running the same language on the client and the server also has some deeper implications. Like, it becomes easy to imagine an app that runs in a hybrid way with computations shared between the client and server, i.e., "offline mode". This is a pretty big deal, and it's one of the major benefits mostly ignored by the vocal critics of "single-page apps," as seen in the latest article on the HN front page.
Re:Interview with Ryan Dahl, Creator of Node.js by gaius on Thursday August 31, 2017 @03:29PM (#15143144)
If you need "offline mode" why not just write a native app? It will be far better in every way - looks, performance, battery drain, you name it.
Re:Interview with Ryan Dahl, Creator of Node.js by lenkite on Friday September 01, 2017 @01:21AM (#15146311)
Nobody likes to download and install stuff. Just imagine the state of the web if you had to install a app for every website you visit ? Oh...you need to add iOS and Android to the list of platforms. That makes it 5 platforms. 5x the work.
Re:Interview with Ryan Dahl, Creator of Node.js by mbrock on Friday September 01, 2017 @12:33AM (#15146140)
I don't want to ask everyone to install a native app, I don't want to use several different native app UI libraries, etc. I'm one of those people who thinks that the web browser as an app platform is a pretty good idea.
Re:Interview with Ryan Dahl, Creator of Node.js by sova on Thursday August 31, 2017 @03:32PM (#15143159)
Make a native app for every independent platform?
Re:Interview with Ryan Dahl, Creator of Node.js by gaius on Thursday August 31, 2017 @03:59PM (#15143384)
Windows, Linux, OSX - there just aren't that many platforms these days, it's perfectly do-able. If your core logic is in ANSI C (or equivalent) and you just need a GUI for each platform, even easier.
Re:Interview with Ryan Dahl, Creator of Node.js by mahyarm on Thursday August 31, 2017 @04:59PM (#15143869)
It's still 3 more platforms, which means 3 more developers, which leads to more $$$. Not everyone is VC backed with multi-millions.
Re:Interview with Ryan Dahl, Creator of Node.js by gaius on Thursday August 31, 2017 @05:05PM (#15143917)
But one of these "offline" apps has to work in Firefox, IE and Safari, so really, it's no different
Re:Interview with Ryan Dahl, Creator of Node.js by squeaky-clean on Thursday August 31, 2017 @06:49PM (#15144643)
As long as you stick to the APIs implemented in each browser, your code can be exactly identical. Realistically, you'll probably need to add some polyfills and edge case handling for IE, but it's much less than developing for different full-on platforms.
Re:Interview with Ryan Dahl, Creator of Node.js by moosingin3space on Thursday August 31, 2017 @07:05PM (#15144743)
With the major exception that all evergreen browsers (most browsers in wide use today) quickly officially support new web standards, but Windows, OS X, and Linux are unlikely to ever officially support each others' native toolkits.
Re:Interview with Ryan Dahl, Creator of Node.js by squeaky-clean on Thursday August 31, 2017 @06:47PM (#15144635)
Don't forget iOS, Android and Windows Phone.
Re:Interview with Ryan Dahl, Creator of Node.js by vilmosi on Thursday August 31, 2017 @05:14PM (#15143992)
Because not every news website and blog needs an app. I think everybody is tired of seeing the "Install our app" banners for every website you visit.
Re:Interview with Ryan Dahl, Creator of Node.js by flukus on Thursday August 31, 2017 @09:40PM (#15145495)
News websites and blogs don't need to work offline. Even if they did, "save page as" or an RSS reader was the way to go.
Re:Interview with Ryan Dahl, Creator of Node.js by steveklabnik on Thursday August 31, 2017 @01:11PM (#15141869)
Not just that, but to accomplish it means that you need to provide the correct client-side APIs on the server side, so that your code renders the same in both places. Doing this nicely is a lot of work.
Re:Interview with Ryan Dahl, Creator of Node.js by apparentlymart on Thursday August 31, 2017 @01:14PM (#15141889)
In this context, I think it usually means that the same rendering paths are available on both the client _and_ the server, whereas formerly it was often the case that the server was responsible for the bulk of the rendering and the client just made minor adjustments to the DOM in response to events.

I agree that it's a bit of a misnomer, but I can see why people would call it that given the path we took to get here: first we rendered almost everything on the server, and then it became popular to render everything on the client, but now we're finding that a compromise is best, and that compromise is easiest to achieve when you have similar technology on both sides.

("We" in the above is intended to represent some vague idea of the web development community at large, not any particular individuals or groups.)

Re:Interview with Ryan Dahl, Creator of Node.js by djur on Thursday August 31, 2017 @01:12PM (#15141871)
They're referring to the ability to execute the same code on the client and server and get the same output, which can provide a great deal of flexibility when optimizing for performance.
Re:Interview with Ryan Dahl, Creator of Node.js by dasmoth on Thursday August 31, 2017 @01:12PM (#15141876)
Potentially a better term is "isomorphic", a label which is specifically applied to setups where you run the same rendering code client-side and server-side. That's still a comparatively new concept, at least as something that's actively supported by frameworks and reasonably straightforward to implement.
Re:Interview with Ryan Dahl, Creator of Node.js by tree_of_item on Thursday August 31, 2017 @02:16PM (#15142468)
That's an awful term because it has nothing to do with the actual meaning of the word "isomorphic".
Re:Interview with Ryan Dahl, Creator of Node.js by dasmoth on Thursday August 31, 2017 @02:37PM (#15142681)
I'm inclined to agree, but it seems to have stuck, and is at least more specific than "server side rendering".
Re:Interview with Ryan Dahl, Creator of Node.js by badosu on Thursday August 31, 2017 @03:27PM (#15143114)
Well, unless you're talking about a homomorphism with an inverse the term seems pretty good for me: the same (iso) shape (morphos) between server-side and client-side.
Re:Interview with Ryan Dahl, Creator of Node.js by alayek on Thursday August 31, 2017 @01:30PM (#15142023)
I was confused with this initially as well.

What I came to understand, was that "server-side rendering" refers to whole application lifecycle steps: - The server generates initial HTML markup, based on the request. - The browser can parse & render the already generated HTML (instead of waiting for the client-side JS to load first, then have it create / modify the DOM). - From that point onward, all changes in UI happen through client-side rendering.

You could do this with Django template / JSP pages / Jade templates as well. Just write your templates, and some jQuery sprinkled here and there, to dictate how user interaction should change the page.

But that's not all there is to it.

We slowly took away SSR, with client side JS frameworks, like Backbone, Angular 1, Ember etc. Applications started to have client side routes, even with ugly hashbangs in the URLs.

It was easier to write entire application logic of your UI in a client-side framework with two-way data bindings; than writing the server side in a template language, and put in some JS here & there to handle interactions. Especially, if your application was big enough.

But this started having problems with SEO, and initial load times.

Say, your app has a homepage URL, of the form https://company.tld/, and a products URL, of the form https://company.tld/products.

If a user goes to homepage, and clicks on the "products" link in the navbar, the page content of /products route would load in the client side, via the framework.

But, if a user directly hits the /products URL from their browser (can be from history and omnibox prompt), the browser would first load the home page with assets, then the client side JS would take over, and route the user to the /products URI endpoint.

New server-side rendering paradigm gives you best of both worlds - get to maintain a single codebase to render your page (be it server or client), while give the initial fast loading, so that your page is interactive quite fast.

This is not easy to do. One big challenge for most server side rendering solution is that, after initial render, the JS in the page would try to re-render the page; thereby creating an impression of a "flash".

Yes, if you're using a framework like React or Vue, which uses VDOM, this won't happen in most cases, because of how a virtual DOM based renderer works. But there are still cases, where you might need to explicitly do something to prevent the re-render.

There are other challenges too. For instance, having the page server-rendered, and hydrating the state.

In the search of maintaining a single unifying codebase for both server and client (isomorphic rendering), we often do things that cannot work on server. For instance, chunk splitting your front-end bundle based on routes. Or CSS media queries.

To sum it all up, "server-side rendering" isn't just about initially rendering the page on server. It's so much more than that. It's mostly about how we can maintain a single codebase (now that we have JS on server too), and run on two different platforms.

Re:Interview with Ryan Dahl, Creator of Node.js by pier25 on Thursday August 31, 2017 @01:28PM (#15142007)
> Lower barrier to entry than other platforms

I think this is the main reason Node caught up.

SSR and code sharing are only useful in full stack projects, not in APIs. I don't know the numbers, but my conjecture is that there are more RESTful APIs written in Node than any other type of server project.

Re:Interview with Ryan Dahl, Creator of Node.js by stephenr on Thursday August 31, 2017 @01:14PM (#15141892)
I wouldn't call npm "well designed".

It's progres bar was the bottleneck causing slow downs.

The size of node_modules directories is basically a meme now.

Re:Interview with Ryan Dahl, Creator of Node.js by amasad on Thursday August 31, 2017 @01:35PM (#15142061)
It's the least shitty of all other designs. It picked the best design decisions from existing package managers. By default it is project local (as opposed to global like what rubygems, pip, and others are), it's recursive and largely reproducible (fully reproducible using lock files). The resolution algorithm is also deterministic and simple, you can implement it in an hour.

Although other languages are catching up they have to do it as add-ons or third party tools -- for example python pipenv https://www.kennethreitz.org/essays/announcing-pipenv

Re:Interview with Ryan Dahl, Creator of Node.js by pier25 on Thursday August 31, 2017 @01:23PM (#15141965)
I don't think amasad was referring to npm but the module system.
Re:Interview with Ryan Dahl, Creator of Node.js by coldtea on Thursday August 31, 2017 @04:01PM (#15143408)
Both issues are irrelevant as to whether npm was well designed.

One is an implementation detail of a secondary part of its operation (progress indication), and the other is about packages having many dependencies, not about npm causing node_modules directories to grow itself.

Re:Interview with Ryan Dahl, Creator of Node.js by jrs95 on Thursday August 31, 2017 @02:18PM (#15142483)
Just use pip for a minute, and you'll quickly realize that npm is pretty well designed ;)
Re:Interview with Ryan Dahl, Creator of Node.js by owebmaster on Thursday August 31, 2017 @05:46PM (#15144237)
I don't think npm became the biggest package repository by accident so it is sure "well designed".
Re:Interview with Ryan Dahl, Creator of Node.js by gkya on Thursday August 31, 2017 @03:16PM (#15142991)
> The size of node_modules directories is basically a meme now.

Not a node user since many years, so I can only guess, but isn't the cause of this is bad community practices (micro-packaging, many different things that do the same thing, etc) rather than the package manager itself? You can get hundreds of deps in any language if the practices are similar.