secretreeve
Posts: 330
Joined: Mon Feb 20, 2012 8:39 am

where to start? (learning C, C++)

Mon Jun 25, 2012 3:38 pm

so im waiting for delviery of my Pi (some time within the next 10 weeks :( )

and although im going to be using it primarily for a media center i would also like to learn programming.

the problem is that i am 25 years old and more mechanicaly/hardware minded than program minded.

This is resulting in not knowing where to start, so if someone can point me in the direction of some beginner tutorials and literature that would be really helpful!

i will probably want to start with C or C++ as i've heard its the best to begin with rather than pythons "get it done fast but not properly" style language. also because python has "limitations" i heard and will probably get through the basic C stuff quite easily once i get my head around it.

i dont really have any ideas what i'd like to program. I mean i wouldnt mind doing something to do with animations but doubt animations are programming lol.

i suppose i should probably just learn to start off with the basics and then figure out what direction to take it in?

i quite like messing around with leds and small 2v motors (you know, the kind in cheap R/C cars)

and if programming can be incorporated, i do really enjoy building RC boats and cars. event tried building a RC helicopter with a nitro engine once. although that was so unstable it took a nose dive and blew up lol.

anyway, your time, help and any links to where to start and tutorials is highly appreciated! so i thank you in advance.

secretreeve
Posts: 330
Joined: Mon Feb 20, 2012 8:39 am

Re: where to start?

Mon Jun 25, 2012 3:42 pm

oh, i should also mention, im rather handy with a soldering iron and electronics!

one thing i WOULD like to work towards is building a macro pad. something like a 4x4 grid of buttons which you can program commands too via a UI for windows using USB port.

but if this was my starting point (making the UI and program for programming the thing, i would need to be able to emulate the hardware as i dont have the hardware made because all i know so far is i would need some perf board and 16 SPST momentary buttons lol so no idea on usb controller or IC or other parts for this)

secretreeve
Posts: 330
Joined: Mon Feb 20, 2012 8:39 am

Re: where to start?

Mon Jun 25, 2012 4:16 pm

oh and yes, im 100% new to programming. so as before, any "where to start" tutorials will be helpful!

secretreeve
Posts: 330
Joined: Mon Feb 20, 2012 8:39 am

Re: where to start?

Mon Jun 25, 2012 8:00 pm

anyone have some links to some C/C+ tutorials or reading material?


secretreeve
Posts: 330
Joined: Mon Feb 20, 2012 8:39 am

Re: where to start?

Mon Jun 25, 2012 8:45 pm

didnt flash up as a link. who ever designed these forums did a rather poor job at a fair few parts of it.

anyway, thanks for the link but its pretty complicated and goes over my head.

anything a tad easier? lol

that is to say C+ seems really badly complicated to start learning on.

theres almost 0 "guides" on where to start around here for someone with NO programming experience so some recomendations are helpful on where to start if you have no real direction where to go yet. i would like some advice on how to go about starting the above project, even if its just the UI design for now.

PaulCheffus
Posts: 381
Joined: Tue May 29, 2012 2:51 pm
Location: Lincolnshire UK

Re: where to start?

Mon Jun 25, 2012 8:58 pm

secretreeve wrote:
didnt flash up as a link. who ever designed these forums did a rather poor job at a fair few parts of it.

anyway, thanks for the link but its pretty complicated and goes over my head.

anything a tad easier? lol
Hi

Not sure what you are after as the second link looked reasonable to me.

Cheers

Paul
Procrastination - The Thief of Time.

secretreeve
Posts: 330
Joined: Mon Feb 20, 2012 8:39 am

Re: where to start?

Mon Jun 25, 2012 9:08 pm

its still overly complicated for beginners.

so if anyone has suggestions for a programming option on the Pi that'll allow me to generate a user interface and make a macro program for a usb macro pad (yet to be built mind) or just some simple (and i mean simple) beginners tutorials, not just reading as i've never learnt overly well by reading and writing, i do learn best by doing, that'd be great.

may move away from C+ as it seems to be overly complicated for me understand starting out with.

definatly a more simple/easier program to start with lol

and paulcheffus, if you read my posts you'll find more information that you seem to have realised.

Vassius
Posts: 25
Joined: Sun Jun 03, 2012 7:56 pm

Re: where to start?

Mon Jun 25, 2012 9:57 pm

secretreeve wrote:... not just reading as i've never learnt overly well by reading and writing, i do learn best by doing, that'd be great.
Sorry, but to be able to do anything more than simple copy-paste of tutorial code, you need to do some serious reading to understand the fundamentals of how a specific language works. Especially with C and C++, though Python is a bit more forgiving.

I also prefer learning by doing, so I can see your point. But I can testify that it's not until I took a step back and got my senses together to do some actual theory reading that I felt I actually learned anything of value regarding programming.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12595
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: where to start?

Mon Jun 25, 2012 10:06 pm

If you want to learn C, there is just one book I can recommend, the original "C bible" from kernigan and ritchie, "The C Programming Language".
see: http://en.wikipedia.org/wiki/The_C_Programming_Language

For C++ the equivalent would be "The C++ Programming Language" by Bjarne Stroustrup.
See: "http://en.wikipedia.org/wiki/The_C%2B%2 ... g_Language"

however C++ is much more split into many "dialects", so the latter book is less a "bible", more a book about the core concepts. Many "Visual" versions each can behave a little different, so in that case I would recommend learning "C++Builder" (originally from Borland).
See: http://www.embarcadero.com/products/cbuilder
But obviously if you want to go the FOSS route, you need to use a GCC compiler version.

P.S. I'm a hardware engineer myself, so I can appreciate where you are coming from.

secretreeve
Posts: 330
Joined: Mon Feb 20, 2012 8:39 am

Re: where to start? (learning C, C++)

Mon Jun 25, 2012 10:20 pm

thanks. i looked at the python wiki page, some helpful information on the python language. still pretty complicated but a bit more agreeable with me.

i suppose it doesnt help that i spent most of today diagnosing a wierd motherboard problem so then looking into programming between that.....like smelling mint then lavender, then mind, then lavender, eventually it all becomes over whelming.

on a side note, does python come with any of the distro's or is it a seperate download? if its seperate, whats the best route to get it?

im currently emulating the Pi (a bit slow but seems to work) so i guess i could make a start learning until it arrives lol

oh and mahjong, the project i have in mind might interest you. i will the full idea over on the projects sub forum about it as with your engineering experience im sure you and many others will be able to contribute to the electronic side of it alot.

yeahbox
Posts: 36
Joined: Sun May 27, 2012 10:35 pm
Location: Manchester, UK

Re: where to start? (learning C, C++)

Mon Jun 25, 2012 11:39 pm

I never miss an opportunity to recommend Python because is is a very nice language and I get payed every day writing Python code. If you are a HW engineer then maybe C would feel more natural because you are closer to the hardware, if you for example want to set some bits in a register somewhere. But if you want to write a simple GUI or some more high level programs then Python is a good choice. You could do all your bit twiddeling in Python also, you just have to be more careful.
secretreeve wrote:i will probably want to start with C or C++ as i've heard its the best to begin with rather than pythons "get it done fast but not properly" style language. also because python has "limitations" i heard and will probably get through the basic C stuff quite easily once i get my head around it.
If you by "properly" mean production ready code that you can sell and earn money on, then Yes. Else No. You can most certainly do it properly in python also, and I think that you will not reach the limits of the language for some time. I think that is true for many beginners, trying to find the "best" language to learn since you want to learn quickly and only have time to spend on one language. I would rather recommend to pick any language, learn the basics, see if it resonates with your feelings and then dig deeper into it. If it doesn't trigger your needs to learn more, pick another language. Once you know the basics of programming all languages are the same but different (!), since programming is many times about structures and algorithms and methods of thinking. The choice of language is merely how your palette of colours look like.
secretreeve wrote:on a side note, does python come with any of the distro's or is it a seperate download? if its seperate, whats the best route to get it?
Yepp, python is pretty much standard on linux distros. If you use the debian flavours then it is already installed. Have a look at this post http://www.raspberrypi.org/phpBB3/viewt ... =31&t=7102 you might like the examples :)

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: where to start? (learning C, C++)

Tue Jun 26, 2012 7:00 am

secretreeve wrote:i will probably want to start with C or C++ as i've heard its the best to begin with rather than pythons "get it done fast but not properly" style language. also because python has "limitations" i heard and will probably get through the basic C stuff quite easily once i get my head around it.
C is an OK language to begin with. C++ is not.

Python is actually far more expressive than either C or C++ (although, turing-equivalence being what it is, you can do the same thing with any of them - usually by badly reinventing half of common lisp - see greenspun) and a far better language to start with than either. Ruby's pretty good, too.

Really. Start with Python or Ruby. Do not start with C++.

jmacey
Posts: 135
Joined: Thu May 31, 2012 1:05 pm

Re: where to start? (learning C, C++)

Tue Jun 26, 2012 7:03 am

I recommend these books to my students learning C++ http://www.mindview.net/Books/TICPP/Thi ... PP2e.html/

Sutty
Posts: 12
Joined: Tue May 29, 2012 10:20 am

Re: where to start? (learning C, C++)

Tue Jun 26, 2012 10:31 pm

Its a very long time since I did any programming, so I decided to get a Pi and start more or less from scratch. I assumed others would be in the same position so I've documented everything I've done in lots of detail. I started using Python on windows and converted code across when the Pi arrived. The aim was to try many different areas rather than concentrate on one. I also wanted to get away from bits of unrelated code found in books. I've attached the code. I found Python better than other languages as it incorporates a database, SQLite, and also manages the GPIO interface to attached LEDs and things. The simple test programs include: A text based maze style game, Text Analysis of Macbeth, A graphics program showing moving atoms, a database program, reading external Web pages, using Classes, a circuit test program that tests a electric circuit and lights up LEDs accordingly. I've also reformatted the SD card, got WiFi working and attached the HDMI to an old computer display. All the details are attached. I plan to incorporate all the elements mentioned above into a program that demonstrates how electronics and computing can be combined. Hope this helps!!

I've not managed to upload the file so have stored it on Google docs here's the link:
https://docs.google.com/open?id=0B_amt9 ... V81Y0dNWUk

broken_face
Posts: 1
Joined: Wed Jun 27, 2012 1:06 am

Re: where to start? (learning C, C++)

Wed Jun 27, 2012 1:08 am

I suggest http://thenewboston.org this helped me more than any intro class in school.

secretreeve
Posts: 330
Joined: Mon Feb 20, 2012 8:39 am

Re: where to start? (learning C, C++)

Wed Jun 27, 2012 8:00 am

this stuff looks invalueble!

thanks for the post and the code, i can get a look at some and see whats what

nadir
Posts: 112
Joined: Sun Jun 10, 2012 5:45 am

Re: where to start? (learning C, C++)

Thu Jun 28, 2012 3:36 am

In case you are still looking for C tutorials:
http://www.eskimo.com/~scs/cclass/notes/top.html
by Steve Summit
and:
http://crasseux.com/books/ctutorial/
Else i use "The C Programming language", by Kernighan and Ritchie, already mentioned above (which i consider to be rather tough, but i am a beginner. Otoh it is written very clear).

User avatar
cheery
Posts: 219
Joined: Wed Jan 25, 2012 9:39 pm

Re: where to start? (learning C, C++)

Thu Jun 28, 2012 4:18 am

I can see how this is going to grow into TL;DR. The poster started it. Every line you type makes it more tiresome to read you know? Not that I'd be any better in most situations either, but you're asking a very common common question. At least you could've done it right!

You can "get it done fast but not properly" in any language. In fact, that's how you should measure the language's quality. How fast is it to do something, although it wouldn't be quite right? Doing great software means you have to try out things and explore. And any programming language should support this.

Anyway here's something you could try in your raspberry pi, or any other linux machine. Write the first snippet into a hello.c and use the second snippet to compile 'hello' -executable:

Code: Select all

#include <stdio.h>

int main() {
    printf("Hello\n");
    return 0;
}

Code: Select all

gcc hello.c -o hello
You could go infinite ways from here. The internet is full of examples and tutorials on C. I'd propose: try learn something new about the language every day, then apply it in a toy program of one kind or another. Move through the features of the language one by one. Once you've learnt one language it's easy to learn another, so keep learning them every once in a while when you get curious.

If you're going to do any serious programming it'd be good to have some theory behind it all. So I'd propose picking up SICP (Structure and Interpretation of Computer Programs), then maybe read something from Donald E. Knuth. Computing -related wikipedia articles could also help you along.

secretreeve
Posts: 330
Joined: Mon Feb 20, 2012 8:39 am

Re: where to start? (learning C, C++)

Thu Jun 28, 2012 11:30 am

thanks guys, got lots to be reading now.

the annoying thing is, i had a college book for learning C kicking around but seems to have got lost in the move. typical. never need it (it was my partners) then when ya do, you cant find it.

Return to “General programming discussion”