Register to reply

I am having a hard time learning to program...What to do?

by thewhills
Tags: learning, programwhat, time
Share this thread:
thewhills
#1
Sep23-08, 01:41 AM
P: 96
I bought a book on C++ that was recommend by a friend and a cheap book on C and I just can't get into it.

It start off ok, but then the throw 50 lines of code at you for even a basic program and I get lost...

I don't know what any of it means and I feel like bashing my head in.

Any suggestions?
Phys.Org News Partner Science news on Phys.org
Experts defend operational earthquake forecasting, counter critiques
EU urged to convert TV frequencies to mobile broadband
Sierra Nevada freshwater runoff could drop 26 percent by 2100
mal4mac
#2
Sep23-08, 03:09 AM
P: 1,145
Get an easier book, and an easier, more fun language:

http://www.amazon.com/Squeak-Program...2157349&sr=1-3
mgb_phys
#3
Sep23-08, 08:53 AM
Sci Advisor
HW Helper
P: 8,953
C++ is a very involved complex language to learn programming with.

Either start with one specifically designed to teach beginning programming like mal4mac suggested.

Or you can learn a general programming langauge but pick a more modern easier one, I would recommend python. Python isn't just easy to learn, it is widely used for real programming.
There is a beginners book and examples free at http://diveintopython.org or if you might like http://openbookproject.net/thinkCSpy/index.xhtml it's also free but aimed at more advanced students.

Rememebr there is more to programming than knowing a particular language. Programming is about describing the problem to a computer, once you know the techniques for doing this most langauges are pretty similair.

OrbitalPower
#4
Sep23-08, 09:26 AM
P: 88
I am having a hard time learning to program...What to do?

I recommend C++ Primer Plus by Prata. It's an easy book to learn from, and wordy.

The fact is many CS programs start you off with either java or c++, so you might as well learn the syntax. You can learn about variables, pointers, control structures, arrays, array lists, and recursions, starting off with C++. Plus you'll learn how the computer manages the data, a very important part of CS, or "Datatology" as some call it.

The hardest part in the beginning CS courses is coming up with your own algoritms for projects, mapping them out, writing the pseudocode is often the most difficult part. Once that is done you should be able to convert it to the language.

As you go along, do some exercises in the book and try and make a few programs that are a little bit harder than what you're used to. That's a good way to move forward.
davee123
#5
Sep23-08, 09:53 AM
P: 657
Quote Quote by thewhills View Post
I bought a book on C++ that was recommend by a friend and a cheap book on C and I just can't get into it.

It start off ok, but then the throw 50 lines of code at you for even a basic program and I get lost...
C and C++ are where you want to start if you're looking to get into serious programming. They're low level enough so that you have to deal with memory management, various data types, and other nitty things. It gives you a very good understanding of how computers work under the covers, but makes you jump through a lot of hoops to do what you might think are simple tasks.

By contrast, things like Perl and Python are very powerful languages. You can do the same tasks with single built-in function calls, rather than writing tons of very detailed instructions. The other benefit to Perl and Python specifically is that they're not compiled. On a personal note, compiling was the thing that drove me away from C (and I guess Java too). So you write it, you run it. Skips the whole compiling phase. Plus, you can do funky things like running new code on the fly with "eval".

For example, if you're programming with an array in C, you have to tell the compiler how big that array is going to be in advance. Oh, and you have to tell it how big each slot in the array is, as well, and what data type is going to be stored there (one and the same, usually). So if you're not sure if you're going to need 10 slots or 5000 slots, you're going to have to either declare the full max right up front, or dynamically allocate new memory on-the-fly as your array grows. In Perl? You don't need to do any of that. Perl's smart enough to handle it for you. Python, too, I assume. Technically, you don't even need to declare the variable (although you should!)-- you just start using it and it's there for you.

The sacrifice is processing speed. If you try and do any intense data processing, like, say, ray-tracing a 3D image or extrapolating out a mathematical formula to billions of iterations, it'll be much faster in C, C++. But 9 times out of 10, you don't care about that for hobby-style programming. Having your programs be easy to build and easy to edit is far more desirable.

Myself, I'm a Perl guy. But Perl may be losing its edge to Python, given that I see more about Python these days than Perl. Maybe because Perl 6 is such a change from Perl 5-- maybe because Perl 6 took so long to release, I dunno. Anyway, I guess I'd have to recommend Python. But Perl's still cool too :)

DaveE
OrbitalPower
#6
Sep23-08, 10:15 AM
P: 88
davee123 makes some really good points. Obviously, it's hard to use arrays especially for basic stuff. I made a bowling score program (all it does is count the score) in C++, completely procedural, and I probably could have done it easier in Python. Plus, I had a roll count that associates a current roll with each frame so I could add in the next two rolls, and I had to use the maximum number of rolls possible for my array. In python, I probably could have made memory management a bit easier.

With variables as well it is easier. For example, I can write x = 100 and it'll probably be an int or x = 100.12 and it will be of a floating-point type. Plus python has built in abilities to handle large numbers. So yes, it is easier.
davee123
#7
Sep23-08, 10:36 AM
P: 657
Quote Quote by OrbitalPower View Post
With variables as well it is easier. For example, I can write x = 100 and it'll probably be an int or x = 100.12 and it will be of a floating-point type. Plus python has built in abilities to handle large numbers. So yes, it is easier.
Oh yes-- excellent example. I forget how C/C++ handles it, but if you want to multiply 1000 * 5.25, and assign the value to an integer, it may give you the answer of 5000 rather than 5250, since the floating point "5.25" may get converted to an integer before doing the calculation. I forget all the details, but I remember having issues with things like that. Similarly, a normal "int" is what, 4 bytes? So if you multiply 1,000,000 x 6580 in C, you'll get some wacky answer, because the maximum size of a normal integer is 2^31 (that 1st bit is for the sign).

So in C/C++, you've got to worry about all those things. In your head, doing math is easy-- a number's just a number, and that's more-or-less how Perl and Python handle things. But in C/C++, an integer is different from a short is different from a double is different than a float, etc. So you're bound to run into problems sooner or later, where how you thought about it in your mind turned out to be vastly different than how the compiler interpreted your code.

DaveE
thewhills
#8
Sep23-08, 07:56 PM
P: 96
The real reason I was looking into C an C++ is because I need something versatile and it seems like anything can be done in C++
mgb_phys
#9
Sep23-08, 08:31 PM
Sci Advisor
HW Helper
P: 8,953
C/C++ can also be used everywhere, from 50c washing machine controllers to supercomputers.
But with available libraries Python, Java and C# can also do almost everything (except write an operating system!) but they are more limited in where.
Python and Java will run on almost anything, C# is largely windows only (there is an unofficial Linux clone)
rcgldr
#10
Sep24-08, 12:48 AM
HW Helper
P: 7,133
It's not so much the language, but the complexity of the first programs you try to write. Here it's the training book that makes the difference. Perhaps an online class via some junior college might be good, but that also can vary between classes.

For some, it would help to understand how a computer works. Being able to step through the instructions one at a time while looking at the register and memory content would be useful. A typical debugger comes close to being able to do this, but a learning tool would be better.
zyh
#11
Sep26-08, 06:14 AM
P: 135
Quote Quote by Jeff Reid View Post
It's not so much the language, but the complexity of the first programs you try to write. Here it's the training book that makes the difference. Perhaps an online class via some junior college might be good, but that also can vary between classes.

For some, it would help to understand how a computer works. Being able to step through the instructions one at a time while looking at the register and memory content would be useful. A typical debugger comes close to being able to do this, but a learning tool would be better.
I do agree with you. C and C++ language is a power tool. If you have ever leant about the computer structure and assemble language, you will understand that C/C++ useful.

I suggest that you can view some video tutorials on the net, such as youtube, or MIT open cource. I'm not sure where the 50 lines code come from, but I can recall my first c code was "print("hello word");"
Defennder
#12
Sep29-08, 10:18 AM
HW Helper
P: 2,616
That's some very informative advice there, davee123
pantaz
#13
Sep29-08, 07:22 PM
P: 589
Using C++ to learn programming is a bit like learning to drive with a Formula 1 car!
granpa
#14
Sep29-08, 07:32 PM
P: 2,258
javascript?
CaptainQuasar
#15
Sep29-08, 07:39 PM
P: 705
A few people have suggested starting off with a simpler language, which I agree with. I really liked learning all of my basic programming concepts in Logo. Whoa, that was a long time ago.

granpa's suggestion of javascript seems like a good idea too.
mabs239
#16
Nov11-08, 02:49 AM
P: 86
Every body has given good advice, but I am surprised to see no one mentioned "BASIC" language. It can be learned in a single day. Most of the things that davee123 has written for python and perl, do apply to basic. I'd recommend QBASIC for anybody who is starting with programming.

I'll enlist some of the features of the QBASIC here:

+Ve's
=====
You donot need to compile
No need to define variable size, or simply you could skip defining variables
While you are programming, code examples can quickly be consulted using build in help
Easy serch to looup library functions
QBASIC programs can be executed in MS-EXCEL as macros with no or little modification. (Which is very easy as you donot need to install anything)
Good online help is available like
http://www.petesqbsite.com/
http://www.qbcafe.net/qbc/english/mi...-qbasic-1.html

Code can easily be converted to executeable file (.exe)
Run time enviornment requieres no installation/path-setting what so ever.

-Ve's
=====
Slower in speed (Tolerable for hobbey and learning programs)
Not objest oriented.
Working enviornment is dos like.

QBASIC version 4.5 is best and can be googled to download.
grelf
#17
Jun27-11, 02:21 PM
P: 10
Basic used to be the thing but the language that's now available to everyone is JavaScript. It works in any browser and every machine (even a phone) has a browser!
For a beginners course see http://www.grelf.net/jscourse
kevinfrankly
#18
Jun30-11, 08:45 AM
P: 17
it always hard on the first time, start from the easy one . honestly i'm start from batch (.bat) hehe , go to python => Java => and now on C++. Actually i'm just learn python for getting the basic understanding about programming .. , once you get that basic you'll get the fun of programming language


Register to reply

Related Discussions
Having a hard time with visual of FBD Introductory Physics Homework 13
How to calculate program execution time? Programming & Computer Science 4
Learning Which Program to Appeal to Recruiters Academic Guidance 0
C program display time Engineering, Comp Sci, & Technology Homework 3
Having a hard time with Lx Introductory Physics Homework 3