• @mark@programming.dev
    link
    fedilink
    14
    edit-2
    2 years ago

    I like TypeScript for its types and type-checking, but I also want to write JavaScript to avoid having a local build step, and having to wait for things to transpile/compile/etc when running locally. I have a pretty large project where I’ve gotten both worlds by just using JSDoc and only using TS for type-checking. VSCode still offers built-in type-checking with JSDocs and ofc the type-checking can also be run separately if needed.

  • @ObsidianBlk@lemmy.world
    link
    fedilink
    282 years ago

    My issue with typescript… and, correct me if I’m wrong… is it doesn’t exist without Javascript. Typescript needs to be compiled down into Javascript to be run. It has no stand alone interpreter (that I’m aware of) and definitely not one baked into web browsers or NodeJS (or adjacent) tools. In essence, Typescript is jank sitting on top of and trying to fix Javascript’s uber jank, simultaneously fracturing the webdev space while not offering itself as a true competitive and independent language for said space.

    That’s my amateur two cents for what it’s worth.

    • @fidodo@lemm.ee
      link
      fedilink
      1
      edit-2
      2 years ago

      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.

    • @DogMuffins@discuss.tchncs.de
      link
      fedilink
      English
      32 years ago

      I agree.

      I’m a hobbyist. I don’t work on really large or complex projects. I just want to get the most productivity for my spare-time-dabbling and having tried a few times to get into typescript it seemed to create more “extra steps” for me than it saved.

    • @brian@programming.dev
      link
      fedilink
      142 years ago

      I don’t think it really fractures anything considering you can call a ts package from js without knowing. The other way also works with third party typings in DefinitelyTyped.

      It really just adds a bit of extra type info into js, looks like js, and transpiles into js that looks almost exactly like the input, including comments and spacing and such if you like, so there isn’t any lockin.

      There isn’t any competition, it’s just an extra optional tool for the js ecosystem in my eyes.

      • @fidodo@lemm.ee
        link
        fedilink
        12 years ago

        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.

        • @brian@programming.dev
          link
          fedilink
          12 years ago

          I mean, tsc without any of the backporting functionality is still a transpiler since it goes from a high level language(ts) to another high level language(js). Transpilation as a concept doesn’t imply that it is for backporting language features or that the source and destination languages are the same, just that it is a transformation from source code to a similar or higher abstraction level language source code

          • @fidodo@lemm.ee
            link
            fedilink
            22 years ago

            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.

      • shastaxc
        link
        fedilink
        -12 years ago

        I think too many people ITT are conflating Typescript with Typescript frameworks like Angular.

    • SokathHisEyesOpen
      link
      fedilink
      English
      112 years ago

      As a professional with 25 years of experience I agree with you. The entire modern architecture was created by people who don’t like simple things that work. I’m pretty sure there are a couple of high ranking master developers sitting at the head of W3C competing to create the most convoluted system possible.

    • @JakenVeina@lemm.ee
      link
      fedilink
      232 years ago

      The fact that TypeScript doesn’t attempt to obfuscate JavaScript, and just fills in the gaps, is what makes it the best solution to the problem.

      It’s not a separate language, it’s Javascript tooling

      • @fidodo@lemm.ee
        link
        fedilink
        32 years ago

        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.

    • @madcaesar@lemmy.world
      link
      fedilink
      102 years ago

      You are correct.

      That says I would never ever EVER start a project without TS.

      It’s like coding with hands vs coding with your elbow.

      • EarMaster
        link
        fedilink
        32 years ago

        I also don’t want to compile my C++ code myself. I’m pretty happy with letting a compiler do it’s job…

      • @fidodo@lemm.ee
        link
        fedilink
        1
        edit-2
        2 years ago

        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.

    • LittleLily
      link
      fedilink
      English
      92 years ago

      Just fyi, while they don’t help with running TS in the browser, the Bun and Deno runtimes both natively run TS without any compilation.

      • @severien@lemmy.world
        link
        fedilink
        22 years ago

        That’s not true, deno compiles TypeScript to JavaScript, it just does it transparently. The code still runs on v8.

        • @brian@programming.dev
          link
          fedilink
          12 years ago

          V8 also doesn’t run js, it does some byte code compilation stuff amongst other things, then interprets that. But that’s all a bit pedantic too, V8 runs js, deno runs ts.

          fwiw https://deno.com even has as one of their first bullet points that they have “native support for TypeScript and JSX”

  • @tram1@programming.dev
    link
    fedilink
    222 years ago

    I’m kind of a beginner… Can someone explain why you would make/use/have a dynamically and/or weak typed language? Is it just to not write some toInteger / as u64 / try_from()? I mean the drawbacks seem to outweigh the benefits…

    • @Knusper@feddit.de
      link
      fedilink
      62 years ago

      They used to be more attractive around the 2000s, before type inference became commonplace and when IDEs/editors were still a lot less powerful.

      As for making a dynamically typed language, to my knowledge, they are actually easier to create than statically typed languages…

    • @Lmaydev@programming.dev
      link
      fedilink
      12
      edit-2
      2 years ago

      If you are writing small and simple apps it will give you more velocity and much less boiler plate.

      As apps grow it becomes harder to keep track of things and can quickly grow into a mess. You then start to need external tools to give you the features of a strong static type system.

      Also from a web point of view you don’t want the website to crash and burn with every error. JS will power through things like invalid types. Imagine if any error caused the website to just stop.

        • @Lmaydev@programming.dev
          link
          fedilink
          32 years ago

          The fact it doesn’t need to be compiled is also a big reason why it’s used on the web.

          But I absolutely agree. I’m not a fan of dynamic typing at all.

        • Nerd02
          link
          fedilink
          English
          142 years ago

          There’s no real alternatives to JS “for websites” (meaning on the frontend, the part of your code that gets executed on your client’s browser). That’s what JS was invented for and what it does best.

          I say “no real alternative” because technically we also have WebAssembly, which is a tool that allows you to run code written with any language on the web, but if you indeed are a beginner approaching to web development you should just forget about this for now and stick to JS as you learn.

          Of course this doesn’t mean that you can’t use Python on your backend, your server.

          • @rederick29@sh.itjust.works
            link
            fedilink
            English
            62 years ago

            Why should beginners approaching web development stay away from WASM? I’ve used it a few times to create online demos of software I made in Rust and it was a very simple and painless experience to get it working in a website. I consider myself a beginner and I have not run into any issues with it so far.

            • @CodeBlooded@programming.dev
              link
              fedilink
              8
              edit-2
              2 years ago

              WASM is simply further down the rabbit hole for someone who is new to programming (but not someone who’s already a programmer and just doesn’t focus on web dev today). You are likely far less beginner than you think if you’re making decisions like “I’m going to compile my software written in Rust targeting WASM so I can demo it.”

    • qaz
      link
      fedilink
      02 years ago

      I prefer using JS because I can see the errors, while having to figure out which part generated the problematic JS code with errors when using something else.

    • @noli@programming.dev
      link
      fedilink
      222 years ago

      The typical arguments for a dynamic typed language are that it takes less time to write something in it.

      The benefits of static typed languages are that your development environment can be a lot smarter (ironically enough leading to faster development speed) and several classes of bugs being unable to happen. In a statically typed language, the IDE can detect if you’re trying to call a function that takes a number but you’re actually providing a string. In this case the IDE will let you know and you can immediately fix silly mistakes like that.

      • Not OP, but generally the arguments I’ve been told are:

        Microsoft is an abomination (true).

        “Don’t make me explicitly state types; it is too confusing!” Installs 20 libraries including fucking pad left to eek out basic functionality.

        Strongly typed haters are right up there with curly brace haters.

        • @seitanic@lemmy.sdf.org
          link
          fedilink
          2
          edit-2
          2 years ago

          Microsoft is an abomination (true).

          Reflexive MS hatred is just as dumb as any other kind of reflexive hatred. TypeScript is free and open source, so what’s the danger?

  • @kewjo@lemmy.world
    link
    fedilink
    82 years ago

    javascript but more for philosophical reasons. when projects use typescript they always get focused on writing more scripts rather than optimizing HTML/CSS. Too many times I’ve seen overly complex scripts trying to solve what a properly arranged div and css tag have already solved.

    • I’ve been dealing with this at my job because a layout library was deprecated and is used throughout our codebase instead of proper css. Came to learn that my whole team doesn’t like/know css, so they used this library that used angular directives in the html instead. We had multiple giant scripts for arranging elements in a grid that changed based on screen width

      • parrot-party
        link
        fedilink
        2
        edit-2
        2 years ago

        There are some cases where this is a serious issue that can’t be solved through pure CSS. Once container units are finally approved though, that will solve quite a few problematic layout issues in CSS.

    • z500
      link
      fedilink
      English
      32 years ago

      I’ve been designing CPUs and writing machine code and assembly for the last month and it’s been a blast.

  • @satrunalia44@lemmy.world
    link
    fedilink
    62 years ago

    I prefer JavaScript personally, but it’s time to acknowledge that TypeScript has won. If you want to contribute and succeed as a developer in the JS ecosystem, you need to learn TS, like it or not.

    • @severien@lemmy.world
      link
      fedilink
      0
      edit-2
      2 years ago

      Unpopular opinion: I hope it’s going to be a flop (apart from the few use cases where it does make sense). The limitation of having just JavaScript ensures level of interoperability which is IMHO one of the big advantages of web as an application platform. If WASM becomes successful, it will fragment the web.

    • @iegod@lemm.ee
      link
      fedilink
      132 years ago

      And then there’s me, missing flash :(

      Flash and AS3 was so much fun to work in. I completely understand why the industry moved away from it but even today we have yet to fully catch up to all the media animation and programmatic features it provided all in one. RIP.

      • @Knusper@feddit.de
        link
        fedilink
        72 years ago

        You can have frameworks which fully generate the JS DOM code for you, allowing you to write complete single-page applications without writing a single line of JS.

        • @float@feddit.de
          link
          fedilink
          52 years ago

          I’m using the leptos framework (Rust) and really like it so far. Not a single line of JS, not even npm as a dependency in that project.

          • @Knusper@feddit.de
            link
            fedilink
            22 years ago

            Yep, that’s the framework, I’m using, too. But most frameworks in the Rust ecosystem can do DOM interop, as the heavy lifting for that is provided by the wasm-bindgen library.