| ▲ | sureglymop 2 days ago |
| A somewhat related thing programmers must understand is that whether you write typescript, JSX, .astro or .svelte files, you are technically not writing JavaScript. You should occasionally look at the build artifacts of your framework but also ask yourself whether it is worth it to write code that may not represent what actually ends up being executed. Lately I just use vite with no starter template but with web components and css modules. It at least feels more convenient than using any framework or library. |
|
| ▲ | wvenable a day ago | parent | next [-] |
| This seems like an issue but in all my practical experience it really isn't. TypeScript becomes JavaScript with the types removed. Then you tree-shake, minify, and whatever is executed is no where near what you actually wrote but at the same it totally is the same because that's no different than any other compilation process. Occasionally, I have to remember that JavaScript has no types at runtime but it's surprisingly not that often. |
| |
| ▲ | sureglymop a day ago | parent [-] | | I mean what makes it more acceptable is that you have HMR and instant preview during development. So, all the transformations and bundling aside, you do see how it runs during development. However I have been in a few situations at work where all of a sudden we did have issues that required us to dig deeper. There were also some bundling related issues that caused problems in production deployments. At that point many co workers had no idea how to even approach it to be honest. | | |
| ▲ | wvenable a day ago | parent [-] | | I've had similar experiences with compiled languages in one form or another throughout my career as well. I don't think JavaScript is particularly special that we need to call it out for things like TypeScript, minification, or bundling. |
|
|
|
| ▲ | umanwizard 2 days ago | parent | prev | next [-] |
| > ask yourself whether it is worth it to write code that may not represent what actually ends up being executed. Doesn't this describe every programming language? When you write C, you are technically not writing machine code. Even when you write JavaScript, what actually gets executed is V8 bytecode and/or machine code (depending on whether the JIT fires). |
| |
| ▲ | sureglymop 2 days ago | parent | next [-] | | That's correct, however I would say there is a small difference in that most of this code still seems just like JavaScript, sometimes it even feels as though it is JavaScript running in the same context when it then gets compiled to run on server/client. I think the point I'm trying to make is that this can be confusing or even dangerous especially for new developers. It just doesn't hurt to actually look at the Vite plugins transforming it all to understand it instead of making assumptions if we work with it on the daily. | |
| ▲ | vlovich123 2 days ago | parent | prev [-] | | Yeah it’s a silly line of reasoning. The transformations of TS -> JS are a lot smaller and simpler than C-> asm / machine code; it’s basically just removing type annotations. Now minification and optimization can make the output a lot more terse, but that can be done for JS too. And it’s not as complicated and detached from the source as an optimizing compiler is. | | |
| ▲ | sureglymop 2 days ago | parent [-] | | Let's not act like it's the same thing. I'm not strictly talking about just Typescript, I'm saying that if you work with these technologies every day it would be wise to go look at their Vite plugins to see how they transform your code and be sure to understand it. It's nice to have magic but it's nicer to use the magic if we have demystified it first. And I don't know about you, but I occasionally do open compiled ELF files in a hex editor and I certainly did at first when I was learning more. That's a good practice also. |
|
|
|
| ▲ | kaufmann 2 days ago | parent | prev [-] |
| Aren't you loosing a lot of the declarative features like signals or similar, when you do your projects without those frameworks? (asking to learn) |
| |
| ▲ | sureglymop 2 days ago | parent [-] | | Somewhat. I could still use framework agnostic state management libraries/patterns and most are (e.g. svelte signals, jotai, zustand, etc.). I've even used Proxies directly to implement some reactivity before. However as for the "declarative" parts, I think it's just a little bit of a different way to work but you get used to it and imo it pays off. Knowing the web APIs should be a requirement anyway and it doesn't hurt to work with them directly as much as possible. |
|