Re: learning c/c++
Posted: Wed Jun 12, 2013 11:40 am
Are you sure that was written by a human and not a computer program?
Nope, you're right.Blacklight wrote:On the grounds that he has clearly never worked with Befunge or Malbolge.Love4Boobies wrote:On what grounds do you make this claim?BMW wrote:No programming language is really useless, it just depends what you use it for.
By that token, zits/pimples al over someone's face in middle school are useful because they give bullies a reason to make fun of the person. Are they actually useful? I think not.BMW wrote:However I still don't think they are useless - they have some amusement value.
You really don't need to unlearn anything - I had multiple language switching events, from Visual Basic to C# to Java later to C and Objective-C (I still hate C++) there is not much issue. Actually the object-oriented background of mine helped me to build OS GDT and IDT in an object-oriented way - I treated GDT and IDT as vectors of objects of type gdt_s and idt_s and I even manipulate them with "instance methods" like gdt_addItem(gdt_s). Check out the books on object-oriented programming in C and you will find migrating what you have learned in C#/Java to C easy.Griwes wrote:If you know C# and Java and want to write something in proper C++, unlearn everything you've learned. Same holds for C.
C and C++, when used without standard libraries, are pretty similar. The main differences are:
1) You have real constructors and destructors, so RAII is possible.
2) You have templates (never underestimate a compile time Turing-complete language!).
3) You have easy to use polymorphism.
4) You have namespaces.
5) You have overloads.
So, basically, to write a *kernel* in C++ (as opposed to writing it in C), you'd have to learn at least those things *and* C. Of course, knowing more things in detail can be really helpful, so I would advise also writing some userspace applications in modern C++; also, there should be some serious style differences between code written in C and in C++.