Programming

Started by Wonkyth, Thu 23/04/2009 11:53:26

Previous topic - Next topic

lemmy101

#20
whoops! Sorry, fair point! ;)

First off make sure you get this:

http://www.microsoft.com/express/vcsharp/

a free, slightly cut down version of Visual Studio which is by far the best IDE to use for C# development. (apart from the full Visual Studio, obv)

For general non-game C# tutorials:

http://www.csharp-station.com/Tutorial.aspx
http://www.softsteel.co.uk/tutorials/cSharp/cIndex.html

If it's games programming you're after doing in it, then have a look at XNA. There's a ton of great samples, starter kits and tutorials on the xna site:

http://creators.xna.com/en-GB/education/gettingstarted
http://creators.xna.com/en-GB/education/catalog/
http://creators.xna.com/en-GB/education/starterkits/

There's a few on our site but as of yet they're all very situational or specific, and not a general introduction to the language for total newcomers, but you might want to pop by later on into your journey. :D

Also, I'm preeeetty sure it is C-Sharp :p

Ghost

Hah, I read up. It IS indeed C sharp, and they're using the hash symbol because keyboards have no convenient way to type the sharp symbol.
*proud*

lemmy101

#22
Quote from: monkey_05_06 on Fri 24/04/2009 11:03:11
Just for the record, I've also thus far stuck with C++ because "see-sharp" is a very silly name for a programming language. :P

Just cause we're so used to C++ as a name it sounds fine to us, and because it makes sense in context of the programming language, are you trying to tell me See-Plus-Plus is any better? :p

Quote from: monkey_05_06 on Fri 24/04/2009 11:03:11
As far as the foreach, does it support a way of getting the key (like PHP's foreach does)?

Nah, but then they're general purpose for any kind of container, including those with no key. It's easily made up for by the sexy awesomeness of Linq though...

Tell me this isn't awesome!

var  screenObjects = new List<ScreenObjects>();

// ... when it's full of objects ...

var objectsInTopHalfOfScreen =
        from o in screenObjects
        where o.Y < 240
        orderby o.Y
        select o;

foreach(var item in objectsInTopHalfOfScreen)
{
    // objectsInTopHalfOfScreen contains a list of all objects in the top half of the screen, ordered by their Y position...

}

LINQ is awesome.

And Extension Methods are amazing:

http://nandokakimoto.wordpress.com/2009/04/06/c-extension-methods/

And Properties too:

http://msdn.microsoft.com/en-us/library/w86s7x04.aspx

Wonkyth

Quote from: Ghost on Fri 24/04/2009 11:39:28
Hah, I read up. It IS indeed C sharp, and they're using the hash symbol because keyboards have no convenient way to type the sharp symbol.
*proud*

Hmm, Didn't think of that
Thanks heaps Lemmy, all the info you've given me should be good.
"But with a ninja on your face, you live longer!"

Paper Carnival

Since we're talking about programming, I suggest you try out the Consolas font, if you haven't already.

I tried a few programming fonts, and this is by far the best. Much cleaner than Courier/ Courier new, and has distinct characters for O, 0, I, l and 1.

Stee

Java is a good language to get stuck into, with all the range with mobile phones at the moment. Good thing with java is the C# is basically a rework of the old J++ they had to discontinue (sun sued the shit out of them), so the languages are very similar in terms of syntax. Of course theyre different, but you pick up one its a lot easier to crossover to the other.

I enjoyed programming in C# when I had the chance. Im back at java now, which is equally handy since theoretically the knowledge I have from C# helps with Java and vice versa. When you think about it it paid off for M$ as they still get to keep the majority of their Java users, and said users can now program for Windows, Xbox, Linux, Mac, Mobile phones etc.

Pretty Impressive. To sum up:

Console.WriteLine("Welcome to the Real Languages!!");

System.out,Println("Java is cool too!!");
<Babar> do me, do me, do me! :D
<ProgZMax> I got an idea - I reached in my pocket and pulled out my Galen. <timofonic2> Maybe I'm a bit gay, enough for do multitask and being romantical

Paper Carnival

cout << "...But I'd rather learn C++ first." << endl;

It's less painful learning C++ first and then C# / Java, than the other way around.

bicilotti

Quote from: Paper Carnival on Fri 24/04/2009 16:19:43
cout << "...But I'd rather learn C++ first." << endl;

It's less painful learning C++ first and then C# / Java, than the other way around.

Second that.

Babar

You mean that C# is so simple and easy that you'd not want to learn C++ after that? :D


I learnt Qbasic first, a long time ago. I think it somewhat slowed down my learning of other languages, because I got annoyed with the feeling that I was doing all that stuff all over again, when I had already done it before.
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

lemmy101

#29
Quote from: Paper Carnival on Fri 24/04/2009 16:19:43
cout << "...But I'd rather learn C++ first." << endl;

It's less painful learning C++ first and then C# / Java, than the other way around.

No no no. Surely not? How? When? Why? :S

So 1) when you're introduced to all the insane weirdness of a C / C++ hybrid you are a complete newcomer, and when you learn a similar yet more elegant language second and have loads of bad habits you've learnt of creating global variable or whatever that you have to unlearn.

Or 2) you learn a next gen language that's proper OOP, designed well and enforces good code design, has no C legacy hang ups,. And then once you've got a handle on all that, and comfortable with C#, go on to learn things like pointers and manual deletion,  to make a MUCH more sizeable jump to learn all the quirks and weirdness of C++ and use it like it's supposed to be used.

And also he's less likely to get frustrated learning it and abandon the plan altogether.

No way. Definitely would be better off learning C# first, IMO. :)

Wonkyth

Keep this up guys, It's fun to watch. ;D
"But with a ninja on your face, you live longer!"

monkey0506

Quote from: lemmy101 on Fri 24/04/2009 11:46:08are you trying to tell me See-Plus-Plus is any better? :p

Duh.

:-*

Trent R

To add onto a previous tangent, the Sharp is actually a throw to the same idea as Plus-Plus of Incrementing. Sharp is the notation in music to increase a half-step, to the immediate next pitch.

And yes, Ghost is right about why the Hash symbol is used more often (though you do see the Sharp on the Microsoft site)


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Stee

If you get into C# and then into XNA may I recommend not getting Benjamin Neitsche's book on the subject (published by Wrox I think). Its really not suitable for a beginner. Microsoft's own book wasn't too bad, my personal preference was XNA Unleashed by SAMS. (SAMS are my favourite publisher ever since my first book on Visual Studio .NET 2003)

Java books are hit and miss. If your first starting I used some old battered book I can't remember what it was called as it was needed for the course. It was really useful. At the moment im skimming through Java 6 in 21 days, which is too broad.

Consequently no one has noticed my typo in my code  :-X
<Babar> do me, do me, do me! :D
<ProgZMax> I got an idea - I reached in my pocket and pulled out my Galen. <timofonic2> Maybe I'm a bit gay, enough for do multitask and being romantical

Paper Carnival

Well, I'm a mere university freshman, so I wouldn't really know what I'm talking about ;) I'm learning new things every day, and I find programming thing to be dangerously fun and addictive.

Quote from: lemmy101 on Fri 24/04/2009 22:55:45So 1) when you're introduced to all the insane weirdness of a C / C++ hybrid you are a complete newcomer, and when you learn a similar yet more elegant language second and have loads of bad habits you've learnt of creating global variable or whatever that you have to unlearn.

I don't really understand what you are saying. Does C# not allow global variables and other nasty habits? I wouldn't know, because I didn't get into it. But when I was learning the basics, my professor(s) would insist on this matter: "This is how you do it, but DON'T do it", to sum it up. Even so, something always exists for a reason, and sometimes things like macros or global variables can be a powerful tool when you know how to use them wisely.

Quote from: lemmy101 on Fri 24/04/2009 22:55:45Or 2) you learn a next gen language that's proper OOP, designed well and enforces good code design, has no C legacy hang ups,. And then once you've got a handle on all that, and comfortable with C#, go on to learn things like pointers and manual deletion,  to make a MUCH more sizeable jump to learn all the quirks and weirdness of C++ and use it like it's supposed to be used.

I don't see how pure object orientation is better than a multi-paradigm language like C++. I like object orientation, but sometimes a linear solution is better or less expensive. Correct me if I'm wrong, but I believe that it's much easier to fall into the trap of writing unnecessarily resource-hogging software in OOP. I'd think that learning C++ you understand more how things are done in the background and you're able to tell which method will run faster.

Quote from: lemmy101 on Fri 24/04/2009 22:55:45And also he's less likely to get frustrated learning it and abandon the plan altogether.

Great point there. Not all people have my patience :D I once spent 6+ hours debugging over a particularly nasty segmentation fault that was caused by misunderstanding how C++ works with the copy constructor. I  had to learn it the hard way, but I'll never forget it now.

Stee

QuoteI don't really understand what you are saying. Does C# not allow global variables and other nasty habits? I wouldn't know, because I didn't get into it. But when I was learning the basics, my professor(s) would insist on this matter: "This is how you do it, but DON'T do it", to sum it up. Even so, something always exists for a reason, and sometimes things like macros or global variables can be a powerful tool when you know how to use them wisely.

C# allows global variables, and we we're taught "this is how you do it but don't do it" too. We are just taught better ways of calling variables outside a class.

<Babar> do me, do me, do me! :D
<ProgZMax> I got an idea - I reached in my pocket and pulled out my Galen. <timofonic2> Maybe I'm a bit gay, enough for do multitask and being romantical

lemmy101

#36
Quote from: Stee on Sun 26/04/2009 08:05:07
QuoteI don't really understand what you are saying. Does C# not allow global variables and other nasty habits? I wouldn't know, because I didn't get into it. But when I was learning the basics, my professor(s) would insist on this matter: "This is how you do it, but DON'T do it", to sum it up. Even so, something always exists for a reason, and sometimes things like macros or global variables can be a powerful tool when you know how to use them wisely.

C# allows global variables, and we we're taught "this is how you do it but don't do it" too. We are just taught better ways of calling variables outside a class.



No C# doesn't. It's got the same strict OOP principals as Java, everything must be inside a class.

That's why it's the better starting place, if not somewhere just to stick around once you've learnt it. If you do C++ first you would probably, unless taught, end up making globals everywhere, then going to a proper OOP language and getting confused as the entire way you think about how programs are put together is vastly different, even though the syntax is very similar.

There can be no argument that OOP is a better way to code than procedural and at some point in the future OOP (or some evolution of it) will be all there is. Even scripting languages are going that way. If you're wanting to learn programming now, it'd be a good idea to learn OOP programming and all the principals that go with it. But despite this being perfectly possible in C++, because of its backwards compatibility with C it's got a lot of weirdness which goes outside OOP which means when learning you're almost guaranteed to learn at best some hybrid form of programming where you will use C disciplines and C++ disciplines together. This will make it very difficult to unlearn all these things when you do move to a pedegree OOP language.

I'm not being down on C++ for the sake of it. I was a huge advocate of C++ at places I've worked that were strictly C orientated. Just now is the cusp of the transition from C++ to whatever's next, and regardless of my feelings for MS I really think C# is going to be it. It's already managed to become a viable mainstream game development platform, something Java has never really managed to do (unless you could browser games or mobile phone games), and it'd be a good idea to become familiar with it now instead of playing catch-up later. IMO.

re: Macros, globals etc. They are of course massively useful 'if used right', but certainly for a beginner with no formal tuition from someone telling them to avoid them they are tempting to the point that you're almost guaranteed to fall into the habit of using them excessively. They're very easy to abuse and I personally don't miss them now I've moved to C#. it provides so much more powerful language features that compensate for this ten-fold, and as they're all tightly bound within OOP principals they are pretty hard to abuse in the same way.

lemmy101

#37
Quote from: Paper Carnival on Sun 26/04/2009 04:30:15
I don't see how pure object orientation is better than a multi-paradigm language like C++. I like object orientation, but sometimes a linear solution is better or less expensive. Correct me if I'm wrong, but I believe that it's much easier to fall into the trap of writing unnecessarily resource-hogging software in OOP. I'd think that learning C++ you understand more how things are done in the background and you're able to tell which method will run faster.

Don't forget we've been through this same situation three times now.

Assembly programmer: Boo! C is too slow. You're not in control of what's going on under the bonnet and it lets you do stuff that's a resource hog! Assembly is FAST!
C programmer: But Assembly is so fiddly to do anything in! With C you can make really easy to read code, and can accomplish better things faster because you can tackle programming problems at a higher level with more powerful language features! This makes the slower code execution worthwhile.

A few years later....

C programmer: Boo! C++ is too slow. You're not in control of what's going on under the bonnet and it lets you do stuff that's a resource hog! C is FAST!
C++ programmer: But C is so fiddly to do anything in! With C++ you can make really easy to read code, and can accomplish better things faster because you can tackle programming problems at a higher level with more powerful language features! This makes the slower code execution worthwhile.

A few years later...

C++ programmer: Boo! C# is too slow. You're not in control of what's going on under the bonnet and it lets you do stuff that's a resource hog! C++ is FAST!
C# programmer: But C++ is so fiddly to do anything in! With C# you can make really easy to read code, and can accomplish better things faster because you can tackle programming problems at a higher level with more powerful language features! This makes the slower code execution worthwhile.

"All this has happened before, and it will happen again"

;)

bicilotti

Quote from: lemmy101 on Sun 26/04/2009 18:45:31
There can be no argument that OOP is a better way to code than procedural and at some point in the future OOP (or some evolution of it) will be all there is.

Calm down lemmy! :)
I understand you found great pleasure programming with C#/XNA (more games: everyone wins -> horray!) but, with all due respect, the one above looks like the statement of a zealot.

Back to the poor OP: what are you trying to code, wonkyth? I'm curious :D

lemmy101

#39
Busted. :D I am a bit of a code language fascist, I grant you. I am right though. :p See my follow-up post for evidence.

SMF spam blocked by CleanTalk