[NTLUG:Discuss] Wanting to speak the language

Steve Baker sjbaker1 at airmail.net
Fri Feb 25 01:42:57 CST 2005


Peter A. Koren wrote:

> For somebody starting out in programming, it would be wise to stay away
> from all languages that require the edit/compile/debug loop. That places
> too great a load on a newbie programmer interested in learning the
> concepts of creating programs in a language.

That's just not true in the modern world.

With the speed of modern C/C++ compilers, you can write a shell script:

  while ( 1 )
    vi myprog.c
    rm myprog
    gcc -o myprog myprog.c
    myprog
  end

...and your turn-around time for the supposedly tedious edit/compile
loop is but a tiny fraction of a second for any program of the kind
of length you'll be writing in your first month of learning!

Personally, I teach people the very, very basics of using 'make' and
set them up with an example makefile.

The edit/compile/run loop then looks like:

% !v           -- edit the file again (presuming you use 'vi')
% !m           -- run 'make' again.
% !.           -- rerun the program (presuming you ran it with ./myprog last time).

All of six keystrokes and less elapsed time than your best reaction time.
If that's more than you can bear, set up three desktop icons and you can
get around that oh-so-tedious loop in under a second and three mouse clicks!

 > The addition of a tool set,
 > which is usually a set of classes meant to create useful objects, such
 > as GUI elements -- eg, dialog boxes -- adds a task larger than that of
 > learning the language itself.

That's undoubtedly true.  Learning the 'glue' necessary to turn an
abstract programming language into a machine that actually drives real
graphics, sound, GUI, etc is a significant task.   Languages that have
that stuff built-in are bigger and harder to learn - languages that don't
are leaner and meaner - but then you have to learn a bunch of API stuff.

I don't see a way around that.

When you start learning C, your first programs are gonna be command-line
stuff with text I/O going to stdout and keyboard input coming in from
stdin.

Which set of library API you learn next is an entirely separate issue
that could require just as much discussion as the choice of lanagues
already has.

> I would highly recommend starting out with an interpretive language that
> requires no compile.

I think that's an old view that dates back YEARS ago when compiling "Hello World"
would take 30 seconds.  Even on my ancient 700MHz box, the compile and link takes
under a third of a second.  That's faster than I can type 'run' in an interpreted
language.  For any program under a couple of thousand lines, the compile time
is simply negligable compared to your thinking time.

If there is still an argument for the ability of an interpreter to get going
quickly, it's for HUGE programs - not the tiny ones that beginners write.

However, for most large programs, the fact that a typical interpreted
language is about 50 times slower than C wipes out a good deal of that
benefit.

> The choices are many.

Oh yes.

---------------------------- Steve Baker -------------------------
HomeEmail: <sjbaker1 at airmail.net>    WorkEmail: <sjbaker at link.com>
HomePage : http://www.sjbaker.org
Projects : http://plib.sf.net    http://tuxaqfh.sf.net
            http://tuxkart.sf.net http://prettypoly.sf.net
-----BEGIN GEEK CODE BLOCK-----
GCS d-- s:+ a+ C++++$ UL+++$ P--- L++++$ E--- W+++ N o+ K? w--- !O M-
V-- PS++ PE- Y-- PGP-- t+ 5 X R+++ tv b++ DI++ D G+ e++ h--(-) r+++ y++++
-----END GEEK CODE BLOCK-----




More information about the Discuss mailing list