Our server costs ~$56 per month to run. Please consider donating or becoming a Patron to help keep the site running. Help us gain new members by following us on Twitter and liking our page on Facebook!
Current time: July 28, 2025, 6:11 pm

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hello everyone
#23
RE: Hello everyone
(April 9, 2010 at 11:33 pm)cppman Wrote: I know that, but that is only true for built-in types. Now what happens when you write your own math class like Point, Vector2/3, Matrix, etc.? Then you are not able to use those operators, because, how will Java know what to add, multiply, etc.? That was my whole point. You have to write methods to do it for you.
You can use those operators if you are using integers within the Points class...that doesn't change. Yes, to do other things you'd have to write methods, but this is to make things consistent. Instead of someone having to read through the documentation of what *, +, /, and - all do in your class, there are methods with *helpful names* that tell you what they do.

Are you honestly saying that given an object you've never worked with before, you'd prefer to see a load of operators which you instinctively think mean "multiply" then "add" yet do completely different things over a method call that was named after the operation it actually does? It's honestly like me giving you the following sentence:

Hello( my name is Adrian& I like to program@

You say to me "That sentence is full of weird symbols", and I reply "No, I've just replaced the function of a comma with a (, a full stop with a &, and an exclamation mark with a @".

Quote:Almost always, that will be the same thing in C++. Someone could potentially use it for something else (that's what is so great about C++), but why would they? They will most likely implement the equivalent of multiplication for their type.
It's the "almost" that scares me. You say "why would they?" yet you've just said that doing so is the great thing about C++. Why would they? Because in C++ you can...and it's apparently a great thing to do.

Quote:And it generally does. It generally is used "to check if the left-value is equal to the right-value". But again, the beauty of C++ lets the user do whatever he would like with the == operator.
That ain't beauty...it's a travesty. How on earth do you read C++ code??? It must be a constant switch between the reference manuals and the code snippets.


Quote:You missed my point. The Point class, as a whole, would implement operators such as "+" and "==". Unless Point is a built-in type (which it probably is, but this is just an example), you cannot check if the two points are equal without expanding it out to what I showed above, instead of simply doing:

Code:
if (point1 == point2) { ... }

as that would compare the references, not the values. That is why operator overloading is useful. Imagine if Java didn't implement a Matrix class (it probably did, I don't know) and you had to write your own. Your class would have to implement "add", "subtract", "multiply", etc. methods to do operations on the matrix, which should naturally be written out as a multiplication symbol, addition symbol, etc.
You are once again ignoring consistency. It's all very well an good having == meaning comparing values, but some classes do not have specific values to compare. Not all classes are as simple as Points, where to work out if you have the same points, you just need to compare X and Y. In order to be consistent, the == needs to do the same thing in every class. Comparing references is actually useful sometimes, especially if you want to avoid errors. For instance, if the creation of a new object is dependant on some random event, and you have a thread that depends on the creation of the new object, then you can't have the thread trying to access a non-existent object. Thus you'd have a check (object != null) to make sure the reference existed before continuing in the thread.

As for the matrix class, there are far more matrix operations you can do than those. This is where overloading gets confusing. You'd have to have operators for cross product and dot product, and everything in between. Finding good operators to represent those operations would mean you have a stupid amount of operators that are non-descriptive, as opposed to the same number of methods that have *names* describing what they do. I'd love to see what operator you'd choose for "invert the matrix". I don't have that problem: invertMatrix(). Done. Why are you so afraid of decent method calls anyway?

Quote:I meant "they must be regretting it now" jokingly, only semi-serious. .NET has taken a lot of competition from Java, including on mobile devices, however.
*spits out drink*

Are you fucking kidding me? This is one of my areas of expertise; I've been working on mobile devices for the past 2 years in various university projects. The top runners for mobile devices are:

1) Symbian (uses Java / C++)
2) RIM Blackberry (uses Java / C++)
3) Apple iPhone OS (uses Objective C)

Windows Mobile have 9% of the operating system market on mobile devices, behind all those three. Additionally, Android (Java based) is suspected to be in second place by 2013. So no, I think your assertion that .NET has taken "a lot of competition from Java" on mobile devices is an outright fabrication.

Quote:I wasn't saying that C# vs. Java wasn't a fair comparison. I was saying that Java vs. Mono was an unfair competition.
Well you were the one who brought mono up. I can't be blamed for a comparison I didn't even make...


Quote:I never said that C++ was exactly a "low-level" language. I said it was low-levelish by today's standards. So are you saying that ASM (NASM, for example) isn't a low-level language (it does 'compile' (depending on what you mean by that word))?
NASM as far as I've understood from what I just read about it, is for the Intel x86 architecture...ergo it is made specifically for one architecture, so it is a low-level language.
Reply



Messages In This Thread
Hello everyone - by cppman - April 8, 2010 at 4:30 pm
RE: Hello everyone - by Autumnlicious - April 8, 2010 at 4:55 pm
RE: Hello everyone - by fr0d0 - April 8, 2010 at 5:25 pm
RE: Hello everyone - by Minimalist - April 8, 2010 at 6:39 pm
RE: Hello everyone - by Tiberius - April 8, 2010 at 6:45 pm
RE: Hello everyone - by cppman - April 8, 2010 at 8:33 pm
RE: Hello everyone - by Minimalist - April 8, 2010 at 8:52 pm
RE: Hello everyone - by Autumnlicious - April 8, 2010 at 9:05 pm
RE: Hello everyone - by Minimalist - April 8, 2010 at 9:23 pm
RE: Hello everyone - by The_Flying_Skeptic - April 8, 2010 at 9:12 pm
RE: Hello everyone - by Disinter - April 8, 2010 at 9:47 pm
RE: Hello everyone - by cppman - April 8, 2010 at 10:10 pm
RE: Hello everyone - by Tiberius - April 9, 2010 at 8:49 am
RE: Hello everyone - by cppman - April 9, 2010 at 2:02 pm
RE: Hello everyone - by Tiberius - April 9, 2010 at 2:09 pm
RE: Hello everyone - by cppman - April 9, 2010 at 2:28 pm
RE: Hello everyone - by Tiberius - April 9, 2010 at 3:33 pm
RE: Hello everyone - by cppman - April 9, 2010 at 6:14 pm
RE: Hello everyone - by Tiberius - April 9, 2010 at 7:02 pm
RE: Hello everyone - by cppman - April 9, 2010 at 9:47 pm
RE: Hello everyone - by Tiberius - April 9, 2010 at 10:26 pm
RE: Hello everyone - by cppman - April 9, 2010 at 11:33 pm
RE: Hello everyone - by Tiberius - April 10, 2010 at 12:45 am
RE: Hello everyone - by cppman - April 10, 2010 at 2:00 am
RE: Hello everyone - by Tiberius - April 10, 2010 at 2:59 am
RE: Hello everyone - by Edwardo Piet - April 14, 2010 at 10:25 am
RE: Hello everyone - by Tiberius - April 14, 2010 at 12:40 pm
RE: Hello everyone - by fr0d0 - April 14, 2010 at 2:09 pm
RE: Hello everyone - by Minimalist - April 14, 2010 at 2:17 pm
RE: Hello everyone - by cppman - April 15, 2010 at 8:20 pm
RE: Hello everyone - by Minimalist - April 15, 2010 at 9:29 pm

Possibly Related Threads...
Thread Author Replies Views Last Post
  Hello everyone Dredon 4 260 June 16, 2025 at 10:09 am
Last Post: Thumpalumpacus
  Hello To Everyone TravestNiggle 8 1736 June 8, 2025 at 4:08 pm
Last Post: MR. Macabre 666
  Hello Everyone Zymurgy 5 814 May 28, 2025 at 8:04 am
Last Post: Gwaithmir
  Hello Everyone! Rift Zone 9 1387 May 22, 2025 at 1:26 pm
Last Post: Pat Mustard
  Hello everyone GANIBALxD 9 1446 March 18, 2025 at 5:15 pm
Last Post: MR. Macabre 666
  Hello, Everyone I Am Hugh 14 2158 February 23, 2025 at 3:56 am
Last Post: Belacqua
Smile Hello, everyone Rolls 21 3019 June 27, 2020 at 9:31 am
Last Post: Fireball
  Hello Everyone! Chicken 33 4252 December 25, 2018 at 10:57 pm
Last Post: Peebothuhlu
  Hello Everyone :) , { Just an ape trying to socialize } Enlightened Ape 31 7931 April 24, 2018 at 1:22 pm
Last Post: Enlightened Ape
Wink Hello Everyone! rskovride 15 3358 February 21, 2018 at 5:45 am
Last Post: ignoramus



Users browsing this thread: 1 Guest(s)