Volvo is using Rust for its in-vehicle software
medium.com
medium.com
The software development timeline is slaved to the rigid manufacturing timeline. There is no allowance for slippage, so making things work By Any Means Necessary is the rule of the day. Concurrency problems often are not debugged; locks and similar are just sprinkled around until they disappear in testing. It is TDD taken to an extreme -- passing the enumerated tests, technically, is the definition of done even if the code is obviously poor or broken.
There are a vast number of software and hardware components sourced from myriad vendors that are swapped out every year to save a few dollars or deal with a supply chain issue. There is no stable baseline but all of these components need to work together. The code has to constantly adapt to the reality that someone sourced parts for a new model year that work differently or are in a different programming language.
This code is usually required to be supported for 10+ years. The developers don't just have this year's tech stack and code base to deliver on a rigid schedule, they are required to maintain several older implementations concurrently, often built in different languages and architectures.
Basically, the automotive industry has failed badly at the transition from being hardware manufacturing companies to being hardware + software manufacturing companies, and try to run their software processes the same way they ran their traditional hardware processes. Choice of programming language is the least of their concerns, that isn't the source of their code quality issues.
Relevant (for those who don't want to watch video):
- 3000 pages of specs
- 1 million LoC from suppliers (because you use different systems from different suppliers)
- 200 problems
- of which more than 100 problems were in the standard itself (standard being AUTOSAR that described how different parts from different suppliers communicate with each other)
What could be an important change is the culture. At the very least, developers who tend to pick Rust may be (hopefully) more inclined to do things the right way and don't just slap shit on the codebase until it sticks. I've seen way too much of this attitude in embedded developers.
And another important change could be management policies. If they are conscious to pick something uncommon, they might have better tolerance toward spending more time but doing things properly, than pushing people to release whatever seem to work (somehow).
I'm pretty sure a lot of bullshit in IoT happens because management want to release things as fast as it's possible, and developers either don't care or can't fight it.
Cars get tricky, though, because bugs can lead to loss of life.
The business processes force the engineering work product to be a dumpster fire.
The great companies dont.
It does sound like Rust could help here
But even then that's usually abstracted away and then a safe interface being provided.
ten_things[11] = blah; // is a buffer overflow so it either won't compile or it panics
However
unsafe { ten_things[11] = blah; } // is still a buffer overflow, same effect but also Rust warns that unsafe is useless here and should be removed
Now of course we can write a potential buffer overflow in unsafe Rust, but now we're not just sprinkling unsafe on stuff and hoping, we've got a plan, perhaps a stupid plan but it's a plan so that's an improvement.
Even OS kernels are borderline, and it's still being figured out how exactly Rust fits, but yes we are slowly moving in that direction. Kernels have a lot of logic that qualify for the safe zone, and software engineering culture that is... let's say ahead of automotive.
This is a bit of a misconception for people who've not worked with unsafe Rust. It's not like the language and most of its features disappear. It just allows a few extra features that are unsafe, like working with pointers... Which, granted, is a lot of interaction with hardware. But you can kinda "cordon" this to a small subset of the codebase dedicated to this low level hardware IO
I'm not really an expert in embedded systems, so take this with a grain of salt, but that doesn't track with my experience or with my theoretical understanding of embedded systems. First off, embedded systems are just regular systems with tighter constraints and less high-level constructs. With that understanding, if embedded code is unsafe... so is any code on any system.
Second, embedded systems have peripherals that are accessed via direct memory reads and writes. Which is only unsafe if access to those peripherals is shared in an unsafe way. Sure, the rust code that reads and writes to memory addresses will use `unsafe`, but everything above that can be written without using unsafe. Which I guess makes your statement technically correct, but imo not practically correct
If anything Rust has a clear boundary, and that's useful for all kinds of static analysis.
And I say this as a fan of D lang. I don't really see any advantage of Rust over D except popularity.
But referencing the parent comment's discussion of business processes, its highly unlikely the problems will appear until Volvo tries to move to some other vendor or swap out the software solution for the next greatest thing.
More complicated than what, C++ which is probably what was used before? It's unlikely to be more complicated in that case.
I'm curious to see if the Rust programmers affect the organizations as well by introducing unions to combat this kind if thing.
On another note I disagree that language will have no meanigful effect, even in a hostile environment such as this.
Whatever ethos you imagine Rust developers uniquely have, it doesn't address any of the constraints and incentives that are creating the code quality problems in automotive. Even the best developers in the world would have a difficult time producing a quality product in that environment.
They tend to seem more of the type to go on strike, form a union, or leave a job because of political views.
> Even the best developers in the world would have a difficult time producing a quality product in that environment.
Right, i'm saying I think at least more experienced rust developers would refuse to work in that environment.
They seem like they would risk more of their own well-being for ethical reasons, for better or worse.
I suppose if Volvo started depending on highly socially conscious domain experts and had a choice between changing working conditions and ditching rust though, they'd change the latter.
I'm happy to be proven wrong, but experienced C programmers seem to be more conservative "don't mix politics and programming" types.
It's amazing that you're saying all that and the same time completely oblivious to the fact that Volvo is in Sweden. Which has unions, labor protection, amazing working conditions etc. etc.
The reason Volvo is doing what it's doing is due to Volvo's commitment to safety [1] and not because of some mythical exclusively social ethos of some programmers.
[1] https://www.volvogroup.com/en/about-us/traffic-safety/safety...
Over the years, I've seen various discussions brush up against the issue of professional certification. Professional Engineer, in civil engineering, is a serious credential, which can hold people professionally liable for bridges that fail, or buildings that fall over. Making cars a network of computers that all talk to each other, operated entirely "by wire," and giving up any consideration of mechanical backups (like with a plane) is going to very quickly drive the point home that the programming profession needs a similar credential. As a mechanical engineer who has made a living writing software for 30 years, I understand the difference, but the legal externalities are not going to care that software is VASTLY more complicated than, say, designing a plane wing with a factor of safety.
Now, I have to go figure out why my Rails application can no longer restart the delayed_job process on deploy. Is the problem in Rails, Ruby, my gems, Capistrano, permissions, SSH, or some updated package on my Linux VM? Designing a bridge, frankly, is easier, because it's "concrete" and closed-form. Sure, I'll figure out my deployment problem, but next month some obscure thing in the 24 layers that make up a simple web app these days is going to get updated, and break something else. At least once a bridge is built, it's done.
Consider existing professional certifications, like, for example, Cisco certification. How many top tier people have it? Some do, but in my experience, not many. Instead, they are overwhelmingly held by low-to-mid skill people, who see it as a ticket to a better job. Top tier people can easily get top tier job, and have no need to waste time on some certifications.
But in software? If management says you need to cut corners to get something out by an arbitrary deadline, well, you cut the corners or they'll find someone who will.
At the end of the day, you still work for them, so with enough "nos" they'll just fire you or assign you to projects which don't matter.
As an electrician for example, we have to check almost everyrthing with various tests and sign it with my name.
For me, the software world still looks and feel like wild west.
They'd have to replace you with someone else similarly certified.
Software certifications, afaik, are not like this, but instead are sort of like merit badges.
In any case, if PE was required to work in software, I wouldn't have had a job in the first place, so I'll always oppose these kind of efforts to shut out the outsiders and underprivileged people.
In any case, I can ASSURE you that it was comprehensive, and you have to "know your stuff" to pass it. I've been Microsoft certified, so I've seen this side too. If there were a similarly-reputable license in software engineering, there would NOT be "certification factories" to crank out people who can pass the cert test, and who can do little else. I don't know what the analogue for doing actual mechanical/electrical/civil engineering problems would be in the software engineering realm, but that's the KIND of thing that would have to be tested. It would require a working computer and internet access, and not a duffle bag of engineering textbooks, like I had. ;-)
If almost no one wants them, then they would pay very well and be in high demand, and that comes with lots of benefits and perks, and you can require the use of the best tools to ensure those disastrous outcomes don't happen. So yes, I'd take that job.
I work in "automotive," and my company created an internal textbook on waterfall development 25 years ago. I know, because I was part of an external consultancy to review it. And it was great! At waterfall! And they're still using it! Now we're getting into alternate power, and we've lifted the same software process we've been using since we had to break our firmware into 8 pieces BECAUSE THAT'S WHAT FIT ON A FLOPPY to send to the plant to upload into the ECM, and started using it with completely new build systems and processes. We've hobbled what could be a completely fresh start with 25-40 years of technical debt before even getting started. I would posit that heading off this train wreck was the place of the CIO or CTO, but they just made the CIO the CEO, so ¯\_(ツ)_/¯.
We know how to solve the problem of software reliability. We have a rich body of formal methods that allow us to build perfectly reliable computer systems, up to the failure envelope of the hardware itself (from thermal, radiative, mechanical, etc. stress).
The reason we only use these techniques on certain critical systems is that the cost is somewhat higher than normal "unsafe" development and the incentives are not there yet.
Instead of turning our industry into a horrific morass of red tape, with questionable upside and unquestionable downside, let's just incentivize the use of correctness technology where appropriate.
Except, that's precisely what they do. Such costs are calculated into the product when it is being developed. Just read about the Avandia drug scandal.
And introducing certification is not going to to stop the killing and will not "cover their asses" either. Out tech currently is simply not adequate to solving this problem in the way acceptable to corporations and the end customers.
When it comes to the issues of safety the proper outcome should be organized by a processes, verification and other things that would not let that piece of code get into production. Putting this kind of load on software developer I think is utterly demented idea.
Proper engineers learn them, not random dudes that decide to call themselves "engineers" after a six weeks bootcamp.
In civil engineering and other, individual engineers can face consequences for disasters like collapses.
And other disciplines; a surgeon can face consequences for a surgery that was done by a team, and so on.
The first person to get jail time during the 'DieselGate' scandal was James Liang, surprise surprise an Enginnering Head at VW. An army of Execs and C-levels were in the know but the first guy to go is a low-rank Engineer.
My point is execs and C-levels always claim that their pay is justified by the risk and liability of their decisions but when the wheels hit the tarmac things change very quickly.
Improve regulation, fund regulators, incentivize companies to fund quality processes.
People without actual engineering background (should) have no place in safety critical systems design.
I don't think it needs the credentials, it just needs (language?) to distinguish between roles where you can sign off on a product and be held legally liable if the product is found to fail its specification.
This, in my mind, is the difference between a software engineer and a software developer (I consider myself a software developer).
I’m not sure what the solution to bad software is, but I don’t think it’s making the spec higher stakes.
https://ncees.org/ncees-discontinuing-pe-software-engineerin...
Here's a scenario. You're nominated to be an ECU supplier or a software sub-supplier for a VW brand, first thing they hit you with is requirements which span 1000 pages for a simple system (door, seat, HVAC), or 10x more for a more complex one (infotainment, engine ECU, "main" vehicle ECU etc.). 1 of those requirements is "SW shall comply with VW 8xxxxx norm" which is one of many VW norms that they deliver to you. The other requirement is "SW shall comply with KGAS", KGAS stands for "Konzerngrundanforderungen Software" which translates to "Group Basic Software Requirements", (group is VW), and both, you guessed it, are thousands upon thousands of requirements.
Then there's Functional Safety, or FUSA, which is a reference to ISO26262 (based on IEC 61508). Then there's also ASPICE (ISO/IEC 15504). New thing is UNECE R155 (cybersecurity). These three prescribe a very detailed development process commonly known as the "V model" for system and software development, which means you need to elicit requirements, define system requirements, system architecture, software requirements, software architecture and software detailed design. After that, you get to coding. For each of those there's a validation method: unit tests, software integration, software qualification, system integration and system qualification. ASPICE 4.0 has expanded to cover Embedded Hardware and Mechanical design as well. Other than the engineering processes they also cover other areas such as project management, configuration management, supplier monitoring, problem & change management etc.
Then come the external and internal audits, pardon, assessments. Your internal Quality department needs to monitor all engineering activities and report them to the customer, customer's Quality dept. will do their own audits, you and them will also hire an independent company to audit/assess you so that there's no bias.
BUT guess what - almost none of this is required for non mission critical software, so your infotainment is actually the only thing developed in a way you've described it. Brakes, ABS, ESP, Engine ECU or the EV powertrain (BMS, inverter etc.) are all written according to what I described above. There's no need for more bureaucracy, the automotive industry (especially German one) is very good at self-regulating and would make an average web developer throw up on his first day. Failures of the UX/UI in modern vehicles is just a business problem - guys who spent decades building and selling options like leather seats, and checking spreadsheets at the end of a fiscal period are still at the helm or their business processes still live on in those companies.
And who will handle the distribution of that credential... The moment it is required to have one, thousands of private universities of questionable quality will be dispensing such credentials just like how they have been dispensing engineering titles. Totally legal. What difference will it make compared to the existing situation...
Or is it so that these credentials should be distributed by a few elite institutions to make it safer.
What difference does this make from the current situation in which top corporations hire top people for top tier work? So everyone will have to hire MIT, Pekin U, Tokyo U or Berlin U graduates?
And what happens when centers like San Francisco suck all of those graduates away from the rest of the market and cram them into the expansive tech business? Leaving the Automotive industry as scarce of such top talent as it is now? Will the auto companies pay more money than Google et al to attract that top talent? Something which they could easily do now, but arent?
...
So basically your proposition will not change anything, but it will just introduce more bureaucracy into software.
And state, that is behind in everything related to technology, is going to be the arbiter of the 'best practices' in a field that progresses faster than what even the top universities of the world can cope up with...
So basically this would force software into a profession lagging from ~100 years behind like other engineering fields...
I think the main problem is that there is no competition since you are buying the car not for the software (at least most people don't).
Make car software an open marketplace, and you will see improvements in quality.
For infotainment inside the cockpit sure knock yourself out. But I absolutely do not want to be on the road or at crossing as a pedestrian with cars running modded ABS or ESP units.
I don't think any car manufacturer combines the functionalities you mention in a single software system so it would be easy to separate them.
Even annoying shit like media controls randomly not responding (including not being able to turn off or change volune), autopilot suddenly wanting to commit suicide, autopilot randomly shutting down, random error messages of stuff not working, random messages for things that were unchanged (child lock engaged, even though it was already engaged)
I really like the design choices, and i like the software and audio quality, but once you actually start using the car, it goes downhill fast.
I’m glad I got rid of mine. After 3 horrible Volvos and horrible shit service, i’ll never get another one even though I still think they look great.
Now driving a Mazda CX-5. Absolutely fault-free, no software issues, runs perfectly.
It shows.
I have nearly every safety feature turned off in the car because they all generate false positives at an astounding rate.
Same here (V60 2021), it skips a beat from time to time (now happy to know that I don't have problems with my brain nor ears :) ). Luckily so far I didn't have issues with the autopilot but thanks for the heads-up.
On the other hand a few months ago the radio volume got stuck for 15 minutes (couldn't even switch it off) while I was on a pass road with nowhere to stop, luckily it wasn't too loud => this made me think "ok, the media device is not directly a safety-critical subsystem, but what if the volume suddenly goes up to max, and maybe it stays there? Or if the trunk automatically opens? Etc... => tricky to define what is important from a safety perspective in a car...".
My FIAT Panda from the early 2000s has none of those problems. I need no updates, and every problem it has can be fixed by any car worshop, or even myself.
Relays and basic electronics that don't handle anything important, that's all it has.
It is lightweight (fuel efficient), agile in town and on dirt roads, cheap and easy to maintain.
But it’s still very, very bad and I hope Subaru’s controls engineers are addressing it.
The rest of the features, however, make this the safest car I’ve driven so far. Adaptive cruise control, reverse automatic braking, and collision avoidance will make all cars safer.
I should write about it but the collision avoidance saved me from hitting a cyclist that flew out of a parking lot with a reaction time I wouldn’t be capable of.
On the other hand, we have a term for people who are always installing the latest beta updates and purchasing shiny gadgets: we call them "heatseekers". It's the heatseekers who tend to have unreliable tech and lose control of the gadgets that are supposed to make their quality of life better.
It seems pragmatic and wise to take new technology with a grain of salt. Since I have used computers and other technology for over 40 years, I have developed a good sense for what will be reliable and proven, and what should be avoided until it has been given a chance to mature. Often there are things in the latter category that can be taken up by scammers and hucksters who are eager to make a quick buck.
As always, keep in mind the adage that those who won the Gold Rush were selling the shovels and supplies. I personally enjoy selling shovels.
However, the collision avoidance is excellent. It works great, never had unwanted breaking, it assists breaking in emergency, and the rear cross traffic frequently senses incoming cars we can't see.
If you had a windows 95 PC controlling the blinker, the exact same bug and symptoms would be totally expected...
Do how in 25 years have we not managed to quash this class of bugs? (Where a simple task needs to be done at a certain time, and gets delayed).
Or just don't use software. I wouldn't expect the blinker delay to use software, just a timer IC.
The main processor then tells this processor to do all timed tasks.
I'm not so sure anyone actually wants fad buzzword salad frameworks du jour driving their multi-decade lifespan appliances - not a ton of upside in your fridge running fullstack cuberentes docker react node restful AI SAAS on bay area RSUs
Clearly, it's a software issue, not a hardware issue. Hard to believe that software is really cheaper than a 555 timer. I wonder why this decision was made.
For example, an ECU that controls blinkers does it with a 555 timer, based on a "start blinking" CAN bus command. It resyncs on each new "start blinking " command. It times out after 50 blinks, if no "stop blinking" command comes.
This makes each ECU autonomous and responsible for doing "the safe thing", once it has been commanded to.
Finding all the new subtle horrible timing problems in this design is left as an exercise for the reader. :)
3 different controllers or software becomes an easy choice when CAN is already running everywhere
I tell myself it’s some component busy GCing for a bit :)
In this case, the older blinks are possibly not deallocated and slow down the processing of newer blinks. Fortunately automotive software has all sorts of watchdogs and at some point the blink watchdog must kick in and it kills the blink manager which is then restarted and it processes the blink queue in quick succession.
I understand what the marketing means. But grep your codebase and dependencies for "unsafe"... That should put paid to your fearlessness.
I think it’s more likely the Danish cops got some big fundage.
I’ve been at the dealer 6 times in 7 months to fix random shit on a brand new car and they managed to fix only two things: the ticking sun roof, and the charge port not opening. (Which is kinda annoying on an EV).
Some EV fans like to claim EVs are more reliable because they have less moving parts. These people obviously never owned a computer.
I bought a 60k eur car in the same building. I do expect you to waste a day finding an issue on a brand new car. If you don’t want to, don’t sell the POS cars.
If you are in the EU, have you spoken to the consumer ombudsman (or whatever name it has)?
The longevity of in car software is utterly attrocious. Taking a very basic car like a Toyota Aygo as an example, in 2015 they released their mid-range models with a large touchscreen in the center console, boasting support for connecting your phone and such. In reality it didn't work from day 1. They used Mirrorlink which had already become out of date tech and wasn't supported by any of the handsets anymore.
Now, they could've released a software update to fix this. Except they didnt. They kept selling that car for several years, advertising phone integration that didn't work.
Car manufacturers give absolutely no care at all to their software and never have.
Those still supersede only the user-facing code (dashboard, buttons, entertainment), and all the other low level code still needs to be written: engine control unit, ABS/ECS etc, airbags, battery management, indicators, windows, heating, wipers, drive by wire, etc - and let’s not forget all the glue code (essentially an OS of its own) to tie all those components together, OTA orchestration, etc.
Automotive EE here, no, absolutely not.
I always saw that the problem it would solve is more about tooling - Rust would be a fairly good fit because it has a good cross-compilation story, and the tooling around e.g. cargo and running builds is quite good (in my opinion). The blocker right now is absolutely vendor support; no reasonable hardware company can afford to hack their own HAL without vendor support (and in fact they pay a lot for support right now, and use it).
I think what these companies usually miss (good for Volvo) is that iteration time in a "higher-level language" like Rust can actually be much faster than in something like C. The setup time for a dev environment in embedded can be a week (making sure exact version match between compilers, checking out files, compiling, resolving build failures). On top of that, just having access to a language with strings and algebraic types is huge.
I think there's maybe room for a Rust consultancy that could take one of the existing large manufacturers, build a toolchain around it (possibly with their blessing / support). Ferrous Systems does this (I hope there is as much demand as I am imagining).
https://dcz_self.gitlab.io/posts/jazda_rust/
Pictures of the less-desired rust included.
— https://dilbert.com/strip/1997-01-12 (“buying a car”)
Actually back then it was the beginning of me stopping carrying about improving and just go with the flow like a dead fish. Everyone is happier, I have much less clashes with coworkers much less stress and you know what they say: Nobody got ever fired for choosing IBM.
I think this is the main reason for the state of software quality in cars now. People who care can't stand the industry and leave, if you want to stay you have to stop carrying.
You can't really do anything about it. In my experience that kind of culture comes from the top and at least where I am those people are part of the problem. Look for another job.
SPARK2014 has been around much longer, does comply with those standards, is a formally defined PL with a great set of verification tools specifically designed for high-integrity software. There are large codebases (software for the safe operation of helicopters at sea (27k LOC of SPARK2014); NATS iFACTS air traffic control system (>529K LOC of SPARK2014).
I am glad that AdaCore is teaming up with Ferrous Systems to help bring some of Ada and SPARK's goodies to Rust, but it's nowhere near them at this point. This seems more a Rust champion at Volvo convinced their group to use it.
>>>JG: Then I pitched to the managers, “If we want to do a serious Rust effort within the company, then I want to take part in that and become an employee”, since I was a consultant at that point.
The availability of programmers in either Rust or SPARK2014 shouldn't be a heavily weighted factor, since anyone working in SPARK2014 probably already has the relevant experience no matter how few apply, whereas the dozens or more of Rust programmers who might like working at Volvo would be cutting their teeth trying to build 1/20 of what Ada/SPARK2014 already have, and possibly deliver far less.
Rust is to C++ as SPARK2014 is to Rust at this point in my opinion, but current popularity wins out a lot in all human endeavors. I'll stick with SPARK2014 and Zig for now until Rust catches up SPARK2014.
Maybe starting in a backend service that they can monitor and deploy changes in events of outage would be an easy start. For something a scale of customer owned cars, I hope they are prepared.
"And it happened to run on the architecture that was best supported in the embedded bare metal space of Rust at the time. It was also not safety critical component, so we did not have to worry about safety certifications."
I find the article very low on actual information. I don't think Rust will be used in an ABS soon. The Android/Elixir/Rust examples in the article are for the useless gadgets that no one wants.
> I thought this would be useful for Volvo Cars because it embodies the same type of Ideology that you want when you’re developing safety-critical software.
So I think "Makes sense that one of the most safety focused manufacturers would go for it." is accurate.
Ah. Found it, [1][2]
[0] https://github.com/PolySync/misra-rust
But for anything regarding networking and UX (screens), a lot of languages and frameworks are being used right now.
Also, if you hate MISRA subset of C so much, you probably won't like Rust, since both impose some similar rules.
I expect something like MISRA for Rust as well. There will probably be rules like "keyword unsafe forbidden". If you really need it, try writing a deviation record. The advantage is that Rust should require fewer rules.
Though simple param checking should be allowed ideally.
But you can always just do a deviation, it's not super hard.
Even the USAF and defense contractors like Lockheed Martin switched to C++ from ADA for the F-35.
ADA is basically dead and buried outside of maintenance for 35+ year old planes, but I doubt those are seeing much active SW development done on them.
It is a little more than just maintenance.
https://www.ghs.com/products/ada_optimizing_compilers.html
https://www.ptc.com/en/products/developer-tools/apexada
https://www.ddci.com/products_score/
http://www.irvine.com/tech.html
I've also had queries about Rust, but it's not going to be available in safety-critical systems for many years. Part of the safety argument is toolchain adherence to a published standard, and there is no such thing for the Rusts (any version). In the in-dash infotainment systems anything goes, so they often run Linux (unsafe) and Python (unsafe) or even Perl (unsafe).
the Linux kernel, the toolchain, or libraries like ssl libs are co created by the very organisations that consume the software. FB, Google, Amazon, Microsoft, IBM with red hat, Suse, Oracle, SAP they all concrete the Linux kernel, and for each kernel release they validate, each of them, the technology.
that's how the reference implementation _is_ the standard.
same goes for rust, which brilliantly leverages build automation of the cargo package repository to protect the compiler and toolchain from regressions:
https://brson.github.io/2017/07/10/how-rust-is-tested
the more crates have sound test suites, the better the quality statement of the compiler is.
It’s all good and well to hear about Ada but how did one start using it for free at home to learn and then evangelize it in the work place?
How did one find learning materials about it in the same amount as an openly available language?
How did one contribute back to the language ?
Lots of cool stuff happens in proprietary spaces first. OSS variants tend to gain traction very quickly though
This made me clutch my chest and gasp and I have no idea why
I don't think there is a QT equivalent? I guess there are bindings for QT, though, but I don't know if it plays well with the particularities of QT.
They explicitly support the RP2040 as well, with demo code. Very useful. :)
Anyway
> Is it that surprising that
where is it implied that it is "surprising" just because it is posted?
Now I have a reason to try Rust.
Just a few warnings. Everybody when they start are “fighting with the borrow checker”. And some people are frustrated by it. But you have to see that it is a good thing. Because Rust is warning you about a whole type of bug that your old way of doing things were actually creating this kind of bug. And now rust can catch them! It’s like a guy the frustration of someone coming from a dynamic language to a typed language and being frustrated because he has a type number but now he wants it to be a string. Sure you can do that in a dynamic language but it can created all kind of bug.
And another point. Remember what the language is made for and also not made for. Yes you are going to be faster in X language for different things. But for what Rust is good at, the power it gives you, the dev experience, and the performance are amazing.
I usually would grab Typescript first for the back and then reach to Rust where speed and security safety is critical. And it’s so good to code in it.
Have fun!
As an experienced C programmer learning Rust, my frustration is less "oh it prevented a bug I would have made" and more "no but its fine in this context leave me alone" :-)
There is this belief "I know C so I know what's fast here", and, while that's sometimes true, I think it's wrong often enough re: Rust to try doing things a different way at a relatively high level. I think when you're starting off with Rust your goal should be to implement virtually everything in the dumbest/most obvious/Python-ic way possible, and then to experiment with optimization/rewrites. And while you should try the thing "You know to be fast because you know C" you should also spend that time reading how the std lib implemented a feature and leaning on the std lib, benchmarking as you go. One reason is because the paradigm is obviously different. Another is because the std lib has lots of features for common uses which are optimized very carefully, which C just doesn't have, and one shouldn't ignore/forget that.
That's a very overused argument and IMHO wrong way to sell Rust. The reality is, even if 100% of C bugs were memory safety related, that still does not mean every C program is riddled with bugs. If that were the case, nobody would write C programs in the first place.
There is a strong selection bias in play here. You only see times where memory safety caused an issue because you get a segfault/overflow/etc but just have invisible correct behavior at all other places.
Maybe I was lucky with the people and companies I worked at, but memory safety overall has never been a big issue with our C softwares. Sure it happens from time to time, but it's definitely not any kind of plague.
Still I'm learning Rust, so why?
For me, it has to do with the library ecosystem. It's very hard to find good quality, easily pluggable, performant C libraries. You always end up having to re implement half of the data structures you need, or use sub par configuration formats just because you don't have readily available libraries.
I think this is a much more compelling, and frankly true, argument for C programmers to use Rust.
Not separate physical controls. No voice commands. Only the ability to tap on the touchscreen at least three times to change the A/C. It was a real bummer and soured me on the brand. It’s hard to believe they are safety focused with design decisions like that.
https://www.jdpower.com/business/press-releases/2022-us-vehi...
I think creating new number types like "Positive" also seems to require using unsafe, or at least the stdlib used it for a few of the number types I looked into.
A few points:
If your software development experience is limited to web or mobile development, please understand you lack a massive amount of context when it comes to software in the context of complex hardware manufacturing. To put it in simple terms, you really don't know what you are talking about. It's like someone who writes code for embedded systems in clothes washing machines having a strong opinion about how to engineer, deploy and maintain a tech stack for a SaaS.
Next, the cults formed around programming languages are some of the funniest things I read on HN. Except, they are not funny at all. There is nothing wrong with C or C++. Nothing. The problem is people who don't know how to program. At the core, to perform a certain function the microprocessor will, for the most part, do pretty much the same things, regardless of what language might be used to describe that. Blink a light in response to a button being pressed? At some point you are sensing and de-bouncing the input and then setting an output pin. Maybe there's I2C, SPI or CANbus in between, but what you have todo is the same.
Languages like C and C++ have been around for longer than most people reading this have been alive. They have been used --successfully and without issues-- for more projects, products and systems than anyone can imagine and at scales from a watch to spacecraft and everything in between. This cult of languages as solutions to problems caused by bad programming is nonsensical. One can write bad code in any language.
Professional certifications. This isn't going to stop people from writing bad code. At all. Designing and implementing complex code for real time systems is far more complex than designing a bridge or a building. Certifications are not magical inoculants against bugs and system design problems. Trying to view and fit software engineering from the context of other engineering disciplines is a mistake. They are not the same thing.
When you are dealing with fault-tolerant hardware + firmware systems things can get exponentially harder. Folks who work on web products have the luxury of being able to make lots of mistakes and fix them as fast as their deployment system allows. Imagine if you got ONE CHANCE to ship a non-trivial codebase and it has to be guaranteed to work to a high degree of certainty for ten or twenty years. Once you ship it, there will be millions of users and you cannot touch it at all. In fact, you have to telemetry data of any kind. You don't know if there are issues, if it has random failures, race conditions or odd failure modes you cannot possibly simulate at scale in the lab.
Imagine this next time you deploy an update. Imagine you are not allowed to touch it at all after that and it has to work. Imagine that, and maybe you can get a sense of what some of this work can be like.
This isn't limited to automotive. This goes for commercial, industrial, aerospace and other domains. Hardware is a million times more difficult that pure software products, particularly web type software. We just shipped a thousand units of one of our new products for installation in a large industrial facility. The firmware had to go through a year of testing before we dared ship even a single unit. That's another thing to imagine; the idea of having to test and qualify your web SaaS --not with clients as test subjects, on your own-- for a year or more before you can launch your business (and you are not allowed to touch it after that).
Anyhow. Don't be language cultists. That isn't the problem. Bad programmers and bad process is far more of an issue. Changing languages isn't going to magically fix that. It isn't a solution. You can build anything with C or C++. If written correctly, it will perform better than just-about anything and be reliable within the bounds of system specifications.
Modern languages are trying to introduce constructs to make safer, more performant software on average, lessening the tendency of hardware chip makers having to hack their way into performant execution of C/C++.
This is not to say C/C++ can’t make good software, it’s that we limit ourselves by clinging to them, and would be far better off with gradual adoption of modern low level languages, just as we shed Assembler for C over time.
Therefore, there are ways to write bad code. Do you think it's reasonable there may be better tools that prevent writing some cases of bad code?
I mean, I think we all can agree that, in general, a codebase with significant test coverage hass less bugs than a similar codebase without test coverage. So, I don't think it's crazy to require, potentially via a tool, some degree of test coverage. Yes, some people will cheat by constructing some bad tests, but, in general, I think we should expect some level of quality improvement.
Rust adds another tool that, on average, should improve quality.
Again, this is not a solution. This is not a silver bullet. Neither is depending on the programmer to write correct code.
Bad code is written every day in every language. The root causes for bad code do not include the chosen programming language. If language was a root cause, every codebase using language <x> would have problem. Clearly that isn't an issue.
Why do we write bad code then?
- Unintended errors
- Bad design
- Not understanding the problem being solved
- Not understanding the constraints
- Not understanding the hardware/environment
- Lack of skill
- Lack of knowledge
- Limited experience with the tools, frameworks, libraries, domain, etc.
- No understanding of lower-level concepts
- Lack of education (formal or self-taught, does not matter)
- Not having a full grasp of fundamentals
- Not being thorough or detail-oriented
- Etc.
There are a lot of reasons for which bad code is written. Language choice isn't one of them. It's an excuse. If baseline languages like C and C++ were so impossible to use properly Linux would be an unmitigated disaster. It is not.In the end, the language isn't the problem, at all, it's bad software developers.
Don't take my word for it, Linus Torvalds [0] has been quite vocal about this very issue. In fact, he recoils at C++. And, frankly, having seen what comes out of, as he put it, substandard programmers, I could not agree more. I believe part of the problem is how we've been teaching programming. The first thing anyone coming out of school reaches for are complex class hierarchies, complex data types and layers of unnecessary crud.
I remember a project a long time ago that used Objective-C to implemente a genetic solver. It was unusable due to just how slow it was. I re-coded it in C. It ran about 400 times faster on the same iPhone hardware. The first was the result of lazy uninformed programming. The new version was simple, to the point, performant and had no bugs. Not to mention it used massively less memory.
Here's something everyone needs to internalize: The processor --the hardware executing the code-- has no concept of object-oriented anything. No polymorphism, inheritance, complex data types, etc. When all the smoke and bullshit clears out, all it knows is a set of very simple and efficient operations we can weave together to do useful things. That's it.
All the abstractions provided by languages are for the benefit of the programmer and have nothing whatsoever to do with code quality, correctness, bug content or suitability for a purpose. Which means most, if not all of that, isn't necessary.
Modern programmers probably have no clue about the range an scale of projects that were completed without any issues while not having access to things like TDD, objects, massive libraries, complex data types, decorators, etc. I mean, we have written operating systems, sent people to the moon, saved lives with medical equipment, developed consumer and industrial products and more. Funny how all of that was possible and people today go on about needing to use a better language.
In my opinion, there's only one area that can justify a new language. Everything else is well covered with C and, if one must C++. That is, AI. And no modern language fits the bill yet.
It is hard to define what an AI-first language might look like. Being that I used APL professionally for nearly a decade, I happen to think that a language based on a notation developed for AI might be the best idea. The reasons are similar to the reasons for which musical and mathematical notation allow for rich expression of ideas. In other words, the justification isn't "I need it to write better code", but rather that, as the field advances, we might very well need better ways to describe what we want the computer to do.
Every programming language has its own style of bad code. Java has enterprise OO overengineering. Haskell has monad obsession. C++ has enterprise OO template shenanigans. C has pointer crazyness.
You should pick the programming language thinking on minimizing issues for the task at hand. That means C is good for the stuff for which is good (obviously) but not for everything but AI.
Yes, C can cover everything. Now go write a web frontend in C, and you will see that, even though you somewhat can, it is a huge pain.
And don't mistake me: I agree with you on OO huge frameworks being terrible, but I disagree with you at C being the pinnacle of programming for everything but AI.
BTW: the Rust borrow checker just ensures that you have properly made your mind about what pieces of code own what data (and by owning, I mean who has the responsibility on writing and calling free on it). I think a piece of software ensuring that is a fair improvement. Worst case, the good programmers will just explain ot to the compiler via type annotations and just continue with their lifes. But they were going to do that already, wouldn't they?
One of my professors used to pound this idea that you should not write one line of code until you have devoted enough time to structural design and, more importantly, data representation. Of course, I am going back to a time when none of the modern languages existed. My choices at the time were assembler, Forth, C or APL. I won't even mention COBOL or FORTRAN as they were never part of my reality.
Today people think nothing of having functions create and pass entire objects, dictionaries and other complex data structures that consume memory, time and energy (in very real terms, Python requires nearly 80 times more energy to do the same thing when compared to C).
As this "contagion" doesn't seem to have an end in sight, CS reality today and in the future will move away from fast, space, time and energy efficient languages like C.
The energy component is something I have been more aware of over time as we start to become more concerned with carbon neutrality and related issues of climate change. While Python is great for what I am going to call "lazy" programming (you don't have to give it any of the thought required in C or C++) it is objectively terrible in terms of execution time, memory footprint and energy consumption. Do we want a world dominated by Python applications? At a large scale you would need more computers --lots more-- energy and resources to do the same things that could be done with more efficient options.
How many CS graduates come out of school with almost a Python-first education? Not to go too far, my own son, MS CS, spent nearly no time at all with assembler, Forth, C and C++ in school. It was crap like Java and utility like Python. Everything is worth learning, of course, but, give me a break. Thankfully he chose to listen to me and invested time and effort getting good at low-level programming. His first job out of school working for a very good company was C/C++ centric and he did great. Most of his school friends could not have landed that job.
To be clear. I am not opposed to reaching for a variety of languages. I have. I still do. What I do not do is blame a language for problems of design, logic and engineering I create. The language isn't the problem. It never is. I am the problem.
To beat it to death: It's like blaming a welding machine for making bad welds. So long as you don't have a truly horrible machine, someone with proper welding skills can make good welds.
I learned this one the hard way actually. I have a Miller 130XP MIG welder. It's a very basic entry-level 120 VAC MIG welder. I could not make a good weld to save my life. Believe me, I tried. I watched videos, practiced, even got some instruction. I sucked.
When I built my solar array I had to weld a number of custom brackets for the ground mount structure. Not trusting my capabilities I asked a professional welder I knew to do the welding. When he came over he saw my 130XP there and say "I'll just use your machine". He had monster machines in his truck. He proceeded to make stunningly good welds with a machine I was convinced was total crap. I could not believe my eyes.
I eventually took college-level classes on welding and got massively better. I can make good welds with that little machine now, because I know what I am doing. And, yes, I later bought a more efficient modern inverter-based ESAB machine. The new machine wasn't going to make me a good welder. Blaming the machine was the wrong mental framework.
Quick question. Why would you do such a thing? How can you square this with your claim that switching languages is never the answer?
I agree with you that a good development process is essential. The thing is, some languages make for a worse development process, because they inhibit automation of important steps in code review. I expect you wouldn't trust the weaker type systems of Forth or BLISS, or the unstructured control flow of COBOL, for a job where you could use C instead. If there are analysis phases that C can automate and these other languages can't, isn't it obvious (given only a moment's thought) that there could be other languages that improve on C?
You mean use Objective-C?
Because that was the only way to write iOS apps. It sucks. It's unnecessary. And yet you could not avoid it for a good portion of an iOS app.
> you wouldn't trust the weaker type systems of Forth
I used Forth professionally for many years. I can't think of a single end-product issue caused by Forth. The range of applications I wrote went from device drivers and low level robotics code to full console-based applications, like specialized text editors.
> isn't it obvious (given only a moment's thought) that there could be other languages that improve on C
At the core, as I said before, these things only exist for the benefit of the programmer and generally don't exist in what I am going to call the real world inside the processor.
Here's an example: A bytes() object in Python and MicroPython is not mutable. It also happens to be one of the lightest data structures you can use if doing communications work. In a recent MicroPython project we needed to manipulate the data in bytes() objects without causing reallocation of new objects. I wrote a set of routines in ARM assembler to do this just. For example, take a bytes() buffer, calculate a CRC-16 of the data, add it to the end and modify values in the front based on this CRC calculation.
In other words: There is no such thing as a non-mutable data type.
I think the simplest way I can put this is:
Bad code is the result of bad programming, not a consequence of the chosen language.
I should make it clear that I don't have a problem using any language (I have, many) or someone choosing to use whatever they like. My argument is that this idea of blaming solid, reliable, battle-tested languages like C for problems that are, in reality, the consequence of bad programming is dishonest.
However what PS2 is also known for is an absolute shite quality of their firmware.
Cars refusing to start and requiring a "service" out of blue (with one lucky guy scoring this in the middle of a forest). Chargers not engaging or, better yet, not disengaging. Basic functions, like blinkers and car locks, breaking after an update. Updates, in general, are more of "oh, fuck, not again" events rather than the positive news.
Like, I understand it's a complex software. I had a Bimmer show at "-10 km to destination", an Audi refusing to open a truck if parked too close to the wall, but the amount of bugs in Polestar is insane over the baseline.
But, yeah, it's (possibly) written in Rust. Yay.
[2] https://www.reddit.com/r/Polestar/
---
Edit - Added "(possibly)". The point was that the choice of the language matters less if your bugs are higher level and your QA process is lacking.They had a central database that kept track of the revision state of every car, including what firmware revision was installed in each ECU. Volvo owners tended to keep using official service centres longer than those of other brands, so this database was usually correct.
After Ford bought Volvo, they expected compliance and sent instructions and materials for the next infotainment system to be used in Volvo cars. A Ford product. Equipment, interface, code platform all sent from corporate out to Gothenburg and that was that. So Ford thought.
When they visited Sweden to check on the progress of the new model. When they saw the infotainment system it was nothing like what Ford had sent with the mandate to use it. Of course they questioned Volvo and I believe the response is true because I’ve known a few born and raised Scandinavians…
“Oh, that system was not good. We decided not to use it and built our own.”
By then it was already working and done to the point Ford just shook its head and let them proceed.
Needless to say, the relationship was not to be long-term, who could’ve seen that coming?! /s
I have nearly every safety feature turned off in the car because they all generate false positives at an astounding rate. Automatic braking kicks in for parked cars, billboards on the side of the road, cars traversing roundabouts in front of you, heck, probably even for gusts of wind.
They refreshed the interface recently with Android Auto, however they’re missing key features and have regressed on some major integrations - for example, they don’t support CarPlay in the current iteration.
I won’t be purchasing another Volvo.
There's usually a mix of Assembly, Simulink, C, C++, Java, JavaScript, Shell scripts, Python, etc...
I've seen the OS be various flavors of embedded Linux, QNX, or even Ubuntu.
You can usually find a bit of everything even in a single vehicle. The code is integrated by an OEM and can come from dozens of potential suppliers.
That's off the point though. The choice of language matters, but it matters less than the development process and the professionalism of people involved.
Jesus fucking christ HN
Volvo and Polestar operate at the arm's length. There are interviews that talk about a shared EV platform. There are also numerous reported issues with core EV functionality in the Polestars, oftentimes so severe that it's unclear how they don't lead to immediate fleet recalls.
It's possible that the people interviewed are unrelated to those responsible for the problematic areas, but the context is still important.