Live data from Hacker News

Hacker News Clone Using GraphQL and React

github.com

181–187 of 187 posts

Re: Hacker News Clone Using GraphQL and React

#181
post #178

Earlier quoted context omitted.

I'm guessing nobody tests for this, because everyone develops on fast, reliable internet connections and it's not super easy to simulate, although there are tools, dummynet probably being one of the oldest: https://gamedev.stackexchange.com/questions/61483/how-can-i-...

Chrome comes with a network throttle built-in.

Cool, didn't know that. No excuses not to test properly then! :)

Re: Hacker News Clone Using GraphQL and React

#182
post #98
post #74

Earlier quoted context omitted.

Declaring what data your UI binds to is not a side effect, so co-locating GraphQL queries with your component doesn't necessarily introduce side effects. You don't have to co-locate GraphQL mutation queries to your component, you can just have your event handlers (or other mutation-creating events) handled elsewhere in your app. > What happens when two components used in two totally different areas of a single page n…

It certainly does introduce side effects (by default, for Apollo or Relay): * A network request is kicked off if the cache doesn't contain the data the component declares a dependency on. * other components that depend on any part of the requested subgraph will update when the response comes in * query observers (which HoC'd components really are) will similarly fire, potentially triggering other side effects in your…

If you include enough in your definition of side effect, everything must have a side effect. Otherwise you wouldn’t be doing it. A pure function that adds two numbers and returns the result has left your system in a different state than it was in before it ran.

Data binding has side effects and the implementation of the thing doing the binding may cause things to happen, may cause some state to change. But I still wouldn’t consider the declarative data binding itself to have side effects.

Re: Hacker News Clone Using GraphQL and React

#183
post #178

Earlier quoted context omitted.

I'm guessing nobody tests for this, because everyone develops on fast, reliable internet connections and it's not super easy to simulate, although there are tools, dummynet probably being one of the oldest: https://gamedev.stackexchange.com/questions/61483/how-can-i-...

Chrome comes with a network throttle built-in.

Is it able to simulate spotty connections, where the connection keeps dropping in and out? Because I find that tends to be the thing that websites and applications most often don't factor for properly.

Re: Hacker News Clone Using GraphQL and React

#184
post #31

Earlier quoted context omitted.

Clone: 22 requests | 1.1 MB transferred | Finish:2.86 s | DOMContentLoaded 636 ms | Load:2.87 ms Real Hacker News: 6 requests | 11.5 KB transferred | Finish: 336 ms | DOMContentLoaded: 325 ms | Load: 343 ms Hacker News is just a static cached webpage

That’s on first load – all future loads are significantly faster on this clone.

1.1Mb is 100 times larger than 11Kb.

Re: Hacker News Clone Using GraphQL and React

#185
post #125
post #122

Earlier quoted context omitted.

That includes devDependencies, too. A bit like counting lines of GCC/Clang/whatever build tool…

Given that this is meant to be boilerplate for building apps, it makes sense to install it with devDependencies. However, let's go along and install it with the `--production` flag. It doesn't get much rosier. Close to 1M SLOC. $ npm install --production added 718 packages in 36.292s $ ls -l node_modules/ | wc -l 518 $ loc node_modules/ --------------------------------------------------------------------------------…

Not to beat a dead horse but:

- Why count Markdown files?

- TypeScript, CoffeeScript, C/C++ headers/source files, basically any language other than JavaScript, are probably part of that modules source, and not the compiled JS output that is used.

Still a good million lines though.

Re: Hacker News Clone Using GraphQL and React

#186
post #31

Earlier quoted context omitted.

That’s on first load – all future loads are significantly faster on this clone.

1.1Mb is 100 times larger than 11Kb.

That would be the case when the bandwidth was the limit, but it’s not.

The limit is in the immense latency for opening a new connection.

Opening a network socket with TLS can take over 4 seconds on mobile, which is why ideally you’d even use an open websocket for communication instead of new GET requests. Navigating to a page in this version causes one or two network requests, in the real HN it takes far more just to check if the images have changed, the CSS has changed, etc.

Re: Hacker News Clone Using GraphQL and React

#187

Earlier quoted context omitted.

1.1Mb is 100 times larger than 11Kb.

That would be the case when the bandwidth was the limit, but it’s not. The limit is in the immense latency for opening a new connection. Opening a network socket with TLS can take over 4 seconds on mobile, which is why ideally you’d even use an open websocket for communication instead of new GET requests. Navigating to a page in this version causes one or two network requests, in the real HN it takes far more just to…

Using websocket looks like overengineering because HTTP/2.0 allows to use a single connection for multiple parallel requests.

Using React to build a simple (student level) site like HN is overengineering too in my opinion. If you don't want to reload the page when navigating you can just reload HTML content with jQuery or fetch() without using client side rendering, without draining device battery and without loading 1 Mb of Javascript that will take much more space in RAM.

SPA approach should be used for interactive applications able to work in offline mode, able to provide rich experience on mobile devices etc.

Post reply on HN