RE: Hello everyone
April 9, 2010 at 9:47 pm
(This post was last modified: April 9, 2010 at 9:50 pm by cppman.)
(April 9, 2010 at 7:02 pm)Tiberius Wrote: No, there are compilers that compile Java down to the host machine byte-code. Yes, any platform Java exists on, C++ can run on too, but the point is that you have to compile your C++ program for that platform, whilst you don't for Java, which is the bonus you get when using JavaThey come with Java, or they are hacked together programs? Either way, C# does as well - and it actually comes with .NET. But yes, having to have a few macros in a config header for your C++ project can get annoying, but I still think the pros outweigh that minor annoyance.
(April 9, 2010 at 7:02 pm)Tiberius Wrote: Ok, but even so, it is good to have consistency in any programming language. If you know that all methods in Java libraries are Camel Case, then you only have to remember that fact and you don't have compilation errors (although if you use an IDE it will alert you anyway).Of course.
(April 9, 2010 at 7:02 pm)Tiberius Wrote: I see it as a moot point to be honest; it's just nitpicking that doesn't affect the functionality or usability of the language in the slightest.I'll give you that one. It doesn't affect usability at all, it is just something that bugs me.
(April 9, 2010 at 7:02 pm)Tiberius Wrote: The problem I have with operator overloading is consistency. You have the same operators doing different things depending on the type of the variable you are using.That's the point. Depending on the needs of your type, you can implement whatever operators you'd like. (see next response)
(April 9, 2010 at 7:02 pm)Tiberius Wrote: All these uses could equally just be made into different methods, so I fail to see how it makes C++ powerful and Java not. You can do the same things with methods in Java that you can with overloading operators in C++.An example would be the STL iterators. You can move to the next node by using the overloaded "++" operator. This flows naturally because when you traverse a list, you will almost always use a for-loop and increment "i". Yes, I know you could have an "iterator.getNext" method, but then you lose the natural flow and it feels like you just wrote a linked-list class.
Code:
for (int i = 0; i < 10; i++) { ... }
for (iterator i = something.begin(); i !=something.end(); i++) { ... }
Another example would be when using a Vector class. When you were using XNA, I'm pretty sure you didn't use a method to do all of your Vector and Matrix multiplication. It comes naturally to use them just like you would in math.
Code:
Vector pos = (x + y) * z + a;
as opposed to
Code:
Vector pos = z.Multiply(x.Add(y)).Add(a);
It just doesn't flow naturally and makes some things hard to debug.
(April 9, 2010 at 7:02 pm)Tiberius Wrote: Again, it's consistency that is argued for. The == operator should have one purpose, and if it can be used on all objects, that purpose should be similar to all objects.In C++, it might not be able to be used on all objects. It is up to you to implement it.
(April 9, 2010 at 7:02 pm)Tiberius Wrote: The only such thing that all objects share is a reference, so == becomes the check for references. As you say, there aren't values associated with some objects, so it becomes absurd to use == for value checking.You should know if the class has a value that can be checked for equivalence. So, it would be absurd to try to use "==" on a class that doesn't implement it in the way you expect it to. So as I said before, it is a "powerful feature" of C++ because it allows versatility and improvement in the flow of code to feel more natural.
(April 9, 2010 at 7:02 pm)Tiberius Wrote: It also flies in the face and purpose of object orientation. Objects are containers for values, not values themselves. If you are dealing with objects, you may have multiple different values assigned within them, so the == operator is messy if used in this way.Not at all. Take a look at checking if two Points are equal. How do we check? If Point1.X == Point2.X and if Point1.Y == Point2.Y. That is how you would overload the "==" operator for the Point class. It actually compliments object-orientation, if you ask me.
(April 9, 2010 at 7:02 pm)Tiberius Wrote: If it's the most amazing IDE ever why doesn't it run on multiple platforms...just sayingHa. How could you possibly ask that after you've used XNA in Visual Studio!? C# is a very beautiful language in Visual Studio.
(April 9, 2010 at 7:02 pm)Tiberius Wrote: Well I can't stand Microsoft, but I don't use that as a reason for not using C# or Visual Basic.It's not the reason I don't use Java, it is just something that adds to the fire for me.
(April 9, 2010 at 7:02 pm)Tiberius Wrote: I've used them in the past (XNA mainly) and whilst it is as easy to use as Java, it lacks the power of Java in terms of reliability and usability (on other platforms).That's not a fair comparison. .NET isn't naturally cross-platform. Novell just took it upon themselves to write a Linux port (called Mono, and Moonlight for Silverlight). So, if anything, blame Novell, not C#.
(April 9, 2010 at 7:02 pm)Tiberius Wrote: Well C++ is a high level programming language with low-level features, as is Java (just with less low-level features). But yeah, I guess it is hard for low-level programmers to make the jump to high-level and like it...and vice versaEh, I really hate to call C++ a "high level" language. With the definition of a "high level" language now-a-days, I would consider it low-levelish with assembly being low-level. Here is my view (in order from low-level to high-level): ASM -> .. old languages .. -> C -> C++ -> C++ 0x -> Java -> C#
I guess I shouldn't have said it was "hard". I just mean I can't stand a language that doesn't have low-level features, even if I never use them. It just annoys the hell out of me, for some reason.
All this talk about programming languages makes me want to write my own now. That should be a fun project, for a while...