• 0 Posts
  • 140 Comments
Joined 1 year ago
cake
Cake day: July 2nd, 2023

help-circle



  • Yes, it’s still a transpiler, I’m not saying it isn’t, but what I mean is that it doesn’t add any functionally specific to the typescript language. There’s a transpiler for TS that doesn’t even do any type checking at all and just does the type stripping and back porting. But of course, that’s not why people use typescript. All the features that are actually important to typescript could be done through a linter instead. If type annotations were added to JavaScript you could get most of typescript’s features with linting rules and just handle back porting in a more standard way.










  • Why would you not want to be using a rendering library? Your code is basically storing your application state in the dom which will turn into a horrible mess as soon as you reach any actual level of complexity. I know first hand. I’m traumatized from having to maintain large jquery code bases in the 00s. No serious professional writes code like this anymore.

    Also, your vanilla code isn’t modern. It should look more like this:

    document.querySelector("#element").classList.toggle("hidden")
    

    I could see not wanting to use a rendering library if you’re building a simple site on top of basic static HTML, but that’s not a serious discussion for industry professionals, and even still, jQuery is such a heavy dependency for saving some characters. If you find yourself using it so much you need the extra convenience then your site is already complicated enough that you should be using a rendering library with state management instead.




  • I feel like there’s no typescript drama, just JavaScript drama. Things are pretty happy in the TS community. I’ve been writing js code since it literally first came out. I’m definitely no js hater. In the early days js code bases quickly turned to spaghetti code, but I genuinely think the js community has done miracles turning what was essentially a super simplistic toy language into a seriously good production quality language. I’ve seen first hand how much work has gone into it, and while most of the js community has been great with embracing change for the better, there’s always been the niche of detractors against any change that adds complexity even when it makes coding safer and more productive.

    I’ve always had a love hate relationship with JavaScript, but with typescript it’s really been just straight up love. Pretty much all the trouble I have with typescript has been due to external libraries that use types lazily or incorrectly, and even then there are solutions to add safety to your own codebase. Sometimes I run into some trouble with the type system itself, but it’s pretty much always because I’m doing something really complicated that would be hard in any type system. I’ve been working with typescript for years now and my code bases are some of the most solid ones in my company. Typescript is really safe as long as you’re actually using it and not telling the compiler to ignore types through using any or making unsafe assertions.

    It makes no difference to me if other people prefer JavaScript. Any important js library will get ts support anyways through definitely typed, and if a library is so sloppy it can’t be typed well then it’s not a good library to use anyways. Having people proudly announce they only want to use JavaScript is also great for hiring. It easily tips me off on who not to hire.


  • I really don’t get how people can feel more productive in JavaScript. With typescript the code practically writes itself. Sometimes when refactoring I’ll change a functions input and output signature and just fix compiler errors until it stops complaining, and the code just works without me having to really even think about what the code is doing.

    Any time I’m forced to go back to js I feel like I’m going crazy trying to keep track of what’s in all the variables. With typescript I can use more powerful object structures without having to constantly double check where they came from.


  • The transpilation that typescript does doesn’t really have anything to do with typescript, it’s just there because typescript wants to support the latest ecmascript features, so transpilation is necessary for that, but technically you could simply strip out the type info and have another transpiler like babel handle the backwards compatibility. I think there are a few minor exceptions to that, like enums. There was even a proposal to add some typescript types to native JavaScript that would be ignored by the interpreter and just act as comments.


  • I’ve used JavaScript since its creation. I would describe typescript as JavaScript as it should have been. I’ve always actually liked JavaScript’s simplicity, but I’ve never liked its lack of type safety. At its core, JavaScript has a tiny conceptual footprint, and that’s actually pretty refreshing compared to other very complicated languages. But it was plagued with terrible implementations and the inherent messiness of dynamic typing. I’ve watched it evolve over the years and it’s improved beyond my greatest hopes. Between the advent of transpilation, tooling, and typescript, I’m very proud of where the language has gotten to. Having made websites in the 90s and 00s, I feel like people don’t realize how much work has gone into getting the ecosystem in a much better place.


  • Typescript doesn’t have strong typing but static typing still gets you really really far. It means you need to be more careful with your io and avoid dangerous type assertions, but I don’t think that’s a bad thing. Having used typescript an absolute ton, the only real jank I’ve encountered is from bad library typings that either use it lazily or incorrectly, but for code bases that use it through and through it has been smooth sailing, and having professionally used both traditional static typed languages and dynamically typed languages, I really enjoy typescript’s type inference and structural typing. I think you should give it an honest try before judging it. But that’s just my 2 cents as an industry professional who has used many languages and have been programming for decades for what it’s worth.