News for hackers. Stuff that matters.
Re:Relive: 50 years of C, the good, the bad and the ugly by KerrAvon on Friday December 30, 2022 @11:48AM (#34186777)
Exactly what, in the year 2023 C.E., is C great for?

I’ve been writing C since 1991 and I can’t think of anything where I wouldn’t start a new project in some other language. There are many interesting choices of varying maturity in the low-level systems programming space: Zig, Rust, Crystal, D, Swift (if the standard library ever gains support for system-level programming). Even the “better C” subset of C++ will allow you to avoid certain classes of security bugs completely.

I don’t think C is even merely adequate for anything at this point; defaulting to memory safety is table stakes in any domain where C was once dominant.

Re:Relive: 50 years of C, the good, the bad and the ugly by matheusmoreira on Friday December 30, 2022 @12:40PM (#34187441)
> Exactly what, in the year 2023 C.E., is C great for?

Writing readable code. I like Zig and Rust too but at the end of the day they just aren't C.

Re:Relive: 50 years of C, the good, the bad and the ugly by fncslothouber on Friday December 30, 2022 @12:06PM (#34187023)
Memory safety / security is important for a subset of all possible applications. It is not important for _all_ applications.

If I use a micro controller to control a string of leds I do not care about security/memory safety. But I do care about being as close to the metal as possible, and being able to understand the compiled code.

Re:Relive: 50 years of C, the good, the bad and the ugly by bonzini on Friday December 30, 2022 @12:40PM (#34187450)
To control a string of LEDs, something like Forth (or some other p-code virtual machine) is going to be just as good as C. PIC microcontrollers have always had BASIC as an option for example.

But many microcontrollers these days will likely have a TCP/IP stack, perhaps even crypto, even if it is to control a string of LEDs via MQTT or Modbus TCP.

Re:Relive: 50 years of C, the good, the bad and the ugly by fncslothouber on Friday December 30, 2022 @03:35PM (#34189776)
Forth would also be a nice choice.

Give you another example. A watch, not an apple watch, but a simple Casio watch. One that does time, alarm and a stopwatch. Not connected to anything. What is important here is the battery life, so the less code the better. C would be a fine choice here. All additional code to prevent security breaches would be a complete waste here.

Give another example. As my day-job I develop embedded software for the railways. Current system I work on operates the brakes when the train goes too fast. Not connected to the internet, and no connection would even be allowed. Written in C. One because it is simple to understand and the developer can focus on getting the functionality correct. Secondly because there is a wide choice of additional tooling and standards that is required to get the application certified.

Re:Relive: 50 years of C, the good, the bad and the ugly by ptx on Friday December 30, 2022 @12:48PM (#34187555)
If people rely on the LEDs working correctly or if the controller has any kind of connection to another system (which could be leveraged by an attacker to penetrate deeper into the network) it seems to me that security and memory safety would still be important.
Re:Relive: 50 years of C, the good, the bad and the ugly by fncslothouber on Friday December 30, 2022 @02:00PM (#34188562)
Not everything is or needs to be connected to the Internet.

There are plenty of things that are controlled by a micro controllers that do not have a network connection.

Re:Relive: 50 years of C, the good, the bad and the ugly by estebank on Friday December 30, 2022 @03:22PM (#34189604)
Not everything needs to be connected to the Internet, and not every micro controller is running a non-mission critical task.

A micro controller hitting a memory safety bug that causes the LEDs to present invalid output can have real world consequences. Even if the micro controller isn't directly actuating machinery, it might cause an operator to incorrectly act because they were mislead.

If the micro controller is running Christmas lights, it might be fine if it falls over, no one will die, but I would still call that a manufacturing defect.

Re:Relive: 50 years of C, the good, the bad and the ugly by pjmlp on Friday December 30, 2022 @05:18PM (#34190745)
Only because liability still isn't a thing across all levels of software development.

Thankfully returns in digital stores, warranties in consulting projects, lawsuits in business losses and cybersecurity bills are slowly changing that.

Re:Relive: 50 years of C, the good, the bad and the ugly by Koshkin on Friday December 30, 2022 @12:02PM (#34186969)
> C.E.

There.

Re:Relive: 50 years of C, the good, the bad and the ugly by jeff-davis on Friday December 30, 2022 @01:40PM (#34188280)
The consequences of C in long-lived software are somewhat known. Granted, the track record of C is mixed, but many important projects have been successful with it.

Rust is exciting and proving itself about as rapidly as such a language could be expected to do. But there are big questions around how all of this plays out in a long-lived project. There's a good argument that C's simplicity is an asset here.

I like Rust a lot and have done some cool stuff with it. I believe the challenges of long-lived projects will be solved. But at the same time, I admit that there are a lot of other factors (including non-trchnical ones). If you pick a language that doesn't last for whatever reason, and you have a couple decades worth of code, the options are grim.

Re:Relive: 50 years of C, the good, the bad and the ugly by addaon on Friday December 30, 2022 @03:45PM (#34189885)
> Exactly what, in the year 2023 C.E., is C great for?

Implementing low-level code that is important enough to prove correct, without going through the additional effort of de novo proving your entire toolchain is correct.

Re:Relive: 50 years of C, the good, the bad and the ugly by tmtvl on Friday December 30, 2022 @05:51PM (#34191070)
Yeah, Ada is pretty great, it takes the best things from Pascal and combines it with unparalleled reliability.