News for hackers. Stuff that matters.
Re:The NSA advises move to memory-safe languages by jmclnx on Tuesday December 12, 2023 @09:25AM (#38612465)
I advise training programmers instead of throwing them in front of a screen without any training. Companies these days provides no training at all. When I was hired over 40 years ago, I spent plenty of time being trained for my first 3 months.

Now, nothing, and you if you want to train a new person, you do it on your own time.

Re:The NSA advises move to memory-safe languages by natsucks on Tuesday December 12, 2023 @10:06AM (#38613093)
"In attempts to mitigate the dangers of memory unsafe code in C and C++, many software manufacturers invest in training programs for their developers. Many of these training programs include tactics designed to reduce the prevalence of memory unsafe vulnerabilities produced by those languages. Additionally, there are numerous commercial and industry trade association training programs. Further, various organizations and universities offer trainings and a professional certificate for demonstrating knowledge of secure coding practices in C and C++. While training can reduce the number of vulnerabilities a coder might introduce, given how pervasive memory safety defects are, it is almost inevitable that memory safety vulnerabilities will still occur. Even the most experienced developers write bugs that can introduce significant vulnerabilities. Training should be a bridge while an organization implements more robust technical controls, such as memory safe languages."
Re:The NSA advises move to memory-safe languages by avgcorrection on Tuesday December 12, 2023 @10:35AM (#38613508)
But what’s your point? Do we expect each other to read the submission (the report) or something? :)
Re:The NSA advises move to memory-safe languages by manishsharan on Tuesday December 12, 2023 @10:23AM (#38613338)
Does the training go beyond showing them how to use Valgrind ?
Re:The NSA advises move to memory-safe languages by ARandomerDude on Tuesday December 12, 2023 @10:44AM (#38613653)
How to quit vim.
Re:The NSA advises move to memory-safe languages by tempmac on Tuesday December 12, 2023 @11:09AM (#38614084)
long-press power button
Re:The NSA advises move to memory-safe languages by hansvm on Tuesday December 12, 2023 @11:18AM (#38614210)
I can see why that would sometimes work, but the better preconfigured vim installations have a long-press of the power button remapped to a 911 call, in case the user has fallen unconscious onto the keyboard and needs medical attention.
Re:The NSA advises move to memory-safe languages by pjot on Tuesday December 12, 2023 @11:29AM (#38614370)
killall -9 vim
Re:The NSA advises move to memory-safe languages by jmclnx on Tuesday December 12, 2023 @12:56PM (#38615779)
>"In attempts to mitigate the dangers of memory unsafe code in C and C++, many software manufacturers invest in training programs for their developers

I have seen that too over the years and even been to a couple when I went to other companies, 99% of the time these classes are worthless and consists of marketing drivel. Half the class contains statements like "You can do it the hard way, or the easy way if you purchase ....".

One instructor even stated "You do not need to worry about running out of memory, allocate as much as you want". That class was 20+ years ago. After that I told my manager I will not go to any more vendor classes.

The training I am referring to is by experienced peers and goes on for many months where your work is reviewed in detail, 1 line at a time with you there. That use to happen decades ago, now no more.

Re:The NSA advises move to memory-safe languages by hnrodey on Tuesday December 12, 2023 @09:39AM (#38612698)
"intentional training" (my term) is one of the most under utilized levers to pull for a team or organization to level up. Your observation aligns with my anecdotal experiences with teams, and it's sad to be honest.

The pushback I've received is something I'd categorize as "cart before the horse" - executives want to know exactly what will be achieved with such effort before approving any expenditure.

The teams I've been involved with - training has generally come organically and grass roots.

Re:The NSA advises move to memory-safe languages by hsbauauvhabzb on Tuesday December 12, 2023 @09:39AM (#38612697)
Sure, but even the best programmers can write buffer overflows and other memory issues. Not that average shops have any interest in actually training people, though.
Re:The NSA advises move to memory-safe languages by citrin_ru on Tuesday December 12, 2023 @10:13AM (#38613199)
Best programmers tend to work on the most complex software though. There are small and relatively simple C/C++ programs around which have no know memory issues (but a person with minimal viable knowledge can introduce new bugs even there and that's where training would be useful).
Re:The NSA advises move to memory-safe languages by VikingCoder on Tuesday December 12, 2023 @10:16AM (#38613240)
I worked with someone who said it great once. I wish I'd written it down. It was something like,

"I'd rather use a threading library written by one great programmer than by ten average programmers."

Re:The NSA advises move to memory-safe languages by hsbauauvhabzb on Tuesday December 12, 2023 @05:17PM (#38619467)
Sure and for every small and simple application there’s are hundreds of terrible apps. I actually think memory safety is a pretty poor measure (in my isolated world I rarely see C code).

I see plenty of php logic which is far more likely to be publicly exposed and generally of a terrible quality.

Re:The NSA advises move to memory-safe languages by munk-a on Tuesday December 12, 2023 @10:05AM (#38613074)
As someone who has worked in C/C++ on teams for a while. My personal opinion is that safe C++ programmers never use pointers - put everything on the stack and use (usually const) references.

But I've really got to ask - at that point do you really want to program in C++ anymore or is it just better to use a safer language that removes pointers entirely?

Re:The NSA advises move to memory-safe languages by UncleMeat on Tuesday December 12, 2023 @10:18AM (#38613266)
And this still permits oodles of memory safety issues. You can have lifetime problems with stack-use-after-return. You can have bounds checking issues on stack allocated arrays. You can have data leakage through use of uninitialized memory.

And while there are some kinds of applications where never performing heap allocations is viable, this design is simply not an option for a huge number of applications.

Re:The NSA advises move to memory-safe languages by butlerm on Tuesday December 12, 2023 @11:04AM (#38614008)
It is basically impossible to write general purpose software like compilers, word processors, and layout engines without doing heap allocations. That means either pointers or references, which are difficult to distinguish if you do not engage in pointer arithmetic.

Any C++ program that does not do heap allocations either uses arrays as a substitute for the same thing or isn't a general purpose application.

Re:The NSA advises move to memory-safe languages by jandrewrogers on Tuesday December 12, 2023 @11:17AM (#38614191)
There are categories of software for which C++ is still the clear best choice due to its superior expressiveness as a systems language. There are also other types of safety beyond memory safety that are better supported in C++ than other systems languages. As a practical matter I haven't seen a pointer issue in years, working from a C++17 foundation, so the expressiveness and other safety benefits are more valuable than a lack of a borrow checker or garbage collector.

I use safer languages when appropriate but there are cases where they would introduce more bugs than they address.

Re:The NSA advises move to memory-safe languages by estebank on Tuesday December 12, 2023 @11:54AM (#38614789)
> There are also other types of safety beyond memory safety that are better supported in C++ than other systems languages.

Such as? Genuinely curious.

Re:The NSA advises move to memory-safe languages by jandrewrogers on Wednesday December 13, 2023 @01:00AM (#38623268)
C++20 has very powerful compile-time metaprogramming and generics facilities. As a consequence, you can codegen complex systems of data structures and algorithms that are verified to be both optimal and safe at compile-time, essentially from a specification. The ability to automagically infer and codegen use-case specific types means that there are almost no naked primitive ‘int’ and similar types anywhere, the types are restricted to what they need to express and little more. While there is some ability to formally verify the correctness of these type interactions at compile-time, it is limited as a practical matter. The real strength is the ability verify the properties pretty exhaustively at runtime, given sufficiently good testing.

If you implement something like a database kernel almost entirely in user space, which is what you want to do if you care about performance, you have a new set of problems that languages like Rust were not designed to solve. Ownership, mutability, and lifetimes are not resolvable for most objects at compile-time, they can only be resolved dynamically at runtime. With C++, you can make these look like ordinary objects with ordinary behaviors, with metaprogramming abstractions under the hood arbitrating the chaos. Things that look unsafe are actually guaranteed safe by the underlying abstractions. In this type of software, almost your entire address space is “unsafe” in some way, so it is enormously useful to be able to overlay a safety model that does not rely on the compiler, since the compiler cannot solve these cases.

I use both C++ and Rust in production environments. There are cases where C++ used well is legitimately safer, theoretically and empirically, which is why I still use C++ for some things. Rust may become stronger at dealing with these cases but it still has many years to go. (Also, Rust async story is a hot mess, and you really need async for scalable, performant systems software.)

Re:The NSA advises move to memory-safe languages by LoganDark on Tuesday December 12, 2023 @10:07AM (#38613097)
Do "references" even exist in C? Aren't they a C++ thing?

How do you manage heap allocations without ever touching a pointer?

Re:The NSA advises move to memory-safe languages by munk-a on Tuesday December 12, 2023 @10:11AM (#38613163)
Edited for correctness - I was indeed talking about C++ and references are relevant only in C++. C absolutely has stack allocations which can make things a fair bit safer but if you're passing around collections it's usually done by pointer just to avoid copy actions.
Re:The NSA advises move to memory-safe languages by LoganDark on Wednesday December 13, 2023 @01:45AM (#38623533)
C has VLA, but I think C++ can still use alloca, although that returns a pointer still.
Re:The NSA advises move to memory-safe languages by genmud on Tuesday December 12, 2023 @11:20AM (#38614242)
If (security) training worked, we wouldn’t have these issues.

Even in highly regulated, controlled environments memory safety is still an issue. I have seen bugs in these environments where I know for a fact that the developer has had 40-80 hours of training on memory safety and they still pop up.

If these people have occasional issues, the rest of the world has no effin chance.

Re:The NSA advises move to memory-safe languages by cryptos on Tuesday December 12, 2023 @10:00AM (#38612991)
Training and technical security measures shouldn't be treated as alternatives. Even trained programmers produce bugs and security issues, if at least some of them can be prevented by an additional safety net, then it would be stupid not to use it.
Re:The NSA advises move to memory-safe languages by brookst on Tuesday December 12, 2023 @10:01AM (#38613007)
Not to worry! In the future most programmers will undergo tens of thousands of GPU hours of training.
Re:The NSA advises move to memory-safe languages by osigurdson on Tuesday December 12, 2023 @10:04AM (#38613059)
We will see. I suspect things will not turn out as expected.
Re:The NSA advises move to memory-safe languages by brookst on Tuesday December 12, 2023 @10:09AM (#38613132)
I think you just said you agree with me?
Re:The NSA advises move to memory-safe languages by datameta on Tuesday December 12, 2023 @10:26AM (#38613370)
There might be a layer of humor you didn't pick up on.
Re:The NSA advises move to memory-safe languages by dylan604 on Tuesday December 12, 2023 @10:34AM (#38613487)
or that this hype about the tech replacing programmers is not going to pan out. so maybe it is you who didn't pick up on something? to be able to provide commentary on a joke does not mean the joke was missed
Re:The NSA advises move to memory-safe languages by datameta on Tuesday December 12, 2023 @04:40PM (#38619005)
it is possible that I missed out on what the other commenter meant but I wasn't trying to be derisive
Re:The NSA advises move to memory-safe languages by AdamN on Tuesday December 12, 2023 @09:37AM (#38612661)
Startups are likely to fail, big tech is likely to fire the developer (or they quit), and poorly run companies just don't know how to train. End result is it just doesn't happen much anymore.
Re:The NSA advises move to memory-safe languages by timbit42 on Tuesday December 12, 2023 @10:30AM (#38613436)
Employers complain they can't find people with the skills they need yet they refuse to provide training for those skills as it's cheaper to hire someone that was trained in the skills they need by another employer.
Re:The NSA advises move to memory-safe languages by staunton on Tuesday December 12, 2023 @10:40AM (#38613595)
> yet they refuse

That doesn't seem like a contradiction at all. As you say, they want to hire trained workers rather than providing training themselves. Also, complaining is free while hiring good people is not...

Re:The NSA advises move to memory-safe languages by timbit42 on Tuesday December 12, 2023 @01:54PM (#38616611)
Sure, but my point is that no one is training anyone so now they can't find people with any training, yet they still refuse to train them.
Re:The NSA advises move to memory-safe languages by joncrane on Tuesday December 12, 2023 @10:01AM (#38613016)
I feel like each company/organization has such a unique DevOps toolset that all the "training" goes into figuring out which IDE you're allowed to use, which git client to install, what even are the processes/policies for installing stuff on your work computer, what's the workflow, etc etc etc. All the bandwidth is used on that and there's not much left over for the actual art of coding.
Re:The NSA advises move to memory-safe languages by staunton on Tuesday December 12, 2023 @10:46AM (#38613695)
It's plausible that in many settings this is actually most efficient from the point of view of the company.

Do training on the things that can cause trouble longer term (inconsistent tooling taking over, security issues, company-specific things you cannot find online) and just hope people pick up the rest as they go. Good workers will usually manage. The people deciding how to train new workers maybe don't even know what kinds of "main" knowledge a given worker would need. Rather than assigning an expensive senior worker to training them, they might hope someone good willing will do it in their spare time.

Re:The NSA advises move to memory-safe languages by rowanG077 on Tuesday December 12, 2023 @09:55AM (#38612932)
No training will prepare a human for writing safe C. It seems to be impossible for a human to do that.
Re:The NSA advises move to memory-safe languages by bjord on Tuesday December 12, 2023 @10:27AM (#38613382)
Depends on the company these days. In my initial role, I was given a couple days to "read over the codebase" and was then expected to start producing results. Most of my peers had weeks or months-worth if training before they started contributing.
Re:The NSA advises move to memory-safe languages by CoastalCoder on Tuesday December 12, 2023 @10:03AM (#38613042)
I wonder of part of the issue is that 40 years ago, people typically stayed much longer with companies.

(I actually don't know what the norm was. My dad was an EE for the defense industry, and IIRC he worked for 3 different employers over his career.)

Re:The NSA advises move to memory-safe languages by munk-a on Tuesday December 12, 2023 @10:07AM (#38613110)
Well 40 years ago stuff was absolutely laden with exploits... if you're talking about code written 40 years ago that we still use today? Most of that stuff is battle tested and came from teams that were highly disciplined to begin with - the good code floats.
Re:The NSA advises move to memory-safe languages by bakuninsbart on Tuesday December 12, 2023 @10:10AM (#38613139)
My dad is in his 60s, started his company with some friends in the 90s. None of them got super rich, but they are all doing well, and all slowly going into pension. The company grew to a mid-size level, but actually most of the early employees stayed, and I think the average tenure is still probably > 10 years. Switching jobs every 3 years is weird, it is pretty much the time it takes to learn the ins and outs deeply enough to be an expert. There's some sense to it, as after learning all you can, it might be better for your career to search for new challenges. There's also the nonsense that switching that often generally yields significantly higher pay.
Re:The NSA advises move to memory-safe languages by underlipton on Tuesday December 12, 2023 @10:54AM (#38613845)
It's impossible to stay long with companies. The nascence of "shareholder value" as an overriding concept means that if you're far more likely to be laid off, or forced to job-hop to maintain purchasing power, than to be able to stay with one business for years and still have a successful career. By companies' own policies, it has become untenable for them to train. So it's all on them. They've got to fix the issue (before the government does it for them).
Re:The NSA advises move to memory-safe languages by synergy20 on Tuesday December 12, 2023 @09:36AM (#38612659)
absolutely correct, in fact now some new hires are expected to do a few git-commit the first day(looking at you, Meta).

no wonder so many bugs here and there.

Re:The NSA advises move to memory-safe languages by HotHotLava on Tuesday December 12, 2023 @12:10PM (#38615054)
Unlike 40 years ago these commits will be reviewed by an experienced colleague and automatically unit and integration tested, so there's no benefit anymore to training people separately before being allowed to touch the real codebase.

Back in the day people with SVN/CVS commit access would push directly to the main branch after testing locally, and testing would be done as part of preparing a release, so it was more necessary to have a "safety" period where new people could get used to the new codebase.

Re:The NSA advises move to memory-safe languages by disgruntledphd2 on Tuesday December 12, 2023 @10:20AM (#38613286)
> absolutely correct, in fact now some new hires are expected to do a few git-commit the first day(looking at you, Meta).

Meta have a phenomenally good training program, called Bootcamp for basically everyone in engineering, so they're probably not the example you're looking for.

Re:The NSA advises move to memory-safe languages by synergy20 on Tuesday December 12, 2023 @10:25AM (#38613367)
I recall meta expects new hires to do first commit the first day, not sure how its training will help in this scenario, this is in no way saying meta has no good training, it just does not add up here though.
Re:The NSA advises move to memory-safe languages by viraptor on Tuesday December 12, 2023 @10:39AM (#38613577)
What kind of commit though? We expect a first commit on the first day. The commit adds you to the maintainers list in readme and grants you some new roles after merging. It is not a "solve this user's issue" kind of commit.
Re:The NSA advises move to memory-safe languages by 0cf8612b2e1e on Tuesday December 12, 2023 @11:30AM (#38614383)
How is that possible? It takes over a week just to get a new employee configured. Laptop, IDE, permissions to the hundred needed things, etc. Let alone opening up an unfamiliar codebase.

Unless it is a “hello world” commit to confirm tooling is operational, I have strong doubts.

Re:The NSA advises move to memory-safe languages by disgruntledphd2 on Tuesday December 12, 2023 @12:42PM (#38615575)
> How is that possible? It takes over a week just to get a new employee configured. Laptop, IDE, permissions to the hundred needed things, etc. Let alone opening up an unfamiliar codebase.

When I started at FB in 2013, I had all the laptop/permissions things done by end of the first day.

At the time, the presumption was that you'd push a really small change by the end of the week, but all of the tasks available tended to be pretty easy (note I wasn't in eng then, so all my info is second hand here).

Re:The NSA advises move to memory-safe languages by DelightOne on Tuesday December 12, 2023 @09:38AM (#38612690)
Why train when they just leave the company in a year for 10%+ more money.
Re:The NSA advises move to memory-safe languages by JambalayaJim on Tuesday December 12, 2023 @09:52AM (#38612883)
Give them a 10% raise if they do well in the first year, problem solved.
Re:The NSA advises move to memory-safe languages by tharne on Tuesday December 12, 2023 @09:42AM (#38612734)
With that attitude, it's not shocking you have a retention problem.
Re:The NSA advises move to memory-safe languages by felideon on Tuesday December 12, 2023 @09:51AM (#38612867)
Obligatory: "what if they stay?"
Re:The NSA advises move to memory-safe languages by claudex on Tuesday December 12, 2023 @10:00AM (#38612988)
You fire them with the yearly 10% mandatory cuts off
Re:The NSA advises move to memory-safe languages by shae on Tuesday December 12, 2023 @11:08AM (#38614064)
Q: What if we train them and they leave?

A: What if you don't and they stay?

Re:The NSA advises move to memory-safe languages by bigbillheck on Tuesday December 12, 2023 @10:50AM (#38613768)
What's that got to do with the issue?
Re:The NSA advises move to memory-safe languages by osigurdson on Tuesday December 12, 2023 @10:02AM (#38613026)
I think people should take responsibility for their own awesomeness.
Re:The NSA advises move to memory-safe languages by VikingCoder on Tuesday December 12, 2023 @10:23AM (#38613333)
I think you do not appreciate that some people have jobs that don't give them adequate support to be awesome.

I just watched the most recent Last Week Tonight, where they went in depth on Freight Trains [1]. Specifically they talked about 3 mile long trains that currently only have two operators - one conductor and one engineer - and the industry is trying to cut it down to one.

That's just an analogy for software development. But I've definitely seen people be over-worked and under-supported.

[1]: https://www.youtube.com/watch?v=AJ2keSJzYyY

Re:The NSA advises move to memory-safe languages by bumby on Tuesday December 12, 2023 @10:15AM (#38613222)
I assume that includes leaders taking responsibility for the organization they are paid to lead. That includes investing in their coworkers' "strategic awesomeness" via training.
Re:The NSA advises move to memory-safe languages by osigurdson on Tuesday December 12, 2023 @02:21PM (#38616982)
Agree. Leaders (though I think "Gatekeepers" is a more accurate term in this context) should not stand in the way of anyone's awesomeness.
Re:The NSA advises move to memory-safe languages by hardware2win on Tuesday December 12, 2023 @10:08AM (#38613122)
Yea, clearly faang level engineers lack of training.

Edit.

Idk why downvotes

Chrome and Windows code bases had 70% of cves due to mem issues and their engineers arent some unqualified and lacking of training opportunities ppl

Re:The NSA advises move to memory-safe languages by ralphc on Tuesday December 12, 2023 @01:16PM (#38616085)
It doesn't take long to find comments on HN about how there are plenty of people out there that can do a good interview but can't code their way out of a paper bag. The standard solution to this, and I've been on the receiving end of this, is to have someone as a contractor for 3+ months before converting them to full time employee.

I'm afraid your approach would mean hiring someone and spending time and money on them before you're sure they'll work out in your organization. Few want to train contractors and firing FTEs after 3 months and change is a dim prospect as well.