On the one side I really like c and c++ because they’re fun and have great performance; they don’t feel like your fighting the language and let me feel sort of creative in the way I do things(compared with something like Rust or Swift).

On the other hand, when weighing one’s feelings against the common good, I guess it’s not really a contest. Plus I suspect a lot of my annoyance with languages like rust stems from not being as familiar with the paradigm. What do you all think?

  • mipadaitu@lemmy.world
    link
    fedilink
    English
    arrow-up
    51
    arrow-down
    1
    ·
    7 months ago

    Depends on if you’re coding for critical infrastructure (i.e. - electrical grid), or writing a high performance video game that can run on older hardware.

    We should absolutely have specific licenses like Civil Engineers do for computer infrastructure that is required for any software written for specific purposes. It would be a nightmare to implement, but at some point, it’s going to be needed.

    • SorteKanin@feddit.dk
      link
      fedilink
      arrow-up
      20
      arrow-down
      9
      ·
      7 months ago

      writing a high performance video game that can run on older hardware

      Unless it’s some really exotic platform, I’d honestly still say no. Rust has shown that memory safety and performance doesn’t have to be a tradeoff. You can have both.

      But sure, if whatever you’re targeting doesn’t have a Rust compiler, then of course you have no choice. But those are extremely rare cases these days I’d say.

      • themusicman@lemmy.world
        link
        fedilink
        arrow-up
        22
        arrow-down
        3
        ·
        7 months ago

        There’s always a trade-off. In rust’s case, it’s slow compile times and comparatively slower prototyping. I still make games in rust, but pretending there’s no trade-off involved is wishful thinking

        • Lmaydev@programming.dev
          link
          fedilink
          arrow-up
          15
          arrow-down
          1
          ·
          7 months ago

          They mean a trade off in the resulting application. Compile times mean nothing to the end user.

          • Dave.@aussie.zone
            link
            fedilink
            arrow-up
            10
            arrow-down
            1
            ·
            7 months ago

            That may be true but if the language is tough to develop with, then those users won’t get a product made with that language, they’ll get a product made with whatever language is easier / more expedient for the developer. Developer time is money, after all.

            • Lmaydev@programming.dev
              link
              fedilink
              arrow-up
              1
              ·
              edit-2
              7 months ago

              You’d be better just using a managed languages in many cases.

              With tiered jit and careful use of garbage allocations they can actually be the same or faster.

      • cm0002@lemmy.world
        link
        fedilink
        arrow-up
        7
        arrow-down
        15
        ·
        edit-2
        7 months ago

        I don’t even think we really need to eek out every MHz or clock cycle of performance these days unless your shipping code for a space vehicle or something (But that’s an entirely different beast)

        We’ve got embedded devices shipping with 1GHz+ processors now

        It’s just time to move on from C/C++, but some people just can’t seem to let go.

        • pycorax@lemmy.world
          link
          fedilink
          arrow-up
          8
          ·
          7 months ago

          Battery life is a reason. I’ve had clients come to me complaining their solution from another vendor didn’t last very long. Turns out it was running Java on an embedded device.

        • Croquette@sh.itjust.works
          link
          fedilink
          arrow-up
          8
          ·
          7 months ago

          Because there is still market for small mcus. A 1GHz processor is a lot more expensive than a 32 bits 75MHz. If you produce even a low number of units, the price difference can be huge.

        • Cirk2@programming.dev
          link
          fedilink
          arrow-up
          7
          ·
          7 months ago

          That is the mindset that gives us text editors using 100% cpu to blink a cursor because their css triggers a bug in the web browser they ship to render the text editor.

          You can be memory save without shipping a whole browser, but disregarding power and memory efficiency will just make performance gained by hardware evaporate in overhead.

  • mox@lemmy.sdf.org
    link
    fedilink
    arrow-up
    21
    ·
    7 months ago

    I’m just glad to see the White House listening to people who understand technology for a change.

    • jkrtn@lemmy.ml
      link
      fedilink
      arrow-up
      11
      ·
      7 months ago

      We need legislators who aren’t all literally older than cryptography. If they weren’t bought and paid for by billionaires that would be nice too.

        • jkrtn@lemmy.ml
          link
          fedilink
          arrow-up
          5
          ·
          7 months ago

          It requires score voting so that, even if heavily gerrymandered, one can still meaningfully express a preference without throwing one’s ballot in the garbage.

          • Hacksaw@lemmy.ca
            link
            fedilink
            arrow-up
            1
            arrow-down
            1
            ·
            7 months ago

            It’s never throwing your ballot in the garbage though. I used to think the same way, but every vote on the left, even if for the lesser evil, even if they lose, moves the conversation to the left. When we all stay home you get maga nutjobs stealing the show running unchecked.

            Last thing is that gerrymandered states are the EASIEST to upset by increasing voter turnout. To gerrymander effectively you have to put your opponent in dense areas they’ll win by a large margin, then spread your side so that you barely win the rest of the districts. That means that a 5% increase in votes on the left can take you from a loss to a nearly complete victory in a gerrymandered state.

            Vote splitting on the other hand is a trickier beast, but in the end if all the left votes go to a moderate then that gives the left a lot of leverage because if the moderate candidate doesn’t bend to the left then they’ll lose the next election.

            Always vote.

        • demesisx@infosec.pub
          link
          fedilink
          English
          arrow-up
          2
          ·
          7 months ago

          Don’t blame the victims for a sham of a democracy. FPTP is there to prevent anything outside of a two party system where primaries are filled with (fully allowed) cheating.

          • parens@programming.dev
            link
            fedilink
            arrow-up
            1
            ·
            7 months ago

            FPTP does destroy a lot, I’ll give you that, but municipal and regional elections have miserable turn-outs too and they have much more potential for perceptible change than state or national change.

            In the USA things have to get way worse than they are now before they get better. A very very large percentage of voters would have to be fed up with FPTP to force change in that area. Also, they would have to be educated enough to understand that FPTP is a problem.

            • demesisx@infosec.pub
              link
              fedilink
              English
              arrow-up
              2
              ·
              edit-2
              7 months ago

              For one, FPTP doesn’t get enough credit for just how nefarious it is. And let me be clear: I am speaking of the presidential election specifically, though I’m sure this applies to many aspects of this “democracy” including state elections, etc that you mentioned.

              Instead, the overarching establishment narrative likes to point the finger at the electoral college (which also quite heavily biases the power of votes toward voters in less populous areas and states).

              Since the established oligarchs (who own the news outlets) tend to control information delivery in this country, how would you break through that wall? Would you engage in peaceful protest (or self immolation)? Well, they’ve got a playbook for that too. They will discredit you and make you seem unhinged. For proof of that, look at the way they’re delegitimizing the brave, selfless active duty Air Force member who engaged in peaceful protest by self immolation outside of the Israeli embassy against the Gaza war for just how easy it is. Most news watching voters probably already think he was crazy. It didn’t quite have the power that that act had during, say, the Vietnam war.


              Since you’re here, I’m guessing you’re a software engineer. Do me a favor: Model the real world dynamics of a US presidential election using domain driven design, making sure to accurately represent the two objectively unfair stages:

              Rule #1: All candidates must pass stage 1 to be eligible for stage 2.

              In stage 1, feel free to cheat, commit fraud, and engage in any strategy you need to prevent anyone but the owners of the party’s preferred candidates from winning. After all, your party is a private organization that can engage in whatever unfair tactic they deem necessary.

              In stage 2, (if you’re paying attention, you ALREADY have irreparably biased the possible outcomes by cheating in stage 1) because of FPTP, you can now simply choose between only two of the MANY, MANY parties.

              If you designed a system like that as a software engineer, your colleagues would be at your throat about how flawed that design was. However, here in the US, that’s just the design of our dEMoCrACy oF tHa gReATeSt cOuNTry iN tHa wErLD! 🥴

              Edit: That “much worse” statement seems to come from a place of privilege. Don’t forget that. RIGHT NOW, more people are homeless and destitute than any other time in MY LIFE (I was born in the late 70’s). And most people literally have no say in whether or not their tax money is being used to genocide Muslims overseas to make room for a puppet government. Remember: You’re an anti-Semite if you oppose genocide.

  • onlinepersona@programming.dev
    link
    fedilink
    English
    arrow-up
    24
    arrow-down
    8
    ·
    edit-2
    7 months ago

    Leaders in Industry Support White House Call to Address Root Cause of Many of the Worst Cyber Attacks

    And it’s called C/C++. It’s gotten so bad that even the friggin’ white house has to make a press release about it. Think about it, the place where that majority barely even understand the difference between a file browser and a web browser is telling you to stop using C/C++. Hell, even the creator and maintainers of the language don’t know how to make it memory safe. If that isn’t a wake up call, then nothing ever will be.

    And this isn’t the first call! The IEEE also says more clearly: GTFO C/C++.

    If you want memory-safe, don’t write C/C++. Trying to get that shit memory-safe is a hassle and a half. You’re better off learning a language that isn’t full of foot-guns, gotchas, and undefined behavior.

    CC BY-NC-SA 4.0

    • abhibeckert@lemmy.world
      link
      fedilink
      arrow-up
      14
      arrow-down
      7
      ·
      7 months ago

      If you want memory-safe, don’t write C/C++.

      Fixed that for you. There’s no situation where you want buffer overruns.

      • cm0002@lemmy.world
        link
        fedilink
        arrow-up
        16
        ·
        7 months ago

        There’s no situation where you want buffer overruns.

        I want buffer overruns in my game consoles for jailbreaking purposes lmfaoooooo

      • evranch@lemmy.ca
        link
        fedilink
        arrow-up
        2
        ·
        7 months ago

        If you don’t want memory-safe buffer overruns, don’t write C~~/C++.~~

        Fixed further?

        It’s perfectly possible to write C++ code that won’t fall prey to buffer overruns. C is a lot harder. However yes it’s far from memory safe, you can still do stupid things with pointers and freed memory if you want to.

        I’ll admit as I grew up with C I still have a love for some of its oh so simple features like structs. For embedded work, give me a packed struct over complex serialization libraries any day.

        I tend to write a hybrid of the two languages for my own projects, and I’ll be honest I’ve forgotten where exactly the line lies between them.

    • Feathercrown@lemmy.world
      link
      fedilink
      English
      arrow-up
      1
      ·
      7 months ago

      You’re better off learning a language that isn’t full of foot-guns, gotchas, and undefined behavior.

      As a JS developer, seeing this quote about C/C++ for a change gives me unbelievable levels of schadenfreude

  • Faresh@lemmy.ml
    link
    fedilink
    arrow-up
    15
    ·
    7 months ago

    What memory-safe systems programming languages are out there, besides Rust?

      • Faresh@lemmy.ml
        link
        fedilink
        arrow-up
        11
        ·
        7 months ago

        I appreciate your answer, but I mentioned systems programming, because I was more interested in languages that do not rely on a garbage collector.

        • BatmanAoD@programming.dev
          link
          fedilink
          arrow-up
          13
          ·
          7 months ago

          To play devil’s advocate, most systems programming can be done even with a garbage collector. Midori was a project to build an operating system on a variant of C#, and although the garbage collector did impose technical difficulties, it wasn’t a dealbreaker. Go isn’t usable everywhere Rust is, but it can in fact be used for many things that previously would have been considered “systems” niches (which is part of why there was a somewhat prevalent misconception in the early days of Rust that they were similar languages). Prominent D developers have defended D’s garbage collector (even though it’s technically optional). Bjarne Stroustrup, the creator of C++, used to express great confidence that C++ would one day have a garbage collector.

          …but you’re right, Rust and its rise in popularity (and, conversely, the C++ community’s resistance to adopt anything with garbage collection) have definitely narrowed the common definition of “systems programming” to exclude anything with a “thick” runtime.

    • psudo@beehaw.org
      link
      fedilink
      arrow-up
      2
      ·
      7 months ago

      Wasn’t Go designed to be a memory safe systems programming language? I haven’t really used it enough to see if it holds true, though.

        • mox@lemmy.sdf.org
          link
          fedilink
          arrow-up
          8
          ·
          7 months ago

          Segfaults aren’t particularly dangerous. They mean the problem was caught. The program usually just exits.

          Failing to segfault, thereby allowing a bad memory access, is where the real trouble happens.

      • arendjr@programming.dev
        link
        fedilink
        arrow-up
        1
        ·
        7 months ago

        Go is almost memory safe, but it does suffer from an issue with its thick pointers (type + address) that can cause race conditions to misrepresent the type of a data structure. This can lead to true segmentation faults and out of bound memory accesses, though it will probably be quite difficult (but not impossible) to exploit them.

  • TechNom (nobody)@programming.dev
    link
    fedilink
    English
    arrow-up
    11
    ·
    7 months ago

    they don’t feel like your fighting the language

    I really understand what you mean wrt Rust. I really do - I was there once. But it’s a phase you grow out of. Not just that - the parts you fight now will eventually become your ally.

    and let me feel sort of creative in the way I do things

    I had the same experience with C/C++. But as the design grows, you start hitting memory-safety bugs that are difficult to avoid while coding - even after you learn how those bugs arise in the first place. Just a lapse of concentration is enough to introduce such a bug (leaks, use-after-free, deadlocks, races, etc). I’ve heard that C++ got a bit better after the introduction of smart pointers and other safety features. But, it comes nowhere near the peace of mind you get with garbage collected languages.

    That’s where Rust’s borrow checker and other safety measures kick in. The friction disappears when you acquire system knowledge - concepts of stack, heap, data segment, aliasing, ownership, mutation, etc. These knowledge are essential for C/C++ too. But the difference here is that Rust will actually tell you if you made a mistake. You don’t get that with C/C++. The ultimate result is that when a Rust program compiles successfully, it almost always works as you expect it to (barring logical errors). You spend significantly less time debugging or worrying about your program misbehaving at runtime.

    The ‘friction’ in Rust also helps in another way. Sometimes, you genuinely need to find a way out when the compiler complains. That happens when the language is too restrictive and incapable of doing what you need. You use things like unsafe, Rc and Refcell for that. However, most of the time, you can work around the problem that the compiler is indicating. In my experience, such ‘workarounds’ are actually redesigns or refactors that improve the structure of your code. I find myself designing the code best when I’m using Rust.

  • xmunk@sh.itjust.works
    link
    fedilink
    arrow-up
    12
    arrow-down
    2
    ·
    7 months ago

    C++ can have excellent performance without ever using a single pointer and avoiding unsafe functions like gets() - this isn’t necessarily a judgment on language - it’s a judgement on bad programming habits.

    Pointers fucking suck, in a modern C++ codebase everything should be pass by value or const/mutable ref. To my preference I’d rather drop mutable refs to force everything to be more functional but whatever.

    • OsrsNeedsF2P@lemmy.ml
      link
      fedilink
      arrow-up
      29
      arrow-down
      2
      ·
      7 months ago

      I mean that’s just the problem with C++. There’s 17 different ways to do things, 2 are always wrong, 14 are contextual, and 1 is reserved for super special cases

      • HornyOnMain@kbin.social
        link
        fedilink
        arrow-up
        12
        arrow-down
        1
        ·
        7 months ago

        And the one you choose is always the one that’s weak to the specific vulnerability you didn’t think of!

    • abhibeckert@lemmy.world
      link
      fedilink
      arrow-up
      14
      arrow-down
      1
      ·
      edit-2
      7 months ago

      Pointers suck in C++. In other languages every single variable is a pointer and it works perfectly with no memory bugs and great performance.

      Pass by value often uses too much memory. Especially if you have a bunch of simultaneous functions/threads/etc that all need to access the same value at once. You can get away with it when your memory is a few dozen integers, but when you’re working with gigabytes of media… you need pointers. Some of the code I work with has values so large they don’t even fit in RAM at all, let alone two or three copies of them. Pass by value could mean writing a hundred gigabytes to swap.

      • xmunk@sh.itjust.works
        link
        fedilink
        arrow-up
        2
        arrow-down
        1
        ·
        7 months ago

        That’s one reason I mentioned pass by reference “smart” languages will do it automatically depending on the size of the argument, some languages (including my beloved PHP) even have a copy-on-edit functionality where everything is technically passed as a mutable reference but as soon as you mutate it (unless it was explicitly marked as a mutable reference) it will copy the original object and have you edit the copy instead of the original.

        Is being explicit about when copies happen almost always a good thing - yea the overhead of that system is undesirable in performance sensitive situations - but for a high level scripting language it’s quite nice.

    • SorteKanin@feddit.dk
      link
      fedilink
      arrow-up
      16
      arrow-down
      5
      ·
      7 months ago

      Working with habits is just not good enough. C++ has far too many footguns to be considered a safe language and there are frankly objectively better modern alternatives that you should use instead, perhaps except if you have a really large legacy code base you can’t replace (but even then, consider calling into it via FFI from a safe language).

      Even if you tried to actually enforce these habits, you’d just end up inventing a new language and it would be incompatible with previous C++ too.

      C++ is not a viable language for the future.

      • xmunk@sh.itjust.works
        link
        fedilink
        arrow-up
        7
        ·
        7 months ago

        I get kinda bad vibes from this comment and I’d like to explain why…

        If somebody said “We’re building a point of sale terminal and to make it secure we’re going to be using C++” I’d probably have a dumbfounded expression on my face unless they immediately continued with “because there are libraries we can lean on to minimize the amount of code we need to write.”

        C++ has an extremely mature ecosystem - Qt is essentially it’s own language at this point! There are reasons to still consider building in C++ and saying “C++ is not a language for the future” feels dogmatic and cargo culty to me. Algol, Cobol and Fortran still have programming communities and while I agree that C++ is outsized in presence for the danger it presents there are still good reasons to choose it for some specific domains - high performance graphical programs being one of those in particular.

        C++ has a plethora of foot guns and you need to be aware of them but when you are they’re easy to avoid in fact your quote:

        Even if you tried to actually enforce these habits, you’d just end up inventing a new language and it would be incompatible with previous C++ too.Even if you tried to actually enforce these habits, you’d just end up inventing a new language and it would be incompatible with previous C++ too.

        Is probably the thing I agree most with - well built C++ isn’t incompatible with regular ol’ C++ but it feels like a different language… but as a not too old old-man-developer different projects often feel like different languages - each company/project has tools and libraries they use and it’ll cause code written in the same language to read really differently… I’m a functionally oriented programmer with a pretty particular style, my C++, Python, Java, PHP, Node and Rust all look nearly the same except for language specific peculiarities.

        So yea, discipline is needed and nobody’s default choice should be C++ but if you follow best practices your C++ can be quite safe.

        that all said… I fucking hate the concept of definition files being sseparate from code files so I’m not going to use C++ anytime soon.

    • arendjr@programming.dev
      link
      fedilink
      arrow-up
      5
      ·
      7 months ago

      Even references aren’t safe in C++ though, since there’s no borrow checker. Unless you copy everything or use reference counting types everywhere, you’ll still hit plenty of memory-violating footguns. But at that point, why use C++ at all?

    • Feathercrown@lemmy.world
      link
      fedilink
      English
      arrow-up
      4
      ·
      edit-2
      7 months ago

      just avoid all the bad stuff bro

      If I was giving a tour of my kitchen and it included phrases such as “avoid using the leftmost cabinet of any set of two”, “the freezer doesn’t work but the fridge can be set to the same temperature”, or “the oven has been deprecated, just use the microwave”, you’d rightfully gtfo. Why is this acceptable of a programming language??

  • fubo@lemmy.world
    link
    fedilink
    arrow-up
    15
    arrow-down
    7
    ·
    7 months ago

    Rust does memory-safety in the most manual way possible, by requiring the programmer prove to the compiler that the code is memory-safe. This allows memory-safety with no runtime overhead, but makes the language comparatively difficult to learn and use.

    Garbage-collected compiled languages — including Java, Go, Kotlin, Haskell, or Common Lisp — can provide memory-safety while putting the extra work on the runtime rather than on the programmer. This can impose a small performance penalty but typically makes for a language that’s much easier on the programmer.

    And, of course, in many cases the raw performance of a native-code compiled language is not necessary, and a bytecode interpreter like Python is just fine.

    • SorteKanin@feddit.dk
      link
      fedilink
      arrow-up
      22
      arrow-down
      1
      ·
      7 months ago

      Rust does memory-safety in the most manual way possible

      The most manual way is what C does, which is requiring the programmer to check memory safety by themselves.😛

      Also will say that outside of some corner cases, Rust is really not that harder than Java or Python. Even in the relatively rare cases that you run into lifetimes, you can usually clone your data (not ideal for performance usually but hey its what the GC language would often do anyway). And reliability is far better in Rust as well so you save a lot of time debugging. Compiles = it works most of the time.

      • 520@kbin.social
        link
        fedilink
        arrow-up
        12
        ·
        edit-2
        7 months ago

        The most manual way is what C does, which is requiring the programmer to check memory safety by themselves.😛

        The difference is, Rust will throw a tantrum if you do things in an unsafe way. C/C++ won’t even check. It’ll just chug along.

        Rust is really not that harder than Java or Python.

        As someone who’s done all three, the fuck it isn’t.

        If you are familiar with C/C++ best practices to any operational level, those things will translate over to Rust quite nicely. If not, that learning curve is going to be fucking ridiculous with all the new concepts you have to juggle that you just don’t with either Java or Python.

      • admiralteal@kbin.social
        link
        fedilink
        arrow-up
        13
        arrow-down
        1
        ·
        edit-2
        7 months ago

        I like Rust a lot, philosophically and functionally… but it is WAY harder. Undeniably very hard.

        Just try and do anything with, say, a linked list. It’s mind-boggling how hard it is to make basic things work without just cloning tons of values, using obnoxious patterns like .as_mut(), or having incredibly careful and deliberate patterns of take-ing values, Not to mention the endless use of shit like Boxes that just generates frustrating boilerplate.

        I still think it’s a good language and valuable to learn/use, and it’s incredibly easy to create performant applications in it once you mastered the basics, but christ.

        • MonkderZweite@feddit.ch
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          7 months ago

          It’s mind-boggling how hard it is to make basic things work

          It’s mind-boggling how broken basic things are.

          • admiralteal@kbin.social
            link
            fedilink
            arrow-up
            1
            ·
            7 months ago

            I have not encountered anything broken, aside from maybe binary app docstring stuff (e.g., automated example testing).

            On the contrary, everything seems precise, reliable, and trustworthy. That’s the thing to really like about Rust – you can be pretty much fearless in it. It’s just difficult. I die a bit in time any time I have a return type that looks like Box<dyn Fn(&str) -> Result<Vec<String>, CustomError>> or some shit . Honestly, the worst thing about Rust is probably that you have to manually specify heap vs stack when the compiler could easily make those determinations itself 99% of the time based on whether something is sized.

      • tiredofsametab@kbin.run
        link
        fedilink
        arrow-up
        7
        ·
        edit-2
        7 months ago

        Software engineer for almost two decades at this point, programming off and on since a kid in the late '80s: Rust is harder. It did seem to get better between versions and maybe it’s easier now, but definitely harder than a lot of what I’ve worked in (which ranges Perl, PHP, C, C++, C#, Java, Groovy/Grails, Rust, js, typescript, various flavors of BASIC, and Go (and probably more I’m forgetting now but didn’t work with much; I’m excluding bash/batch, DB stored procedures (though I worked on a billing system written almost entirely in them), etc.)

        That said, I don’t think it’s a bad thing and of course working in something makes you faster at it, but I do think it’s harder, especially when first learning about (and fighting with) the borrow checker, dealing with lifetimes, etc.

        The availability of libraries, frameworks, tools, and documentation can also have a big impact on how long it takes to make something.

    • abhibeckert@lemmy.world
      link
      fedilink
      arrow-up
      12
      arrow-down
      1
      ·
      edit-2
      7 months ago

      A better approach is the one Apple uses with Swift (and before that, Objective-C… though that wasn’t memory safe).

      In swift the compiler writes virtually all of your memory management code for you, and you can write a bit of code (or annotate things) for rare edge cases where you need memory management to do something other than the default behaviour.

      There’s no garbage collection, but 99.999% of your code looks exactly like a garbage collected language. And there’s no performance penalty either… in fact it tends to be faster because compiler engineers are better at memory management than run of the mill coders.

      • roanutil_@programming.dev
        link
        fedilink
        arrow-up
        7
        ·
        7 months ago

        To be fair, Swift uses reference counting instead of garbage collection which has different tradeoffs than GC but does incur a performance penalty.

    • floofloof@lemmy.ca
      link
      fedilink
      English
      arrow-up
      8
      ·
      edit-2
      7 months ago

      I’m no Rust expert, but in what I have done with it I’ve always found it reassuring to know the compiler has my back, and I haven’t found the rules too onerous. In some ways I prefer this to counting on some black-box garbage collector with unpredictable performance costs, and I certainly prefer catching as many errors as possible at compile time not runtime.

  • Simulation6@sopuli.xyz
    link
    fedilink
    arrow-up
    4
    ·
    7 months ago

    The interpreter or compiler could also introduce memory issues into the code. Much less likely to happen, but it is not unknown.

  • dohpaz42@lemmy.world
    link
    fedilink
    English
    arrow-up
    16
    arrow-down
    14
    ·
    7 months ago

    I’m going to probably be downvoted to Hell, but I disagree wholly that it’s the language’s fault that people can exploit their programs. I’d say it’s experience by the programmer that is at fault, and that’s due to this bootcamp nature of learning programming.

    I’d also blame businesses that emphasize quantity over quality, which then gets reflected in academia because schools are teaching to what they believe business wants in a programmer. So they’re just churning out lazy programmers who don’t know any better.

    There needs to be an earnest revival of good programming as a whole; regardless of language, but also specifically to language. We also need to stop trying to churn out programmers in the shortest time possible. That’s doing no one any good.

    That’s my two cents.

    • andyburke@fedia.io
      link
      fedilink
      arrow-up
      16
      arrow-down
      1
      ·
      7 months ago

      Gently, I would ask you to think about yourself in a future role where you have too little time, and are under too much pressure, and you haven’t gotten enough sleep, and you’re distracted on this particular day, and you happen to make a mistake, leave out a line, forget to fix a section of code you were experimenting with…

      And even if you, a paragon of programming power and virtue, would never find yourself able to be hurt by your tools, you must surely know that mortals have to work with them as well, right?

    • words_number@programming.dev
      link
      fedilink
      arrow-up
      11
      ·
      7 months ago

      Id say it’s experience by the programmer that is at fault, and that’s due to this bootcamp nature of learning programming.

      You are getting downvoted, because this is factually proven wrong by studies and internal analysis of several huge companies (e.g. google/android and microsoft). A huge number of exploitable bugs are preventable using memory safe languages, nowadays even without performance costs (Rust).

      Apart from that your point is orthogonal to the point of the post. You can have better trained coders and have them use better, safer technologies.

      We could also just train every driver more thoroughly including mental training and meditation to make sure they are more calm and focussed when driving and we maybe wouldn’t need seatbelts anymore. But:

      1. Is that a realistic scenario?
      2. Why not use seatbelts anyway, so there’s a higher chance of not dying if some driver didn’t sleep well that day?
    • Kissaki@programming.dev
      link
      fedilink
      English
      arrow-up
      9
      ·
      edit-2
      7 months ago

      Memory safety issues were a thing even before bootcamps and “bootcamp culture”.

      Even if you fix expertise, intention, and mindset - the entire workfield environment and it’s people - mistakes still happen.

      If you can categorically evade mistakes and security and safety issues, why would you not?

    • fidodo@lemmy.world
      link
      fedilink
      English
      arrow-up
      7
      ·
      edit-2
      7 months ago

      Even the best programmers are going to make mistakes at times. Saying the solution is to just be perfect all the time is impossible.

    • TechNom (nobody)@programming.dev
      link
      fedilink
      English
      arrow-up
      7
      arrow-down
      1
      ·
      edit-2
      7 months ago

      but I disagree wholly that it’s the language’s fault that people can exploit their programs. I’d say it’s experience by the programmer that is at fault, and that’s due to this bootcamp nature of learning programming.

      Considering that even the best programmers in the world can’t write correct programs with C/C++, it’s wrong to absolve those languages of the massive level of memory safety bugs in them. The aforementioned best programmers don’t lack the knowledge needed to write correct programs. But programmers are just humans and they make or miss serious bugs that they never intended. Having the computing power to catch such bugs and then not using it is the real mistake here. In fact, I would go one step further and say that it isn’t the language’s fault either. Such computing power didn’t exist when these languages were conceived. Now that it does, the fault lies entirely with the crowd that still insist that there’s nothing wrong with these old languages and that these new languages are a fad.

    • crimsonpoodle@pawb.socialOP
      link
      fedilink
      arrow-up
      4
      ·
      7 months ago

      While I agree wholeheartedly with the idea that we need to emphasize quality over quantity, so long as software pays well there will be people who don’t care. In my university I’ve met a fair few people that complain about having to learn about compilers, assembly, and whatnot because “I’ll never need to know that in my actual job”. While to some extent in the United States you can blame the fact that classes just cost a ton, I think it’s a sad reality that, barring some key change in the way our whole education and economic systems work, there will be unimaginative apathetic people that will ruin things for the rest. Plus people are fallible or something I dunno. But yeah void pointers are my jam because I don’t have to wait precious clock cycles making new ones jk.

    • nomadjoanne@lemmy.world
      link
      fedilink
      arrow-up
      2
      arrow-down
      3
      ·
      7 months ago

      Absolutely. The problem is, most programmers are mediocre. So sadly the protection of stupid people tends to take cultural precedence.

  • Adanisi@lemmy.zip
    link
    fedilink
    English
    arrow-up
    0
    arrow-down
    1
    ·
    edit-2
    7 months ago

    I’m going to advocate for C here: the sheer simplicity, fast compile times, and power it gives you means it’s not a bad language, even after all these years. Couple that with the fact that everything supports it.

    Rust, while I don’t actually know how to write it, seems much more difficult to learn, slower to compile, and if you want to do anything with memory, you have to fight the compiler.

    And memory bugs are only a subset of bugs that can be exploited in a program. Pretending Rust means no more exploitation is stupid.

    • Pipoca@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      7 months ago

      And memory bugs are only a subset of bugs that can be exploited in a program. Pretending Rust means no more exploitation is stupid.

      This is facile.

      According to Microsoft, about 70% of security bugs they see are memory safety issues.

      Yes: if you introduce memory safety, there’s still those 30% of security bugs left. But, well, I’d rather worry about 30% of issues than 100%…

      Similarly, I use libraries that eliminate SQL injections unless you really go out of your way.

    • carpelbridgesyndrome@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      1
      ·
      7 months ago

      In cases where bugs have been counted they tended to make up the majority of vulnerabilities. Chrome, Firefox, and Windows reported that around 70% of security vulnerabilites were memory corruption. Yes a subset, but the majority of the worst subset.

      • Adanisi@lemmy.zip
        link
        fedilink
        English
        arrow-up
        0
        arrow-down
        1
        ·
        7 months ago

        I’ve also heard that unsafe Rust is even more dangerous than C. I guess that’s probably something to do with the fact that you’re always on your toes in C vs Rust? I don’t know. But if you need to do any sort of manual memory management you’re going to need unsafe Rust.

        • Rustmilian@lemmy.world
          link
          fedilink
          English
          arrow-up
          1
          ·
          edit-2
          5 months ago

          I’ve also heard that unsafe Rust is even more dangerous than C.

          Utterly Untrue :
          It’s important to understand that unsafe doesn’t turn off the borrow checker or disable any other of Rust’s safety checks: if you use a reference in unsafe code, it will still be checked.

        • carpelbridgesyndrome@sh.itjust.works
          link
          fedilink
          English
          arrow-up
          1
          ·
          7 months ago

          The thing is the whole c program is unsafe. In rust individual parts are marked unsafe. This means auditing should be easier. Also being always on your toes isn’t really viable. Breaking down the program into safe vs unsafe is probably an improvment

        • IAm_A_Complete_Idiot@sh.itjust.works
          link
          fedilink
          arrow-up
          1
          ·
          7 months ago

          No, rust is stricter because you need to think a lot more about whether weird edge cases in your unsafe code can potentially cause UB. For ex. If your data structure relies on the Ord interface (which gives you comparison operators and total ordering), and someone implements Ord wrong, you aren’t allowed to commit UB still. In C++ land I’d venture to guess most any developer won’t care - that’s a bug with your code and not the data structure.

          It’s also more strict because rusts referencing rules are a lot harder then C’s, since they’re all effectively restrict by default, and just turning a pointer into a reference for a little bit to call a function means that you have to abide by those restrictions now without the help of the compiler.

        • lolcatnip@reddthat.com
          link
          fedilink
          English
          arrow-up
          1
          ·
          7 months ago

          Unsafe code should be a very, very small part of any Rust codebase. Lots of major libraries have a policy against including any unsafe code at all, because 99.9% of the time you can do just as well with safe cost. The major exception is when you need to call C code.

    • lolcatnip@reddthat.com
      link
      fedilink
      English
      arrow-up
      1
      ·
      7 months ago

      I’ve written quite a bit of Rust and a lot of C and C++ code. I’ll take Rust over C or C++ for any task, including ones where memory safety isn’t a concern. Yes, there’s a learning curve, but overall it’s just more pleasant to use. Now that I’m used to it, writing C++ code feels just as much like fighting the compiler as Rust ever did.

    • okamiueru@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      7 months ago

      Zig is a pretty interesting alternative to C

      Pretending Rust means no more exploitation is stupid.

      I guess? Are you alluding to someone or something in particular?

  • CaptainProton@lemmy.world
    link
    fedilink
    English
    arrow-up
    3
    arrow-down
    6
    ·
    7 months ago

    Oh yes, improve security by mandating that everyone uses higher level languages that encourage importing libraries.

    I hate to pull the AI card, but AI has a better chance of catching low level language type issues than forcing people to use tools they didn’t want to has of accomplishing anything positive.

    • Miaou@jlai.lu
      link
      fedilink
      arrow-up
      6
      ·
      7 months ago

      Yeah let’s audit code using heuristic tools, after all safety is just about probabilities in the first place!