News for hackers. Stuff that matters.
Re:PureBasic switches to a C backend by blizdiddy on Wednesday August 18, 2021 @07:29AM (#28219804)
C is an ISO standard. That's how it works when you code to the standard.
Re:PureBasic switches to a C backend by coder543 on Wednesday August 18, 2021 @12:37PM (#28223677)
I wish C were that simple and well defined.

The C standard leaves a lot of UB/implementation specific behavior. Fully “standards-compliant” code that works on one compiler may behave in unexpected ways under another compiler, just due to differences in UB handling. And no, it is not trivial to write UB-free C code. Let’s say you are generating C code from your own programming language. Did you know that an infinite loop that doesn’t do anything might be ignored?[0] This materially changes the behavior of the input program in ways that most people wouldn’t expect. C can quickly go from “infinitely portable assembler for my cool new language” to “major source of confusion.”

That’s before even discussing compiler bugs, which will unintentionally break all assumptions of well-behaved code. Rust has run into (and submitted fixes for) so many LLVM bugs over the years that caused silent miscompilation. Complex software tends to have bugs somewhere, and a lot of compilers are complex.

The less trivial the C code, the more likely you are to run into compatibility problems between compilers. “Hello world” should reliably work everywhere, so that’s something… I guess.

But that’s just like… my opinion. If generating arbitrary C code and shoving it through arbitrary C compilers works reliably for you, then that’s cool?

I personally would want to see a large battery of tests that ensures the program code is likely to be working under each new compiler.

[0]: https://stackoverflow.com/questions/59925618/how-do-i-make-a...

Re:PureBasic switches to a C backend by mercurialuser on Wednesday August 18, 2021 @03:47PM (#28226218)
I understand what you say but FPC and Harbour just show that writing portable c code is actually possible...

https://github.com/harbour/core#supported-platforms-and-c-co...