Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » rant about the state of c++ software

This thread is locked; no one can reply to it. rss feed Print
rant about the state of c++ software
BAF
Member #2,981
December 2002
avatar

You're making a pretty damn big assumption here.

For one, when dealing with such huge amounts of data, especially if randomly accessed, you will want to load it in chunks on demand, rather than load it all to RAM at first.

Java doesn't choke on filesize unless you try to read it all at once. A file handle doesn't care if the file is 1B or 7TB.

Darizel
Member #10,585
January 2009
avatar

As far as I know, word processors do need to read the entire file...
And is that 7 Terabytes??!!

----------
struthersgames.com - fun games for free download ;)
I am not an idiot.*
*in my opinion.

BAF
Member #2,981
December 2002
avatar

It was just an example.

Why does a word processor need to read all 800+ pages at once? You can't read that much at a time...

Furthermore, I fail to see how C++ could provide a noticeable speed boost when using the same algorithm. If you're reading what is presumably a few hundred MB of data, it's going to bottleneck at the hard drive no matter what language you're in.

Neil Black
Member #7,867
October 2006
avatar

Quote:

Why does a word processor need to read all 800+ pages at once? You can't read that much at a time...

I'm going to buy a crapton of monitors and display an entire 800+ page document at one time, just to prove you wrong!

Quote:

Furthermore, I fail to see how C++ could provide a noticeable speed boost when using the same algorithm. If you're reading what is presumably a few hundred MB of data, it's going to bottleneck at the hard drive no matter what language you're in.

I agree (my above statement was an obvious lie). Well, if you use something really ancient, or really inefficient, then the language could make a difference.

I'm just trying to cover all the bases so someone doesn't bring up Uber_Obscure_Language_That_Sucks_At_Making_Text_Editors--

axilmar
Member #1,204
April 2001

Quote:

You're making a pretty damn big assumption here.

For one, when dealing with such huge amounts of data, especially if randomly accessed, you will want to load it in chunks on demand, rather than load it all to RAM at first.

Java doesn't choke on filesize unless you try to read it all at once. A file handle doesn't care if the file is 1B or 7TB.

It sounds like you haven't used Word. Do you know what re-pagination is? type a character in page 10, and the whole document has to be re-paginated, up to page 800.

Quote:

Furthermore, I fail to see how C++ could provide a noticeable speed boost when using the same algorithm. If you're reading what is presumably a few hundred MB of data, it's going to bottleneck at the hard drive no matter what language you're in.

You are right. Strictly speaking, C++ and Java can not use the same algorithm. Because in C++, objects take much less memory than in Java. So, C++ has the advantage, because the algorithm used in C++ can't be used in Java.

Practical example:

C++:

class Bar {
public:    
    int i;
};

class Foo {
public:  
    Bar bar;  
};

Size of Foo + Bar = 4 bytes.

Java:

class Bar {
    public int i;
};

class Foo {
    public Bar bar = new Bar;  
};

Size of Foo + Bar = 28 bytes (12 bytes for each object, plus 4 bytes for the bar's member).

The Java objects are 24 bytes bigger than the C++ objects.

So, it's not really possible to use the same algorithm, strictly speaking, because Java objects are much more heavyweight than C++.

If you multiply the above by, let's say, 1 million objects, then the Java overhead is 24 MB.

In practice, the difference is bigger. In C++, I can do this:

std::list<int> data;
data.push_back(10);

The memory allocated for this operation is:

1) 12 bytes for the linked list node: 8 bytes for the previous-next pointers, 4 bytes for the integer.

Total: 12 bytes.

In Java:

List<int> list = new LinkedList<int>();
list.add(10);

The memory allocated for this operation is:

1) 16 bytes for the Integer instance (due to auto-boxing, remember Java does not have templates): 12 bytes for the Object bookkeeping data, 4 bytes for the integer field.
2) 24 bytes for the linked list node: 12 bytes for the Object bookkeeping data, 8 bytes for the previous-next pointers, 4 bytes for the pointer to object.

Total: 40 bytes.

So, for the linked list, the difference is 28 bytes.

It is even worse for maps. In C++, a key-value pair takes exactly the amount of memory required for the key and value types, plus the pointers to other nodes; in Java, both the key and the value are objects.

There is also the overhead of interface invocation in Java.

All this, and if we also consider that in C++ most objects live in the stack, makes C++ preferable over Java.

In practice, that is the exact reason no major desktop application is written in Java.

Java has other advantages, which make it suitable for other types of projects.

Steve++
Member #1,816
January 2002

Quote:

Perhaps business world does not need C++ anymore, but business world != entire world.

You're right. The business world represents only the real world.

Quote:

Quote:

And, like it or not, the business world fuels the evolution and adoption of programming languages, the same way with Java and C# as with C++.

I'd like to see some proof of that. Academia has been creating quite a few innovative languages these days, irrespective of their business applicability.

Yes, C++ is a good example of "irrespective of their business applicability".

Quote:

In practice, that is the exact reason no major desktop application is written in Java.

Whoa, that's a bold claim. Certainly not one you could back up. I know of many successful desktop apps built on Java. The best PHP IDE currently in existence is a Java desktop application. There are very many more Java desktop apps developed and used internally by large corporations. Then there is the huge amount of Java web apps used in commercial sectors, such as Internet banking systems. Perhaps your claim is based on the Microsoft Office not being written in Java?

Axilmar, you're right and wrong. You're right about it sucking that Java has generics, but templates aren't the answer. C# has the best parameterized class system. It generates classes at runtime as needed and (as far as I know) allows primitives as type parameters. You're wrong about stack allocation being superior to heap allocation and garbage collection. First of all, Java uses a generational garbage collector by default. It has been found that most objects typically survive only one generation, so object creation patterns in Java closely resemble stack-based patterns in C++ anyway. Secondly, heap allocation and garbage collection liberates the programmer from managing responsibility for object deletion. This allows objects to be passed around freely without fear of memory leaks. Of course, you can get the same effect in C++ with boost::shared_ptr, but then you're addding memory overhead and cluttering code with boost::shared_ptr.

One thing that irks me about C++ is that it could retain all its perceived benefits without being so damn cumbersome to use. It could use a package system (like Java's) instead of header includes and library linking. It could ditch the requirement for forward declarations. It could have a much simpler template system. Its syntax in general could be much more readable. All this without losing one little bit of runtime performance, while significantly improving developer performance. The people behind C++0x had their opportunity to improve developer productivity and they blew it. This is one reason why C++ is becoming a niche language.

Vanneto
Member #8,643
May 2007

Quote:

Whoa, that's a bold claim. Certainly not one you could back up. I know of many successful desktop apps built on Java. The best PHP IDE currently in existence is a Java desktop application.

PHPEdit is actually written in Delphi...

In capitalist America bank robs you.

Matthew Leverton
Supreme Loser
January 1999
avatar

Quote:

It sounds like you haven't used Word. Do you know what re-pagination is? type a character in page 10, and the whole document has to be re-paginated, up to page 800.

Pagination requires knowing the text and the dimensions of the objects. That does not take up much memory.

Given a high of 500 words per page, that is only 400,000 words. If they average six characters, that is 2.4MB. The dimensions of embedded objects would only be a few KB.

Thus memory is of no concern here.

If anything, it's a CPU intensive task. But really, all you have to do is re-page the currently visible pages. The rest can be done in the background. The user won't notice, as most of the time you're not inserting a character and then jumping 500 pages ahead.

Timorg
Member #2,028
March 2002

As an off-topic, a word processor shouldn't care about the layout of the paging, it should edit text and do grammar and spell checking. Allowing the user to meddle with layout and the like, leads to horribly formated documents. The few non web documents I have had to write have been in LaTeX, and they came out looking fantastic, and I wasn't required to guess at what would be the best way to format something.

____________________________________________________________________________________________
"c is much better than c++ if you don't need OOP simply because it's smaller and requires less load time." - alethiophile
OMG my sides are hurting from laughing so hard... :D

axilmar
Member #1,204
April 2001

Quote:

Whoa, that's a bold claim. Certainly not one you could back up. I know of many successful desktop apps built on Java. The best PHP IDE currently in existence is a Java desktop application. There are very many more Java desktop apps developed and used internally by large corporations. Then there is the huge amount of Java web apps used in commercial sectors, such as Internet banking systems. Perhaps your claim is based on the Microsoft Office not being written in Java?

I said major applications. Please check out the following link: http://www.lextrait.com/vincent/implementations.html

Quote:

but templates aren't the answer. C# has the best parameterized class system. It generates classes at runtime as needed and (as far as I know) allows primitives as type parameters.

Generation of classes at runtime is good for two reasons:

1) it does not slow down compilation.
2) it does not bloat the result executable.

But this is irrelevant to performance.

Quote:

You're wrong about stack allocation being superior to heap allocation and garbage collection. First of all, Java uses a generational garbage collector by default. It has been found that most objects typically survive only one generation, so object creation patterns in Java closely resemble stack-based patterns in C++ anyway.

"Closely resembles" does not make it equal. In practice, the difference for big data sets is not negligible.

Quote:

Secondly, heap allocation and garbage collection liberates the programmer from managing responsibility for object deletion. This allows objects to be passed around freely without fear of memory leaks. Of course, you can get the same effect in C++ with boost::shared_ptr, but then you're addding memory overhead and cluttering code with boost::shared_ptr.

I agree with that. I am talking about code performance. I am a supporter of garbage collection in C++, I have registered an online petition, written numerous times to Bjarne Stroustrup and posted countless threads here about smart pointers.

Quote:

One thing that irks me about C++ is that it could retain all its perceived benefits without being so damn cumbersome to use. It could use a package system (like Java's) instead of header includes and library linking. It could ditch the requirement for forward declarations. It could have a much simpler template system. Its syntax in general could be much more readable. All this without losing one little bit of runtime performance, while significantly improving developer performance. The people behind C++0x had their opportunity to improve developer productivity and they blew it.

I couldn't agree more. In fact, I fully support a movement for a new programming language that has the qualities of C++ but none of its problems.

Quote:

Pagination requires knowing the text and the dimensions of the objects. That does not take up much memory.

Given a high of 500 words per page, that is only 400,000 words. If they average six characters, that is 2.4MB. The dimensions of embedded objects would only be a few KB.

Thus memory is of no concern here.

If anything, it's a CPU intensive task. But really, all you have to do is re-page the currently visible pages. The rest can be done in the background. The user won't notice, as most of the time you're not inserting a character and then jumping 500 pages ahead.

You have forgotten that a Word document is composed of COM objects. Which means that each little item in a page is a fully COM object, and has visual attributes like Color, font, style; also parents, siblings, pointers to interfaces, etc.

And then you have also forgotten that a document can contain images, tables, OLE objects etc.

And Word does the re-pagination in the background, but if your document is 800 pages, it causes heavy swapping, and stops all the other tasks. Which means it is memory intensive.

Quote:

As an off-topic, a word processor shouldn't care about the layout of the paging, it should edit text and do grammar and spell checking. Allowing the user to meddle with layout and the like, leads to horribly formated documents. The few non web documents I have had to write have been in LaTeX, and they came out looking fantastic, and I wasn't required to guess at what would be the best way to format something.

I couldn't agree more.

Matthew Leverton
Supreme Loser
January 1999
avatar

I haven't forgotten any of those things. None of them affect what I've said.

axilmar
Member #1,204
April 2001

They do affect what you said. The document is technical, i.e. it contains lots of diagrams, bitmaps, tables etc.

The fact is that there is no office, database, web browser, and other major software written in anything else than C++.

Matthew Leverton
Supreme Loser
January 1999
avatar

I don't care what it contains. My Commodore 64's word processor could hold hundreds of pages with 64K of RAM. :P

Quote:

The fact is that there is no office, database, web browser, and other major software written in anything else than C++.

So? First, there are seasoned programmers like who you would never consider using anything except C++ (for these "major" projects). Those people have to retire first, as learning a new language is impossible. (Cannot teach an old dog new tricks.)

Second, I don't expect anybody to recode their existing C/C++ codebase to another language. "Major" software isn't rewritten. It's extended and upgraded until it breaks under its own weight. Then something else replaces it. Switching to a new language isn't reason enough to start up a new project to compete with existing "major" software.

Third, there aren't many choices yet if you want to do cross platform, native programming. C# is great for Windows, but doesn't have much support for other platforms. Java is a good language, but suffers a lot from abstraction. I think D is a more practical language, but it doesn't get much attention.

Fourth, your definition of "Major" software is meaningless. I, for example, would consider Paint.NET major software. But you wouldn't because it's not written in C++. Any example I give, you can just say it's not major.

Fifth, your "fact" is wrong. There are HTML/CSS2 web browsers written in Java.

Timorg
Member #2,028
March 2002

Do you define major as in user base, or in scope? If its in scope, Singularity OS is way up there.

____________________________________________________________________________________________
"c is much better than c++ if you don't need OOP simply because it's smaller and requires less load time." - alethiophile
OMG my sides are hurting from laughing so hard... :D

BAF
Member #2,981
December 2002
avatar

Steve++
Member #1,816
January 2002

Does anyone see firms like Oracle and IBM really getting behind C++? No, they put their eggs in the Java basket. Especially Oracle. They are certainly major corporations.

Quote:

PHPEdit is actually written in Delphi...

NetBeans 6.5 is a better PHP IDE than PHPEdit. It's also free and open source.

axilmar
Member #1,204
April 2001

Quote:

I don't care what it contains. My Commodore 64's word processor could hold hundreds of pages with 64K of RAM. :P

You should, because different and much more complicated data structures are required to hold drawings, tables etc than simple text.

Quote:

So? First, there are seasoned programmers like who you would never consider using anything except C++ (for these "major" projects). Those people have to retire first, as learning a new language is impossible. (Cannot teach an old dog new tricks.)

You are wrong. I am also a Java programmer :-). And I have learned C#, and a little bit of LISP, Smalltalk, Haskell, Erlang, ADA and Eiffel in my spare time.

Quote:

Second, I don't expect anybody to recode their existing C/C++ codebase to another language. "Major" software isn't rewritten. It's extended and upgraded until it breaks under its own weight. Then something else replaces it. Switching to a new language isn't reason enough to start up a new project to compete with existing "major" software.

Which only shows that new languages don't have any substantial benefits over the old ones.

Quote:

Third, there aren't many choices yet if you want to do cross platform, native programming. C# is great for Windows, but doesn't have much support for other platforms. Java is a good language, but suffers a lot from abstraction. I think D is a more practical language, but it doesn't get much attention.

Agreed. The only options are C++ and ...C++.

Quote:

Fourth, your definition of "Major" software is meaningless. I, for example, would consider Paint.NET major software. But you wouldn't because it's not written in C++. Any example I give, you can just say it's not major.

Paint .NET is not called to handle lots of data in very short time.

Read the docs of uTorrent. The author says that it chose C++ because the other languages were slower.

Quote:

Fifth, your "fact" is wrong. There are HTML/CSS2 web browsers written in Java.

You could have written a browser in QBasic, or any Turing-Complete language. The issue here is performance.

As a 'personal' database, Hypersonic is good. I don't know how well would it perform when big performance is required though.

Quote:

Does anyone see firms like Oracle and IBM really getting behind C++? No, they put their eggs in the Java basket. Especially Oracle. They are certainly major corporations.

Not for the database engine. Java for the client, the tools, the server back end...

And let's not forget Google's Map-Reduce...in C++.

Matthew Leverton
Supreme Loser
January 1999
avatar

What is your definition of "big" applications?

Is it something that moves a lot of data? You mentioned uTorrent. So that must be big. But what about the Java bittorrent clients? They don't count as big, but uTorrent does?

eBay moves a lot of data. It's written in Java, as are a lot of other huge websites. I know they aren't desktop applications, but if we are talking about handling a lot of data in a short amount of time (your words), surely they all qualify.

I don't expect reasonable answers, as you make false black-and-white claims (there are no databases, no web browsers, etc in Java) and then when shown that you are wrong, you just raise the bar even higher, just as I predicted.

And as I've already said, the lack of "big" software written in C# is not any indication that it is incapable of being used for that. It has only been around for eight years. Most of the programs you would mention as "big" have been in existence for longer than that.

It seems that you are shrinking your definition of C++'s niche into data crunching programs. In that case, I believe you've come over to our side in that C++ is a dieing language that will only be used for components of programs that deal with large amounts of mission critical, time-sensitive calculations.

axilmar
Member #1,204
April 2001

Quote:

Is it something that moves a lot of data? You mentioned uTorrent. So that must be big. But what about the Java bittorrent clients? They don't count as big, but uTorrent does?

The uTorrent author said that he chose C++ over the alternatives because C++ produced faster and lighter programs.

Quote:

eBay moves a lot of data. It's written in Java, as are a lot of other huge websites. I know they aren't desktop applications, but if we are talking about handling a lot of data in a short amount of time (your words), surely they all qualify.

eBay moves a lot of data, but it does not process huge data sets which have a high degree or coupling.

Quote:

I don't expect reasonable answers, as you make false black-and-white claims (there are no databases, no web browsers, etc in Java) and then when shown that you are wrong, you just raise the bar even higher, just as I predicted.

I never said there are no databases, there are no web browsers. I said there are no major databases and web browsers.

Moving huge data sets around can easily be done in Java, as the code effectively is the same as in C++: the underlying O/S code is invoked to handle the reception or transmission of data.

If you wanted to create objects from those data and process them (let's say 10,000,000 objects), then C++ is much more preferable than Java.

To put it in perspective:

in C++:

MyObject *hugeDataSet = new MyObject[10000000];

In Java:

MyObject[] hugeDataSet = new MyObject[10000000];
for(int i = 0; i < 10000000; ++i) {
    hugeDataSet<i> = new MyObject;
}

Big difference in performance...

Quote:

And as I've already said, the lack of "big" software written in C# is not any indication that it is incapable of being used for that. It has only been around for eight years. Most of the programs you would mention as "big" have been in existence for longer than that.

Did I say anything about C#? I did not. But the fact is Microsoft Office is written in C++, not C#. Visual Studio as well.

C#, coming after Java, has many constructs that allow better performance than Java.

Quote:

It seems that you are shrinking your definition of C++'s niche into data crunching programs. In that case, I believe you've come over to our side in that C++ is a dieing language that will only be used for components of programs that deal with large amounts of mission critical, time-sensitive calculations.

But I've said it from the start: C++ is for big heavy stuff. I clearly said so from the beginning.

My difference with you is that it is not a dying language though, because the big heavy stuff is not going away any time soon.

I wonder if my English is so bad that confused you so much Matthew.

Matthew Leverton
Supreme Loser
January 1999
avatar

Your exact quote is:

Quote:

The fact is that there is no office, database, web browser, and other major software written in anything else than C++.

You did not say:

Quote:

The fact is that there is no major office, major database, major web browser, and other major software written in anything else than C++.

You implied that all database, office apps, and web browsers were major.

Quote:

The uTorrent author said that he chose C++ over the alternatives because C++ produced faster and lighter programs.

I'm asking for your definition of a major/big application. What is it? I don't care about what his definition was. Other people have used Java to make fast bittorrent applications.

And of course the C++ one is smaller. The Java runtime is huge! That has nothing to do with the conversation at hand. Raising the bar to avoid Java again?

And of course C++ (compiled code) will not be slower than managed code. Neither will Assembler be slower than C++. But we are talking about being sufficiently fast for the task at hand.

Quote:

eBay moves a lot of data, but it does not process huge data sets which have a high degree or coupling.

So now it has to "process huge data sets with high degree or coupling" to be big. Bar raises again.

What is your exact definition of big/major software?

axilmar
Member #1,204
April 2001

Quote:

You implied that all database, office apps, and web browsers were major.

Nope. Read again. Talking about all major things does not exclude the existence of minor things.

Quote:

I'm asking for your definition of a major/big application. What is it? I don't care about what his definition was. Other people have used Java to make fast bittorrent applications.

Any application that processes big data sets with heavy coupling amongst the data.

Quote:

And of course the C++ one is smaller. The Java runtime is huge! That has nothing to do with the conversation at hand. Raising the bar to avoid Java again?

...and lighter, but you conveniently left that out.

Quote:

And of course C++ (compiled code) will not be slower than managed code. Neither will Assembler be slower than C++. But we are talking about being sufficiently fast for the task at hand.

As I said above, and for the Nth time (oumf!!!): C++ is here to stay when the processing load is very big. Huge. Enormous. Gigantic.

;D

Quote:

So now it has to "process huge data sets with high degree or coupling" to be big. Bar raises again.

What is your exact definition of big/major software?

For the Nth time (I guess some people can only learn by repetition):

http://www.lextrait.com/vincent/implementations.html

Matthew Leverton
Supreme Loser
January 1999
avatar

So the GIMP and Photoshop are big/major software according to the link. Then surely Paint.NET is as well, which is written in C#. So you've disproved your point. That's all.

Ultimately, I think we come to the same conclusion: In the future, C++ will only serve the niche of "processing large datasets."

BAF
Member #2,981
December 2002
avatar

Is that link even... correct? They claim Linux has no asm in it (idk if its true or not). They claim the GUI for OS X is in C++ (it's.... not, everything is obj-c.). They claim the Win32 GUI is in C++ (they wrote a C API in C++? What?).

It also appears to state games used to be written in ASM and C, and are only in C++ now. Uhm, what?

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

They claim Linux has no asm in it

It does, but I doubt theres all that much in the x86[_64] port[s].

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

BAF
Member #2,981
December 2002
avatar

It seems like a very biased chart, to say the least.



Go to: