All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
The flip side of that is that if you learn C, then you only have to learn part of a language to know a language. Thus making it easier to learn and remember.
Why not? Why?
edit: maybe that's a bad question...
In case you don't need all that "power", "flexibility" and "speed," I think you'll agree that you would choose a higher language to do your work!
Typically C#, Java or C++ are the popular ones, I believe?
So why learn two languages instead of one when it can be avoided?
Of course I have
Typically they are small console, test applications, though.
I have never been in a situation where I need to write typical C code (I don't write for embedded systems, nor do I write drivers or operating systems, etc), so I have never had the need for C.
Doubtless there are others who do need to do this, so why not try doing it in C++ for once!?
It doesn't matter what cpus are. CPUs understands machine language and nothing more.
Ideally, we'd write machine code directly, but for us, this impossible. Thus we rely on a language and a compiler to translate our code into machine language.
All languages translate into assembly code so they don't need to be anything. And it also makes it possible to write efficient code in any language.
I never felt that I had to loose anything learning C++.
The C part I already knew. And I use the extensions provided by C++ as and when I feel good.
I don't know more than maybe 20% of C++. But it works for me.
I am making the switch slowly and conveniently.
For e.g:
In C I used int for boolean values, but now I use bool.
I like passing by reference and it helps me avoid some *s from my code.
In line functions are cool.
Function overloading is very good.
Sometimes I use templates too. But very basic use.
I haven't yet wrote a program that uses classes (except for some demos to clear my concepts about classes).
When I write in C++ I get a more comfortable version of C
C has inline functions. C99 has _Bool, and bool by extension of stdbool.h.
Nothing is impossible. I know people who can pull the opcodes for instructions for x86 architectures out of the air. I felt like a very small programmer at that moment. ;-)Ideally, we'd write machine code directly, but for us, this impossible. Thus we rely on a language and a compiler to translate our code into machine language.
Er, all languages? Java? PHP? any other interpreted, and not complied, language? It's a bit of a thin argument, as eventually _something_ executes in the processor, but hopefully you catch my drift.All languages translate into assembly code so they don't need to be anything. And it also makes it possible to write efficient code in any language.
Really... is it this big a deal? I was defiant that C was better in every way over C++. That is, until I actually tried C++. I miss having classes, std::string/vector/list/map/etc, and all the other warm fuzziness that comes with C++ when for some reason something has to be in C. (There are dark places inside the earth where code must be written in C, or some exotic form of assembler.)
Although I may have been permanently turned away from Java thanks to an exam dealing with the most ridiculous inheritance examples that drove me nuts. That, and I'm always clueless as to whether it's pass by reference or value... so much clearer in C/C++...
(The whole "use code tags" == very annoying... find the 'code' in this post...)
long time; /* know C? */
Unprecedented performance: Nothing ever ran this slow before.
Any sufficiently advanced bug is indistinguishable from a feature.
Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
The best way to accelerate an IBM is at 9.8 m/s/s.
recursion (re - cur' - zhun) n. 1. (see recursion)
Now that's something I'd like to see
I think we can agree, however, that even if it's possible to write machine code as fast as can you can write a C/C++ program, otherwise that argument is void
I do catch your drift. So maybe they don't execute directly on the processor, the the framework translates it into machine code basically. The general "idea" is pretty much the same.Er, all languages? Java? PHP? any other interpreted, and not complied, language? It's a bit of a thin argument, as eventually _something_ executes in the processor, but hopefully you catch my drift.
Well, maybe it's not like the world will end, but I would still like to see C go away. At the very least, C89. Ridiculously unsafe.Really... is it this big a deal? I was defiant that C was better in every way over C++. That is, until I actually tried C++. I miss having classes, std::string/vector/list/map/etc, and all the other warm fuzziness that comes with C++ when for some reason something has to be in C. (There are dark places inside the earth where code must be written in C, or some exotic form of assembler.)
Although I may have been permanently turned away from Java thanks to an exam dealing with the most ridiculous inheritance examples that drove me nuts. That, and I'm always clueless as to whether it's pass by reference or value... so much clearer in C/C++...
But the worst of everything is that a lot of newbies are writing C and I doubt they're going to make embedded systems, drivers or operating systems, so they should be taught C++ instead.
My thoughts on the whole.
>I would still like to see C go away. At the very least, C89. Ridiculously unsafe.
If you think C89 is ridiculously unsafe, how would you claim that C99 is any better? I mean, C99 doesn't add any features that make the language significantly safer, so if C89 is "ridiculously" unsafe then C99 must be as well. Then again, I would argue that the language is perfectly safe if you use it intelligently.
>But the worst of everything is that a lot of newbies are writing C
When I learned C, I was told the same thing that you've been saying: "C is a crusty old language that was replaced by C++; learn C++ because you're not going to be writing code for toasters anytime soon". But I wanted to learn C, and to this day I don't regret it because C gave me a lot of low level understanding that has made me a better programmer all around.
>so they should be taught C++ instead.
Most newbies won't be doing anything that C++ is best suited for either. They'll end up writing business applications or web applications that would be better implemented in something like Java or VB or PHP. Your argument doesn't match your logic, because if you continue to the logical conclusion, you're extremely unlikely to end up at "so they should be taught C++".
My best code is written with the delete key.