Live data from Hacker News

Beating C with one line of Brainfuck

kiwec.net

41–50 of 91 posts

Re: Beating C with one line of Brainfuck

#41
post #24

Earlier quoted context omitted.

Yes, the -pedantic is what will trigger that. See linked post. But that's not on by default (fortunately!). ISO C is so restrictive ;)

> (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.

Not all warnings. Try clang -Weverything (that enables all warnings) sometime. Some warnings are even contradictory!

Re: Beating C with one line of Brainfuck

#42

Earlier quoted context omitted.

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.

I guess what jacquesm was getting at was that instead of extending C, the world should have left C behind a long time ago and transitioned to other, safer languages.

These days there are excellent alternatives to C, but of course we also have vast codebases written in C that would be too big of an undertaking and too much of a risk to rewrite in a safer language.

There may not have been any sufficiently widespread alternative in the past in terms of developer mindshare, and sufficiently performant considering how limited the hardware was in terms of both speed and memory and storage. There is also the issue of portability and of embedded platforms, and that remains problematic to this day in some cases but in other cases the possibilities for using safer languages are already really good.

Even in cases where an alternative was known and suitable, people in the past had legacy codebases that they were working with too that they didn't want to risk rewriting in any other language. So they just kept adding to the code that they had.

The legacy-code that we are sitting on now is so many lines of code that one might wonder, was it even justified that they didn't want to take on the risk of rewriting the code in the past, while there still was a chance to do it all in one go? Maybe, maybe not.

Either way, we can do nothing about the past, but if we keep growing the legacy codebases, the problem only gets bigger in the future.

We should not strive to rewrite it all at once, but we should use safer languages when we extend our codebases, and we should use safer languages when we start new projects.

Every line of code that we write today adds to the amount of code that will make up the legacy code of tomorrow.

Let's strive to make the legacy code of the future safer, so that our children may run their societies on safer software!

Re: Beating C with one line of Brainfuck

#44
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…

>one of those things that C is renowned and notorious for: something that is useful at times but unpredictable because it is flirting with undefined behavior.

This describes all the stuff that makes C useful.

Re: Beating C with one line of Brainfuck

#46

It seems we've beat the webserver serving this blog with one hug from HN.

There must be way more people reading HN than I would think.

Here we are 7 hours after post, overloading it.

Suppose "overloading" this blog is a mere 2 requests/s.

Suppose that an entire 10% of people reading HN click on this link, and on average click on it twice.

Further suppose that the average "active" HN user reads HN 5 times a week.

That means there are 1,210,000 active HN readers.

Re: Beating C with one line of Brainfuck

#47

Earlier quoted context omitted.

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.

Variadic macros are a special form of footgun. It is a footgun disguised as a massage device to trick you into pointing it at your foot. It also comes with an auto-trigger that will keep on shooting until the magazine is empty.

I've used them with great care and still got burned. But they are useful. The bigger issue is that they are work-arounds for things that really should have been in the language proper.

Re: Beating C with one line of Brainfuck

#48

Earlier quoted context omitted.

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.

I guess what jacquesm was getting at was that instead of extending C, the world should have left C behind a long time ago and transitioned to other, safer languages. These days there are excellent alternatives to C, but of course we also have vast codebases written in C that would be too big of an undertaking and too much of a risk to rewrite in a safer language. There may not have been any sufficiently widespread al…

I'm somewhere in the middle. I love my C compiler. At the same time I recognize the limitations of a lanuage that is now well in it's 5th decade.

The problem is that we have so much tooling and of such high quality that it is hard to switch to anything else. For myself mostly because of habit, existing libraries and speed of compilation. The edit-compile-test cycle length is a very high factor in my productivity. Go would score high on that list, other languages not so good. The stuff I do is for myself for the most part so I don't particularly care about security but in an environment where security is important with my present day knowledge of the pitfalls of C it would likely be the last language I would pick, and that is including the recognition that there are far more ways to create security holes than just memory safety, something proponents of other languages sometimes overlook.

C is a very sharp knife, it allows you to cut your fingers off in a very smooth and painless way. You'll likely realize it when you faint from bloodloss. At the same time, it is still, in spite of all those shortcomings my usual tool of choice. Simple, no huge superstructure, no whole eco system and mountains of dependencies rammed down my throat when I don't need them.

Re: Beating C with one line of Brainfuck

#50

Earlier quoted context omitted.

I guess what jacquesm was getting at was that instead of extending C, the world should have left C behind a long time ago and transitioned to other, safer languages. These days there are excellent alternatives to C, but of course we also have vast codebases written in C that would be too big of an undertaking and too much of a risk to rewrite in a safer language. There may not have been any sufficiently widespread al…

I'm somewhere in the middle. I love my C compiler. At the same time I recognize the limitations of a lanuage that is now well in it's 5th decade. The problem is that we have so much tooling and of such high quality that it is hard to switch to anything else. For myself mostly because of habit, existing libraries and speed of compilation. The edit-compile-test cycle length is a very high factor in my productivity. Go…

> Simple, no huge superstructure, no whole eco system and mountains of dependencies rammed down my throat when I don't need them.

This is my main reason for using C too.

Post reply on HN