• @[email protected]
    link
    fedilink
    623 days ago

    This is why I will never touch Javascript again. Long ago when I worked on web stuff, half my workflow was spent in the debugger tracing garbage to find where a typo was. The industry moved to Typescript, and now assuming the strictness checks are enabled, if some Typescript transpiles successfully, I can be 95% sure whatever fuckup I observe at runtime is a logic problem.

    Weakly typed languages were an awful idea. But in general, if the compiler isn’t able to detect most runtime issues (like with C++ here), it’s not going to be the most productive language to use for building solutions compared to smarter alternatives.

    • @[email protected]
      link
      fedilink
      English
      93 days ago

      I’ve thought about moving to typescript. Do you have suggestions for a 20+ year JavaScript dev?

      • @[email protected]
        link
        fedilink
        22 days ago

        I suggest against it. Just use JSDocs syntax and typescript (the CLI and VSCode checker) will check it. No need to use transcompiler anymore. It was more useful when JS itself was more ES5 based and CommonJS.

        Using something like esbuild will get you minification if you want it, but it’s only for deployment, not actually needed for runtime. Having pure JS code is much easier to work with and debug.

      • @[email protected]
        link
        fedilink
        163 days ago

        Try porting a very small bit of behavior into a new tiny library or module that is Typescript based and independently published. Enable the strictness checks in tsconfig - really, really resist the urge to use any, and enforce that any is disallowed in tsconfig. Familiarize yourself with its utility types that really trip new authors up. “Record” comes to mind here, and others that involve generics if you haven’t before worked with generics. Some of the type error messaging can be pretty obtuse - don’t be afraid to paste them into an LLM (or use Copilot enhanced Intellisense) to explain what it actually means. IMO the type violation messaging is a weak dev experience point for new authors, so don’t sweat it if you occasionally “struggle to make the squiggles go away”.

      • @[email protected]
        link
        fedilink
        73 days ago

        Just try it. You can usually convert a single file at a time. Start small (or even with a pet project)