PDA

View Full Version : I'm new :)


szianci
04-16-2007, 04:17 PM
Hello everyone! I'll try as best I can to make my problem as simple as possible.

p.s: I'm a complete newbie >.<

I'm new here, on the forums I mean. I've read most of the photoshop and started on the flash guides on this site, but recently I've developed an interest in programming as well.

I wanted to start with programming a long time ago, and like many others (I think) I didn't know where to start. 'Bout a week ago I just sat down and google'd my way to a simple "teach yourself in C 21 days" html book.

So I started reading it, and I got as far as "compiler" before the trouble began. After a couple of hours of searching and testing I found a working compiler/linker.

I wrote the standard "hello world!" app, and saved it, compiled it and linked it. Then tried to excecute it. My compiler simply made a "DOS app", or how should I put it... I think you understand. So the app instantly closed before I could read what it said.

Tried the same thing with an app that calculated the area of a circle, with the user providing the radius of the circle. The application actually worked fine if I excecuted it within my compiler app, but not outside it (e.g excecuting it from total commander or explorer).

Now, here's the problem: I'm right now trying to use Visual C++ as a compiler instead, and trying to figure how to make a application that would work "normally" in Windows XP. That's how I would like to start. Could anyone help me with that?

I've gotten as far as creating a new text file in Visual C++, writing the circle area program, and saving it as a .c and trying to compile it with the command prompt inside Visual C++. That worked about the same as the old compiler... somewhat different.

there we go.. hope that isn't too much for you :S

Does anyone have the time to help me? Any suggestions are welcome.

-szianci

Templarian
04-16-2007, 04:57 PM
Its doing exactly what you told it to do. Once it outputs the code you told it nothing else to do.


#include <iostream>

int main()
{
std::cout << "Hello, world!\n";
}
I was gonna type something up but this explains it:

http://www.we11er.co.uk/programming/basic-cpp.html

If i were you I would go out and buy yourself that Sams Teach yourself C++ its very very well done (all of their books for that matter).

szianci
04-17-2007, 02:08 AM
Ah, I'll look into that book mate.
Thanks for the quick reply

Al6200
04-17-2007, 06:46 AM
This is just my opinion, but I don't think C or C++ is a good choice for a first language. I'd actually recommend by starting with C# or Java, and then to get some scope on things I'd recommend getting a book on how a computer actually works, and you should probably focus most on the processor. Maybe early on you'd want a relatively general book, but later on you'll probably want something along the lines of "x86 architecture" or "Assembly for x86", something like that.

C# and Java have much simpler syntax than C or C++. Maybe some other programmers have opinions on what is a best first language?

Templarian
04-17-2007, 07:35 AM
^Nah, starting with C++ is fine, it teachs the fundamentals of programming and the use of data types, and its syntax is nice to learn. Once he gets over pointers and class it becomes a lot simpler language to work with.

TheColonial
04-17-2007, 07:59 AM
Learn C++ and you'll never have a problem picking up another language again (except maybe ASM).

C++ is a great language to learn first.

szianci
04-17-2007, 12:41 PM
Thanks everyone for your different opinions. Btw, it's Sams book I got already ^^

Think I'll buy a copy just to get it on paper and to support the people behind it.

szianci
04-17-2007, 12:49 PM
edit: double post

λ
04-17-2007, 05:39 PM
I'd say start with C, it'll give you a good insight into hardware fundamentals without you needing to learn object orientation.

It actually has a smaller syntax than C# or Java, C is a very simple language really - if anything, being simple is its main flaw, it's basically platform-neutral assembly language :)

Al6200
04-17-2007, 08:00 PM
it's basically platform-neutral assembly language :)

I don't know about that... In a lot of ways (structs, complex types) its far more abstract than assembly. Saying myArray[k + 2] is quite a bit more abstract than assembly, but I'd suppose *(myArray + 2) is a bit closer to what's really going on. But its true that it is very low level, and is closer to assembly than any other language that I've seen.

TheColonial
04-17-2007, 09:16 PM
I'd say start with C
If you do, make sure you get yourself a mentor. It's hard to learn to write good code in C if you don't have an experienced person helping you. Learning the syntax of a language doesn't mean you know the language. It's very easy to shoot yourself in the foot with C, and half the fight is knowing when you've pulled the trigger!

it'll give you a good insight into hardware fundamentals without you needing to learn object orientation.
Hardware fundamentals? I don't think so. It'll introduce you to the major and common areas of software development, but that goes for any language (except mabye those bizarre esoteric langs). Most mainstream languages will introduce you to the basics, I can't see how C does it any better.

It actually has a smaller syntax than C# or Java, C is a very simple language really
What do you mean by 'smaller syntax'? Do you mean less keywords? I'm not sure what you mean. Not counting a few extra keywords, the syntax is actually very similar to a lot of languages.

It's simple to those people who understand procedural programming. The syntax is very simple, but as I've already said, it's hard to write good C code which is easy to maintain, especially if you're a beginner.

if anything, being simple is its main flaw
Again, I disagree. Keeping things simple is a good thing, and it's not a flaw of the language (IMHO). I won't go into what I think the flaws of C are because I'll be here all day :) (j/k)

it's basically platform-neutral assembly language :)And just to be different, I whole-heartedly disagree. It's nothing like ASM. And just because you write code in POSIX C it doesn't mean that your code is 100% portable, as there are some things that vary from architecture to architecture which C doesn't cater for. This isn't specific to C, it happens with other langs like C++, but I just wanted to point it out :)

Having said all that, I'm not against people learning C as a first language :) I my humble opinion, there are better ones to choose.

Cheers.
OJ

kirupa
04-18-2007, 01:43 AM
My 2 cents on this is just learn any language that you feel most comfortable with. Different people have different preferences, so a language that you like may not be someone else's favorite language, etc. In the end, as long as you know one language really well and know how to think about problems in a way that computers can solve them, you can learn new languages easily.

I agree with AL that something like Java, C#, and I'll throw in Flash's ActionScript also as being good languages to start off with. The reason is because it is extremely easy to download Eclipse, Visual C# Express, or the Flash trial and have a working "hello world" output in a few moments. Some languages require you to jump through some extra hoops before you can get to that spot, and when you are more focused on learning a language, those extra steps can be really discouraging.

To elaborate further, I see the difficulty with programming as not being the language choice, but really, it is about taking a problem and thinking about it in a way that a computer can solve it. Being able to break a large problem into smaller sub-problems and feeding them to your computer is really what most programmers do. That really comes from experience and lots of trial and error.

I haven't used my bad analogies in some time, so if you were to paint a picture, what you envision in your mind is what gets drawn. Let's say you have a choice of colored pencils that you can use for your painting. The quality of your colored pencils certainly affects the quality of your finished product, but in the larger scheme (http://en.wikipedia.org/wiki/Scheme_%28programming_language%29) of things, the highest quality pencils will not allow you to make a better painting if you are unable to transfer what you mentally visualize onto paper and apply the basic principles of design.

To tie this up, your painting is like a computer program and the colored pencils are the various programming languages you can use. There are brilliant programmers out there who use a wide spectrum of languages to create their art, and they are brilliant not because of the language they use, but because they have a unique ability to better think about computer problems than others.

Once you figure out how to think about computer problems and articulate a solution, the rest is just syntax. From there on, you can pick the right language for the right job. No language is good in all cases (or even most cases), so try not to get too caught up in the language wars and use what would be the best language for the task at hand :elderly:

:bounce:

TheColonial
04-18-2007, 02:08 AM
You raise some interesting points here Kirupa :) And I'd like to share a few more thoughts:
Every language (well, perhaps not VB ;)) has its place. Language evanglism is a bad thing. There is no "catch-all" language which is the perfect choice for every possible type of problem/solution. I'm a fan of C++, but I'd never use it to build cgi scripts. I like ruby, but I wouldn't write a game engine in it. I like ASM, but there's no way I would consider writing an enterprise or n-tier system with it. Lots of languages are designed for a specific purpose and generally shouldn't used for other purposes.
Some languages you don't have a choice to use (such as SQL when querying data from a database), so you have to learn them regardless.
Newbies to the world of programming face a tough challenge of learning to write software regardless of the language they use. An important thing to note is that new people to the field need to feel like they're achieving something. The sense of achievement varies from person to person. Eg. Some people like to see something appear on screen as quick as possible. Others like to feel like they've actually learned something instead of just seeing something appear. Some like to have a deep understanding of what happens under the hood, others don't care. These are the kinds of things you need to be aware of when you're choosing your first language. If you want to learn object-orientation, then don't choose C :) If you want to learn what happens under the hood, learn ASM. If you're keen to see things happen quickly, then pick something higher level like C#.
Different languages have a different set of tools and utilities in which you can write programs. If you're new, then learning to write ASM code using VIM is going to be a huge challenge :) However, a neat IDE like Visual C++/C# Express edition gives you an easy environment to learn the ropes in before trying something else. If you're new to software, it's a good idea to try and make your development environment as easy to use as possible and hence reduce possible frustrations and deterrants. Some languages are platform specific, and hence might not be an option for someone depending on the platform they use (ie. Mac/Windows/Linux/etc)

I stick by what I said though :) I think C++ is a great option for first timers. It's "low" enough to give you a understanding of some of the key programming concepts (such as calling conventions, pointers, ) that other languages might not give you, but also "high" enough to allow you to get moving quickly. It's also OO, which to a new programmer might be easier to understand. There are a stack of options for your development environment (regardless of the platform you use), and there are lots of tutorials/whitepapers/resource around to help you.

However, if all you're ever going to do is write a few PHP apps, some HTML and some actionscript, then learning C++ might be a waste of your time. So depending on the area of software you're interested in working in, your language choice may also vary.

Thanks for listening :)
OJ

kirupa
04-18-2007, 02:23 AM
Oh sorry TheColonial, I incorrectly attributed AL's comment as being that of your's. It was AL who mentioned C# or Java. I've corrected my post to reflect that!

TheColonial
04-18-2007, 02:29 AM
No need to apologise :)