Log in

View Full Version : Dynamic C++ Proposal


Daniel Pistelli
December 17th, 2008, 18:21
As anticipated, I just finished my Dynamic C++ proposal. This is not a reversing related article, but a good knowledge of C++ internals and assembly is necessary to read it. I'd like to thank my friend Quake2 for his support during the last month.

http://ntcore.com/Files/dyncpp.htm

I wrote this document because I needed to express myself about this subject. Despite the fact that C++ is one of the most used programming language, especially for serious projects, it gets much criticism for being messy, bloated, complicate etc. I believe these critics miss the point. Yes, C++ is a very powerful programming language and that's why it is difficult. And this is also why sometimes C++ source codes are poorly written. I don't believe in improvements of C++ resulting in a new programming language. All attempts in that direction have failed. I think that C++ is here to stay for many reasons. Not only because of the amount of code already available in C++, but also because at the moment there isn't a better programming language for large projects. The only thing I want is for C++ to evolve, but not by losing compatibility with older code or by removing some features. No, I'd like C++ to evolve in a healthy and compatible way. This paper contains the suggestions to achieve this and I will demonstrate technically how it can be implemented at low level.

Everybody should be warned that the material contained in this paper is purely theoretical. The first idea behind this paper came out while working on a particular project. At the time I discovered myself in need of particular dynamic features. So, for many months I had some ideas in the background of my mind and decided eventually to write them down. So, in this paper I'm going to talk about the current status of dynamism for C++, why dynamism is important and what could be done. At the time of writing (November 2008) the new C++0x (or C++09) standard has not yet been introduced. However, I will talk about it throughout this paper when the related topic is affected by it.

Maximus
December 20th, 2008, 10:35
mah.
C++ is flawed since its first ANSI approval (but was damn cool at its start, really!). It has become since long time an useless FAPP soup in my opinion.
A programming language must be easily readable. Try to grasp a meaning in a Delphi project, try to do the same on a C++ project. First one is x5 maintainable (aka cost less).
I think that the next evolution of C++ is C#, which is exactly Delphi with C syntax (not a case, since it is a Borland project transferred to M$).
The problem of C++ is never been the fact of not having 'not enough' features: but the fact it has too many and produces almost unreadable code in 95% of the times if you use its features.
For the remaining 5% it is good as they learned how to use it at its very best? That is not cool enough. I'd rather prefer a large base of decently-written codebase to a minority of exceptionally well written code (as any project manager/team leader would, by the way).
Performance is rarely an issue nowadays, as we are not anymore in '91/'92. Even VB is fast enough today (bleah!), and not because M$ made VB fast. Because we have so much raw horsepower that even the worst code in the world could run fast ('xcept Vista32, since I still have to understand how it can be slower, but this is another thing...)

Nacho_dj
December 20th, 2008, 12:14
First, thanks for another good work from you!

I have at the door of C++, just trying to start learning to code it since I always coded in Delphi, but I find C++ of course the most powerful environment.

So, I think this is a great opportunity of learning by first reading your document...

Many thanks!

Nacho_dj

Daniel Pistelli
December 20th, 2008, 12:23
Well, as you might know I am also a C# developer. I share in part you critics of the C++ language as many write difficult to mantain source code. However, even C# has many flaws. I have yet to see an enormous project written entirely in C# (apart form the singularity research project by Microsoft). Most programs written in .NET are industrial applications, databases, small utilities etc. .NET is ideal to write that kind of stuff, also because it has lots of libraries to do most things. Try capturing the webcam input with .NET, it's a matter of a few lines of code. Also, this is partly the reason why C++ source codes often suck. When dealing with these issues in native C++ most of the time COM objects play a role and there you already have a horrible C++ code. Also, let's consider MFC, how can GUI be written in an elegant way with MFC? It's impossible. Compare that to a GUI written in Qt. Wanna talk about C# issues? Well, there are many which wouldn't it make my language of choice for a large project. Let's start with a very personal one: C# has no header files. Header files, in my opinion, give a clear overview of the object's code to the developer. You can add comments in .NET code, but unless you use an external utility which parses the code and shows only method declarations and comments, you don't have a clear overview of the code. This has to do with the style of the language of course. As for implementation, I don't think that the forced garbage collector was that good of a choice. I like a forced garbage collector in python, which is a scripting language. I have for long time considered the garbage collector issue and I have two conclusions. First, it's useless, since 99% of the times a memory leak will be inferior compared to the expenses of a garbage collector. Second, it's a bad habit. Why don't I have to delete an object when I have created it? I surely close a file after I opened it. Should I deference it every time:

obj = null; ?

Well, most .NET programmers will never do that. So, the garbage collector will just hang there with unused objects until they are deferenced (which might not even happen). Compare that with C++ memory leaks.
Also, .NET applications are easily reversable. Even if they are compiled to native code, the forced metadata will always be of great help to the reverse engineer. I throughoutly described that in a paper I wrote. There are more things, I just wanted to list a few examples. I jut considered C# and its implementation, since that's what you mentioned. I could be saying a lot about the .NET libraries which are very incoherent. .NET in my opinion is taking a very bad turn (not C#). I won't even talk about WPF.

So, I agree with you that C# is the language of choice of most people, especially for certain kind of projects, and also that C++ may be complicated etc. But I still prefer C++ a ^1000 times. And I might be one of the few who still loves C++.

Daniel Pistelli
December 20th, 2008, 12:24
Ehi Nacho, thanks! =)

Long time no see, hope that the arteam forum will be back up soon.

evilcry
December 20th, 2008, 12:34
Great Work Daniel!
I appreciate your proposal, Delegates for c++ is would be a great functionality and improved flexibility of Dynamic Classes open the way to numerous coding alternatives =)

About C++ .. I think that C++ is really really a Great language, especially for complex applications, C++ offers an extreme flexible and modular support for every coding necessity..

Without C++ no MFC..and without MFC? =)

Regards,
Giuseppe Bonfa'

Daniel Pistelli
December 20th, 2008, 12:40
Hi evil, long time no see even you.

I have to thank evilcry because he knows that I had this paper for many months on my mind and he had to keep hearing about the development of it. Evilcry is very patient with me =)