Zig vs Rust. Which one is going to be future?

I think about pros and cons and what to choose for the second (modern) language in addition to C.

@[email protected]

  • paw@feddit.org
    link
    fedilink
    English
    arrow-up
    1
    ·
    2 minutes ago

    What are your goals?

    If you want to learn another language just for the fun of it (the best reason) than learn both.

    Of you want to improve your tool set to be able to land a job, then there is no good answer. Probably some other high level language like Python, Java, JavaScript, C#. Etc.

    Also: Zig bay be easier to get started when coming from C, because it is mostly imperative.

    Rust introduces concepts from functional programming. This could be interesting for you, of you don’t have any experience in functional programming to get in touch with other programming styles. Or not, of you explicitly don’t want to learn such things.

    I use both languages, and I enjoy both. Shameless plug: I’ve written a blog post ~ 2 years ago what I like about each language: https://zigurust.gitlab.io/blog/posts/three-things/

  • dudinax
    link
    fedilink
    arrow-up
    13
    ·
    4 hours ago

    Rust. It’s a qualitative improvement over the old ways.

    The future won’t belong to Rust itself, but one of its descendants. Rust is too clunky to be the ultimate expression of its best ideas.

    • xigoi@lemmy.sdf.org
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 hour ago

      What does Rust improve over its predecessor? The only really new thing is the borrow checker, which is only useful in very low-level programming.

    • yoevli@lemmy.world
      link
      fedilink
      English
      arrow-up
      2
      ·
      4 hours ago

      In what ways do you feel Rust is too clunky and how do you think it could be improved? Not looking to argue or even disagree necessarily; I’m just curious where that perspective comes from.

  • TehPers@beehaw.org
    link
    fedilink
    English
    arrow-up
    19
    ·
    6 hours ago

    Honestly C is the future. I don’t know why people would move from C to any other language. It does the job well enough that there’s no reason not to use it.

    Think about it. Every modern application depends on a piece of code written in C, not Rust or Zig or any other language (except assembly). It can be used to solve any problem, and works in more places than any other language.

    These arguments about “security” and “memory safety” are all pointless anyway in the face of modern code scanning tools. Cross-platform dev can be done trivially with preprocessors. If that’s not enough, I don’t know what to say. Get better at writing C obviously.

    Lifetimes and UB should all be kept in mind at all times. You can explicitly mark lifetimes in your C code if you want using comments. Any index-out-of-bounds bugs, use-after-free, etc are just signs that your team needs more training and better code scanning utils. Write more tests!

    Anything more complex than a simple typedef is just a sign that you’re over-engineering your solution. #include is both simple, and does exactly what you’d expect any reasonable language to do - paste your referenced code inline. It’s genius, and doesn’t require any complicated explanations on namespaces and classes and subclasses and so on.

    So which will be the future? C obviously.

    /s

    • slacktoid@lemmy.ml
      link
      fedilink
      English
      arrow-up
      16
      ·
      5 hours ago

      The number of people that genuinely believe this ( I saw the /s) … Tells me that they haven’t written any useful C or C++ code

      • TehPers@beehaw.org
        link
        fedilink
        English
        arrow-up
        4
        ·
        edit-2
        5 hours ago

        I’m not going to say that C is unusable by any means (and I’m not saying you are saying that). It’s a perfectly usable language. I do think that more people would benefit from exploring other options though. Programming languages are tools, not sports teams. People should familiarize themselves with many tools so they always have a good tool to use for any job.

        I think a lot of people believe this because there is some truth to parts of it. I think we see languages like Rust and Zig (and others) popping up to try and solve specific problems better than others.

        As for OP’s post, there is no single “C successor” or anything like that. People will use the best tool they know of for the job whether that’s C, Rust, C++, Zig, Python, C#, etc. Many languages will “replace” C in some projects, and at the same time, C will replace other languages in some projects (likely to a lesser extent though).

        (Not /s this time)

        • slacktoid@lemmy.ml
          link
          fedilink
          English
          arrow-up
          2
          ·
          2 hours ago

          Oh completely. C is here to stay, C has surpassed language and become protocol cause of libc being so centric to Unix like languages. But it needs to be done carefully and thoughtfully. The other languages are solving some of the pain points C has which I think a lot of people would be better off using than C.

    • robinm
      link
      fedilink
      arrow-up
      17
      ·
      6 hours ago

      You got me in the first 3 quarters, not gonna lie!

  • OpenStars@discuss.online
    link
    fedilink
    English
    arrow-up
    9
    arrow-down
    1
    ·
    6 hours ago

    Isn’t exactly this kind of thing what is mostly responsible for the demise of Perl?

    As I heard it told, the developers of Perl worked so long & hard on the next version after Perl 5, but then veered off to make a new language (Raku) and despite the reality being otherwise, people feared so much that Perl would die (i.e. that 6 would never materialize) that in the meantime “everyone” had switched to Python (despite it clearly being an inferior language - hehehehe:-P).

    So that would be a “con” I suppose, if fights over which language is better ends up diluting efforts to work on or with either.

    • mox@lemmy.sdf.org
      link
      fedilink
      arrow-up
      1
      ·
      23 minutes ago

      Isn’t exactly this kind of thing what is mostly responsible for the demise of Perl?

      Perl died because better tools became available.

      • OpenStars@discuss.online
        link
        fedilink
        English
        arrow-up
        1
        ·
        5 hours ago

        I have never quite understood this mode of thinking - I think it must be an imprecise statement. Yes, improper usage of Perl coding can be bad, but then so too can C/C++ with e.g. improper memory management? Yet, I don’t see people knocking down doors to learn the memory-safe Rust (and e.g. thereby be able to contribute to the Lemmy codebase), probably bc despite it being “better”, it also has a steep learning curve (and I don’t even know but I would assume: even for someone who already knows C?). Instead, people seem to want to learn Go, or Java - okay so that’s a rabbit hole b/c they are for entirely different purposes, but anyway I mean that each language has its own balance of trade-offs.

        So while on the one hand the worst-case scenario from a poor coder for Perl seems significantly worse than for Python, there are also benefits too: doesn’t Perl run up to 20x faster than Python, which is why many places e.g. booking.com have chosen to use it? In the hands of an experienced person, perl code is quite readable, while in contrast, I just absolutely HATE aspects of Python such as whitespace delimiting and the package management, plus I don’t know if I am imagining things (is is likely) but the code just seems to me to look obtuse, by comparison.

        Sometimes I’ll use awk, other times I’ll bump that up to a Perl one-liner or even full script, still other times demand Python or for number-crunching full C/C++, or Java for whatever reason, but… for things that you want fast & easy, I don’t really see Perl as “bad”? Granted, it shouldn’t be someone’s first language these days, compared to C or Python, but what is wrong with it, like awk, continuing to exist these days? Especially if it’s not in a production environment.

        I’m listening.

        • deegeese@sopuli.xyz
          link
          fedilink
          arrow-up
          3
          ·
          5 hours ago

          Collaboration is a fact of life in software development.

          Therefore we must choose tools based not on a single developer’s preference, but by what their colleagues can use effectively.

          • Tools that are easy to write bugs with (C/C++)
          • Tools that are hard to learn (Perl)
          • Tools that are hard to hire for (Perl, Ruby)

          All of these should be fixed or shunned in favor of languages that are easier to hire, easier to learn, and easier to debug.

          • OpenStars@discuss.online
            link
            fedilink
            English
            arrow-up
            2
            ·
            edit-2
            5 hours ago

            So *I* who am careful to write readable and safe code, have to use a non-preferred language preference b/c someone else cannot handle using it properly?!

            Sadly, that is the realization that I have come to as well. A chain is only as strong as its weakest link and all that… but no, really, that’s true, b/c modifications are likely to be made at some point (kinda biasing towards production there but even so, answers with perl one-liners on e.g. StackOverflow are ubiquitous, but someone would have to know the language to be able to modify them to suit their specific use-case, so also not at the same time).

            Fwiw I really did not think that Perl was hard to learn - though that was coming from the likes of assembly, various Basic styles, C/C++, and having already learned regular expressions via Unix e.g. grep and awk and sed. “Regular expressions” are quite a steep learning curve, though that’s not the same thing as Perl, and quite frankly Perl is the undisputed (iirc?) master of them all, so whether someone wanted to write Perl without those, or wanted to do try to do regular expressions without Perl, either way Perl seems good for having included regular expressions, not something to penalize the entire language for. Also, C/C++ (and Rust) has a bit of a known learning curve as well…:-) Though indeed it’s entirely fair to say that if someone were to pick just one language, then I would be hard pressed to find any justification for that being Perl. C/C++, Java, Python - all of these, depending on the situation, are fine choices, whereas Perl is absolutely niche.

            But even so, why would it follow that it would necessarily be a good thing if Perl, or let’s say awk, would fully “go away”? I kinda see Perl and awk as being in the same boat these days - both niche and powerful, yet both steadily becoming obsolete? Just b/c something else is “better” doesn’t mean that everything else must die. Except, as you mentioned, for reasons of collaboration and thus code-reuse. Even there though, putting all of our eggs into a single basket scares me: what if tomorrow Microsoft, or Google, decides to purchase the rights to Python and suddenly control that entire industry sector in one fell swoop?

  • macniel@feddit.org
    link
    fedilink
    arrow-up
    7
    arrow-down
    1
    ·
    7 hours ago

    Who wants oxidised Metal when you can take off every Zig! You know what you doing!? Move Zig. For great justice.