On Thursday 22 February 2001 01:48, Olivier Dagenais wrote: > > In
You can’t have it all - but C and C++ give almost everything at a cost that
the majority of programmers are ready to pay. One may claim that every
problem has it’s tool. So, are you going to use 3 - 5 different languages for
every program…?
Within reason, of course, and you have to weigh your options carefully
(see below).
Not me. C + C++ == 1.5 languages, and they can deal with almost any problem
in an acceptable way, so I’d rather learn to handle their weaknesses than
learn a bunch of other languages, finding interpreters/compilers, sort out
the linking/integration problems and all that.
Well, I suppose you must also do CGI scripting and relational databasing
in C/C++… In many cases you don’t need to do linking or integration
because your language is fully interpreted (as in Perl or Java) and your
entire project is written in it! The difficulties you have described often
solve more problems than they create, while stubbornness not to learn a
new language often produces convoluted “solutions” that are difficult to
maintain and modify. In many cases, this is something you can live with,
but occasionally this problem that could be better solved with another
language is too big a part of your whole project that it would clearly
benefit from being either wholly rewritten in that other language or
somehow combined with other languages.
If one really needs to do lots of work in an area where these languages suck,
there’s always the classical GUI toolkit solution; write up a preprocessor
that translates some custom extensions into real code. That usually results
in a syntax and level of error checking that beats any "general purpose"
language.
Try using this approach to write a custom AI engine for an RTS or
something similar! C/C++ definitely suck at this, and an RTS is
definitely the sort of thing that would benefit from a multi-language
approach. What I would do is write the bulk of the program in C or C++,
but do the AI core in Lisp, Scheme, or Prolog. Embed an interpreter for
the language chosen in C or C++.
By the way, writing AI for even a simple game is not something you want to
do in C or C++. I’ve tried. I once wrote an AI engine for a simple card
game, starting in C, but after a week’s worth of frustration, I found a
book on Scheme and in another week was able to produce an AI engine that
was much cleaner and simpler than my abortive attempt in C. With Guile
available the integration went fairly swiftly. (BTW, I only have the
sources for the AI engine with me; the whole project was done in a mix of
VB, C, and Scheme)
Most of the time you are right, the extra effort of learning a new
language and figuring out how to make everything fit is not worth it.
However, one must learn how to weigh the options available and not to be
too reluctant to actually learn a new language when it will clearly
produce long-term benefits and simplify the problem significantly.
Well, we’ve somehow stumbled onto language issues in software engineering
with this thread! It’s clearly one where opinions run deep…On Thu, 22 Feb 2001, David Olofson wrote:
–
Rafael R. Sevilla <@Rafael_R_Sevilla> +63 (2) 4342217
UP Diliman Mobile Robotics Laboratory +63 (917) 4458925
OpenPGP Key ID: 0x0E8CE481