- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Admin
Why do you keep discussing these outdated languages? Learn Scala and get on with the program.
Admin
Admin
Choosing C++ over Java is not a WTF. If anything, its the anti-WTF.
Admin
Java has steadily increased in speed to the point it is in the same order of magnitude as C code. The advantage of a static compilation vs. dynamic compilation is immense. We are replacing C code with EJB3 code at present, and the performance increase is approximately 41x. The difference is in how easy it is to distribute the work. If we need to increase performance we let the app server create another MDB. If the server runs out of capacity, we add another. The point is that C and to a degree C++ suck arse in performance in most applications. Java and .Net as Virtual Machine based languages are the future. Long live the VM.
Admin
There's also a port of Quake 2 for Java. Can't remember where it was, but it was pretty scary-awesome - click a link, JWS pops up, you tell it where your Quake2 data lives, boom, you get a pretty decently working Q2.
Admin
You really see it when you run old stuff on new machines - everything runs and finishes, meanwhile your finger hasn't left the enter key.
Admin
'The Java Faster than C++' Benchmark Revisited
Happy trolling ;-)
Admin
[quote user="xtremezone"]A library is just reused code and that concept still exists for Java on top of the JVM. Java programs need to be run inside of the JVM, which is a different concept all together, and qualifies as "special software" IMHO.[/quote]
Different purpose? Sure. Fundamentally different? No.
[quote] In college (two years ago), one of the things that confused the Hell out of me was how I could be downloading version 5 of the JDK or JRE if the most recent version was 1.5... WTF?! I didn't figure out WTF they were doing until a year outside of college... [/quote]
So that Java 5 == JVM version 1.5 is a highly confusing concept for you?
[quote]Sure, show the C-like syntax to try to make it seem the same, but any C/C++ coder that's moved on to Java will quickly point out the frustrating semantics. For example, immutable strings.[/code]
You are confusing core language semantics with the semantics of a particular library or class.
To get on a sidetrack, the String class in Java is immutable for a very good reason: multi-threading and performance (something Java and its core libraries were designed for from the ground up). If you need mutable but still thread safe strings use a StringBuffer. If you don't care about thread safety you can also use a StringBuilder which is generally the fastest mutable String manipulation class in the core libraries.
As a StringBuilder
[quote]Again, you're using C-like syntax to make it appear the same, when in reality there are very different semantics in Java. One of the things I find extremely ugly about Java code is that there are no operator overloads (except for those provided as part of the language, like operator+ for String) which results in lots of verbose, nested method calls with really long lines (or that many more lines if you split it up).[/quote]
This is one reason why Java 1.5 and above have Autoboxing which allows you to treat Objects and primitives interchangeably (with an equalities caveat).
Now, while operator overloading can be useful, the functionality is just as easily done with other language tools (methods, classes, etc.) and arguably much more clearly.
There isn't a great deal of gain to be had from something like:
cout << MyObject;
over the much more clear:
MyObject.print();
There's nothing you can do with operator overloading that you can't do in a different and often more clear way. The latter is also a more elegant solution because it allows for proper encapsulation of functionality.
Plus, you won't have some jackass who overloads the dot operator or some stupid thing like that.
[quote]I'm not trying to come across as a senseless Java basher. I recognize that Java has its niche and can be used effectively. I just haven't really found it useful yet, and I've tried many times (both in college and out).[/quote]
I agree that Java is not a very good solution for desktop apps, but desktop apps are only a small portion of apps. Java excels in the enterprise environment.
[quote] The syntax of Java is very similar to C and C++ because it's a C-like language. The semantics, however, are VERY different. If you don't understand semantics, implicitly passing arguments by reference is an example of a semantic with consequences. [/quote]
Are you claiming that C++ does not have pass by reference?
[quote] Another thing that bothers me about Java is its lack of constants... [/quote]
WTF? Have you ever actually programmed in Java? It doesn't allow GLOBAL constants (though you can easily achieve the same functionality), but to say that Java doesn't have constants is nonsensical.
Admin
Now that arrays are always objects in modern languages, it doesn't make sense to have a separate class for strings (StringBuilder, sure, but not string).
Anyway, I guess I take it back because it looks like D does has immutable strings (now, anyway). >_> However, you can still use an array of chars and accomplish everything if you need a mutable one. I liked the concept of "strings aren't special", which really they aren't... They're just arrays of data like any other data. We want to concatenate, replace, remove, join, splice, split, etc., all types of data in arrays.
What made it particularly nice (and I forget most of it now) was the syntactic sugar for working with arrays. You didn't need to call methods on them a lot of the times because there were operators for lots of things. It's been so long I don't really remember anymore though.
Admin
Sicko:
Admin
In C#, I haven't found a solution for this problem... You pass an object into a method and to my knowledge you have no way to ensure that the method doesn't modify it... AFAIK, Java is the same.
Of course I have, but only a little bit here and there. I play with it now and then until I get frustrated with the semantics and return to the sane world of me being in control. :DPlease demonstrate how to accomplish constants in Java. It's been a while, but as I remember it, final isn't the same thing...
Admin
If you can't outthink a marketer, then I'm very sorry.
No, strings are not just arrays of chars, they are strings that happen to be stored as an array. Java Strings are an improvement over the mishmash of C++ string classes and I like them a lot better. If you don't like the slightly better abstraction, that's fine, but it isn't Java's problem.
public static final String CONSTANT="Some stuff"
The only reliable way is to use immutable objects, like your maligned String.
Admin
I was at a conference and they were describing the NUnit framework. (or was it XUnit?)
NUnit 0.1 was simply JUnit run through the C# compiler. They then fixed all the errors, lather rinse repeat until it compiled.
They said it was the fastest way to get a port running.
Admin
[quote user="Franz Kafka"][quote user="xtremezone] Blah blah blah [/quote][quote]
Um, hate to break it to you, but there's NO way in C++ to ensure a method doesn't modify a variable so I'm not sure why in the world you're expecting that from C# (and there are design patterns to account for this - cough properties cough). If you're starting to think 'const' ensures constness in C++, please read-up about it and don't bother replying. Also, C++ doesn't have constants. C# does.
Some code-
C++
const - not guaranteed to be constant
C#
const - guaranteed to be constant
C# wins.
Java
public static final String FAKE_CONSTANT = "Some stuff"
C#
public static readonly string FAKE_CONSTANT = "Some stuff";
Tie.
C#
public const string REAL_CONSTANT = "Some stuff";
Java
none
C# wins. =P
Admin
If your company has a Dick, keep him zipped.
Admin
Do tell: how do Java constants differ from C# constants? Specifically, why is the Java constant 'fake'?
Admin
That would be jake.
And for the comments about pass by reference vs. pass by value:
Java passes everything by value. End of story.
Explanation in mind-numbing detail can be found here
Admin
If you rewrote my spreadsheets into a Java App, I'd never ask for your help either.
(My sarcasm detector may have malfunctioned when I read this...)
Admin
Knock knock.
Who's there?
Java.
Java who?
Java na lemme in, already?
Admin
This is true, however the value is an object ref, so it behaves much like pass by ref.
Admin
GOAL!!!!
Admin
FMD, what a refreshing break from the "Java Rocks" vs "Java is Shite" debate.
I'll be laughing all day on that one.....
Admin
Went & looked up that java quake2 port previously mentioned, and interestingly it had benchmarks!
http://bytonic.de/html/benchmarks.html
Fullscreen (probably more reliant on CPU)
C - 315fps Java 1.5 - 250fps
Admin
You have noticed, though, that while the apps eat much of the resource improvement, they do a hell of a lot more than they did on your old machine, haven't you?
Sure the resources get eaten up, and some of this may be lazy choice in development language, but some of it is because they have more bu..(I mean "Features"). Often the language chosen makes it easier for such features to be quickly added, and the difference to resource usage only becomes apparent because the application is doing more nifty little things. In addition, choice of language can minimise problems down the track - a program written purely in assembler would be more likely to have (unknown) bugs. Quick is not always best, and lots more, but I suddenly can't be bothered....
Admin
This reminds me of a project from college. I had to design an AI to trade stocks. I wrote the beta in C++, but then so my team could more easily work with me I rewrote the code in Java. It wasn't running very fast, so and I realized I could speed it up if I ran multiple threads. Well, this would be true if Java didn't go from a slight memory hog to a devourer of all memory as soon as you start forking off processes. My prof told me no one ever managed to kill the server before, I was kinda proud (and I had the spawn limit set to only 4 threads. When we got the proof of concept working, I rewrote it in C++, and it brought a tear to my eye.
Admin
Using proper encapsulation and access controls is the proper way to prevent unintended modification of your class members.
Is there some other issue you have?
Admin
Errm...I don't think a special runtime needs to be installed before a c++ app can be run (unlike the Java which [I think] needs the JRE installed)
How is Java dev time any quicker to c++ dev time? They are (on the whole) very similar languages (and have very similar libraries [although I'm not sure that's what java calls them - classes, perhaps] available to them).
Let me say I am not anti-Java, and think (as with most things) there is a time and place for it, however to try to make an argument that it is an easier or quicker language to use than c++ is laughable at best. That being said, to make the claim the opposite way is probably laughable too - in terms of development, I can't see that there would be significant savings in dev time using either of them - other than if you don't know one of them as well as the other, that one would probably take you longer to debug.
Admin
Yes a runtime does need to be installed for C++. The only difference is that the runtime is almost always installed already
Java dev cycles are faster due to shorter compile loops and better behavior on failure - instead of a random memory stompage, you get an exception and a stack trace. In terms of web sites, java has a lot going for it over C++.
Admin
I don't understand how Java Code is more maintainable than c++? Maintainability is largely affected by coding style, rather than by language. Finding people with enough experience to maintain either can be a difficult thing, but I don't see how maintaining one can be more difficult than the other - It boils down to the understanding of the language (and possibly the techniques used by predecessors). It may be easier to write obfuscated code in c++ than java, but this doesn't suggest that c++ developers write obfuscated code.
Deadlines are a management issue, and are not affected by the language. If you are suggesting that c++ takes longer to develop, I'm not convinced. A complicated App will always take longer to develop than a simple one, irrespective of language. If deadlines are tight, though, it's more to do with management and planning (I would think)
the .NET stuff confuses me a little. Is it somehow more universal than Java? If you hire someone with c# experience, he will do the job provided the job requires c# experience. If you hire someone with COBOL <Shudder> experience to fill a COBOL role, I'm sure they will do the job too. I'll take your word for c# being better supported ('cos frankly, I don't know any different).
As so many others have said it's a 'horses for courses' thing. All languages have different weaknesses, and most languages have some strengths, and are best suited to different tasks/applications. To say out and out that one language is better than another is a brave thing to do - particularly without much justification.
Admin
The funny thing is, there's actually a fairly big guy in the Java space named Rod Johnson (http://blog.springsource.com/author/rodj/) - he created the Spring suite of Java frameworks.
Definitely one of the manliest names ever, after Staff Sgt. Max Fightmaster.
Admin
I don't use java much, but AFAIK foreach was introduced through the Iterator class around version 4 or 5... As for Dates, I think the biggest problem in Java is that they made a mistake, and then tried to fix it causing confusion. Pretty sure one of the Calendar (or was that Date) classes would be equivalent to C# these days.
Admin
CodeBlocks (codeblocks.org) is supposedlymulti-platform, multi-language. I've only ever used it on win for c++ and c, so I don't know whether it supports other languages well (I know of people using it on various Unix Flavours).
Notepad++, though it isn't actually an IDE it has Syntax Highlighting, Code Folding and lots of other handy little tricks for a variety of languages
Xemacs - you either like emacs or you find it difficult
Admin
Both of these are over 4 years old... try that one for a more up-to-date and neutral roundup:
http://www.stefankrause.net/wp/?p=9
Admin
I believe emacs is developed in LISP not C++
Admin
My main issue with Java is that Hello World in Java is slower than it is in Python. This causes people to want to shove every single little thing every program on the system does into one VM because of the startup costs.
I think the world belongs to good 'scripting' languages like Python combined with C++ for optimizing the speed sensitive portions. I don't like Java at all. It has the worst tradeoff between ease of development, speed and verbosity of any language in popular use today.
Admin
I was thinking http://bruscy.republika.pl/pages/przemek/java_not_really_faster_than_cpp.html
There are many others....
Admin
And this one for a comparison of java with C# http://kingrazi.blogspot.com/2008/05/shootout-c-net-vs-java-benchmarks.html
or even better: The computer Language Benchmark Game for always up to date benchmarking of a lot of languages. Pretty cool benchmark place.
After that, the conclusion is Java is slower than C/C++, but not by an awful margin (around 50% slower)
Admin
[quote user="Zer0"][quote user="Franz Kafka"][quote user="xtremezone] Blah blah blah [/quote][quote]
Um, hate to break it to you, but there's NO way in C++ to ensure a method doesn't modify a variable so I'm not sure why in the world you're expecting that from C# (and there are design patterns to account for this - cough properties cough). If you're starting to think 'const' ensures constness in C++, please read-up about it and don't bother replying. Also, C++ doesn't have constants. C# does.
Some code-
C++
const - not guaranteed to be constant
C#
const - guaranteed to be constant
C# wins.
Java
public static final String FAKE_CONSTANT = "Some stuff"
C#
public static readonly string FAKE_CONSTANT = "Some stuff";
Tie.
C#
public const string REAL_CONSTANT = "Some stuff";
Java
none
C# wins. =P
[/quote]
perhaps I miss the point, but if you define a constant in c++ (ie use #define) is it not constant?? Forget const...
Admin
The myth of Java beeing awfully slow is mainly due to the fact that is used to be, but isn't any more. It basically 3rd fastest, right after ASM and C/C++.
Admin
Java makes you write out what you mean. This is certainly more bureaucratic, but it makes the life of maintenance programmers much better. That's really important for a lot of software...
Admin
IIRC, #define doesn't allow you to build a complicated object/structure and use the same copy multiple times accross your program. Due to the fact that it is just a preprocessor trick, you end up with many copies of the same data.
Admin
Admin
Nope, there are several ways to deal with this: make your object immutable, wrap it in an immutable wrapper class, or make a defensive copy that you pass around (but that might end up being quite expensive since you need to make a copy of all the readable references your object holds if they don't refer to immutable object themselves).
First solution: if your class is immutable (like String, or the class Foo below), you can pass it around and it can never be modified:
Second solution: if you wrap your class in an immutable wrapper (like Collections.unmodifiableCollection() for instance - but beware references to other objects), it won't be able to be modified either:
Last solution: make a copy constructor, or introduce a copy() method (do NOT use clone() for that purpose). Implementation left as an exercise for the reader.
Admin
Um, yeah. But I think the point of that article is that the value of a variable is a reference not the object itself. Consider:
(Assuming SomeObject is a class with SomeProperty and associated getter and setter methods, and we have a method bar() that takes SomeObject) Will print 2 give the same thing as 1?? Always? No Matter what bar() does? If you pass by reference, any change made within a method is made to the Object referred by that reference. If you pass by value, the object is 'cloned' (probably bad terminology), and a clone is passed to the method. That is, the method has its own COPY of the object, but not the object itself, and modifying it does not modify the original object.
Try passing an object in java to a method that modifies it, and you will find that the original object is modified. This is because java passes by reference, not by value. What the article you refer to is saying, is that the variable itself is a reference, and it is passed by its value. The article is merely being a little facetious.
NB: If you answered that the code may print something different the second time, you are only half right. The code doesn't compile - it's missing a semi-colon on the method call, but nice try.
Admin
I don't think you are understanding the constant deal correctly. C++ has const correctness (http://en.wikipedia.org/wiki/Const_correctness) which both Java and C# are missing.
Basically in Java and C# there is no way to guarantee that a method you call doesn't mess with the internals of your object (unless your object is immutable). This is possible in C++.
Admin
Point Taken, I've never used a Constant Object. #define works nicely for my ints and strings....
Admin
#define is a preprocessor trick, but it is (reasonably) invisible to even the developer for simple uses (more complicated macros bring trouble very quickly - make sure to overuse brackets, and all that)
For more complicated constant Objects/structures (that you want lots of reuse), wouldn't a static class suffice? This would be reasonably constant (assuming you didn't allow it to be modified), or am I not switched on today??
Perhaps I'm clutching at straws....
Admin
TRWTFs here are:
a) They told Dick about the meeting b) They let Dick within 10 miles of the offices on the day of the meeting
Either that, or they knew they were not going to get the contract, and they set Dick up so they could fire his ass.
Admin