New to programming

SuperFungus

Member
Aug 23, 2006
141
0
0
Hi, I'm interested in getting started in programming. I have a little bit of experience from programming the basic stamp II for a couple robotics projects and i took a semester of visual basic in high school (only language they offered). I tried C++ using the DEV-C++ IDE but it's a little intimidating for me yet i feel. I can get simple things to work easily enough i guess but being as inexperienced as i am the barrier to entry for doing cool stuff is a little steep for me to stick with it I'm finding. I thought maybe I'd do Microsoft visual C# express edition because Microsoft seems to have tons of support and well written tutorials on their coding 4 fun site and because I'm familiar with visual basic. I'm am looking for more experienced programmers thoughts on this route. Will what i learn in visual C# be useless to me if i want to move on to something else? I'm not sure how standard it is. Any input would be appreciated, thanks.
 

Aikouka

Lifer
Nov 27, 2001
30,383
912
126
The ability to understand a problem is universal and is only harbored by the understanding of a language. Programming in any language can help refine your ability to understand problems and proper methodology to solve them. C# sounds like a fine route to go to me, although I went from VB to C++ without a problem. It sounds like you may've been jumping into the deep end a little too soon with it though ( some advanced tutorials perhaps? ) Put the floaties back on and head to the shallower end with some easier tutorials. The syntax is fairly different and may throw you off at first. You'll find yourself moving out into the deep end quite quickly. But if you can't find good tutorials, don't be afraid to use whatever language (in your story, C#) can provide them that interests you.
 

SuperFungus

Member
Aug 23, 2006
141
0
0
Good thoughts, you're probably right about me expecting too much too soon. I think one of my biggest problems with Dev-C++ is that everything i can make runs from the command prompt. In hindsight i think i liked using the controls from Visual Basic, it meant i got to make a cool and useable program. Call me shallow, but answering Y/N questions and typing in numbers/strings and watching the program do some math/print a message just isn't as engaging as making something with a bonified gui. I actually just noticed that microsoft also makes a visual C++ so i'll be downloading that and giving it a shot as well. Does anyone have any thoughts on this IDE? My only real concern is that perhaps these visual studio IDE's are non-standard and that i'll be screwed if i try to move on to something else. Anyways, thanks for your input Aikouka.

Oh and i really appreciate that "without a problem" bit. :p
 

Descartes

Lifer
Oct 10, 1999
13,968
2
0
In programming languages, there are two main families: C-derived and BASIC-derived. I say main families, because these are the most widely used languages. There are of course dozens of other languages, many of which are fantastic and useful, but won't help you if your main concern is knowledge transfer.

C-derived:
C (this is the syntactical basis for most of the languages)
C++
Java
C#

BASIC-derived:
QBasic/PowerBasic/etc.
PowerBuilder (to some degree)
Visual Basic
Visual Basic .NET

So, learning anything in any of the two families will have some degree of knowledge transfer. I probably left out a few languages as well. Unfortunately, learning the language is a lot more than just syntax. If you have prior experience in a C language, you should be functional in Java, C#, etc. in a matter of a few hours. The problem is that you won't be able to do much. It's learning the libraries, idioms of the platform, etc. that take the time.

Having said all that, my recommendation is going to go in a direction opposite of what you said you wanted. Forget the language. As I said above, there is very little knowledge transfer beyond syntax; instead, focus on the abstractions upon which these languages are built. For Java, C++, C#, etc. this means OO. I don't mean just learn how to use OO; rather, I mean learn how to think in OO. It really is a different way of thinking, and if you're not thinking in those terms now then you'll be duplicating a lot of efforts across all languages.

In my career as a developer (10 years now) I've worked in x86 assembly, C, C++, VB, Java, C#, VB.NET, Eiffel, Perl, Python, COBOL and a handful of other languages I want to forget. Nothing has helped me more than my intuitiveness with OO. I would even suggest that this is as much as 75% of solving the problem. Once you learn how to organize your thoughts and derive a solution the actual code is almost immaterial.

What I'm saying probably isn't making sense to you at this point. You're probably thinking, "Oh sure, I'll learn OO." You'll know what I mean when you get there. I would recommend a few books to start with:

Fundamentals of Object-Oriented Design by Jones - This covers UML, but his treatment of basic OO is very solid. I'd probably start here.
Object Thinking - This is the best modern treatise on the topic that I've read
Design Patterns - This is the classic "Gang of Four" text; still worth a read.

That's it for now. Object Thinking will either make complete sense or very little at all. If it makes no sense, then you're still thinking procedurally and learning any OO language isn't going to be all that beneficial. Of course, many developers know how to use an OO language, but they can't do so effectively.

As to your question of IDE: Don't worry about VS.NET. It's an outstanding IDE and you'll be rewarded for learning it. There are some open-source options as well, including SharpDevelop. Finally, you could just as easily download the .NET Framework and just use any text editor; you can compile via the command-line and do everything you could do with the IDE. The only difference is that it'll take longer and you have to learn more; I actually consider this a good thing initially.

Everything I said above also applies to Java. Both C# and Java are widely supported C-derived languages in the industry. You'll do well learning either one, but I would still focus on OO.

Let me know if you have any questions.

 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
Some good points in here by Aikouka and Descartes. To Descartes' list I would add "Pascal-derived" if only to get Delphi onto the list. :)

Aikouka's fundamental point is very important: the concepts involved in creating programs, i.e. an understanding of stepwise execution, flow of control, modularization into subroutines, layout of memory and the idea of type, and most importantly the concept of an algorithm as a set of steps for transforming data, are universal. Languages present barriers because you have to learn to translate those concepts into a different syntax. Gaining exposure to more than one can only help. Over the years I have written substantial programs in BASIC, Pascal, 8086 assembler, Delphi, C, C++, C#, and javascript, to the point where I almost think in terms of my own abstract mental syntax when envisioning an algorithm.

To answer your more specific question: C# is a Windows development standard. If Windows is your target platform you can't go far wrong with it. If you aspire to cross platform development the only real practical choice at this time is Java, imo. Java and C# are rather similar. Furthermore, if you're going to be doing Windows development in C# you will be learning not only the language, but the class framework that provides access to the system, just as earlier programmers had to learn C/C++ and the Win32 API in order to get anything substantial done.

My advice: it's so much easier today than ever before, because all answers are at your fingertips. Pick whatever language engages you, then start writing little programs and graduate up to more complicated stuff. Have an idea about something you'd like to do, then sit down and try to make the machine and system do it. Follow tutorials where they interest you, and strike out on your own where the tutorials leave off.

In other words, just program, and the rest will come :).
 

SuperFungus

Member
Aug 23, 2006
141
0
0
Ok, so i guess what i'm hearing is that C# is as good a move as any. It'll allow me to ease into the C style syntax and OO mindset without worrying about pointers and such. As far as my target platform goes, thats a good question. I got into programming for the BSII (way back in like 6th or 7th grade, i believe the exact version is called Pbasic?) and i want to learn C so eventually i can maybe get into C based pic compilers/microprocessors for projects and such, or at the very least understand other's projects better to begin with. I don't have a problem with everything i develop being stuck in PC's with .NET as long as what i learn working under .NET isn't going to spoil me for the cooler stuff later.

I was going through some of the msdn site's library and hit an article where the guy described the difference between thinking about a problem "procedurally" vs. "Object Oriented...uh..ly". Can't remember the exact terms he used i guess :p but it did seem to make some sense; languages like basic make you think of the problem in terms of the steps towards solving the problem while OO make you think of the problem in terms of what the basic components that need to be completed in order to solve the problem. Am i understanding this distinction correctly? Please feel free to set me strait, i want to 'get' this. I also read the introductory chapter of "thinking in C++" by Bruce Eckel, but that was more geared to existing developers so i didn't a whole bunch out of that.

Also i just tried a "hello world" program in C# and i have trouble when i try to get the program to loop. I want to start main over again, but i can't call main. Do i hit these difficulties because i'm still approaching this with the wrong mindset? How would an OO thinker approach this?

Anyways, thanks for all your input everyone I really do appreciate your help.
 

irishScott

Lifer
Oct 10, 2006
21,562
3
0
Originally posted by: SuperFungus
Ok, so i guess what i'm hearing is that C# is as good a move as any. It'll allow me to ease into the C style syntax and OO mindset without worrying about pointers and such. As far as my target platform goes, thats a good question. I got into programming for the BSII (way back in like 6th or 7th grade, i believe the exact version is called Pbasic?) and i want to learn C so eventually i can maybe get into C based pic compilers/microprocessors for projects and such, or at the very least understand other's projects better to begin with. I don't have a problem with everything i develop being stuck in PC's with .NET as long as what i learn working under .NET isn't going to spoil me for the cooler stuff later.

I was going through some of the msdn site's library and hit an article where the guy described the difference between thinking about a problem "procedurally" vs. "Object Oriented...uh..ly". Can't remember the exact terms he used i guess :p but it did seem to make some sense; languages like basic make you think of the problem in terms of the steps towards solving the problem while OO make you think of the problem in terms of what the basic components that need to be completed in order to solve the problem. Am i understanding this distinction correctly? Please feel free to set me strait, i want to 'get' this. I also read the introductory chapter of "thinking in C++" by Bruce Eckel, but that was more geared to existing developers so i didn't a whole bunch out of that.

Also i just tried a "hello world" program in C# and i have trouble when i try to get the program to loop. I want to start main over again, but i can't call main. Do i hit these difficulties because i'm still approaching this with the wrong mindset? How would an OO thinker approach this?

Anyways, thanks for all your input everyone I really do appreciate your help.

I don't know C#, but OO is all about classes, inheritance, and methods (terms may vary depending on who you ask).

Classes: A class is a collection of blocks of code know as "methods". Each method is defined separately (although they can interact with each other if you wish), and accomplishes whatever the user wants.

Think of a class as a keypad. Each key does something that you define, and there is no set required number of keys.

Ex: (This is in Java so don't copy this verbatim)

public class Dog
{
//Variables and methods go here
}

Lets say there is a "method" called "bark" in the above class. From the main, you first need to "instantiate" (aka create) an "instance" of the class Dog (think of it as waving a wand and summoning a dog into existence)

In Java, this is done via a line of code similar to the following (C# syntax is slightly different IIRC):

Dog dog = new Dog();

Then you can "call" any of "dog's" methods via a command such as

dog.bark();
dog.sit();
dog.run();
etc.

The "." allows you to access code within the "Dog" class.

Deciphering this statement:

"Dog" is the "type" of "object" (as in "Object" Oriented) that we are instantiating. In this case, we are trying to make a Dog come into existence.

"dog" is the name that the class is referred to WITHIN THE MAIN (or wherever else you instantiate it). Think of it as naming a dog: "dog" in Real Life.

"= new" just tells Java that the object we are referring to is "equal to" a "new" object. "We are not referring to an object that already exists, but creating a new one."

"Dog()" is a "method" known as a constructor. It is this statement that "brings the dog into existence." More on these further down.


METHODS:

In short, a "method" is a block of code that does something. This code is "called" from the main after it's containing class is Instantiated. The command used to "call" it is defined when the method is made.

Ex of a method: (This is in Java, so don't copy the code verbatim)

public int add(int a, int b)
{
//Code goes here
}

What everything means:

"public" is a feature that you don't really care about at this stage (although you will soon). Basically, it sets permissions on what can access the method and how it can be accessed ("public" means anything can access it, but there's also "private", "protected" and other parameters which mean different things).

"int" (short for integer) is what the method "returns" (this can be replaced with double, float, char, anything. Even user made types when you learn how to do those)

Ex: If I made a method that added two numbers together, I would want to obtain the result right? This result would be "returned" by the method via a statement known as "return".

Ex" (the code within this method (between { & }) is universal to all C based languages):

public int thisFunctionReturns1()
{
return 1;
}

"1" is of type int. When this method is called, it will "spit out" one.

How this is useful:

Going back the addition method above:
Let's say I made a "int" variable in the main called "result". I would then call the addition method to add the two numbers together, and set "result" equal to whatever the method "returned". If a method doesn't return anything, the "return type" of the method would be "void", and while this is sometimes useful, any given method is more likely to return something then not.

Continuing from before:

"add(int a, int b)" is the good stuff. This is the actual command that gets the code working. The stuff within the parenthesis is known as "parameters". These parameters are user defined and can be practically anything (you can have as many parameters as you want when you define a method). They can also be used within the method.

An example of the addition method would be (once again, in Java)

public int add(int a, int b)
{
return (a + b);
}

If there are multiple parameters, they must be separated by a comma. Each parameter type must also be specified (as we are add integers, each parameter is of type "int")

Now let's say that the method "add" is inside a class "Calculator"

In Java, the main method would look something like this:

public static void main(String[] args) //Java's way of declaring the main
{
Calculator calc = new Calculator(); //Instantiate a new "Calculator" object named "calc"
int result = 0; //Declares a new integer Variable "result" that is initially set to zero.
result = calc.add(1, 1); //Set's result equal to the addition of 1 and 1 (2)
}

Hope this helped. Sorry if it seems rushed toward the end, but I've got a Chem lecture in 5 min. Feel free to ask any questions.
 

hasu

Senior member
Apr 5, 2001
993
10
81
Originally posted by: Markbnj
Some good points in here by Aikouka and Descartes. To Descartes' list I would add "Pascal-derived" if only to get Delphi onto the list. :)

Glad that someone mentioned Delphi!

If any one is wondering what kind of animal it is -- Delphi is the only real RAD (Rapid Application Development) tool. Try Turbo Delphi for Win32 to believe it. Since Delphi is inherently component based, naturally you will tend to think in terms of Objects.

Programming (especially non-system Applications) is not too tied to any language. If you know what you want you can implement it in any language. Catch is that you should know what you want.