• 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
      21
      ·
      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
      ·
      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
        4
        ·
        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
          12
          ·
          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.