5 ms·
I know of someone who switched to cpp with wt because the java code he first developped to generate a pdf out of a big database ran out of memory after minutes
by raphinou 13y ago
I know of someone who switched to cpp with wt because the java code he first developped to generate a pdf out of a big database ran out of memory after minutes of work. The cpp code generates the pdf in a second. Not everyone‘s situation, but this is an example, on a server, where efficient resource utilisation is important.
Also, did you see wt is widget oriented and has a java version, which you can use with jruby if you want?
- RyanZAG 13y agoJust sounds like a mis-use of Java. Java is slower than C++, but it's a fairly small difference, ie. between 1x and 3x the speed. So if the cpp code did the work in a second, the Java version should have taken at most 3 seconds. The real reason for the difference is that the rewrite into C++ used all of the domain knowledge he had acquired in writing the Java version. If he has made a Ruby version next, it would likely have been similarly efficient (maybe 5 secs? Who knows). It's a key problem in these kind of anecdotes: a rewrite will nearly always be more efficient as it has more knowledge to work with during the architecture phase of the project.
- raphinou 13y agoFrom what i know the code was quite simple and even trivial, using existing java libraries as much as possible. The fact is that using corresponding cpp libraries let him get what he needed with much less fuss. I do not know why the java version was so inefficient and used all memory,it might be due to one ofnthe librariez, but this is illustrating an example where cpp was relevant , which was the point of my comment.
- RyanZAG 13y agoAnd if he now rewrote the code in Scala using even better domain knowledge and it ran in 0.1 seconds, would this be proof to you that C++ isn't relevant after all? The point of my comment is that your basis is flawed. The apples to chimpanzees reasoning you are using is not valid.
- raphinou 13y agoI think you missed the point there was no domain knowledge advantage in the second version.
- Skinney 13y agoIf you run out of memory you're just not doing it right. C++ uses less memory than Java, this is true. But if using the same algorithm in C++ with a larger database, generating a bigger PDF perhaps, you will still fail. Could also be that just increasing the managed heap will help, but I guess this is a case about keeping to much in memory.
- raphinou 13y agoThe code was trivial, using common libraries for the language. I wanted to show a situation where a c++ web framework was useful.
- Skinney 13y agoI understand the intent. However, out of memory exceptions usually mean wrongful use of libraries, or poor quality of said libraries. It doesn't make C++ more or less usefull than Java for a particular task, as the exact same code in C++ would lead to the same result, altough it would take longer for C++ to get there.
- raphinou 13y agoWe agree. The fact is that the java libs blew, and not the cpp libs. Making the decision to develop the solution in cpp the right one, contradicting the top comment of this thread.
- Skinney 13y agoNo we still disagree. A poor library, or poor use of said library, is not a reason to use an entirely diffrent language. It's a reason to use a diffrent library or fix your code.
- codex 13y agoSwitching to C++ solved his problem; if tools don't exist to solve problems, what, indeed, are they for?
- pkulak 13y agoSounds like CPP is great at generating that one PDF. I'd have just had it do that long before I rewrote the whole app.