• jpeps@lemmy.world
    link
    fedilink
    arrow-up
    113
    arrow-down
    5
    ·
    1 year ago

    What Typescript drama is there? It’s fantastic. It’s been an industry standard for years. In my anecdotal experience the only people that hate it are juniors who did pure JS at their bootcamp and seniors that have refused to learn anything for the last 5 years.

    • Fluffysquash@lemmy.ml
      link
      fedilink
      arrow-up
      75
      arrow-down
      1
      ·
      1 year ago

      DHH (guy who founded Ruby on Rails) ripped typescript out of a supporting library and swapped it for JavaScript. He did it in his typical fashion of not allowing discussion and being a dick (PR only open for a couple hours and then merged disregarding all the negative feedback about the change) . So people are mad at him again.

      He does stupid shit like this all the time because he’s a fucking knob.

      • jpeps@lemmy.world
        link
        fedilink
        arrow-up
        43
        ·
        edit-2
        1 year ago

        RoR will always have a special place in my heart, but yeah… DHH sure does have opinions. What possible justification is there for removing it when it’s already there? Guess someone could just shift the types out to DT.

        Edit: So I read his blog post about it. He’s dropping it because he just doesn’t like it and he’s allowed to not like it. Okay then 🤷

        • zebbedi@lemmy.world
          link
          fedilink
          arrow-up
          18
          arrow-down
          1
          ·
          1 year ago

          His blog to me sounds like he did it because it was too difficult for him to understand a few errors. Says it all.

            • zebbedi@lemmy.world
              link
              fedilink
              arrow-up
              9
              arrow-down
              1
              ·
              1 year ago

              You only have to read the PR comments with people asking how you know if something is optional when there is absolutely zero jsdoc to know it was idiotic.

        • Pipoca@lemmy.world
          link
          fedilink
          arrow-up
          4
          ·
          1 year ago

          From his blog post:

          While you may compile dialects into it, you still have to accept the fact that running code in the browser means running JavaScript. So being able to write that, free of any tooling, and free of any strong typing, is a blessing under the circumstances.

          By his logic, JS linters are bad because they’re tooling that restricts your access to all of Javascript. But linters mean you don’t have to read PRs with a fine tooth comb to make sure there’s no footguns like using == instead of ===.

          Also, you could use that same logic to advocate for writing JVM bytecode directly instead of Java/Kotlin/Scala/Clojure/etc.

          The question is really whether tooling pays its way in terms of lower bug rates, code that’s easier for coworkers to read, and code that’s easier to reason about.

      • EnderMB@lemmy.world
        link
        fedilink
        arrow-up
        9
        arrow-down
        1
        ·
        1 year ago

        As a general rule, if DHH says something, the opposite probably has some true merits.

    • fusio@lemmy.world
      link
      fedilink
      arrow-up
      25
      arrow-down
      1
      ·
      1 year ago

      or people used to work alone never having to go back to their code (e. g. bad consultancy jobs)

      • jpeps@lemmy.world
        link
        fedilink
        arrow-up
        21
        arrow-down
        2
        ·
        1 year ago

        Even alone I find it indespensible. I find it’s mainly useful for writing code correctly the first time around.

        • fkn@lemmy.world
          link
          fedilink
          arrow-up
          2
          arrow-down
          3
          ·
          1 year ago

          Some people think better with typing information explicitly written out. Some people don’t. In my opinion it is a creativity thing. Some people like to make art that is photo realistic, some people like to make abstract art.

          I understand both viewpoints. In my free time I vastly prefer late bound, dynamically types languages with robust reflection engineers built into their interpreters. For work, I heavily prefer late bound, strictly typed with reflection optional or minimal.

          Different people think differently.

          • jpeps@lemmy.world
            link
            fedilink
            arrow-up
            2
            ·
            1 year ago

            I think that’s fine if that’s how you like to work on your own, but I’d challenge anyone to do that and write better documentation while also getting a team or whole business to do the same. A huge strength of TS is that it gives people no choice but to document their work.

            • fkn@lemmy.world
              link
              fedilink
              arrow-up
              2
              ·
              1 year ago

              I didn’t say JavaScript… and I certainly wouldn’t choose TS for a personal project because I personally feel that its organization is terrible but I would choose TS over vanilla js for work projects because it does produce better group work and is easier to maintain long term because of the structure imposed on it.

      • fidodo@lemm.ee
        link
        fedilink
        arrow-up
        4
        ·
        edit-2
        1 year ago

        TS is amazingly powerful when it comes to refactoring. I swear it practically writes itself. Half the time by the time I fix all the compiler errors the refactoring is done. I barely need to think about it which means I can spend more time thinking about the best architecture. When people say they don’t see how TS makes you more productive it just makes me think they never refactor their code.

    • beeb@lemm.ee
      link
      fedilink
      arrow-up
      14
      arrow-down
      1
      ·
      edit-2
      1 year ago

      Svelte decided to ditch it because it became impractical due to the compilation step slowing down development and making debugging their compiler harder. I think for libraries it makes sense to go the jsdoc way as long as consumers can choose typescript.

      • marcos@lemmy.world
        link
        fedilink
        arrow-up
        9
        arrow-down
        2
        ·
        1 year ago

        Am I the only one scratching my head trying to understand why Svelte supported it at the first place?

        The TS type system is not a good match for the project.

    • fidodo@lemm.ee
      link
      fedilink
      arrow-up
      3
      ·
      1 year ago

      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.

      • jpeps@lemmy.world
        link
        fedilink
        arrow-up
        4
        ·
        1 year ago

        I can understand that. Does it’s open source status not change anything for you?

        • Knusper@feddit.de
          link
          fedilink
          arrow-up
          2
          arrow-down
          4
          ·
          1 year ago

          If it’s dumped under an open-source license, but still developed exclusively by one corporation, they can swap out that license pretty easily.

          • jpeps@lemmy.world
            link
            fedilink
            arrow-up
            2
            ·
            1 year ago

            For what? If they took it away, the source code would still be there if someone wanted to fork it. Not to mention removing TypeScript from an application is relatively trivial.

            • Knusper@feddit.de
              link
              fedilink
              arrow-up
              2
              arrow-down
              2
              ·
              1 year ago

              They’re not that dumb, to just pull it completely. That would obviously result in a successful fork.

              Companies usually start with e.g. the BUSL, so source-available but proprietary restrictions.
              For TypeScript/Microsoft, I could imagine some variation of their EEE playbook.

              But really, the whole point of avoiding Microsoft et al, is that I don’t want to think about, how they could fuck this whole thing up. They’ve proven quite creative in this regard for as long as they’ve existed.

      • marcos@lemmy.world
        link
        fedilink
        arrow-up
        4
        ·
        edit-2
        1 year ago

        Incredibly powerful type system λλλ

        And the best part, those two interop better than in native code.

          • marcos@lemmy.world
            link
            fedilink
            arrow-up
            2
            ·
            1 year ago

            The wasm ABI allows for a bit more flexibility than the C one.

            I’m not sure how much impact it has on practice (probably very little, otherwise somebody would have fixed it), but in native code there’s a lot of potential for mismatching behaviors from the two different runtimes.

    • redcalcium@lemmy.institute
      link
      fedilink
      arrow-up
      13
      ·
      1 year ago

      You can even compile Fortran code to wasm and run it on a web browser. Who need Javascript’s puny 64bit floating point precision when you can have Fortran’s superior 128bit floating point precision?

      • Knusper@feddit.de
        link
        fedilink
        arrow-up
        10
        ·
        1 year ago

        No, but GUI frameworks can generate it for you. Same goes for DOM access, for which there’s normally only a JavaScript API.

        So, you’ll likely want to read JS, when researching what events or properties you can read/write for certain HTML nodes in the DOM, but with a mature GUI framework, you should not need to write any JS.

  • Deleted@kbin.social
    link
    fedilink
    arrow-up
    63
    arrow-down
    2
    ·
    1 year ago

    I’d rather stay out of the frontend all together but I’d rather chop my balls off than go back to JS.

  • hblaub@programming.dev
    link
    fedilink
    arrow-up
    55
    arrow-down
    1
    ·
    1 year ago

    TypeScript of course. The compiler often times catches mistakes in variable names, API methods, whatever. So it saves time by not having to run the whole application all the time. Also the input help is much better, when the editor knows sth is a string or a number, for example.

    • o_d [he/him]@lemmygrad.ml
      link
      fedilink
      arrow-up
      8
      arrow-down
      1
      ·
      1 year ago

      Oh yeah. Or when it’s a union of multiple strings or an enum and you get that sweet popup of all your options. So good 🥹

      • fidodo@lemm.ee
        link
        fedilink
        arrow-up
        5
        ·
        1 year ago

        And being able to use more complex object types like discriminated unions without having to constantly look up what’s in them!

  • TheHarpyEagle@lemmy.world
    link
    fedilink
    arrow-up
    41
    ·
    edit-2
    1 year ago

    Honestly, as a mainly backend dev wanting to do more full stack, webdev is frustratingly intimidating. I keep trying to look up best practices but there’s so little in the way of consensus. “Use JQuery, no use Vue! React is better, but also React is clunky and bad. Write pure js, no don’t that’s a waste of time, at least use typescript.” It’s all such a mess and I spend so long trying to figure out what to use. I’m trying to just pick something and stick with it, but I keep worrying that I’m not doing things the best way.

    • 9point6@lemmy.world
      link
      fedilink
      arrow-up
      19
      arrow-down
      3
      ·
      edit-2
      1 year ago

      I’d agree with you if you were saying this about 8 years ago, but IMO the post-jQuery-front-end dust has settled and the “best” (in terms of what most organisations end up choosing) hasn’t really changed in a while.

      • Typescript unless you’ve got a really good reason not to.
      • React if you have anything remotely complex.
      • Webpack (or one of the wrappers) to bundle it up.

      Sure, someone may like a React alternative, and that’s completely fine. But at the end of the day, most companies are using React because it’s basically industry standard at this point, and it’s got too much momentum behind it for that to change any time soon.

      I’d say the back end is where all the choice is these days

        • railsdev@programming.dev
          link
          fedilink
          arrow-up
          1
          arrow-down
          1
          ·
          1 year ago

          Ha! Webpack. I ripped that shit out as soon as import maps were added to Rails; I cut my Docker image size by 50% and kissed Node goodbye.

      • fidodo@lemm.ee
        link
        fedilink
        arrow-up
        2
        ·
        edit-2
        1 year ago

        Maybe I’m just too used to it, but with next.js static site generation I find react to also work really well for simple sites too. If you’re not dealing with state, react is basically just functions that return templated html. IMO it’s pretty sleek for static websites since tsx let’s you do basic templating with functions.

      • Strawberry@lemmy.blahaj.zone
        link
        fedilink
        arrow-up
        2
        ·
        1 year ago

        We must be in different organization circles because almost every frontend I’ve seen at my jobs or those of my friends at other organizations uses Angular

        • Phen@lemmy.eco.br
          link
          fedilink
          arrow-up
          4
          ·
          1 year ago

          I’ll be honest, I think it’s been years since I last saw anyone even mention Angular anywhere.

    • Kuresov@programming.dev
      link
      fedilink
      arrow-up
      7
      ·
      1 year ago

      As a previously front-end gone full-stack gone and settled in backend/infra… don’t bother. But if you have to bother, or really, really want to 🙂, pick a relatively popular thing (e.g. Vue), and learn that, ignore the rest. By the time you come up for air the new hotness will have changed anyways, and the wheel will have been reinvented twice. It’s a moving target, just learn the fundamentals with something and you’ll be good to go.

    • AVengefulAxolotl@lemmy.world
      link
      fedilink
      arrow-up
      6
      ·
      1 year ago

      If you just want to try frontend, not trying to get a job there are these frameworks you should try:

      • Solidjs (love it so far) for a web application so SPA with separate backends
      • htmx to have a decently interactive website, it can be integrated with any webserver
      • astro for generating static sites

      And i think everyone should use either Typescript or JSDoc for any bigger application.

      • beeb@lemm.ee
        link
        fedilink
        arrow-up
        6
        ·
        1 year ago

        Svelte is a happy middle ground between vue/react and SolidJS which is maybe too bleeding edge still

        • AVengefulAxolotl@lemmy.world
          link
          fedilink
          arrow-up
          4
          ·
          1 year ago

          Agreed on the svelte part.

          But I think solidjs has a real chance of taking over React, because its similar, meaning JSX and hooks, but without the footguns. After using React, its so much cleaner and easier to work with, i cannot recommend it enough.

          • dubbel@discuss.tchncs.de
            link
            fedilink
            arrow-up
            2
            ·
            1 year ago

            Thanks for recommending it, it does look really nice. I’ll definitely check it out when a fitting project comes along.

    • aubertlone@lemmy.world
      link
      fedilink
      arrow-up
      5
      ·
      1 year ago

      For sure don’t use jquery.

      React is industry standard, but not my favorite. That being said, even my personal projects I do in react. I’m happy with my current role, but if I wanna switch down the line there’s less openings for a dev with mostly Svelte (my favorite framework) experience.

      • TheHarpyEagle@lemmy.world
        link
        fedilink
        arrow-up
        3
        ·
        1 year ago

        Right now I’m working on a personal project with Vue because it happened to be the one I was hearing most about when I started. I’ve got one project that I’m definitely gonna finish at some point started in react, so maybe I’ll try out svelte on my next project.

    • icesentry@programming.dev
      link
      fedilink
      arrow-up
      5
      arrow-down
      1
      ·
      1 year ago

      The main issue is that frontend is complicated and it can do a lot of very different things. Frameworks exist to solve some issues that may or may not exist in your project.

    • haruki@programming.dev
      link
      fedilink
      arrow-up
      4
      ·
      1 year ago

      Wait until you meet “Platform Engineering”/DevOps. The sheer amount of CNCF projects and new tools out on a daily basis are on par with the JavaScript world.

        • SnowdenHeroOfOurTime@unilem.org
          link
          fedilink
          arrow-up
          2
          ·
          1 year ago

          Do you need to support 15 year old browsers? Practically all the jQuery features I used (which was a lot) are now available in standard js

          • fidodo@lemm.ee
            link
            fedilink
            arrow-up
            3
            ·
            1 year ago

            Even if you do, you can still use most modern js features with transpilation.

          • severien@lemmy.world
            link
            fedilink
            arrow-up
            1
            ·
            1 year ago

            Yes, the features are there. Just the API is still horrible.

            As an example, make a hidden element visible (extremely common imperative operation).

            jQuery:

            $("#element").show();
            

            Native JavaScript:

            document.getElementById("element").style.display = '';
            

            I hope you’d agree that the native JS is certainly not an example of good API.

            • fidodo@lemm.ee
              link
              fedilink
              arrow-up
              2
              ·
              1 year ago

              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.

              • severien@lemmy.world
                link
                fedilink
                arrow-up
                1
                ·
                edit-2
                1 year ago

                Why would you not want to be using a rendering library?

                Because it’s just not very useful in some contexts. I’ve seen web extensions which mostly query the current page, and it doesn’t render much or even anything.

                Not all pages are SPAs either. Many apps are the old request-response with some dynamic behavior sprinkled on top. jQuery covers that well.

                This model is also quite compatible with the rising HTMX where the state/rendering is driven from backend and you just insert few dynamic pieces with JS.

                document.querySelector(“#element”).classList.toggle(“hidden”)

                There’s no difference between document.querySelector("#element") and document.getElementById("element"), they’re both same level clunky.

                Also, what you wrote is not functionally identical. $el.show() is idempotent, the el.toggle("hidden") is not (as the name suggests, it toggles a class). It also needs an extra boilerplate class.

                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

                There are plenty of non-professionals doing web stuff and I think it’s great!

                jQuery is such a heavy dependency for saving some characters

                jQuery is 24 KiBs (minified, gzipped), that’s a good price for the egonomics it provides. If you’re constrained, there are API-compatible alternatives like cash which go down to 6KiBs.

            • SnowdenHeroOfOurTime@unilem.org
              link
              fedilink
              arrow-up
              3
              arrow-down
              1
              ·
              1 year ago

              That’s actually a great example of the shortcomings of jQuery. There are multiple ways to hide an element yet they standardized on one that often wouldn’t work.

              Also you’re using an ancient method getElementById… I think visuals should still be controlled with css. So what is the right way to do that in modern js? document.querySelector(‘.some-name’).classList.add(‘hidden’) with that class defined in the css, with whatever makes sense, including maybe a css transition.

              • severien@lemmy.world
                link
                fedilink
                arrow-up
                1
                ·
                edit-2
                1 year ago

                There are multiple ways to hide an element yet they standardized on one that often wouldn’t work.

                It’s the most common one. And it’s not like you can’t hide the element with some other mechanism with jQuery.

                Also you’re using an ancient method getElementById…

                And? What’s the difference from document.querySelector() when querying for ID?

                So what is the right way to do that in modern js?

                What is the right way is context dependent. I don’t see how having extra .hidden { display: none; } boilerplate is somehow modern or superior.

                • SnowdenHeroOfOurTime@unilem.org
                  link
                  fedilink
                  arrow-up
                  2
                  ·
                  edit-2
                  1 year ago

                  What’s the difference

                  Your code reads like it’s from 1992 mainly, which makes sense I guess, given that you still find jQuery better than modern vanilla js. jQuery was created as a way to account for browser support challenges but is now obsolete. Anyhow, if I read “getElementById” in recent js code I would assume something was weird about that code. It’s old hat and there is rarely a reason to use it.

                  What is the right way is context dependent

                  Precisely my point. Which is why I think it’s opinionated in a bad way to arbitrarily pick one of them as the defacto. I often had trouble with jQuery’s .hide() method because while it felt natural to use it, it often conflicted with what actually needed to happen for good UX.

                  What you’re missing is that the hidden class can contain anything you want. Animations or whatever else. In other words, the idea that there is a “right” or “most common” way to hide an element is flawed at its core.

    • Strawberry@lemmy.blahaj.zone
      link
      fedilink
      arrow-up
      3
      ·
      1 year ago

      jQuery is obsolete and insufficient if you’re looking for an easy monolithic framework. Angular, React and Vue are all good (disclosure, I haven’t used react), just pick one and learn it well and you’ll have a good foot in the door. If you already know JavaScript and don’t want to learn typescript, Vue can be used with plain JavaScript.

      • o_d [he/him]@lemmygrad.ml
        link
        fedilink
        arrow-up
        4
        ·
        1 year ago

        I’ve used all 3 although, not very much Angular so I don’t have much to say on it. Vue is the easiest to learn imo. It bundles in routing and state management so you don’t have to worry about picking supporting libraries for this. It’s a pretty standard template style with lots of helpers and some magic going on behind the scenes. React is better if you want to write JavaScript. I prefer it for this reason.

        • fidodo@lemm.ee
          link
          fedilink
          arrow-up
          3
          ·
          1 year ago

          Curious if you’ve used next with react. React itself has a scope rendering design goal and leaves the rest of the app to the community, and next sets up all the stuff around it for you and I think they did a really great job with the defaults they close, and it’s still fully extendable.

          • o_d [he/him]@lemmygrad.ml
            link
            fedilink
            arrow-up
            1
            ·
            1 year ago

            Yup! Next is the most mature and complete framework for React. If I need SSR and/or SSG with hydration, it’s my go to for now. It adds some complexity, so it can be overkill if you don’t need these things. My experience working with it has been excellent.

            • fidodo@lemm.ee
              link
              fedilink
              arrow-up
              1
              ·
              1 year ago

              It can be overkill if you need something simple that doesn’t match next’s defaults, but if the default settings of next work for your use case I found the base project setup very simple to use.

    • fidodo@lemm.ee
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      Best practices are pretty straight forward in the typescript community. Frankly I think all the serious professionals from the JavaScript community just went to TS so the people left over that didn’t migrate are well…

    • iegod@lemm.ee
      link
      fedilink
      arrow-up
      15
      arrow-down
      2
      ·
      1 year 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
        arrow-up
        7
        ·
        1 year 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
          arrow-up
          5
          ·
          1 year 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
            arrow-up
            2
            ·
            1 year 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.

    • severien@lemmy.world
      link
      fedilink
      arrow-up
      2
      arrow-down
      2
      ·
      edit-2
      1 year 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.

  • Nerd02@lemmy.basedcount.com
    link
    fedilink
    English
    arrow-up
    35
    arrow-down
    1
    ·
    1 year ago

    I think there’s a positive coming from this competition, though. Apparently this infighting has re-lit the want for type annotations to be embedded in vanilla JS (ECMAScript proposal). I feel like this would be the ideal scenario: things working right out of the box without needing a compile step or additional tooling.

    You can get as close as it gets to this experience by using alternative runtimes such as Deno or Bun, which have native TS support (meaning you can just execute a .ts file without having to transpile it), but of course as soon as you have to write code for a browser you are back in the middle ages.

    • TheCee@programming.dev
      link
      fedilink
      English
      arrow-up
      4
      ·
      1 year ago

      That’s not a positive, though.

      Depending on how it pans out, it’s either not useful enough. Who the hell doesn’t use namespaces or enums. Or - as

      These constructs are not in the scope of this proposal, but could be added by separate TC39 proposals.

      implies - a door opener to outsource TypeScripts problem unto other peoples and not to investing into improving WebAssembly. That’s just MS being lazy and making their problems other peoples problems.

      I feel like this would be the ideal scenario: things working right out of the box without needing a compile step or additional tooling.

      It’s just annotations. No proposed semantics of a type system which your browser could check on its own.

      • Phen@lemmy.eco.br
        link
        fedilink
        arrow-up
        3
        ·
        edit-2
        1 year ago

        Who the hell doesn’t use namespaces or enums

        Uhhh, typescript devs? Enums were useful once, but typescript evolved everything else around it and these days using direct values is actually far better.

        And I don’t think anyone uses Namespaces other than for defining external modules.

        • TheCee@programming.dev
          link
          fedilink
          English
          arrow-up
          1
          arrow-down
          1
          ·
          edit-2
          1 year ago

          My bad, I’m not deep enough into our frontend stack to realize Hjeilsberg already did what he does best - ruining enums. (I guess he is not to blame for global imports in c#, so i can not add ‘questionable import module/namespace ideas’.)

          And it seems like this proposal contains type declarations (in order to compensate for their enums), among other typescript specific things. So, guess it is option B, then.

      • rockstarpirate@lemmy.world
        link
        fedilink
        English
        arrow-up
        2
        ·
        1 year ago

        Yeah it’s interesting because JS is interpreted, not compiled. The proposal allows for type annotations in the syntax but no actual interpreter consequences. On the one hand that makes sense because otherwise you’re in the territory of runtime type-checking which would be a huge performance hit and would sort of defeat the purpose of static types anyway. But that means you still have to rely on your IDE or a linter for this to be useful.

      • fidodo@lemm.ee
        link
        fedilink
        arrow-up
        2
        ·
        1 year ago

        I don’t see any practical use case for it as is as anyone wanting to use them would want the full TS feature set anyways, but I could see it being a good step forward for more meaningful features to be added in the future.

        • TheCee@programming.dev
          link
          fedilink
          arrow-up
          1
          ·
          1 year ago

          but I could see it being a good step forward for more meaningful features to be added in the future.

          I think you are right. And that is unfortunate.

  • lobut@lemmy.ca
    link
    fedilink
    arrow-up
    35
    arrow-down
    1
    ·
    1 year ago

    I dunno, Typescript can be nice at times but it always feels like I’m bolting on something that doesn’t belong on top.

    I’ll still use it for now. Not sure JSDoc is as adequate for an enterprise app for me. I know Svelte and stuff do, but I’ll wait and see.

  • Phen@lemmy.eco.br
    link
    fedilink
    arrow-up
    33
    ·
    edit-2
    1 year ago

    Typescript may have a million problems that make getting into it annoyingly hard and even seem pointless, but once it’s settled in your project and used well… Damn is it fucking good.

    And I’m saying that even though I had to disable intellisense and most of those advanced features because the project I work for is too large and typescript would easily use over 20GB of RAM and get my computer to freeze.

    But if you’re trying to use it like a traditional typed language, you’ll only see the bad side of it and you’ll certainly hate it.

    • JakenVeina@lemm.ee
      link
      fedilink
      arrow-up
      8
      ·
      1 year ago

      More like a tourniquet and a prosthetic. It doesn’t solve the underlying problem, but it’s the best solution we’ve come up with.

      • fidodo@lemm.ee
        link
        fedilink
        arrow-up
        2
        ·
        1 year ago

        I view it more like a powered exoskeleton around a blob fish. IMO static typing is way more valuable than strong typing and I’d take static typing only over strong typing any day if I can only choose one.

      • Kuresov@programming.dev
        link
        fedilink
        arrow-up
        4
        ·
        edit-2
        1 year ago

        Mypy is just okay. Haven’t used TS to know the dark corners there, but any type system that’s bolted on to the language is going to have dark corners in the best case.

        It’s better than no type system, however. I remember when typed languages were “bad” because it “slowed you down” and “wasn’t necessary if you know what you’re doing”… how naive I was when I repeated those words so many years ago :)

  • ObsidianBlk@lemmy.world
    link
    fedilink
    arrow-up
    34
    arrow-down
    6
    ·
    1 year 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.

    • JakenVeina@lemm.ee
      link
      fedilink
      arrow-up
      24
      arrow-down
      1
      ·
      1 year 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
        arrow-up
        3
        ·
        1 year 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.

    • brian@programming.dev
      link
      fedilink
      arrow-up
      14
      ·
      1 year 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
        arrow-up
        1
        ·
        1 year 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
          arrow-up
          1
          ·
          1 year 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
            arrow-up
            2
            ·
            1 year 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@lemm.ee
        link
        fedilink
        arrow-up
        1
        arrow-down
        2
        ·
        1 year ago

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

    • SokathHisEyesOpen@lemmy.ml
      link
      fedilink
      English
      arrow-up
      13
      arrow-down
      2
      ·
      1 year 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.

    • madcaesar@lemmy.world
      link
      fedilink
      arrow-up
      10
      ·
      1 year 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@lemmy.world
        link
        fedilink
        arrow-up
        3
        ·
        1 year 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
        arrow-up
        1
        ·
        edit-2
        1 year 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@shinobu.cloud
      link
      fedilink
      English
      arrow-up
      10
      arrow-down
      1
      ·
      1 year 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
        arrow-up
        2
        ·
        1 year 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
          arrow-up
          1
          ·
          1 year 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”

          • severien@lemmy.world
            link
            fedilink
            arrow-up
            1
            ·
            1 year ago

            Sure, but part of the claim was “without any compilation”. But bun/deno do compile TS into JS.

          • SoBoredAtWork@lemmy.world
            link
            fedilink
            arrow-up
            1
            ·
            1 year ago

            I’ve never worked with it and don’t know in detail, but it lets you compile several languages into web based client/server code (basically, converting other languages into website code). Works with C, C++, C#, Go, Rust, Swift, etc)

    • DogMuffins@discuss.tchncs.de
      link
      fedilink
      English
      arrow-up
      5
      arrow-down
      2
      ·
      1 year 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.

    • fidodo@lemm.ee
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      1 year 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.

  • tram1@programming.dev
    link
    fedilink
    arrow-up
    22
    ·
    1 year 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…

    • noli@programming.dev
      link
      fedilink
      arrow-up
      22
      ·
      1 year 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.

    • Lmaydev@programming.dev
      link
      fedilink
      arrow-up
      13
      arrow-down
      1
      ·
      edit-2
      1 year 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.

      • ironbeard@lemm.ee
        link
        fedilink
        arrow-up
        5
        ·
        1 year ago

        But a statically typed language would catch those errors before it even compiles…

        • Lmaydev@programming.dev
          link
          fedilink
          arrow-up
          3
          ·
          1 year 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@lemmy.basedcount.com
          link
          fedilink
          English
          arrow-up
          14
          ·
          1 year 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
            arrow-up
            6
            ·
            1 year 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
              arrow-up
              8
              ·
              edit-2
              1 year 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.”

    • Knusper@feddit.de
      link
      fedilink
      arrow-up
      6
      ·
      1 year 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…

    • qaz@lemmy.world
      link
      fedilink
      arrow-up
      1
      arrow-down
      1
      ·
      1 year 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.