Welcome, Guest. Please login or register.

Author Topic: C vs C++ ... or whatever language  (Read 21493 times)

Description:

0 Members and 2 Guests are viewing this topic.

Offline asrael22

  • Jr. Member
  • **
  • Join Date: Mar 2017
  • Posts: 70
    • Show all replies
Re: C vs C++ ... or whatever language
« on: February 07, 2018, 08:55:36 PM »
Quote from: Thomas Richter;835871
The good part about C++ is that there is more than a single way how to approach it and how to use it. Look at other languages: Every java program looks pretty much alike - there is only one style that is supported by java, this is the correct style, and everything else is wrong.


There are different styles in Java as well.
Some 'design' for extensible use of anonymous subclasses.
Some use other styles, there are many. Especially with Java 8 where Closures came into play.

But I agree, Java, like C++, gives you more opportunity to architecture your program better. Abstractions, Dependency Inversion, etc., its all a bit easier to implement.


Cheers
 

Offline asrael22

  • Jr. Member
  • **
  • Join Date: Mar 2017
  • Posts: 70
    • Show all replies
Re: C vs C++ ... or whatever language
« Reply #1 on: February 08, 2018, 06:14:36 PM »
Quote from: Daytona675x;835908
@kamelito
Sorry?

But you do know that a class is ultimately just a struct?
And that an C++ object is just an instance of that struct in memory, just like a C struct?
And that a member function call like ObjType* object->Func() is ultimately nothing else than writing Func(struct ObjType *this) in C?
And that a virtual function is ultimately nothing else than invoking a function-pointer in C?
And that, if you wanted to achieve the same semantics / behaviour in C, you'd either have to write / maintain some switch-case-construct or a function-pointer-table by hand?
And that deriving one class from another is first of all nothing else than creating a new struct, either copying over the stuff from the other or by putting the other inside, just in a much more convenient way?

And I repeat it: since many of the additional language-features of C++ help the compiler to better grasp what you want to achieve (or what you explicitely DONT want to do, e.g. const), it has a chance to create superior code.



Yep. The Sun JVM is written in C (the majority of the backend code at least) and uses lots of this stuff. Well, you don't really have much choice. :)



Manfred
 

Offline asrael22

  • Jr. Member
  • **
  • Join Date: Mar 2017
  • Posts: 70
    • Show all replies
Re: C vs C++ ... or whatever language
« Reply #2 on: February 08, 2018, 08:12:37 PM »
This might be interesting as well (it's actually f...ing awesome):
https://www.youtube.com/watch?v=pvkn9Xz-xks&t=3s

And the views of this guy on C language, interesting:
https://www.youtube.com/watch?v=443UNeGrFoM



Manfred