|Note - BerkeleyLUG blog posts are written by BerkeleyLUG members of various backgrounds, levels of experience etc... The views and opinions in each blog post do not represent the views of the group as a whole or the founders.|
|Posted on Friday, March 16, 2012 at 6:50 pm
by goossbears ||
My search findings on Learning C/C++ Programming and Using an IDE
I’ll have to preface my search findings on these subjects, by mentioning that according to Risto S. Varanka’s Programming Languages mini-HOWTO: Programming Languages ;
C, Lisp and Perl are traditional hacking languages in the
GNU/Linux culture; Python, PHP, Java and C++ have gained new
Furthermore, and mostly according to Veranka’s mini-HOWTO and to forum threads such as this one at ProgrammersHeaven.com/ ;
A. Perl is a great first programming language to learn for Beginners; Perl has the advantage of being an interpreted language instead of a language that requires a compiler and linker for creating binaries. Perl is an Object Oriented Programming (OOP) language that is especially powerful for handling text and strings. Perl is commonly used for scripting, for sysadmin-type tasks, and for web server tasks.
B. Python and Java are also great first programming languages for Beginners to learn; both Python and Java are modern up-to-date OOP languages used on web servers and for web-processing tasks. Python is especially useful for more general and application-specific scripting while Java is especially useful for cross-platform applications.
C. as appropriate ;-)
C and C++ are apparently NOT languages for Beginners to first learn programming. Although executable binaries created from C or C++ generally run faster than interpreted source code, executable binaries (i.e., the actual applications) require the EXTRA steps of compilation and linking from original C/C++ source code, not to mention any necessary required debugging and optimization steps. Both C and C++ programming languages are especially useful for creating applications. C is more of a Procedural than an OOP language such as C++, and many describe C as being the MOST suitable for the system and in-depth OS tasks that Linux distros rely upon using the GNU Compiler Collection’s ‘gcc’.
* Note that “GCC” is the acronym for the overall GNU Compiler Collection whereas “gcc” is the specific acronym specifically for the GNU Compiler Collection’s C compiler itself.
From my own limited experience, I would probably place Perl and maybe Bash shell-scripting ahead of C and C++ for Beginners first learning how to program. I would guess that many of us who have already programmed using Perl and Bash shell-scripting could probably use a refresher or two in these :-).
A good “Perl tutorials” web search using the privacy-minded search engines ixquick and/or Startpage should yield worthwhile hits very similar to these handful :
- Learn Perl in 10 easy lessons
- The comprehensive Perl Tutorial Hub meta-review site.
- The perlmonks’ Getting Started with Perl
- Linuxtopia’s Picking Up Perl (2nd Edition) and Perl Tutorial – An Introduction to Perl
- Perl.org’s Learn Pearl, perlintro and Online Library
grantbow has a collection of good Bash shell scripting tutorials and resources within his Learning the Command Line webpage, and also helpful in this regard is chapter 7 of the Rute User’s Tutorial and Exposition.
With all that being said, here are some working links I have found regarding learning and compiling C/C++ programs.
I. Tutorials to learn C/C++
- The love_C.ps.Z zipfile containing the ANSI C for Programmers on UNIX systems tutorial. Once the compressed love_C.ps.Z file is downloaded and copied over to a particular folder, it would need to be uncompressed with ‘gunzip’ and then converted to a pdf or to a standard ASCII textfile using the respective conversion commands ‘ps2pdf love_C.ps’ or ‘ps2ascii love_C.ps > love_C.txt’.
** I find that a key benefit to having such a tutorial in these formats (pdf or textfile) is that you can study and use the material WITHOUT requiring a web-browser or Internet access.
Unfortunately, Tom Love’s ANSI C tutorial is well over a dozen years old.
- Dave Marshall’s Programming in C : UNIX System Calls and Subroutines using C.
Nicely displayed tutorial webpages.
- HowtoForge’s Learning C/C++ Step-By-Step.
Got this by recommendation, but haven’t looked into this. Seems fairly straightforward though.
- The Learn C and C++ links at Cprogramming.com’s C Programming and C++ Programming.
These combined C and C++ tutorials are definitely easy to find and remember(!), and are fairly comprehensive all the way from Beginner to Advanced.
- The Linuxtopia online books Learning GNU C, The GNU C Programming Tutorial, Thinking in C++, and Thinking in C++ Vol 2 – Practical Programming
II. Simple C/C++ Compilation
The simplest and probably the best initial manner of learning C/C++ programming in Linux using these tutorials on the command line is to:
- Type in and edit your C/C++ source code using whatever text editor you most prefer (e.g., vi/vim/nvi, nano/pico, gedit, nedit, leafpad, mousepad,…whatever else) and then save the file with the suffix `.c’ for C programs or one of the suffixes `.C’, `.cc’, `.cpp’, `.CPP’, `.c++’, `.cp’, or `.cxx’ for C++ programs.
- Compile and link your properly-suffixed source code file from the command line using the typical ‘gcc’ or ‘g++’ command+options for C and C++ respectively.
- Run the default executable file by entering ‘./a.out’.
For getting more familiar with using gcc and g++ in steps 2 and 3, there are:
- Cprogramming.com’s aptly-titled gcc compiler and g++ compiler webpages.
Quick, simple, and these provide appropriate mention of the GNU Debugger, ‘gdb’.
- develvid’s YouTube video Compiling with GCC (probably should be “gcc” instead)
This video shows sequence of command line screenshots using the vim editor and a few ways to use gcc to compile and run a pair of simple C programs. Covers the above steps 1 through 3 in a quick 4 1/2 minutes.
- Brian Gough’s An Introduction to GCC for the GNU Compilers gcc and g++ with a Forward written by RMS.
- The FSF gnu.org’s Invoking GCC – GCC Command Options.
Given that the entire site, gcc.gnu.org/onlinedocs/gcc, is the gnu.org’s official guides to GNU compilers, this webpage is as fully complete and as up-to-date as the FSF can make it. It seems a bit too complex for Beginners to proceed very far beyond the basic ‘Invoking GCC – GCC Command Options’ though.
- The gcc(1) and g++(1) man[ual] reference pages.
Their SYNOPSES and DESCRIPTIONS sections seem to be the most useful, although their OPTIONS sections can be overwhelming with the vast number of listed options for both gcc and g++.
III. Using an IDE
Instead of creating and testing C/C++ programs through the three-step manual method just described above, I have also discovered a few Integrated Developmental Environments (IDEs) for Linux to handle C/C++ program development all the way from editing C/C++ source code to correcting syntax, compiling, linking, full debugging amd code optimizations.
Using a C/C++ IDE also goes a long way to relieving the need for Beginners to venture too heavily into the more Advanced-level programming processes of contimually running the gcc/binutils toolchain, ‘make’ and ‘gdb’ to create Linux system binaries.
- The Comparison of integrated development environments for C/C++.
Besides the chart comparing IDEs for C/C++, there are also charts above and below this C/C++ chart comparing IDEs for Perl, Python, Java and a whole host of additional programming languages.
- The Code::Blocks open source, cross platform, free C++ IDE.
Although Code::Blocks is listed as a “C++” IDE, it still quite readily uses gcc for compiling C programs as well. Code::Blocks is distributed under the GPL.
- The Eclipse CDT (C/C++ Development Tooling).
The Eclipse CDT is distributed under its Eclipse Public License (EPL), which is slightly more restrictive than the GPL as far as commercial distribution purposes.
IBM’s developerWorks has good Eclipse CDT resources including Integrated Development Environment: C/C++ development with the Eclipse Platform and Developing applications using the Eclipse C/C++ Development Toolkit.
Good and better recommendations & suggestions regarding these are always welcome :-)
Go Open Source Software Bears!