News for hackers. Stuff that matters.
Re:C99 doesn't need function bodies, or 'VLAs are Turing com... by ufo on Thursday August 04, 2022 @12:11PM (#32344787)
They mention that while loops are limited because C doesn't have tail recursion. However, in my experience gcc and clang are pretty decent at tail recursion. It happens via the -foptimize-sibling-calls setting, which is enabled by default on -O2 or higher.

The caveat is that the standard doesn't guarantee these optimizations. But there are some non-standard __attribute__ declarations that can help with that.

Re:C99 doesn't need function bodies, or 'VLAs are Turing com... by lsof on Thursday August 04, 2022 @02:51PM (#32346835)
Well, I meant that loops are limited within the normal constraints of the C standard, which doesn't offer tail call elimination, but indeed as you point out it is easy to work around it in practice using clang or gcc optimization passes.
Re:C99 doesn't need function bodies, or 'VLAs are Turing com... by monkpit on Thursday August 04, 2022 @12:21PM (#32344917)
> opiltimization

Is this some portmanteau for “compile time optimization”?

Re:C99 doesn't need function bodies, or 'VLAs are Turing com... by SavageBeast on Thursday August 04, 2022 @12:44PM (#32345235)
On the topic of "compile time optimization" ... There was once a merry bunch of very excellent and brilliant crack smokers at Google who created a project called GWT. The raison d'etre of the project was simply "We know you can write JS but Java has more guardrails - why don't you write Java and we'll transpile it down to better JS than you're smart enough to write because JS basically sucks and is always changing and browsers are F'd".

Before it was all said and done you could enable a "deep compile" option that would even look at your java code for cases that would never execute - rarely execute (you're a dumb human right?) - etc and build an opinionated JS runtime around it for performance and size (size complexity? Space-Time-Trade-Off).

I was enamored with GWT for quite some time and developed a high level of skill using the tool. I still miss it frankly. People who seek to write one language and execute another are fundamentally insane. Even though this is basically necessary with a lang like C (one step above shifting bits and understanding instructions etc) those people still amaze me.

I'm glad I wasn't born with the requisite intellect to go down such rabbit holes myself. This makes me feel dumb and be OK with it at the same time.

Re:C99 doesn't need function bodies, or 'VLAs are Turing com... by mrkeen on Thursday August 04, 2022 @12:51PM (#32345318)
> People who seek to write one language and execute another are fundamentally insane.

That would be people who use compilers.

Re:C99 doesn't need function bodies, or 'VLAs are Turing com... by chucksmash on Thursday August 04, 2022 @01:20PM (#32345683)
You're technically right, which is the best kind of not invited to happy hour.
Re:C99 doesn't need function bodies, or 'VLAs are Turing com... by SavageBeast on Thursday August 04, 2022 @01:34PM (#32345845)
I wrote more or less the same reply but opted not to post it - well done on you sir!
Re:C99 doesn't need function bodies, or 'VLAs are Turing com... by ufo on Thursday August 04, 2022 @12:43PM (#32345215)
Nah, it was just a typo. But I like your idea!