Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » C# - The Good and The Bad.

This thread is locked; no one can reply to it. rss feed Print
 1   2   3   4 
C# - The Good and The Bad.
Kitty Cat
Member #2,815
October 2002
avatar

Quote:

On the other hand you could say that fair competition is good

Fixed.

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Matthew Leverton
Supreme Loser
January 1999
avatar

I think C# is a great language. Perhaps Java is too, but I cannot get past the ugly and slow implementations of it. :P

nonnus29
Member #2,606
August 2002
avatar

I agree with Peter Hull: they're almost identical languages. So the java vs c# argument seems kind of....

I don't get the point of properties. It's the equivalent of making your private class variables public, so why not just do that?

jhuuskon said:

The root cause of that hatred is of course the putrid pile of frustration that is C and C++. :P

There, it's been said, and you won't see me attempting to deny it.... 8-)

Matthew Leverton
Supreme Loser
January 1999
avatar

Quote:

I don't get the point of properties. It's the equivalent of making your private class variables public, so why not just do that?

No it's not...

nonnus29
Member #2,606
August 2002
avatar

Okay, it's not, they're a little more involved. But I still don't see the advantage:

http://www.c-sharpcorner.com/UploadFile/rajeshvs/PropertiesInCS11122005001040AM/PropertiesInCS.aspx

In particular I don't see how they're better than get/setFoo. That's just my opinion by the way. In case anyone was wondering...

Archon
Member #4,195
January 2004
avatar

Quote:

I don't get the point of properties. It's the equivalent of making your private class variables public, so why not just do that?

Properties are a cleaner equivalent of getters and setters. You can do more than just "return x;" and "x = value;" in the properties.

nonnus29
Member #2,606
August 2002
avatar

You can do more than that in getters and setters too...

Epsi
Member #5,731
April 2005
avatar

Quote:

In particular I don't see how they're better than get/setFoo. That's just my opinion by the way. In case anyone was wondering...

Here's a why: you can add logic inside properties methods, for stuff that needs to be done before or after the new "set".

Example, let's say that changing the position of a sprite is a very expensive method in term of computation, you can just add this to the setter:

public Point Position
{
  get { return position; }
  set
  {
    if (position != value)
    {
      position = value;
    }
  }
}

And there you have nice optimization that users don't need to care about.

Of course you can add all sort of logic, like move other sub-sprites once one's position is changed, etc.

And yes, you can do that with Java, but in C# it looks so much cleaner. I really like properties.

___________________________________

piccolo: "soon all new 2d alegro games will be better. after i finsh my MMRPG. my game will serve as a code reference. so you can understand and grab code from."
piccolo: "just wait until my invetion comes out its going to take the wii to the next leave of game play. it will run sony and microsoft out of busness if i dont let them use it aswell."

Matthew Leverton
Supreme Loser
January 1999
avatar

Getters and setters are generic ways to solve a common problem. C# takes it a step farther and provides a natural way to implement them. Advantage C#.

Jonny Cook
Member #4,055
November 2003

Quote:

You can do more than that in getters and setters too...

Well yeah, of course you can. Why have a for loop, when you can do the same with a while? The syntax for "for" loops is nicer, just as the syntax for properties is nicer.

Java is a great language, but I still prefer C# over it. C/C++ can be too low level, Java can be too high level, and C# is just about right.

The face of a child can say it all, especially the mouth part of the face.

count
Member #5,401
January 2005

About properties...

You start your class wit a simple attribut which doesn't need getters or setter.

public int Something;

Others can use this by doing stuff like:

int i = Something;
Something = 5;

Later you decide that there has to be more advanced stuff to go on in your class.

So you change your class to this:

1private int something;
2 
3public int Something
4{
5 get
6 {
7 dosomethingadvancedhere;
8 return something;
9 }
10 set
11 {
12 dosomethingadvancedheretoo;
13 something = value;
14 }
15}

The code that has been weritten by others has NOT to be changed.
That is the great thing of properties beeing used in the same way as attributes.

You can't do this whit java because if you add getters and setters later the written code has to be changed to:

int i = getSomething();
setSomething(5);

thats why all java classes are cluttered with setters and getters for everey variable there is just in case you need it.
which is ugly.

BAF
Member #2,981
December 2002
avatar

Quote:

Its too bad it doesn't work that way. I hear the newer MSVCs rock, and my favorite non ancient non super-expensive keyboard had to be the "MS Ergonomic Internet Keyboard" I had for years. Same goes for the MS Mouse I had, It was great.

I've never used a MS keyboard, but I do have a MS wireless laser mouse. The range on it isn't the best, but other than that it works great and goes months on one set of AA batteries. I also have a MS wireless router here. MS since discontinued network hardware... the router function of it blows, but it has a dedicated AP mode, and it works awesome in that mode, I can easily push 20-30mbit through it over wifi. I even think it can run some Linux firmware like ddwrt as opposed to the Windows CE or whatever this one runs.

Quote:

But it feels better just because of the saner licensing.

Saner licensing? What's not sane about MS's licensing?

Quote:

I don't understand the 'hate Java, love C#' people, since they are about as similar as two languages could be.

I hate Java because of dumb little differences like having to use .equals() instead of == on strings/objects, etc. C# is more similar to C++ and seems more sane to me. Also, it feels like it runs a hell of a lot faster than Java.

Quote:

Oh, and Eclipse is a pretty good IDE, as good as MSVC.

I haven't used Eclipse much, but Visual Studio is about the best IDE I've used so far.

Quote:

I haven't really used C# at all, been avoiding .NET stuff forever. Mostly because it would force users to download the framework just to get some small application going.
Thats no excuse nowadays though since almost everyone has .NET installed.

That used to be why I avoided .NET. But as you said, most people have it. Windows Vista comes with it out of the box, for example. That is the reason I am avoiding .NET 3.0 at the moment, at least until it's adopted some more and works with mono better.

Quote:

In c# you aren't forced to catch exceptions. If this is good or bad... you decide.

I HATE that in Java. For example, creating a new mask. I know it's not going to throw an exception, yet I have to create the mask in a method someplace so I can wrap it in try/catch for exceptions that are never going to happen. Uglifies the code, IMO.

Quote:

On the other hand, there are a couple of open Java alternatives that can run on the JVM (Groovy, Scala), and I don't know of any that run on the .NET framework.

Not sure what the alternatives are... just different languages? Managed C++, VB.NET, C#, and J# all run on the .NET framework, and IIRC it's not too hard to create more.

Quote:

You can do more than that in getters and setters too...

I think foo.bar = 3; looks cleaner and more to the point than foo.setBar(3). Same with foo.baz versus foo.getBaz(). Also, it's much quicker to type.

Hard Rock
Member #1,547
September 2001
avatar

Quote:

exception handling is diffrent. In c# you aren't forced to catch exceptions. If this is good or bad... you decide.
I think it's good.
All java programmers handle this forced exception handling with try {...} catch { // TODO } which is worser than not doing it at all.

That's not exactly true. There are two kinds of exceptions in Java, one that you are forced to catch and one that you don't have to catch. This is actually better since you can intentional throw and use exceptions like they should be and know for a fact that another developer will have to catch and deal with the problem. You can always decide to make it a runtime exception and it wont need to be caught.

Quote:

C# is ECMA standard. Java isn't.

Personally I don't really care either way, but wasn't there a whole big thing about how ECMA stamps anything Microsoft tells them to? Like their new document format? I really don't think that means anything. Java is used far more in the enterprise world and there are more jobs for it, so what does that tell you?

Anyway I do like properties and would like them in Java, but they aren't absolutely necessary. Mostly just a time saver. What I would really like is Delegates to be ported over to Java.

_________________________________________________
Hard Rock
[ Stars Dev Company ][ Twitter ][Global Warming: ARA My TINS 07 Entry][Pong Ultra Website][GifAllegS Ver 1.07]
"Well there's also coolwebsearch but we'll let that be an IE exclusive feature" - arielb on the New Browser Plugins "What's better, HTML or Variables?"

count
Member #5,401
January 2005

Quote:

Java is used far more in the enterprise world and there are more jobs for it, so what does that tell you?

Windows is used far more in the enterprise world, so what does that tell you?
Just because its USED more doesn't mean its better.. actually that doesn't mean anything but that it's used more.

Vanneto
Member #8,643
May 2007

Quote:

Just because its USED more doesn't mean its better.. actually that doesn't mean anything but that it's used more.

Actually, its more profitable investing in and learning a language that is used more and there are more jobs available that require that language.

But yeah, this thread has intrigued me and I have myself downloaded C#. MSVC# Express is too bloated if you ask me. But thats just me, I'm used to a very very simple interface and little hassle. Here you have assembly files, some strange files in the bin directory, etc, etc. Its all very confusing... I need to look into this more. :P

In capitalist America bank robs you.

ixilom
Member #7,167
April 2006
avatar

I'm not sure how properties work in C#, but if they did like Borland did in BCB you could do this:

MyObject->SomeIntegerProperty++;

Java would be like this?

MyObject->SetSomeIntegerProperty(MyObject->GetSomeIntegerProperty()+1);

Ofcourse, You could just provide some function to increment SomeIntegerProperty, but thats just more code ;)

___________________________________________
Democracy in Sweden? Not since 2008-Jun-18.
<someone> The lesbians next door bought me a rolex for my birthday.
<someone> I think they misunderstood when I said I wanna watch...

Jonatan Hedborg
Member #4,886
July 2004
avatar

Operator overloading 8-)

BAF
Member #2,981
December 2002
avatar

Quote:

Java is used far more in the enterprise world and there are more jobs for it, so what does that tell you?

Either that Java needs more maintenance or that it's been around longer than C# so it's use stems from those days.

Quote:

But yeah, this thread has intrigued me and I have myself downloaded C#. MSVC# Express is too bloated if you ask me. But thats just me, I'm used to a very very simple interface and little hassle. Here you have assembly files, some strange files in the bin directory, etc, etc. Its all very confusing... I need to look into this more. :P

I don't see where it's that bloated, the interface is fairly simple. What strange files are you talking about? The manifest and other linker files? They are mainly for faster compiles and debugging, in most cases you won't need to distribute anything more than the exe file.

Vanneto
Member #8,643
May 2007

Well, OK, thats seems reasonable. But, where the fuck is the Run application button? :P

In capitalist America bank robs you.

Hard Rock
Member #1,547
September 2001
avatar

It's F5.

_________________________________________________
Hard Rock
[ Stars Dev Company ][ Twitter ][Global Warming: ARA My TINS 07 Entry][Pong Ultra Website][GifAllegS Ver 1.07]
"Well there's also coolwebsearch but we'll let that be an IE exclusive feature" - arielb on the New Browser Plugins "What's better, HTML or Variables?"

BAF
Member #2,981
December 2002
avatar

F5 for debug, ctrl+f5 for normal mode. There should be a play button up top you can hit to run it.

Vanneto
Member #8,643
May 2007

Holy shit! How come that wasn't obvious! :P Thanks to both of you! ;D

In capitalist America bank robs you.

alethiophile
Member #9,349
December 2007
avatar

I like C++ for the OOP that I do; never tried C#, and won't; tried Java and don't really like it.

--
Do not meddle in the affairs of dragons, for you are crunchy and taste good with ketchup.
C++: An octopus made by nailing extra legs onto a dog.
I am the Lightning-Struck Penguin of Doom.

BAF
Member #2,981
December 2002
avatar

Quote:

never tried C#, and won't;

What kinda attitude is that to have?

alethiophile
Member #9,349
December 2007
avatar

If it works on Linux, then maybe. I thought it was only a Windows thing.

--
Do not meddle in the affairs of dragons, for you are crunchy and taste good with ketchup.
C++: An octopus made by nailing extra legs onto a dog.
I am the Lightning-Struck Penguin of Doom.

 1   2   3   4 


Go to: