Re:Meanwhile, C++ goes nowhere
on
Java 1.5 vs C#
·
· Score: 1
What I don't like about C++ standard, is the lack of a decent socket library that would be part of the i/o streams. There are non-portable classes for this of course, and everyone could roll their own, but it's not in the C++ standard (yet).
I agree. Recently, I had a job that introduced me to the ACE (Adaptive Communication Environment) toolkit, which has portable classes for sockets, threads and thread pools, message queues, processes, and higher-level communications contructs. It's an excellent library that cut development time and resulted in high-quality code. The main drawback was that it has its own classes for containers, streams, strings, etc. It would be great if the C++ standard libraries brought in at least some of the core functionality of ACE in a way that made it seamlessly interoperable with the existing library classes.
Essentially, instant runoff voting allows you to vote for your favorite 3rd party candidate without throwing away your vote. This allows smaller parties like the greens and libertarians to grow, and people can align with the parties that more closely express their ideas.
I was fortunate enough to take one of Jim Kurose's networking classes about a decade ago at UMass Amherst. It was very hands on - one early project was a simple C program to send an email using SMTP using sockets. Another was a DNS routing simulation, if I recall correctly. His teaching style was very pragmatic and engaging without completely avoiding theroetical discussions. The large room in which the class was taught was always standing room only.
I didn't realize Kurose's book (which we were given early printouts of while I was there) had become a "classic", but I'm not suprised. I guess it just goes to show that the professor can make a huge difference in what you learn in a given course.
C++ iostreams are built on top of C io functions, no?
The last time I benchmarked cout was a while back, so things might have changed, but they were ridiculously slow compared with straight C, at least in the libraries I was using.
Hmm.. Didn't realize the tests were run with n=1000000000. Doh. Still, in a real program, the lack of stack objects in Java can really affect performance of typical programs.
How, then, can Java out-methcall C++ by an order of magnitude?
One example of why the tests are BS
on
Java Faster Than C++?
·
· Score: 5, Insightful
From methcall.cpp:
int main(int argc, char *argv[]) { int n = ((argc == 2) ? atoi(argv[1]) : 1);
bool val = true; >> Toggle *toggle = new Toggle(val); for (int i=0; i<n; i++) { val = toggle->activate().value(); } cout << ((val) ? "true" : "false") << endl; delete toggle;
val = true; NthToggle *ntoggle = new NthToggle(val, 3); for (int i=0; i<n; i++) { val = ntoggle->activate().value(); } cout << ((val) ? "true" : "false") << endl; >> delete ntoggle;
return 0; }
Why allocate and deallocate an object within the scope of a function? Well, in C++, there's no reason, so this is bad code. You can just declare it as a non-pointer and it lives in stack space. But guess what? You can't do that in Java: all objects are allocated on the heap.
That, and using cout instead of printf, are probably why this is slower than the "equivalent" Java.
> Do you not think that Microsoft has patents on many of the things in that code?
Yes, but then, wouldn't reading the publically available patents be a problem?
The answer to this is, of course, yes. I used to work at a major game developer which strictly forbid us to read any patents. This policy wasn't just something you might read in the fine print of the employee manual: there was a mandatory-attendance presentation on the subject. The argument was that if a single employee read a particular patent, the whole company is legally tainted by that knowledge. Even though it's not supposed to matter, knowledgeable infringement apparently makes for a stronger case in the courts than coincidental infringement. So, if I read patent X, and another employee working on the other side of the planet unknowingly infringes on X, a case can be made that they actually knew it., because the company knew it as a whole. How could they prove I read it? There could be a server log that shows my PC was at that url at uspto.gov. Crazy stuff.
I just inherited $7500 from my grandmother, God rest her soul. I want to do something good with the money. I believe my first purchase will be a donut. I want to spend less than $1000 on the donut. It has to be sweet, and low in fat if possible. I like chocolate filled, but I might be willing to consider just about anything with a nice glaze on it. I've searched the web for donut review sites and haven't found any, so I figured I'd put it to the slashdot crowd. So, what kind of donut can I get for under a grand?
> What's retarded is fancy window managers that > make the entire underlying UNIX filesystem > layout visible to end users by default. If > you're going to build a desktop abstraction, > do the whole job.
The parent post was explaining an opinion that the core of the package manager problem comes from what he considered an unwieldy and non-standardized directory structure. Different Linux distros, including diffrent versions of the same distro, put certain files in different places, use different files to do the same thing, have different file dependencies, etc.
Hiding the file system layout from the novice end user might arguably be a useful thing, but it has nothing to do with the discussion.
There is a bootloader which can load either CE or Linux. The bootloader takes up a relatively small amount of flash, so once that's in place, you can reinstall CE or Linux as much as you want. It's not exactly a point-and click procedure, but it's not too hard.
OK, that's actually 2 words. But they're important words describing a feature CVS lacks. Basically it means that when I commit a bunch of files, they either all are committed or none of them are. No partial commits that break the build. No chance of getting latest during what happens to be the midst of someone else's multi-file commit.
In the last 10 years, I've worked on projects with RCS, CVS, Sourcesafe, Perforce, and Subversion. Once you get used to atomic commits in Perforce and Subversion, you'll wonder why any source control software is still used that doesn't do it this way.
"If the victim scharrt afterwards in the sand and shits into the yard, the adjustment was wrong or the dose too high."
A: DVD players don't have a network connection.
I agree. Recently, I had a job that introduced me to the ACE (Adaptive Communication Environment) toolkit, which has portable classes for sockets, threads and thread pools, message queues, processes, and higher-level communications contructs. It's an excellent library that cut development time and resulted in high-quality code. The main drawback was that it has its own classes for containers, streams, strings, etc. It would be great if the C++ standard libraries brought in at least some of the core functionality of ACE in a way that made it seamlessly interoperable with the existing library classes.
-_-_-
Now I can listen to Rush Limbaugh yell at me all day long!
http://www.fairvote.org/irv/
Essentially, instant runoff voting allows you to vote for your favorite 3rd party candidate without throwing away your vote. This allows smaller parties like the greens and libertarians to grow, and people can align with the parties that more closely express their ideas.
_-_-_
I was fortunate enough to take one of Jim Kurose's networking classes about a decade ago at UMass Amherst. It was very hands on - one early project was a simple C program to send an email using SMTP using sockets. Another was a DNS routing simulation, if I recall correctly. His teaching style was very pragmatic and engaging without completely avoiding theroetical discussions. The large room in which the class was taught was always standing room only.
I didn't realize Kurose's book (which we were given early printouts of while I was there) had become a "classic", but I'm not suprised. I guess it just goes to show that the professor can make a huge difference in what you learn in a given course.
Indeed. It appears to be an interesting new approach to the not-so-new field of mesh optimization.
And if the code were written with local objects, the code would have been:
:)
val = toggle.activate().value();
And the g++ compiler would hopefully realize that it's a non-virtual function call and potentially inline it.
Not that I was thinking about that originally...
And you are a coward. My point was cout is generally slower than C IO. So "puts", OK. Geesh!
C++ iostreams are built on top of C io functions, no?
The last time I benchmarked cout was a while back, so things might have changed, but they were ridiculously slow compared with straight C, at least in the libraries I was using.
Hmm.. Didn't realize the tests were run with n=1000000000. Doh. Still, in a real program, the lack of stack objects in Java can really affect performance of typical programs.
How, then, can Java out-methcall C++ by an order of magnitude?
From methcall.cpp:
int
main(int argc, char *argv[]) {
int n = ((argc == 2) ? atoi(argv[1]) : 1);
bool val = true;
>> Toggle *toggle = new Toggle(val);
for (int i=0; i<n; i++) {
val = toggle->activate().value();
}
cout << ((val) ? "true" : "false") << endl;
delete toggle;
val = true;
NthToggle *ntoggle = new NthToggle(val, 3);
for (int i=0; i<n; i++) {
val = ntoggle->activate().value();
}
cout << ((val) ? "true" : "false") << endl;
>> delete ntoggle;
return 0;
}
Why allocate and deallocate an object within the scope of a function? Well, in C++, there's no reason, so this is bad code. You can just declare it as a non-pointer and it lives in stack space. But guess what? You can't do that in Java: all objects are allocated on the heap.
That, and using cout instead of printf, are probably why this is slower than the "equivalent" Java.
-_-_-
#include <stdio.h>
void main(void)
{
for(int i = 0; i < 5 ; i++) printf("\t\t\b\b\b");
}
Darn html. And me for not previewing.
OK, well besides...
... which essentially boils down to an exploit in a device driver.
#include
void main(void)
{
for(int i = 0; i 5 ; i++) printf("\t\t\b\b\b");
}
Challenge: Post C code that, when compiled and executed on Windows XP, crashes the OS.
So, every time I check my mail, not only will I be reading Spam, but it'll smell like Spam too?
-_-_-
> Do you not think that Microsoft has patents on many of the things in that code?
Yes, but then, wouldn't reading the publically available patents be a problem?
The answer to this is, of course, yes. I used to work at a major game developer which strictly forbid us to read any patents. This policy wasn't just something you might read in the fine print of the employee manual: there was a mandatory-attendance presentation on the subject. The argument was that if a single employee read a particular patent, the whole company is legally tainted by that knowledge. Even though it's not supposed to matter, knowledgeable infringement apparently makes for a stronger case in the courts than coincidental infringement. So, if I read patent X, and another employee working on the other side of the planet unknowingly infringes on X, a case can be made that they actually knew it., because the company knew it as a whole. How could they prove I read it? There could be a server log that shows my PC was at that url at uspto.gov. Crazy stuff.
-_-_-
Seriously, this is the best one ever! Hurry up, less than 24 hours to bid!
I just inherited $7500 from my grandmother, God rest her soul. I want to do something good with the money. I believe my first purchase will be a donut. I want to spend less than $1000 on the donut. It has to be sweet, and low in fat if possible. I like chocolate filled, but I might be willing to consider just about anything with a nice glaze on it. I've searched the web for donut review sites and haven't found any, so I figured I'd put it to the slashdot crowd. So, what kind of donut can I get for under a grand?
-_-_-
> What's retarded is fancy window managers that
> make the entire underlying UNIX filesystem
> layout visible to end users by default. If
> you're going to build a desktop abstraction,
> do the whole job.
The parent post was explaining an opinion that the core of the package manager problem comes from what he considered an unwieldy and non-standardized directory structure. Different Linux distros, including diffrent versions of the same distro, put certain files in different places, use different files to do the same thing, have different file dependencies, etc.
Hiding the file system layout from the novice end user might arguably be a useful thing, but it has nothing to do with the discussion.
-_-_-
I'm pretty sure the beer was named after the medical condition.
> What kind of donut should I buy tomorrow?
I'd recommend a cruller.
There is a bootloader which can load either CE or Linux. The bootloader takes up a relatively small amount of flash, so once that's in place, you can reinstall CE or Linux as much as you want. It's not exactly a point-and click procedure, but it's not too hard.
Fry's carries packs of miscellaneous screws.
-_-_-
OK, that's actually 2 words. But they're important words describing a feature CVS lacks. Basically it means that when I commit a bunch of files, they either all are committed or none of them are. No partial commits that break the build. No chance of getting latest during what happens to be the midst of someone else's multi-file commit.
See the Subversion site to try it out.
In the last 10 years, I've worked on projects with RCS, CVS, Sourcesafe, Perforce, and Subversion. Once you get used to atomic commits in Perforce and Subversion, you'll wonder why any source control software is still used that doesn't do it this way.
-_-_-