[Wolves] Programming

Aquarius aquarius-lists at kryogenix.org
Mon Dec 15 08:26:44 GMT 2003


Mo Awkati spoo'd forth:
> I think I am clear that if I want to creat applications that will run
> under Linux I can use KDevelop and Qt.For this I will need to learn to
> programme with C++.

Mo,

I'm about to advocate that you use Python instead of C or C++. Other
people in the LUG will not be surprised by this.

I am firmly of the opinion that there is no need to use C or C++, the
compiled languages, for most programming that people need to do. I
think that pretty much everyone would agree that writing code in C or
C++ is harder than writing them in a "scripting language", which is a
language that is of a higher level than C. Without wishing to go into
mind-smashing technical detail, C and C++ operate at a lower level than
scripting languages -- they give you more power, but at the cost of you
having to do more management. To take an analogy, think of building a
car. Using a scripting language is like buying a kit car: you buy a
chassis, a body, an engine, seats, and so on, and you bolt them
together using a ratchet spanner. It's relatively simple, and a
relative amateur can build a car in a weekend. Writing in C or C++ is
like buying all the bits separately; instead of getting an engine, you
get a distributor cap and a rotor arm and sparkplugs and pistons and
you put them all together. It's a skilled job, and it's not for
amateurs. Now, your C++ car, if you know what you're doing, will be
better than a kit car, because you can choose just the right pistons
and distributor and sparks for it, but it is a lot harder to build, and
requires more knowledge and effort on the part of the builder. A kit
car is perfectly good enough for nearly all the driving that you need
to do. That's like the difference between C/C++ and a scripting
language.

The flip side to this, slightly, is that you will find more
documentation on writing C code (especially when working with windowing
programs like Qt or Gtk) than you will with a scripting language, in
much the same way as cars -- there are dozens of manuals telling you
what a distributor is, but if you buy a kit car you'll generally just
use the docs that came with it to know how to build it.

I hope that's convinced you to take a look at scripting languages to
write code. There are loads, but there are only really a few main
competitors: Python, Perl, Ruby, Lua, and bash. In reverse order:

bash
----
This is what trog was talking about: bash is the command shell. It is
possible to do an awful lot of what might be considered "programming"
using nothing more than the command line. The big downside here is that
it is not designed for writing graphical applications, so if you're
interested in that then bash scripts are not for you. It is useful to
have some familiarity with bash scripting if you intend to do complex
things with Linux, but it's not essential.

Lua and Ruby
------------
These two scripting languages have a certain amount of support, but I
don't know a lot about them myself. They are less popular than the two
main scripting languages, Python and Perl, and I don't know whether
anyone on this list knows about them. I'll leave this open for someone
else to jump in.

Python and Perl
---------------
I'd recommend you choose one of these languages to work in. I'm not
going to attempt to outline the differences between them -- there are
lots of differences, but I am hopelessly biased in favour of Python and
against Perl, so I don't trust myself to be the least bit objective.
I'd recommend that you take a look at both, briefly, and see which best
suits your own style -- if you find one complicated and the other not,
then stick with the one you liked and don't worry. Like bash scripting,
it is often handy to know one or the other of these. Most dedicated
Linux hackers have at least a nodding familiarity with both, but prefer
one to the other.

More comments from other people welcome. In particular, note how I have
not let this degenerate into a Perl slagging match, so do try and do
the same :)

Aq.

-- 
Hov ghajbe'bogh ram rur pegh ghajbe'bogh jaj
(A day without secrets is like a night without stars)
           -- Klingon proverb



More information about the Wolves mailing list