Hacker News new | ask | show | jobs
by shittyanalogy 4167 days ago
"isn’t there a better way to speed up client side loads times without having to mix server side and client side code?"

You're not mixing them, you're using a javascript engine serverside to pre-run your client side js. There is still code separation and your back end doesn't have to be written in JS to accomplish this.

Separately the notion of "isomorphic javascript" if that's what it's called, is not to "mix" client and server code. It's 2 fold: 1 to take down the boundary between client and server code so that there is much re-use and code can just be "marked" as server or client only. 2) So that you can re-use many of your tools like libraries, testing, and language best practices across your whole project.

1 comments

I think that boundary is important though. If you design your app correctly there won't be the need to rewrite code over the front and back. Also if your building an Android or iOS app you have to build that boundary. So why build the web frontend differently? They should all consume the same backend.

Of course there will probably be repeat code but I'd rather minimize that than try to make universal code.

You're thinking of the wrong boundary. You should definitely have a boundary for your data that is agnostic of the view code.

However, a web application is not like an iOS or Android application. It has a server-side that sends pre-rendered view code and it has a client-side that renders view code on the fly. It still makes sense to share the view code between the server and the client and it still allows for a separate data backend.

These systems are surprisingly easy to create and maintain with React.

In essence three things are supplied to a client. A pre-rendered view, raw data, and the code to turn the raw data in to the pre-rendered view.

OK that is where we diverge, i'm thinking no pre-rendered view. Ideally your frontend would be serving statically from lets say Amazon S3 and your api from another domain. Treat your frontend as if it were a mobile app. Now if you apply the data bootstrapping technique this can't happen totally but the only thing to do dynamically is insert some initial API data.