Earlier quoted context omitted.
This would be a lot better of a read if he focused on how C is good Then it would be a Twitter post, not a blog post.
This isn’t a blog post. It’s the preface to a longer work – contents at the left.
C Craft
31–40 of 60 posts
Re: C Craft
#32Earlier quoted context omitted.
I noticed that too, and what's weird is that's not at all how you should do it. Since the char c[0] has zero size you can do sizeof on the struct so that you can do the malloc correctly. struct thing { int n; char c[0]; }; int i_need = 16; struct thing * foo = malloc(sizeof(struct thing)+i_need); foo->n = i_need; for (int i = 0; i n; i++ ) { foo->c[i] = 'a' + i; } And if your compiler won't let you do char c[0] you c…
Well, being pedantic, that should be struct thing *foo = malloc(sizeof(struct thing) + sizeof(char) * i_need); since sizeof(char) isn't guaranteed to be 1 byte on all systems.
Re: C Craft
#33Earlier quoted context omitted.
The point still remains that he arrived to this conclusion by misusing his tools. The problems of inheritance are not a universally recognized truth. There are plenty of OO advocates who believe that inheritance is perfectly fine. Maybe the issue with inheritance in OO languages is people misusing their language.
Working on any reasonably large project in a (mainstream) OO language makes dealing with someone's code that misuses inheritance incredibly likely, and design errors in class hierarchies can inflict their problems on everything they touch. OO has been sold as a tool to reduce complexity, but can become a major source of it as projects develop. Also, reading code with several levels of inheritance (more than three, pe…
Sometimes complexity is intractable. There are no silver bullets.
Re: C Craft
#34Earlier quoted context omitted.
No, his probelm with OO is that inheritance is problematic as a primary means of abstraction . It sounds nice on paper, but can lead to horribly unmaintainable code and wasting time arguing over specifics of tangled inheritance hierarchies. (This is a bigger issue in statically typed OO languages - being able to just send a message and get an exception if the recipient doesn't support that interface helps quite a bit…
The point still remains that he arrived to this conclusion by misusing his tools. The problems of inheritance are not a universally recognized truth. There are plenty of OO advocates who believe that inheritance is perfectly fine. Maybe the issue with inheritance in OO languages is people misusing their language.
Whether a truth is universally recognized has no bearing on whether it is true, quite irrespective of what OO advocates believe or who/what they choose to blame. The big issue with C? It's tough to use correctly. The criticism that is being made against OO? It's tough to use correctly. Why does OO[1] just get to opt-out of the criticism by blaming the user, but C can't?
[1] Not even OO, but inheritance in particular.
Re: C Craft
#35Earlier quoted context omitted.
Well, being pedantic, that should be struct thing *foo = malloc(sizeof(struct thing) + sizeof(char) * i_need); since sizeof(char) isn't guaranteed to be 1 byte on all systems.
Actually, the C standard guarantees that char is equal to one byte.
Re: C Craft
#36I think the author of this document would really appreciate a lot of things in Go. Given his wish for := as the assignment operator, CSP semantics and some other things...
The author works for Google, and his most recent blog post is actually about the Go language: http://benlynn.blogspot.com/2009/11/it-go-time_6644.html
"Most of my wishes for C have been granted."
Re: C Craft
#37Earlier quoted context omitted.
The point still remains that he arrived to this conclusion by misusing his tools. The problems of inheritance are not a universally recognized truth. There are plenty of OO advocates who believe that inheritance is perfectly fine. Maybe the issue with inheritance in OO languages is people misusing their language.
The problems of C are not a universally recognized truth. There are plenty of C programmers who believe that C is perfectly fine. Maybe the issue with C is just people misusing the language. /snark Whether a truth is universally recognized has no bearing on whether it is true, quite irrespective of what OO advocates believe or who/what they choose to blame. The big issue with C? It's tough to use correctly. The criti…
Re: C Craft
#38well, he mentions hating OO languages because it makes it hard for him to program in a style similar to C. That's a bit like saying you hate hate hammers because they don't work with screws very well.
Re: C Craft
#39Earlier quoted context omitted.
Working on any reasonably large project in a (mainstream) OO language makes dealing with someone's code that misuses inheritance incredibly likely, and design errors in class hierarchies can inflict their problems on everything they touch. OO has been sold as a tool to reduce complexity, but can become a major source of it as projects develop. Also, reading code with several levels of inheritance (more than three, pe…
So design errors and language feature misuse are less likely in procedural languages like C? Come on, that's ridiculous. You can't judge a language by the people who misuse it, otherwise nobody would be using JavaScript and HTML these days. Sometimes complexity is intractable. There are no silver bullets.
Re: C Craft
#40Earlier quoted context omitted.
The point still remains that he arrived to this conclusion by misusing his tools. The problems of inheritance are not a universally recognized truth. There are plenty of OO advocates who believe that inheritance is perfectly fine. Maybe the issue with inheritance in OO languages is people misusing their language.
The problems of C are not a universally recognized truth. There are plenty of C programmers who believe that C is perfectly fine. Maybe the issue with C is just people misusing the language. /snark Whether a truth is universally recognized has no bearing on whether it is true, quite irrespective of what OO advocates believe or who/what they choose to blame. The big issue with C? It's tough to use correctly. The criti…