4 ms·
Of 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?
by Farer 2y ago
Of 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.
- solardev 2y agoYou're kinda preaching to the choir here on HN, where many people feel the same way (not me personally, but generally speaking). That's fine, you can still use Typescript with vanilla JS and not use any frameworks. Typescript shouldn't result in unnecessary code in production. It's just developer hinting during dev, but it gets removed during the build. If you don't want to use a build tool at all, you can also use JSDoc formatting to provide some basic type and parameter information. Your IDE can still use that to provide hints. It's totally up to you. If it's a solo dev codebase that only you ever see and you don't want to type it, then don't :) If you do end up wanting to share the code though, Typescript makes it a lot easier for other devs to use because they can instantly see when something is wired up wrong during development.
- Farer 2y agoI totally get what you mean. I'm also someone who finds compiling or building unnecessary when running JavaScript in the browser. It feels like we end up studying and dealing with issues that aren't directly related to actual development. I really like TypeScript as well. In fact, the back-end of this project is developed with .NET 8.0, and since TypeScript gives off a similar vibe to C#, I genuinely enjoy using it. I've already made the web front-end open source: https://github.com/Farer/breathingworld_client_web https://github.com/Farer/breathingworld_client_web Even though I’m using Vanilla JavaScript for personal preference and to minimize performance issues, I’ve also been concerned about potential challenges when collaborating with others in the future. I’m currently looking for collaborators, but it hasn’t been easy. Honestly, I might be going against the trend, but that’s a possibility I’m aware of.
- wruza 2y agoIf you wanna try ts frontend with no friction, start with Vite, a modern dev and build tool for frontend. It’s mostly zeroconf, everything just works.
- Farer 2y agoOh, I briefly looked over Vite but haven't actually used it yet. This is a good opportunity to seriously take a look at it. Is the final HTML and JavaScript code generated clean and without unnecessary bloat? As always, minimizing the resources that a first-time visitor has to download is one of my main goals as well.