[lug] Learning to code on Linux.

Davide Del Vento davide.del.vento at gmail.com
Sat Mar 28 13:14:12 MDT 2009


Hi,

> What's a good way to learn how to write C apps for Linux?
What kind of apps? At first I thought something CLI, or qt or gtk, but
then... see below.

> installed Linux for him but didn't include the source packages.  He wants to
> rewrite a FORTRAN app in C, so that it will be more portable and
> maintainable down the road.
Ok, so I guess it is something "scientific", namely something
not-so-complex from the software point of view (but maybe very complex
from the underlying mathematics).

> A friend called me today to ask about getting the source for libc.
> So, I can get him the source.  He said, "if I have the source it will answer
> all my questions about libc, and probably teach me what I need to write my
> app."  He's not scared of doing hard work to gain a skill.
Well, it wouldn't hurt, but I don't think will be a very useful point to start.

> But I wonder what might be more efficient for him.
Since he is familiar with Fortran, I'd suggest at first to become
familiar with C syntax in doing exactly the same things. I'm thinking
just of curly brackets instead of do-end sections, no difference
between functions and subroutines, the way in which you pass command
line parameters, etc.

When he is familiar with that, I'd suggest to go to more "advanced"
features, like pointers and pointers arithmetics (in Fortran pointers
are different) and things Benjamin mentioned.

A good editor will help, for example highlighting the "related" curly
bracket. I like jedit a lot, but also vi in recent ubuntu does that
without any special configuration.

> A study group or book might be a big help.
For the purpose I explained above, I think that any book would be ok
to start with (they were giving away old books at NCAR library, I can
check if they still have something on this subject)

> I expect he can figure out gcc, make, etc, but might need some help with the
> easiest way to get source packages, how to use -dev packages, etc.
Depends on what he wants to do. In my experience, if he is coming from
Fortran, he doesn't need anything, besides gcc. He might later find
make & makefile (very!) useful, but it might be confusing for him, at
first.

Bye,
;Dav



More information about the LUG mailing list