6 ms·
Ask HN: What do you think about developing a web front with Vanilla JavaScript?
What do you think about developing a web front-end with Vanilla JavaScript to minimize performance issues?
I believe I have reached a certain level of success. The canvas seems to have excellent performance. Could you take a look at the ongoing test and provide feedback?
https://alpha.breathingworld.com/
- deleted 2y ago[deleted]
- satvikpendem 2y agoI think at the very least, TypeScript should be used.
- Farer 2y agoOf course, type safety is great, I understand that. But I want to know the detailed reason why. Why do you think it's so important?
- solardev 2y agoIt's a developer experience thing. Moves many bugs from runtime to coding time, letting you catch them preemptively and fix them right in the IDE without going through build cycles or hot reloads. You instantly know if something will break because of mismatched types. Probably doesn't matter much for performance. It all gets stripped away during build anyway.
- Farer 2y agoI've worked with various frameworks and libraries in the past, like Prototype, jQuery, AngularJS, React, and Next.js, but I think I've ultimately come to trust Vanilla JavaScript the most. Compared to developing with Vanilla, I noticed that using these tools often results in unnecessary code in the final product. As a side note, I was never really fond of jQuery, even when it first came out, and it ended up becoming almost obsolete. Lately, I'm also not entirely happy with the direction React and Next.js are heading. It could just be because I've grown so accustomed to Vanilla JavaScript.
- satvikpendem 2y agoThose frameworks are unrelated to TypeScript, as you can use TypeScript as a preprocessor for vanilla JS DOM operations.
- Farer 2y agoOkay. I think what I said might cause some misunderstandings. As I mentioned in another comment above, it seems to be because I don't like adding builds, compiles, issues, etc. that are not pure JavaScript. I also like TypeScript. It ensures stable development, right? There probably isn't anyone around you developing with vanilla JavaScript, is there?
- satvikpendem 2y agoWhy would there be? Everyone I know has migrated to TypeScript.
- Farer 2y agoAnd are you using React and Next.js these days?
- satvikpendem 2y agoI am but more so because I like them, there is no need to use them with TypeScript.
- Farer 2y agoNot a single exception? :)
- satvikpendem 2y agoHonestly, no, I haven't heard of anyone in my circle still using JS without TypeScript.
- 2y ago
- solardev 2y agoIMO I think this is pretty laggy once you zoom in, at least on my phone (Pixel 7 running Chrome). Switching zoom levels takes a long time to load the assets. The bunny has some temporary displacement relative to the background. Panning results in visible lag. I don't think vanilla is a magic performance pill. Everything compiles down to vanilla, after all, and in this case this app's performance seems quite a bit slower to me than Leaflet, OpenLayers, OpenSeadragon, Konva, Pixi.js, etc. I haven't looked at your code, but maybe it could benefit from tile-based rendering and asset virtualization? I also think if this is the extent of your desired usage (rendering graphics on a zooming panning canvas) you're reinventing a wheel that's already been invented, abandoned, reinvented, improved, forked, improved, rewritten a thousand times. Why do you want to? Just for fun? To make an even better one? To make a custom game or mapping engine? Those are all fine, it's just a lot of work with uncertain payoff vs using a ready made library (not necessarily framework). Just my opinion. I'm a lazy dev though.
- Farer 2y agoAh, the reason you feel it's slow is because the server is located in Seoul, Korea. You're probably not in Korea, which is causing some network latency. If you try adjusting the map to a single spot and wait for a moment without moving it around, you'll notice it runs more smoothly. I also want to mention that the map size is 245,760 x 138,240, which is exactly 128 times 1920 x 1080. I’ve managed to make that enormous map, along with the data for hundreds of thousands of weeds and countless rabbits, run smoothly without issues. It even works perfectly on mobile phones. If I get the chance, I'll integrate Kafka and set up servers abroad.
- solardev 2y agoYes, some of it may be network lag (asset prefetching can help) but some of it is also just UI jank that has nothing to do with the network. I wouldn't really call it smooth compared to an optimized mapping lib like the other ones. Have you done any benchmarking by FPS, or even just noticing what happens visually when you pan (things blink in and out of existence, for example). Keep in mind that it's already more optimized than any code I could write on my own (kudos!), just not as smooth as the big solutions. If you don't want to use them, more power to ya! Just providing one opinion because you asked for it. Not necessarily trying to convince you to do it differently if you don't want to. Typically people will have made up their minds already anyway, lol.