Jump to content
  • Advertisement
moeen k

why c++ doesnt have many features of many modern languages like c# languages?

Recommended Posts

im a c# programmer, also i want to learn c++  in advance. as i searched many different book, i couldnt find many aspects of c# in c++ in those books. features like event, delegate, property and... but we have pointers, references and templates in c++

i know c++ has many different distributions and different versions work on different platforms.  but doesnt really c++ have those features? 

can you introduce me a reference(book or website) that helps me understand all advanced features of c++ specally for programming DX and OpenGL?

 

Share this post


Link to post
Share on other sites
Advertisement
15 hours ago, moeen k said:

features like event, delegate, property

Yeah C++ doesn't have those in the 'core' language, mainly because they're the kind of functionality that can be provided through libraries.

For example instead of events you might use Boost Signals2.

For delegates the C++ standard library has std::function that you can use.

For properties I would just say it's something that is typically achieved by writing member functions.

 

15 hours ago, moeen k said:

can you introduce me a reference(book or website) that helps me understand all advanced features of c++

https://en.cppreference.com and http://www.cplusplus.com/reference are pretty good for learning about what's in the core language and what's in the standard library.

While https://www.boost.org/doc/libs/ is a large set of high-quality community libraries and one of the most influential projects in the C++ world. Several libraries from Boost have since been standardised into the C++ standard library (e.g. boost::shared_ptr became std::shared_ptr).

Share this post


Link to post
Share on other sites

As @dmatter pointed out, some features aren't part of the language itself, but rather of the STL (or Boost). Since in other languages (C#, Java, Python, ...), the default library is such an integral part of the language, some language features can completely depend on the existance of this library. An example would be

MyStruct? value;

wich is equivalent to

System.Nullable<MyStruct> value;

and thus requires System.Nullable to be present.

The short-hand events (meaning you don't implement add or remove explicitly) rely if I'm not mistaken on a List implementation or another data structure to handle += and -= assignments. On the other hand, the explicit syntax (comparable to properties in C#) doesn't depend on any library, because basically only offers an alternate syntax for method calls to add and remove (similar to properties with get and set).

On the other hand, one complaint about properties I heard was "this way you can't differentiate between a direct member access and an (implicit) method call just by looking at the call itself". This would apply to events as well.

Share this post


Link to post
Share on other sites
4 minutes ago, Sound Master said:

Nice downvoting, thanks again.

Well, your post wasn't helpful at all. Instead of just saying "You got brainwashed by microsoft", one should look at the advantages and disadvantages of a certain feature, and how well it could be integrated into an existing language/system.

Share this post


Link to post
Share on other sites
Posted (edited)

C++ is a long term language for huge projects
If C++ somehow added all those high-level features into the standard library, there would be even more legacy to maintain until C++ has to break backward compatibility or die. If you want a fresh start, there are many competing languages with a better balance of safety, speed and readability, but their elegance comes at the cost of being forgotten when the next shiny language arrives with adaptations for the next hardware or abstract platform.

STD is already bloated and outdated
The C++ standard collections belong to a museum by having older parts optimized for single-core computers with small but fast memory that's insignificant compared to computation. Today we have huge but slow memory with fast computation and using a linked list as a default container is like a bad joke about cache misses. This obsoletes iterators and the whole system that relies on them. Third-party libraries can be changed with every new project, adapt for custom needs using operand overloads and take advantage of the latest hardware using SIMD extensions and GPU features.

Edited by Dawoodoz

Share this post


Link to post
Share on other sites
47 minutes ago, Dawoodoz said:

This obsoletes iterators and the whole system that relies on them.

Why do you think that iterators are obsolete ?

Few days ago, while wanting to optimize a part of a project, I removed an std::vector since I was doing many push_back in it, and replaced it with a good old C-style array. And you know what ? std::vector was far more fast.

Except if you deal with big-data (and few are here), std::vector will give you very good performances, when used well.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!