Amine Quentin
- 12
- 0
Hi Guys
Do I need to learn C before C ++?
Do I need to learn C before C ++?
I expect a student to start learning with assembly.Amine Quentin said:Hi Guys
Do I need to learn C before C ++?
. But I had been learning how pushed registers increased or decreased program performance.I don't think this is a reasonable expectation. Very few schools in the US or Europe start off budding computer science types with assembly language of any kind, to the best of my knowledge.Silicon Waffle said:I expect a student to start learning with assembly.
Mark44 said:One way that C++ frequently is taught is by presenting it first as a procedural language with no mention of the OOP features such as classes and inheritance, and using the C runtime library functions such as printf(), scanf() and the like.
Mark44 said:I don't think this is a reasonable expectation. Very few schools in the US or Europe start off budding computer science types with assembly language of any kind, to the best of my knowledge.
A bit of assembly language at the start would be a good thing, though...


Mark44 said:I don't think this is a reasonable expectation. Very few schools in the US or Europe start off budding computer science types with assembly language of any kind, to the best of my knowledge.
A bit of assembly language at the start would be a good thing, though...
My first practical computer course (in 1964) was based on assembly programming for an obscure computer called the "Wegematic". The theory was a mix of old-fashioned electronics (relays, tubes, Josephson junctions and germanium transistors) and the ALGOL 60 programming language.Hornbein said:At Harvard in 70's assembly language was the second and main computer course. No wonder Bill Gates dropped out.
Agreeing with what you said, but here's an anecdote. About 10 years ago I read an internal Microsoft white paper (I used to work for Microsoft) that advised using C instead of C++ in parts of the Windows kernel, for the reason that it was difficult to predict the compiled object code size of C++, due to the compiler generating constructors, destructors, and copy constructors, etc. Note that I'm not talking about all of Windows, just some of the code that runs in the kernel. I don't know if that white paper is still in effect.QuantumQuest said:Strictly speaking, it is not required to learn C before learning C++, but there is no harm to do so. There are cases - although few nowadays, that you'll need pure C as a programmer.
QuantumQuest said:But I think, that learning C, will definitely teach you good procedural programming and some unique features, that you'll not find in any other language and depending on your goals e.g. for system programming, drivers etc., this may prove to be of great help. If you want to go for modern application programming, then probably it's better to learn everything in the context of C++.
Polymorphic behaviors are not feasible in driver development but other OPP features are.Svein said:If you are going to write drivers or "close to the hardware" software, you cannot rely on having access to any run-time libraries. This means that you can use C, but not C++.
No. Just go straight to C++. And if you're familiar with OOP before, you might want to take a glance at C++ OOP. But like @phinds says. Study the C first then the ++ later.Amine Quentin said:Hi Guys
Do I need to learn C before C ++?
Yes, Mark. It is very easy to predict the assembly result from C than C++.Mark44 said:Agreeing with what you said, but here's an anecdote. About 10 years ago I read an internal Microsoft white paper (I used to work for Microsoft) that advised using C instead of C++ in parts of the Windows kernel, for the reason that it was difficult to predict the compiled object code size of C++, due to the compiler generating constructors, destructors, and copy constructors, etc. Note that I'm not talking about all of Windows, just some of the code that runs in the kernel. I don't know if that white paper is still in effect.
int Func1(int a)
{
return(a);
}
int Func1(inta, int b)
{
return(a+b);
}
I think by the time the compiler has finished with it 'Func1' is no longer an entity.Stephanus said:I have no idea how in the .obj file these two functions coexist together.
Compiler vendors are free to do whatever "name mangling" is necessary to disambiguate overloaded functions like these two. It's been a long time ago that I read about this, but I seem to recall that one vendor (Borland? Microsoft?) generated a symbol for each of these functions based on the function's name as well as the number and types of parameters.Stephanus said:Yes, Mark. It is very easy to predict the assembly result from C than C++.
In C++, these line numbers are valid:
I have no idea how in the .obj file these two functions coexist together.Code:int Func1(int a) { return(a); } int Func1(inta, int b) { return(a+b); }
Okay, this is off topic. But I'm just curious.Mark44 said:Compiler vendors are free to do whatever "name mangling" is necessary to disambiguate overloaded functions like these two. It's been a long time ago that I read about this, but I seem to recall that one vendor (Borland? Microsoft?) generated a symbol for each of these functions based on the function's name as well as the number and types of parameters.
That really needs a long answer. The short answer is - it depends. And the reason is the way C handles function calls.Stephanus said:So the .obj files for C++ can't be linked to every programming language freely? Only cdecl can be linked?
meBigGuy said:You WILL learn C before you learn C++. I took my first computer science course, a graduate level C++ class. I barely knew C. The process of learning all the subtleties of C syntax while also trying to learn the complex concepts of C++ made the class nervous breakdown material.
You need to go in knowing declarations, pointers and arrays, structures, enumeration, arrays of functions, casting types, etc etc etc. If not, you will be learning them as you go and take it from me, it's a tough one. Don't forget that C++ is built on top of C. The class (no pun) will assume you know C syntax.
Like this?Svein said:That really needs a long answer. The short answer is - it depends. And the reason is the way C handles function calls.
The cdecl keyword specifies that the function is compiled according to the C convention.
- In C, the last parameter in a function call is pushed first onto the stack. And the caller is responsible for tidying up the stack after the function call.
- In Pascal, the first parameter in a function call is pushed first onto the stack. And the callee is responsible for tidying up the stack at the end of the function call.
For the long answer, see https://en.wikipedia.org/wiki/X86_calling_conventions.
TestPascal proc
ret 4
TestPascal end procTestC proc
ret
TestC end proc
push AX
push BX
call TestPascal
; no add SP
push BX
push AX
call CestC
add SP,4
int Func1(int a)
{
return(a);
}
int Func1(int a, int b)
{
return(a+b);
}