10 ms·
Hacker News written with Angular 2.0
- bikamonki 11y agoMuch slower, why?
- devfactor-io 11y agoAngular is naturally a poor choice for social networking sites. The reason being, is because the 2 way data binding requires a metric crap ton of listeners. Once you hit about 1000 listeners Angular tends to crap out a bit. It is better for dynamic sites hosting more or less static content. Not for social.
- spartanatreyu 11y agoAngular 2 is built for tomorrow. It uses a lot of apis either not available (and so must be shimmed which is slow) or not optimised in today's browsers.
- djm_ 11y ago> Angular 2 is built for tomorrow. If tomorrow means we're going to give up serving any HTML on first render and pretend that performance doesn't matter, then yes, it's built for tomorrow. As an aside: Meteor is in the same slowly sinking boat. React is not as you can easily render server side before pushing that initial page to the client.
- bsimpson 11y agoIt's all coming around. React taught the value in using a virtual DOM for isomorphic rendering. Ember is adopting it with Fastboot, and I'm sure Angular will end up doing something similar.
- quaunaut 11y agoI'm not an Angular user(Ember here), but in time all of the major frameworks will allow for serverside rendering. The React model works very well, and most projects are taking a lot of ideas from it. Ember will have fastboot in a couple of months to match the same idea, and it won't even require any custom code- it'll be little more than 'drop in, run server', and you're good for life. I expect a lot of other frameworks take a similar approach not long from now.
- djm_ 11y agoIt's really great to hear that, thank you. Nice to know the performance crowd's rants are eventually being heard.
- quaunaut 11y agoYup. And Ember's getting even ridiculously fast post-load, too, thanks to Glimmer. When it comes out, it should be the fastest full-fledged framework. I'm sure the others will catch up super soon though!
- deleted 11y ago[deleted]
- ralusek 11y agoSo much misinformation here. For one, Angular 2 will allow for server side rendering as well, as it doesn't rely on a DOM. Secondly (and I already linked this in a separate comment), I built a very ugly but effective reddit angular client that receives no HTML whatsoever and renders pretty much instantly. This is in Angular 1.3 and much slower than Angular 2.0: http://bredd.it.s3-website-us-west-1.amazonaws.com/ http://bredd.it.s3-website-us-west-1.amazonaws.com/
- douche 11y agoThat's kind of a waste for something like the HackerNews site. It's just dog-simple HTML. There are a handful of vanilla JS functions to run the voting buttons (at least that I can see). It seems like a use-case that would be perfect for server-side templating like Razor.
- hswolff 11y agoFYI: The angular team is working on server side rendering: https://docs.google.com/document/d/1q6g9UlmEZDXgrkY88AJZ6MUrUxcnwhBGS0EXbVlYicY/edit#heading=h.19ijfd7mxdt4 https://docs.google.com/document/d/1q6g9UlmEZDXgrkY88AJZ6MUr...
- fadsasda432 11y agoThis is not a critique to the author, but for me, who just did classic webdev (server side templated html), this was very surprising. I am not that into webdev, but shouldn't a page like HN be fast TODAY, as it has very basic functionality (CRUD)? I mean if this is slow, how can I expect acceptable performance from involved applications?
- error54 11y agoI think it's the firebase api that's slowing everything down.
- djm_ 11y agoThe problem is the site is not sending any (useful) HTML during the first HTTP request. Therefore the browser has to wait for the JS to render the page before it can even think about displaying anything. The fact the site then loads content from firebase is obviously a problem, but it's not so much firebase's problem as it is of the codebase itself - in an ideal world it should be rendering the initial HTML to send to the client on the server. I have seen React based websites with server side rendering work with firebase with much better performance.
- nperez 11y agoWell, it seems to be loading data in via websockets. Compared to server-side rendering of cached data, that's not going to be performant.
- gfosco 11y agoTaking something simple and making it complex and limited, with Angular 2.0.
- MichaelApproved 11y agoThat's not the point of sample projects like these. It's to showcase what's possible with the technology and allow developers to see how something can be implemented. The developer was having fun with the technology and showing others how it could be done. Let's encourage this type of behavior. "I created this to see what it's like to create an AngularJS 2.0 application. I've previously experimented creating a Hacker News clone with AngularJS 1 so this was fun to play with."
- 13 11y agoHacker News loads in milliseconds, why does this take over 10 seconds to even start showing comments? It's not so much a showcase as a reason to ever never use this in any product, it's obviously unsuitable for displaying even the most simple, static data without taking forever and making FireFox stutter. It's not an isolated situation with this either, other websites like this perform terribly even thought they are written in the hippest language with the most popular libraries on the market.
- Igglyboo 11y agoProbably because the angular site is using a third party API to get the comments and stories?
- MichaelApproved 11y agoHacker News loads in milliseconds because the content is generated on the server and insanely optimized. It's different architecture. Optimized server side page loads will always load faster than client size AJAX API calls + page 2x page rendering. Of course Angular doesn't make sense for a site like HN but this is just a demonstration of what's possible with a site we're all familiar with. A real world example of Angular is when you're working with HIPAA complaint applications which depend on 3rd party data storage sites, such as http://TrueVault.com http://TrueVault.com. None of the patient information is stored on the application server. Instead, it makes client side API requests to the TrueVault storage and updates the page with the data. Yes, Angular doesn't make sense for a majority of the websites in existence but it does work well for certain applications.
- jdotjdot 11y agoThanks so much for sharing this. I've been waiting a while to see something complete written in Angular 2.0 to see what it looks like. Really enjoyed looking through the source on this.
- hswolff 11y agoGlad you enjoyed! Thanks for the kind words!
- insin 11y agoSeconding that, this is far more useful than another TodoMVC implementation for getting a feel for how an Angular 2 app is put together, with multiple pages, data from an API and at least one component with more complex display logic.
- hswolff 11y ago:) I've always enjoyed looking through your React HN site as well insin. It's very well done, kudos. Glad to see you continue to iterate on it.
- darthdeus 11y agoThis is interesting, when I opened the link I thoguht to myself "this might be a nice and faster way to browse HN" ... but wow, this thing I slow. Not just slow, but the back button isn't working as well. Or maybe it is, but it loads the whole content again when you click back?
- hswolff 11y agoSomething I have in my todo list is to use the new angular router (https://github.com/angular/router/ https://github.com/angular/router/) however it doesn't appear to be currently available for angular 2. See issue https://github.com/angular/router/issues/233 https://github.com/angular/router/issues/233.
- mattmanser 11y agoIt's based on the firebase API, that's what's probably slow.
- insin 11y agoThe Firebase API is pretty quick after the initial connection, here's an un-optimised React version (i.e. no shouldComponentUpdate hooks) which uses the Firebase API, for comparison: http://insin.github.io/react-hn http://insin.github.io/react-hn
- douche 11y agoThis is pretty cool, thanks for sharing. I may start using this to browse HN all the time, since it does have the one feature that I miss from the normal site, e.g. highlighting new comments since the last time I viewed a thread. It also appears to autoload new items? I assume this must be cookie/session based, but I'll have to look at it.
- mattmanser 11y agoLocal storage, full source is linked at the bottom: https://github.com/insin/react-hn/blob/master/src/utils/storage.js https://github.com/insin/react-hn/blob/master/src/utils/stor...
- pdkl95 11y agoSeems to be serving a broken page... <div class="bodyContainer"> <hacker-news></hacker-news> </div>
- hswolff 11y agoauthor here, Are you still seeing that? Can you open an issue with further details please?
- pdkl95 11y agoIt is a mistake to assume a browser supports javascript. Angular/meteor/etc do not generate sane output, as throwing up what is essentially an empty body tag (literally so, in some cases) is not only totally unusable outside the one use-case you have planned for, the page being generated is equivalent to a server error. The correct solution, of course, is to render the page server side (and cache it, if you're sane), and progressively enhance any features such as XHR-style loading. Some comments later in this thread have mentioned that this might be an upcoming feature in the near future, which is great. Without server-side rendering? That is still no excuse to serve up an empty page. Put some sort of fallback there, or a link to some alternative page. At a minimum, at least have a proper error message about how your site only only works in browsers that support javascript.
- djm_ 11y ago> It is a mistake to assume a browser supports javascript. I really feel at this stage in the battle that that argument is hurting the call for server side rendering. Don't get me wrong, I have been a pusher for PE for many years but it quite clearly is falling on deaf ears these days. The reason being is that it's very easy for someone to turn around and say "none of our users that we care about turn js off". However it is much harder to ignore the fact that initial page load times with server side rendering are minimal in comparison to the render-via-js frameworks of today. I believe we need to follow the performance argument.
- iovar 11y agoThat's the body before any javascript runs. Did you really open a link about an angularjs project, with javascript disabled, just to be able to say it's broken?
- deleted 11y ago[deleted]
- lightningstorm 11y agoThe repeated animation for each content is very annoying. Would be better to have a single spinner for the whole page.
- mambodog 11y agoAn 'isomorphic' approach would really help with that first page load time. Here's one I built with isomorphic React: http://hackernewsmobile.com/ http://hackernewsmobile.com/ (source: https://github.com/jsdf/hacker-news-mobile https://github.com/jsdf/hacker-news-mobile)
- hswolff 11y agoI agree. Server side rendering is not currently available for Angular 2.0 but it is in the queue: https://docs.google.com/document/d/1q6g9UlmEZDXgrkY88AJZ6MUrUxcnwhBGS0EXbVlYicY/edit#heading=h.19ijfd7mxdt4 https://docs.google.com/document/d/1q6g9UlmEZDXgrkY88AJZ6MUr...
- jzelinskie 11y agoYou throw the term 'isomorphic' around a bunch in the descriptions of this project. It would be nice if the README explained what that meant. I know what an isomorphism is, but have no idea what this means in this context.
- mmmmrrrr 11y agoThey use the term isomorphic to mean that it is written in one language throughout the app. Typically, JS on the front and back end. They really should be saying something like isoglossic (not a Greek scholar here) to imply that it's in the same language, instead of isomorphic, which implies a lot more than what they intend.
- mambodog 11y agoIf you google 'isomorphic Javascript' you'll get a bunch of hits explaining this particular (ab)use of the word, here's a good one: http://nerds.airbnb.com/isomorphic-javascript-future-web-apps/ http://nerds.airbnb.com/isomorphic-javascript-future-web-app...
- Hobotron1 11y agoDoesn't work with JavaScript disabled. =P
- seba_dos1 11y agoThat's exactly the purpose one shouldn't use Angular for.
- criswell 11y agoHere is a Hacker News clone done with Vue: http://yyx990803.github.io/vue-hackernews/#/news/1 http://yyx990803.github.io/vue-hackernews/#/news/1 I find it easier to follow if you're looking around for alternatives.
- thrownaway2424 11y agoThe perfect indictment of Web development these days.
- trustfundbaby 11y agoAnd its better ... how?
- error54 11y agoIs everyone missing the point of this? It's a proof-of-concept app using an alpha[1] framework that, in a year or two, will likely be one of the dominant frameworks on the web. I for one find real examples like this much more useful than underwhelming "Todo"[2] examples. Yes, it's slow. Yes, it has lots of bugs but hell, at least the author is giving it a shot. I just hope they write a decent blog post about it with some of the lessons learned. 1- https://github.com/angular/angular/blob/master/package.json#L3 https://github.com/angular/angular/blob/master/package.json#... 2- http://todomvc.com/ http://todomvc.com/
- Geee 11y agoThis is a great example why you shouldn't use a client-heavy stack for a site like HN. You could, in theory, make something that's a bit better than original HN, but it requires way more work and/or quite possibly something else than Angular.
- bitwize 11y ago(gruff Solid Snake voice) The web... has changed.
- ralusek 11y agoTo people who are complaining that this is slow, please understand that 1. Doesn't have to do with Angular 2. Doesn't even have to do with a single page implementation I made a really shit take on a single page reddit client, and I'm sure you'll see that the browsing experience is actually quite nice (and much faster than using native reddit). This was written in Angular 1.3, and Angular 2.0 is MUCH faster. http://bredd.it.s3-website-us-west-1.amazonaws.com/ http://bredd.it.s3-website-us-west-1.amazonaws.com/ My point is that implemented correctly, even a content site like reddit or hackernews could work quite well with a single-page implementation. Don't blame Angular for this demo, its server responses are just impossibly slow
- EugeneOZ 11y agoIf author see result is slow and reason is not ng2, then don't publish it. Otherwise everybody will think ng2 is slow and in next article with click-catching-title this example will be taken as proof of some "sensational" statement. Nobody will read explanations - people more trust own feelings than explanations.
- emocakes 11y agoslow shit