News for hackers. Stuff that matters.
Re:How to Write Portable C Without Complicating Your Build by kodfodrasz on Friday March 31, 2017 @03:47AM (#14001863)
I've seen C used for safety critical software. I've used it for that. I've seen the insane amount of tooling and support and processes and rules to make it suitable for the task it is utterly not suitable for.

It does not get the job done fast and efficient, if you consider the develpment costs. The fast code the compiler generates could be genrated from other sources just as well, it's not especially the merit of that language.

Re:How to Write Portable C Without Complicating Your Build by exDM69 on Friday March 31, 2017 @03:56AM (#14001891)
I write security critical software with C and I know exactly what you're talking about.

It's written in C because the tooling to analyze and certify it for security in embedded/automotive/aerospace is targetting C (or C++). For some industries, Ada might be an alternative.

It may be paradoxical, but you're not going to be able to write safety critical software in Rust because the tooling to certify it for security doesn't exist and it'll still take years to get there.

Do I like this situation? No, I do not. Do I think it's a big problem? No, not big enough that it can't be solved by pouring money and engineering resources on it.

Re:How to Write Portable C Without Complicating Your Build by adrianN on Friday March 31, 2017 @05:17AM (#14002196)
I also write safety critical software, in C++. I disagree that the necessary tooling for certification doesn't exist for Rust. You don't need that much tooling. Measuring test coverage is the hardest part (and Rust doesn't do this very well currently, but it is possible). Most of the things coding standards for C (e.g. MISRA) require are irrelevant for safer languages, so you don't need complex checkers. For static analysis the story is similar.
Re:How to Write Portable C Without Complicating Your Build by jacobush on Friday March 31, 2017 @07:12AM (#14002656)
In safety stuff, not only has the source to be vetted. Also the compiler building the target binary must be blessed and hopefully well understood.
Re:How to Write Portable C Without Complicating Your Build by kodfodrasz on Friday March 31, 2017 @07:42AM (#14002777)
I have seen a certified compiler (GreenHill) compiling invalid code happily (not one relying on undefined behaviors), despite its certifications, for which even an ancient 3.x gcc complained (rightfully!)

These certifications unfortunately often are on the level of the golden shields CAs provide to customers to put on their sites as sign of trustworthiness.

So yes, blessed is a nice word for it.

Re:How to Write Portable C Without Complicating Your Build by jacobush on Friday March 31, 2017 @08:39AM (#14003065)
I hate GreenHill C compiler as much as the next guy [insert huge rant] but the Blessed Compiler of Choice in its frozen buggy state at least usually means it's a KNOWN ENTITY. We code around the bugs, we compile in -O0 mode etc etc, we analyze the assembler output to death and so on.

I see these "certified" stamps less as "secure" and more of a huge slowing down of progress and change - which strangely can translate to more secure since you know what you are dealing with.

If I can dream, I'd take a "certified" GNU Ada, or Rust, or something over C. But that is bound to take many years to happen if ever. I think we sooner will see Rust compiled to C which is fed to something like the abominable Greenhill so security consultants can pour over the intermediate C output and put it through the abominable Greenhill.

Re:How to Write Portable C Without Complicating Your Build by aidenn0 on Friday March 31, 2017 @10:41AM (#14004257)
For safety stuff I've worked on, the source had to be vetted, and then someone goes through line by line and confirms that the assembly generated for each line of code matches the source code. For C or Ada with conservative optimizations, this is fairly mechanical (and extremely boring), but means that trusting the compiler is not a requirement.
Re:How to Write Portable C Without Complicating Your Build by adrianN on Friday March 31, 2017 @11:52AM (#14005023)
Then you must have worked on tiny software.
Re:How to Write Portable C Without Complicating Your Build by adrianN on Friday March 31, 2017 @08:42AM (#14003080)
Blessing a compiler consists of running it on a trivial test suite and writing down the results, however bad they may be.
Re:How to Write Portable C Without Complicating Your Build by sclangdon on Friday March 31, 2017 @04:09AM (#14001940)
Actually, it is the merit of the language. C - and FORTRAN for that matter - are fast because their restrictions force you to program a certain way. A way that just-so-happens to be efficient (if not particularly safe).

For example, generally, people use a lot of static arrays in C. Arrays are efficient. The way you program with fix-sized structures like arrays tends to be different to how you program with dynamically-sized structures and that style of programming tends to be more efficient.

In the vast majority of cases, a C or FORTRAN program will be more efficient than other languages not because they are C or FORTRAN, but because they force you to use an efficient paradigm.

Even other compiled languages like C++ or D are, more often than not, slower than the C counterpart UNLESS they are programmed in a "C style".

e: To be clear, the fact that they are compiled low-level languages obviously does help, but I'm trying to make the point that it's not the only reason.

Re:How to Write Portable C Without Complicating Your Build by adrianN on Friday March 31, 2017 @05:23AM (#14002219)
C is fast because decades of work have been spent on making good compilers and excellent libraries. C's lack of e.g. templates makes it more difficult to write efficient code in certain cases, c.f. sorting. I disagree that a typical desktop program that hasn't been specially optimized for speed will always turn out more responsive in C that, say, in Java.