Live data from Hacker News

Fixing C

embedded.com

11–20 of 123 posts

Re: Fixing C

#11
> Suppose you could wave a magic wand and change just one aspect of C. What would that be and why?

> I’d prefer requiring matching begin and end blocks, with the end statement indicating which block is being closed.

The author's magic wand sounds like C macro to me.

Re: Fixing C

#13
C has many, many problems. Curly braces are really not one of them. If I could wave a magic wand and fix C I'd make arrays and strings know their size.

Edit for the nitpickers: Yes, arrays decay to pointers and that's the real problem. Sorry.

Re: Fixing C

#15

Removing curly braces? I have to paraphrase Torvalds on this: > The answer to that is that if you need > more than 3 levels of indentation, you're screwed anyway, > and should fix your program. Breaking the code into manageable chunks is a huge part in writing clear, maintainable software. A high amount of curly braces implies deep nested loops and/or branches, which also implies a high complexity (measured by cyclom…

Doesn't this equally imply the opposite argument? You could get away with enforced indenting, remove the curly braces, and there should still be no problem.

Re: Fixing C

#17
When I was reading I was thinking - if you like that kind of grammar just use Ada. And then later down he specifically mentions Ada. So - why not just use that?

With Ada, it is straightforward to create the kind of tight, fast code you'd write in C. You can control your own garbage collection and it has a fabulous type system. And - unless you need templates - it can do pretty much everything C++ can do as well.

I don't use Ada due to its verbosity. That's makes refactoring hard, and I refactor constantly. But only yesterday I picked up my copy of _Concurrency in Ada_ and flicked through to look at some ideas. There's lots of good stuff in there. I guess at the back story - a team who have spent years with difficult enterprise problems, who have thought really hard about them, and then rolled their conclusions back into the platform.

In the near future, a language called "flash" or "rock" or "bourne" will hit the hn frontpage. People will be amazed by its bootstrap website, its features, and will compare it well to Go. It'll get a whole lot of momentum. Weeks later a greybeard will publish an article, "Rock vs Brand X". The author of Rock will come clean in the comments saying that Rock is just a syntax transform that feeds to gnatmake, and that the whole thing was an April Fools joke.

Re: Fixing C

#18
post #13

C has many, many problems. Curly braces are really not one of them. If I could wave a magic wand and fix C I'd make arrays and strings know their size. Edit for the nitpickers: Yes, arrays decay to pointers and that's the real problem. Sorry.

Good news. Arrays have sizeof(arr)/sizeof(arr[0]) elements and strings have strlen(str) letters.

Re: Fixing C

#19
post #13

C has many, many problems. Curly braces are really not one of them. If I could wave a magic wand and fix C I'd make arrays and strings know their size. Edit for the nitpickers: Yes, arrays decay to pointers and that's the real problem. Sorry.

C arrays “know” their size. (String literals do too.)
Post reply on HN