Live data from Hacker News

Beating C with one line of Brainfuck

kiwec.net

31–40 of 91 posts

Re: Beating C with one line of Brainfuck

#32
post #11
post #6

Generated C: #include char mem[30000] = { }; #define OUTPUTS 0 char outputs[OUTPUTS] = { }; int main() { char* ptr = mem + 0; fwrite(outputs, sizeof(char), OUTPUTS, stdout); ptr[2] = getchar(); ++ptr[2]; while (ptr[2]) { ptr[2] -= 11; while (ptr[2]) { ptr[2] -= 22; while (ptr[2]) { ++ptr[3]; --ptr[1]; while (ptr[1]) { ++*ptr; ++ptr[1]; } ptr[2] = 0; } ptr[2] = 0; } ptr[1] = 0; ptr[1] += ptr[3] * 1; ptr[3] = 0; ptr[2]…

Note that: #define OUTPUTS 0 char outputs[OUTPUTS] = { }; is not valid C (or C++) - zero length arrays are not a thing in either language,

[deleted]

Re: Beating C with one line of Brainfuck

#34

I wonder if Brainfuck wins by his 100th of a second since he already called a program with words.txt, and therefore it was already loaded into memory, thus saving just a slice of time, as it would already be in the cache.

But the file is loaded in cat, which isn't timed

Re: Beating C with one line of Brainfuck

#36
post #34

I wonder if Brainfuck wins by his 100th of a second since he already called a program with words.txt, and therefore it was already loaded into memory, thus saving just a slice of time, as it would already be in the cache.

But the file is loaded in cat, which isn't timed

But the timed program still has to wait for cat to load the file. Both programs are launched (almost) simultaneously by the shell.

Re: Beating C with one line of Brainfuck

#37
> Following on the recent “faster than wc” blogposts, I decided to end this fad once and for all, using the best language ever created : Brainfuck.

This "Go faster than C" post was a complete joke, one could very easily write a "C faster than C" the exact same way to prove the absurdity of an optimized implementation that does not do what the original program does.

Re: Beating C with one line of Brainfuck

#38
post #24

Earlier quoted context omitted.

> (fortunately!) Unfortunately. All warnings and errors should be on by default. That they are not is one of the things about GCC that really pisses me off.

Still not getting the joke. Yes, they should be on, in fact GCC should not do this, 'extensions' to a language that invite undefined behavior are not in line with solid software development practices. Neither is brainfuck...

I feel obliged to point out that some of those extensions a) are pretty important for large scale projects, and b) end up standardized later on anyway— eg variadic macros being added in C99.

Definitely a case to be made that the default behaviour should be what the standard says, with extensions as an opt-in. But experimental extensions also move the language forward.

Re: Beating C with one line of Brainfuck

#39
post #34

Earlier quoted context omitted.

But the file is loaded in cat, which isn't timed

But the timed program still has to wait for cat to load the file. Both programs are launched (almost) simultaneously by the shell.

The article only listed user and sys time usage, so technically that doesn't matter.

That being said, in my experience those timings are not very accurate at this time scale; timing a program which takes just a few tenths to execute may report halving or doubling the user time between subsequent runs (and vice versa for systime).

Re: Beating C with one line of Brainfuck

#40
post #11

Earlier quoted context omitted.

Note that: #define OUTPUTS 0 char outputs[OUTPUTS] = { }; is not valid C (or C++) - zero length arrays are not a thing in either language,

(base) jam@jam-XPS-8500:~/svn/src/music/mp3tomidi$ cc -c -Wall x.c (base) jam@jam-XPS-8500:~/svn/src/music/mp3tomidi$ cat x.c #define OUTPUTS 0 char outputs[OUTPUTS] = { }; Looks like you're wrong about that; at least for GNU C. It's not official C but if it works and generates no warnings it will be used too. Long HN thread about this subject: https://news.ycombinator.com/item?id=11674374 Zero length arrays are one…

Isn't countering the G-force when cornering to keep your head straight the equivalent of lifting 25kgs with your neck?

C sounds like one hell of a ride.

Post reply on HN