C Board  

Go Back   C Board > Platform Specific Boards > Linux Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 03-31-2008, 04:32 PM   #1
Registered User
 
Join Date: Mar 2008
Location: PEI.Canada
Posts: 3
Wink Wanting to begin programming in general and for Linux.

So, I'm new to programming. I'm not sure whether or not I should use C or C++. I used to know some C and found it... 'simpler' than C++.

What is the best of the two?

Anyway, I was thinking C because the Linux kernel is programmed with such.

Also, I am currently running PC Linux OS (very cool, IMO ).

Anyso, whatever advice you have will be much appreciated.

Later. :3
Pipes is offline   Reply With Quote
Old 03-31-2008, 04:45 PM   #2
Senior software engineer
 
brewbuck's Avatar
 
Join Date: Mar 2007
Location: Portland, OR
Posts: 5,768
The problem with simple is that it's simple.

C is simple to understand, but you also have to do practically everything "by hand." C++ is much harder to fully understand, but gives you more powerful tools.
brewbuck is offline   Reply With Quote
Old 04-01-2008, 02:15 AM   #3
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
You'll be needing a LOT of C knowledge before you can tackle the Linux kernel code.

As stated, C is a lower level language, and many of the things that are easy to do in C++ becomes a whole lot harder in C. And to fully understand C++ you obviously should understand and know the basis of C too - as nearly everything you can do in C can be done in C++, which of course means that some people WILL do that.

--
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
matsp is offline   Reply With Quote
Old 04-01-2008, 09:51 AM   #4
and the hat of Jobseeking
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,710
What sort of programming interests you?
Writing user applications or kernel / device driver work?

Have you learnt how to program yet?


The analogy is learning to drive vs. choosing your car.

It's all very well buying a Ferrari, but without knowing how to use it, all you're going to do is wrap it round the nearest tree.
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.

Salem is offline   Reply With Quote
Old 04-02-2008, 08:45 AM   #5
Registered User
 
Join Date: Mar 2008
Location: PEI.Canada
Posts: 3
Wink Well...

I want to do application programming and game programming via OpenGL. I know the basics of C, and very, very little C++. Also, OS programming interests me, but yeah, I do need a lot more knowledge before I can tackle that.

Anyway, what are some good books do you think are worth recommending?

Also, which would be better for my needs, C or C++? I know I've asked it before, but now that you know what I wish to do, perhaps you could help me to decide.

Anysuch, thanks again.
Pipes is offline   Reply With Quote
Old 04-02-2008, 09:36 AM   #6
and the hat of Jobseeking
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,710
http://www.rafb.net/efnet_cpp/books/
Remember to separate learning the language (C++) from the APIs (say OpenGL).

If I were starting today, I think I'd go with C++ first.
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.

Salem is offline   Reply With Quote
Old 04-02-2008, 10:40 PM   #7
Registered User
 
Join Date: Mar 2008
Location: PEI.Canada
Posts: 3
Ok, C++ it be.
Pipes is offline   Reply With Quote
Old 04-03-2008, 05:22 AM   #8
Banned
 
Join Date: Nov 2007
Posts: 678
My first language was Java. Then I started doing C. And to my dismay, it lacked everything.
Then I learned C++. Since they talked about Java being secure, and I was more interested in hacking
(in my school days), and C++ allowed you system level access.

Then came the myth buster:
Java, C++ - Two books - Same number of pages
I was done with Java book in say 2-3 months, was writing GUIs, networking code, applets, games etc.
2-3 months later I was still confused about the basic syntax of C++. Let alone about learning an API to make C++ worth something practical.

But I like your selection, your guts, your enthusiasm. Good luck with C++!
manav is offline   Reply With Quote
Old 04-30-2008, 03:17 AM   #9
Registered User
 
Join Date: Apr 2008
Location: USA
Posts: 22
Arrow

C is an intermediate language which means that it resides somewhere between a true high level language (HLL) and assembly for the sake of this argument. C++ is the encapsulation of C functions into groups within libraries as they would apply to system objects and it is this wrapping of C that makes C++ a true HLL. C++ could compared to acting like a make file with linking instructions for managing the compilation of a C application's system code.

The stepwise top down structure that basically presides over the systematic breakdown of C++ (atomic level) is as follows:

1.) C++ [ high level language:encapsulates C ]
2.) C [ Intermediate language: uppermost to assembly ]
3.) Assembly [ True intermediate language:uppermost to binary ]
4.) Binary [ Machine lingo in ones and zeros I/O:instruction sets ]

C is what Unix was originally written in and BSD/Linux distros pretty much follow suit. C++ is the best choice out of C and C++ because you will inevitably learn C anyway while learning C++. Addressing C++ first will eliminate double work and suppress the confusion that allot of C developers encounter when trying to migrate to C++.

An example of some of the confusion that exists between C and C++ could be summated with the following example:

C's print to the console output is printf while in C++ it is std::cout. What's more confusing is the fact that you may use both printf and std::cout in the same method. The point that remains is that you would have to use/include the header files for both C and C++ in the pre-processor directives region of your file that contains the printf and std::cout function methods.

To make a long nightmare short, get several books regarding:
- general C++ programming
- the standard template library for C++ (STL)
- C++ Templates Design
- the Boost Library.

There will be around four to five thousand pages of reading in short order here, but it will be well worth the effort and extremely fascinating. OpenGL will simply fall into place after a good walk around the block with the previously mentioned subject matter under your hat.

You will not regret the commitment.

Last edited by TheRaven; 04-30-2008 at 03:37 AM.
TheRaven is offline   Reply With Quote
Old 05-01-2008, 08:44 AM   #10
Afraid of widths
 
medievalelks's Avatar
 
Join Date: Apr 2008
Location: Chicago
Posts: 887
You're completely new to programming? Start with Python.
medievalelks is offline   Reply With Quote
Old 05-01-2008, 09:07 AM   #11
Registered User
 
Join Date: Oct 2001
Posts: 2,110
I don't agree with the concept of "learning languages". If you want to learn C, learn C. If you want to learn C++, learn C++. If you want to learn assembly, Python, Pascal, or Perl, learn those. But don't learn something because you want to learn something else. That's silly.

Last edited by robwhit; 05-01-2008 at 11:03 AM.
robwhit is offline   Reply With Quote
Old 05-01-2008, 09:16 AM   #12
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
Also, I'd like to point out that languages is very small part of learning to program. Learning how to solve problems using a computer is much larger part of the learning experience. Once you know how to solve a problem in C, you can solve the same problem in Pascal, Fortran or Cobol by learning the language, but no matter how much you know the syntax and semantics of a language, if you don't know how the problem itself should be solved.

A similar example would be to know exactly how a diesel engine works, and how you change wheels on a lorry (truck or whatever you like to call a big transport vehicle), but you haven't even got a driving license for a car - so you can do all the work to make the vehicle ready to drive, but you can't actually use it. [And remember, part of learning to drive is learning what is the right ways to do certain maneuvers in different situations, such that you comply with laws and customs of the country where you are driving, such as stopping at red lights (except in Italy ), overtaking on the correct side (except in certain US states), etc, etc].

The process of learning how to write software is a much more difficult part than understanding the language.

--
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
matsp is offline   Reply With Quote
Old 05-01-2008, 12:12 PM   #13
Afraid of widths
 
medievalelks's Avatar
 
Join Date: Apr 2008
Location: Chicago
Posts: 887
Quote:
Originally Posted by robwhit View Post
I don't agree with the concept of "learning languages". If you want to learn C, learn C. If you want to learn C++, learn C++. If you want to learn assembly, Python, Pascal, or Perl, learn those. But don't learn something because you want to learn something else. That's silly.
Well, actually I'd recommend more CS background before jumping into any programming language. But I'd still recommend a scripting language without the nits of memory management, compile/link, etc, if someone wanted to learn basic programming.

I'm not recommending learning Python to help learn C, I'm recommending it to help learn basic programming. Scope, flow of control, data structures, functions, classes, etc.

Last edited by medievalelks; 05-01-2008 at 12:16 PM.
medievalelks is offline   Reply With Quote
Old 05-01-2008, 01:30 PM   #14
CSharpener
 
vart's Avatar
 
Join Date: Oct 2006
Posts: 5,336
Quote:
But I'd still recommend a scripting language without the nits of memory management, compile/link, etc, if someone wanted to learn basic programming.
Brrr... And someone continues to use this basic programming when switch to more fastidious language...

as a result I need to support the C code where reading from file is done char by char into the temp buffer and calling strcat to append the read char to the destination buffer...

[sarcasm]Thanks for such advices...[/sarcasm]
__________________
If I have eight hours for cutting wood, I spend six sharpening my axe.
vart is offline   Reply With Quote
Old 05-01-2008, 01:50 PM   #15
Registered User
 
Join Date: Oct 2001
Posts: 2,110
Quote:
Originally Posted by medievalelks View Post
Well, actually I'd recommend more CS background before jumping into any programming language. But I'd still recommend a scripting language without the nits of memory management, compile/link, etc, if someone wanted to learn basic programming.
What? That's what programming is all about!
Quote:
I'm not recommending learning Python to help learn C, I'm recommending it to help learn basic programming. Scope, flow of control, data structures, functions, classes, etc.
If you only needed to learn the concepts, then the choice of language is completely irrelevant, since you'll never be needing to make a program after you learn how.
Quote:
Originally Posted by vart View Post
as a result I need to support the C code where reading from file is done char by char into the temp buffer and calling strcat to append the read char to the destination buffer...
That made me laugh.
robwhit is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump


All times are GMT -6. The time now is 05:20 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22