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: December 25, 2024, 11:23 am

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hello everyone
#21
RE: Hello everyone
(April 9, 2010 at 9:47 pm)cppman Wrote: They 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.
This web page: http://www.bearcave.com/software/java/why_native.html discusses the native code compilers for Java, but also some interesting benchmarks that suggest the performance of Java is actually in a lot of cases better than C++, due to the amount of work that has gone into the JVM, compared with some failures in C++ compilers to create efficient native code.

Quote:That's the point. Depending on the needs of your type, you can implement whatever operators you'd like.
You shouldn't have to though, that is the point of consistency. A '+' should always "add" things, whether you are adding together two integers, or two strings (concatenation). A '*' should always multiply, etc, etc.

Quote: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.
Begging your pardon, but this is clearly an absurd example. In Java, if you multiply, you use * (not a Multiply() method) and if you add, you use + (not an Add() method). I'm not sure what experience you have with Java, but if you are honestly suggesting this is how things work, I suggest you take another look...

The idea behind consistency is that a programmer can pick up a piece of code, and know exactly what it is doing by looking at it. If you have to learn what * does under a multitude of different types, then the simple code:

Code:
a * b

could mean any number of things. In Java, it means one thing: a multiplied by b.

Quote: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.
Yes, you should know. However in terms of consistency, knowing shouldn't matter, the == should behave the same way for every object. In fact, checking the reference of an object using == is very useful when coming to design patterns. The Singleton pattern requires it in Java (to detect whether an Object is null), and so you could argue that == is useful for checking the reference of every object in this instance.

Quote: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.
That isn't overloading. X and Y are variables within the class, and if they are primitive types (which they are in Java if I recall - integers) then you are checking the reference (which returns the value stored by the variable).

Quote:Ha. How could you possibly ask that after you've used XNA in Visual Studio!? C# is a very beautiful language in Visual Studio. Smile
I want an IDE I can actually use. What is the point of having an IDE that only runs on Windows if I want to take my work home from the office and I run Linux or Mac? In my opinion, a good IDE should support multiple Operating Systems. If you only use Windows-only programming languages, then I can understand why you'd love Visual Studio more than anything else. I use three different operating systems with different languages that are all multi-platform (Java, Ruby, PHP); I need a powerful IDE, and that would be NetBeans.

Quote: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#.
Well it is a fair comparison. Java is designed to run on multiple operating systems...C# has yet to implement that feature. I love the logic of blaming a company that doesn't have any responsibility to port these things across though...good show. Novell port things because Microsoft don't want to.

You originally said that Sun must have been regretting the decision that led to Microsoft making C#. Well, C# still isn't multi-platform, so it isn't a competitor to Java in that field. It's only an unfair comparison if you asume that C# wasn't a competitor to Java, which you seem to think it was...

Quote:Eh, 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#
A low-level programming language runs on a specific instruction set architecture with little to no abstraction. It also doesn't have a compiler since it is written for the processor.

C++ isn't written for a specific instruction set (it is compiled down to one), contains abstraction, and has a compiler. Ergo, not a low-level programming language in any sense of the word Tongue

Heck, even C is a high level programming language (although most people like to call it "middle" level).
Reply
#22
RE: Hello everyone
(April 9, 2010 at 10:26 pm)Tiberius Wrote: This web page: (your URL) discusses the native code compilers for Java, but also some interesting benchmarks that suggest the performance of Java is actually in a lot of cases better than C++, due to the amount of work that has gone into the JVM, compared with some failures in C++ compilers to create efficient native code.
I haven't used Java in a pretty long time, so maybe some things have changed. I'll look into that.

I'm clumping these quotes together because they all have the same response...
(April 9, 2010 at 10:26 pm)Tiberius Wrote: You shouldn't have to though, that is the point of consistency. A '+' should always "add" things, whether you are adding together two integers, or two strings (concatenation). A '*' should always multiply, etc, etc.

(April 9, 2010 at 10:26 pm)Tiberius Wrote: Begging your pardon, but this is clearly an absurd example. In Java, if you multiply, you use * (not a Multiply() method) and if you add, you use + (not an Add() method). I'm not sure what experience you have with Java, but if you are honestly suggesting this is how things work, I suggest you take another look...
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.

(April 9, 2010 at 10:26 pm)Tiberius Wrote: The idea behind consistency is that a programmer can pick up a piece of code, and know exactly what it is doing by looking at it. If you have to learn what * does under a multitude of different types, then the simple code:

Code:
a * b

could mean any number of things. In Java, it means one thing: a multiplied by b.
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.

(April 9, 2010 at 10:26 pm)Tiberius Wrote: Yes, you should know. However in terms of consistency, knowing shouldn't matter, the == should behave the same way for every object. In fact, checking the reference of an object using == is very useful when coming to design patterns. The Singleton pattern requires it in Java (to detect whether an Object is null), and so you could argue that == is useful for checking the reference of every object in this instance.
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.

You could do the same thing in C++ using pointers, and in that case, the "==" is always the same. This is where the argument seems to drift apart. Java, and most other high object-oriented languages, hide the pointer from you and call your object a reference (and rightfully so, of course). C# does the same thing. However, C# took the smart route and inverted Java's method. Operators are overloadable and the base Object class has a few virtual methods such as "Equals", which can compare references. So, if we use pointers in C++ to do what Java does, it works exactly the same. But again, we still have the option to use our overloaded operator by dereferencing the pointer. I don't want to get too technical, but here is an example of my point.

Code:
int *x = &a;
int *y = x;

if (x == y) { .. } // this is a reference equality check
if (*x == *y) { ... } // this is a value equality check

MyWeirdClass *x = &a;
MyWeirdClass *y = &b;
if (x == y) { ... } // this is a reference equality check, our '==' operator is NOT called.
if (*x == *y) { ... } // this is a value equality check, which means it'll call our '==' operator.

(April 9, 2010 at 10:26 pm)Tiberius Wrote: That isn't overloading. X and Y are variables within the class, and if they are primitive types (which they are in Java if I recall - integers) then you are checking the reference (which returns the value stored by the variable).
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.

(April 9, 2010 at 10:26 pm)Tiberius Wrote: I want an IDE I can actually use. What is the point of having an IDE that only runs on Windows if I want to take my work home from the office and I run Linux or Mac? In my opinion, a good IDE should support multiple Operating Systems. If you only use Windows-only programming languages, then I can understand why you'd love Visual Studio more than anything else. I use three different operating systems with different languages that are all multi-platform (Java, Ruby, PHP); I need a powerful IDE, and that would be NetBeans.
I absolutely love Visual Studio when programming on Windows. For PHP, and all of those other similar languages, I use notepad++ because I don't care too much for the bulk of a full IDE. However, when developing on Linux I tend to use (depending on my mood) either gedit or Code::Blocks. But no way in hell would I choose Code::Blocks over Visual Studio if I am compiling/working on Windows. Even if my project is cross-platform, I still create a Visual Studio project for Windows, and generally just have a makefile for linux.

(April 9, 2010 at 10:26 pm)Tiberius Wrote: Well it is a fair comparison. Java is designed to run on multiple operating systems...C# has yet to implement that feature. I love the logic of blaming a company that doesn't have any responsibility to port these things across though...good show. Novell port things because Microsoft don't want to.

You originally said that Sun must have been regretting the decision that led to Microsoft making C#. Well, C# still isn't multi-platform, so it isn't a competitor to Java in that field. It's only an unfair comparison if you asume that C# wasn't a competitor to Java, which you seem to think it was...
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. Probably not enough to hurt Sun, but Microsoft has in fact taken some of the competition. I wasn't saying that C# vs. Java wasn't a fair comparison. I was saying that Java vs. Mono was an unfair competition.

What you were doing was comparing another company's funded implementation of the language to that implementation of the original developer. Compare Microsoft's implementation of C# to Sun's implementation of Java, not Novell's implementation of Mono to Sun's implementation of Java. That's all I meant. I never agreed that Novell did a bad job at implementing it either, I was in no way blaming that company for anything. I'm not sure where you got that from. And yes, Novell is funding the porting of .NET, so they did take the responsibility of mono - keep that in mind. But again, I'm not blaming Novell for anything. I, for one, think they've done a great job and I'm glad they ported silverlight and .NET.

(April 9, 2010 at 10:26 pm)Tiberius Wrote: A low-level programming language runs on a specific instruction set architecture with little to no abstraction. It also doesn't have a compiler since it is written for the processor.
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))?

(April 9, 2010 at 10:26 pm)Tiberius Wrote: C++ isn't written for a specific instruction set (it is compiled down to one), contains abstraction, and has a compiler. Ergo, not a low-level programming language in any sense of the word Tongue
Again, I never said it was. I said I considered it "low-leveish" compared to the higher leveled languages we have today.
Reply
#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
#24
RE: Hello everyone
(April 10, 2010 at 12:45 am)Tiberius Wrote: 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.

(April 10, 2010 at 12:45 am)Tiberius Wrote: 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?
First of all, I would read the documentation on the object. Second of all, what makes you assume the operation being done is something completely different? As I said, almost all operator overloads are done in an equivalent way. For example, an iterator will overload the "++" operator. That operator increments the current list node element. Nobody in their right mind is going to overload the "++" operator and make it free every resource allocated by the class. There is a relevance between the operator being used and the operation it performs - you really need to keep that in mind. Just like the "==" for the string class will check if two strings are equivalent, it isn't going to append something to your string. The dereference operator (*) for the iterator class returns a reference to the node's object, it doesn't delete the node.

What you are saying about operators is equivalent to me saying that people can label methods with names such as "add" but really do something slightly different such as incrementing a value by 2 or something completely different, like deleting itself.

(April 10, 2010 at 12:45 am)Tiberius Wrote: 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 @".
Again, you are implying that people assign random operations to random operators. There is almost always a relevance between the operator being overloaded and the operation it performs. People don't just pick random operators to overload, that does nobody any good.

(April 10, 2010 at 12:45 am)Tiberius Wrote: 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.
I was implying that the great thing about C++ was it's versatility. The option for the user to implement the operators however they wish, not that people giving random operations to random operators is a beautiful thing. It is just like the issue with pointers. People say C++ is bad because it gives users access to pointers, which can have dangerous consequences.

(April 10, 2010 at 12:45 am)Tiberius Wrote: 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.
It's common (programmer) sense, really. (and I don't mean that offensively)

(April 10, 2010 at 12:45 am)Tiberius Wrote: 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.
Then they shouldn't overload the == operator, simple as that.

(April 10, 2010 at 12:45 am)Tiberius Wrote: 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.
Of course not. Then they don't need to implement the == operator. As I've stated before, if you are working with pointers in C++, the == operator, the + operator, the - operator, etc. all do the same thing regardless of the type being worked with. This is equivalent to using references (objects) in Java or in C#.

(April 10, 2010 at 12:45 am)Tiberius Wrote: 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.
Hence the use of pointers, in C++. Natively you can't compare a value-type (except for integral primitive types) to NULL anyways. So, with that said, if you are comparing against NULL in the first place, it is impossible for you to overload the != operator for that comparison.

(April 10, 2010 at 12:45 am)Tiberius Wrote: 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?
Of course, most Matrix classes include both methods and operators, however. Generally the basic, add, subject, multiply, etc. operators are implemented.

I'm not "afraid" of method calls, I just prefer operators where operators should be used. It simplifies things, makes code more readable, and makes the code easier to debug when you come across problems.

(April 10, 2010 at 12:45 am)Tiberius Wrote: 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.
Eh, sorry about that. Let me separate my statements. C# has taken a lot of competition from Java. Some of that competition taken also includes mobile phones. Symbian OS actually has (from what I've heard/read) .NET Compact Framework.

But either way, you apparently know more about mobile phone development than I do, so I can't argue it. So, point taken.

(April 10, 2010 at 12:45 am)Tiberius Wrote: Well you were the one who brought mono up. I can't be blamed for a comparison I didn't even make...
You said,
Quote: it lacks the power of Java in terms of reliability and usability (on other platforms).
.NET only runs on Windows, so when you say "on other platforms", it implies mono.

(April 10, 2010 at 12:45 am)Tiberius Wrote: 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.
Alright, good. Just because something is "compiled" doesn't mean it can't be a low-level language. A compiler can be specific to an instruction set (like the NES compiler - forgot the name, however).
Reply
#25
RE: Hello everyone
Great. I just typed up a response and then everything just got deleted somehow...

I guess I'll talk more about this on MSN.
Reply
#26
RE: Hello everyone
That happens to me sometimes... and in Google Chrome I can never seem to get it back. That's the only thing I don't like about chrome - otherwise it seems to be brilliant.

Welcome Cppman.

EvF
Reply
#27
RE: Hello everyone
I found a great extension to combat it though; the annoyingly named "Lazarus" https://chrome.google.com/extensions/det...dkppkifgno
Reply
#28
RE: Hello everyone
Cwl. Cwl name too Wink Big Grin
Reply
#29
RE: Hello everyone
Hey, cppman.

Arch just send me a pm. He thinks that I'm you or you're me.

Idiot.
Reply
#30
RE: Hello everyone
(April 14, 2010 at 2:17 pm)Minimalist Wrote: Hey, cppman.

Arch just send me a pm. He thinks that I'm you or you're me.

Idiot.
Wow. He sure is an idiot...
Reply



Possibly Related Threads...
Thread Author Replies Views Last Post
Smile Hello, everyone Rolls 21 2015 June 27, 2020 at 9:31 am
Last Post: Fireball
  Hello Everyone! Chicken 33 3077 December 25, 2018 at 10:57 pm
Last Post: Peebothuhlu
  Hello Everyone :) , { Just an ape trying to socialize } Enlightened Ape 31 6666 April 24, 2018 at 1:22 pm
Last Post: Enlightened Ape
Wink Hello Everyone! rskovride 15 2500 February 21, 2018 at 5:45 am
Last Post: ignoramus
  Hello Everyone Shai Hulud 32 8950 May 14, 2017 at 12:04 pm
Last Post: Shai Hulud
  Hello Everyone! Driggs 22 3196 April 12, 2017 at 10:29 pm
Last Post: c172
  Hello everyone account_inactive 25 4454 April 12, 2017 at 9:55 am
Last Post: Brian37
  Hello Everyone! Flavius 9 1536 March 30, 2017 at 6:54 pm
Last Post: TheoneandonlytrueGod
  Hello everyone Yoo 11 2736 August 29, 2016 at 12:11 pm
Last Post: account_inactive
Brick Hello to everyone Wryetui 23 5194 May 4, 2016 at 9:27 pm
Last Post: ignoramus



Users browsing this thread: 1 Guest(s)