[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference 7.286::atarist

Title:Atari ST, TT, & Falcon
Notice:Please read note 1.0 and its replies before posting!
Moderator:FUNYET::ANDERSON
Created:Mon Apr 04 1988
Last Modified:Tue May 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1433
Total number of notes:10312

939.0. "Why use C" by BRUMMY::LOXTON () Wed Aug 15 1990 09:57

    	I recently decided to learn a "real" programming language,and chose
    C.
    	My first attempt was to write a program to generate the mandelbrot
    set,a program I have already written in GFA basic.
    
    	The resulting program took twice as long to run as my compiled GFA
    basic program.
    
    	Now my question.-
    
    	Programming in C is difficult to learn,the process of
    editing,compiling and linking is time consuming and I end up with a
    program that runs slower than Basic.
    
    	Whats the advantage of C over Basic.
    
    
    		Thanks
    			Brian...
T.RTitleUserPersonal
Name
DateLines
939.1Your test seems unfairMIDIOT::POWERSI Dream of Wires - G. NumanWed Aug 15 1990 12:1743
     Re: .0

        You didn't specify in your note how long you had been programming
     in Basic when you wrote the program, and how long you had been programming
     in 'C' when You wrote the program.  It sounded like you just started
     programming in 'C', and you expected the code you wrote to be the
     fastest thing on two wheels.  Several possible reasons come to mind
     for the discrepency.

     1) In your BASIC program were you using 4 byte reals?  In C, when you
        pass floats they get promoted to 8 byte reals automatically by the
        compiler.  Unless you have prototyped the functions so that they
        only pass 4 byte reals.

     2) You didn't specify which C compiler you were using, I haven't done
        any benchmarking of C compilers on the ST but I'm sure there are
        some very good code generators as well as some very bad code generators.
        I have heard of at least one C compiler for the ST that isn't a
        native code compiler,  (I think that it is Hisoft C), it interprets
        your code.

     3) Did you use as many subroutines in the Basic program that you call in
        the C program and pass the same parameters that are the same size?
        Pushing stuff on and off the stack can get expensive.  Compared to
        straight code (ie no subroutines).

        As for reasons why to use C over any other language in this case Basic.
     There are many reasons for and against.  The best language debate has
     always been an unsettled religious battle throughout computer science
     history.  You will undoubtedly make up your own mind if you haven't
     already.  But it sounds like you have without giving yourself proper
     time to compare the two languages (IMHO).  I know one of the projects
     I worked on when I first came to DEC was to write a small program to
     control and collect data from an Airborne Particle Counter which measures
     sub micron size particles in a semiconductor FAB.  I wrote the program
     in C for the VAX.  As it turned out, my group also needed it to run
     on a PC.  The port was trivial just needed to change my calls to $qio
     to something appropriate for the PC.  This would have required having
     two different programs had it been written in VAX Basic as Basic is
     not as standardized as C is.

     Bill Powers
939.2SIEVAX::JAMIEUse me, Use me... Ooops! Excuse me!Wed Aug 15 1990 14:2018
    I agree with .1 !
    
    In addition, I'd like to point out that it's usually fairly easy to
    port "C" code from one system to another since the language tends to be
    fairly consistently implemented by different companies. You may even
    have a switch on the compiler to indicate that only "basic" (!!!) "C"
    should be used...
    
    GFA basic is one of the fastest basics on the ST... I'd have thought
    that the only "fair" test (ok, fairest!) would be to use the fastest
    "C" on the ST and have an experienced programmer, fluent in both
    languages, to code the same program as efficiently as possible in both
    "C" and BASIC.
    
    
    
    
    				Jamie.
939.3More infoBIRMVX::LOXTONWed Aug 15 1990 15:0425
    
    The c compiler i used is Mark Williams C.and I don't know what size fp
    numbers it uses but in the C book I was using for reference it says
    that a variable defined as float uses 32 bits.I need to check the GFA
    manual.
    
    	The program I wrote is very small,It just dumps one part of the
    mandelbrot set to a mono monitor.The algorithm I used was very
    straightforward ie not optimized at all for either language.
    
    This is probably an unfair test as it's only really testing the fp
    routines.I didn't expect 'the fastest thing on two wheels' but I was
    suprised to find GFA 100% faster.
    
    	If I had already made up my mind,I wouldn't have entered this
    note.I do want to learn C because it is a challenge and I believe C must be
    a superior language because it is so widely used.
    	What I need is to find out why it's superior so that I have an
    incentive to learn it.
    
    	Thanks for your replies
    		Brian
    
    	
    
939.4A little clearer nowMIDIOT::POWERSI Dream of Wires - G. NumanWed Aug 15 1990 15:3621
     RE: .3

          Ok,  Mark williams C uses VAX Floating pt format.  I would expect
     that GFA Basic uses IEEE format.  I don't know if there is a speed
     difference here.  But even though you declared values to be type float
     if you call any of the RTL routines provided by Mark Williams C, ie
     sin(), cos(), exp() any functions which take floating pt values as
     parameters, they will be promoted to size double (8 bytes).  Thus
     taking twice as long to perform the operations.  

          Mark Williams C is known not to be the fastest code.  I'm not
     exactly sure whose is, but I would expect it to be Turbo C.  Which is
     available from Germany.  I know it doesn't use the stack to pass
     parameters, it uses registers.

          If the program is not too big, why don't you post it here (both
     versions) and we can take a look to see if you might be doing something
     else which could be accounting for the discrepancy.

     Bill Powers
939.5wear an asbestos suit if you talk about "C" :-)NORGE::CHADWed Aug 15 1990 17:2520
The issue of C being better is a very religious issue (see the occasional
"discussions" in the DECwdinows conference and probably other conferences).

"C" is widely used because it is perceived to be the correct thing by many.
It is perceived to be portable and "everyone else is doing it".  It is also
powerful in that you can do low level things with it quite easily.  It is also
a very dangerous language because you can do low level things very easily.  It 
is also one that has proven itself to be hard to maintain (that is what reports
I've read have said, don't flame me :-).  IMHO -- a lemming issue for many
people who use it -- it must be good if so many people use it so I'll use it 
too.  To be fair, there are many folks who are very good at it and like it and 
use it because they've decided it meets their needs the best.

MHO -- learn Modula-2.  Popular among academics and "enlightened" :-) folks
and also very powerful.


opinionatedly yours,

Chad
939.6GFA may be fasterBAGELS::FELDMANJerry Feldman DTN 227-3279Wed Aug 15 1990 20:3630
    If anyone wants to use a language because a lot of people use it, try COBOL. .
    Your Mandelbrodt program would probably be 60 pages long and take 2 days
    to compile, and move about 1 pixel per minute.
    
    I use Laser C, but I also have Prospero, Laticce, and Aztec. I would like
    code your program in True Basic, and Laser to see if I can evaluate
    why the difference. I suspect that the difference is that with compiled
    GFA, some of the floating point code is generated in-line. Most C
    compilers generate function calls. But I suspect that you probably
    defined your numbers as floats. If you change your floats to double,
    then you will avoid the expansion. As mentioned before, the C standard
    requires that floats be promoted to doubles for all the math functions.
    (The new ANSI standard changes this if you are using prototyping).
    Also, C has never really been a good language for number crunching.
    Many engineers and physicists still use FORTRAN. 
    
    As a comment to Chad: C should be no harder to maintain than other
    languages, and easier than some. If it is reasonably well commented,
    and the programmer structured it properly, it should be very easy
    to maintain. While Modula II is an excellent language, C is the one
    that is the standard for development. 
    
    As far as BASIC goes, there is, and has been an ANSI standard. However
    it is such an old language, that many implementations are available, and
    need to be for maintenance of old code. Some of the new BASICS have true
    procedures and functions. Also, gone is the requirement for line numbers.
    Unfortunately, there are still some terrible products still around, like 
    Atari Basic, PC BAsic (Microsoft), etc. 
    
    
939.7I just have to get involved... AISG::MISKINISThu Aug 16 1990 00:388
Hello,

	I use Mark Williams "C" extensivley, and it has suited all of my needs
in a language.   I've used their assembler also, and although it lacks some
features of other assemblers, I've managed to accomplish everything I've had
to do on the ST...

_John_
939.8Turbo C on the STCOMICS::HOGGANNo, I am not kidding !!!Thu Aug 16 1990 08:2014
    Hi,
    
    On the subject of C compilers for the ST, does anyone know when it will
    be possible to get Turbo C V2.0 from the USA? No doubt the price will
    be 'interesting', but from what I know of the German version it will be
    worth it - v. fast, v. compact!
    
    As an aside, is it possible that Borland don't know that withholding a
    UK release of Turbo C will(has) only increase(d) piracy?!?!??
    
    
    
    Dave.
    
939.9SIEVAX::JAMIEUse me, Use me... Ooops! Excuse me!Thu Aug 16 1990 14:085
    Another point I'd like to make is that speed isn't necessarily an
    indication of how good a language is; it all depends on what you want
    to do as to what language you should use - if you really need speed,
    machine code's the way to go... C provides access to the low level
    structures that many Basics don't provide...
939.10Speed of languagesCOMICS::HOGGANNo, I am not kidding !!!Thu Aug 16 1990 14:4313
    hi,
    
    Speed of code can not only be measured in terms of execution, but also
    in terms of coding, debugging and maintenance. A good C compiler (did I
    say Turbo C!?!?!?) will optimise code to that approaching 68000. Is the
    10-20% increase in execution worth the reduction in coding etc? Again,
    in the long term, 68000 will become 'old tech', whereas C may evolve as
    technology allows... Then again C may bow down to 4GL's
    
    
    dave.
    
    
939.11From whence "languages" spring FORTH (ba-dum-bah!)DUGGAN::LEEThu Aug 16 1990 18:3214
In his book titled "Quick C", Al Stevens gives us a quick rundown
on the origin, purpose and usefulness of so many programming
languages.

	COBOL was designed so that managers could read code.
	BASIC was designed for people who are not programmers.
	FORTRAN is for scientists.
	ADA comes from a committee - a government committee no less.
	PILOT is for teachers.
	PASCAL is for students.
	LOGO is for children
	APL is for martians.
	FORTH, LISP and PROLOG are specialty languages.
	C, however, is for programmers.
939.12COBOL designed by a WAVEBAGELS::FELDMANJerry Feldman DTN 227-3279Thu Aug 16 1990 18:549
    I fully agree with the list in .11. I have a couple of additions and
    exceptions. ADA was not designed by a Government committe, it was put
    out by government contract (which is worse than a committee). However,
    it was Bull who got the contract and designed the language. Considering
    all the other accomplishments of that company, its a wonder that ADA
    came out as good as it is. 
    
    COBOL was designed by a WAVE. (eg. Grace Hopper).
    
939.13related problems?MINNIE::DOUGjust sing it like you feel itFri Aug 17 1990 08:0111
    i've just bought a country and i'm trying to decide what language to
    speak in it...so which is better: english, american, irish, italian,
    armenian, turkish, russian, or what...? 
    
    i've just bought a church, and i'm trying to decide what religion to
    hold in it...so which is better:  protestant, catholic, jewish, muslim,
    agnostic, atheist, or what...? 
    
    please submit all opinions to /dev/null
    
    			--dd
939.14A Language X is better than Y debate????COMICS::HOGGANNo, I am not kidding !!!Fri Aug 17 1990 08:1712
    hi,
    
    The analogy used in 939.13 cannot wholly be applied to the choice of
    language used on a machine. The choice should be dictated by the
    application being written at the time, therefore an active developer
    may find themselves using 3 or 4 different languages, perhaps on the
    same project. Writing interrupt routines in C, for instance, is not the
    easiest thing to do, so why not combine the use of 68000 with C. Spoken
    languages are a mish-mash of others anyway.
    
    Dave.
     
939.15BRUMMY::LOXTONFri Aug 17 1990 11:0825
    The previous replies have convinced me that that which language depends
    on the aplication.
    
    	I tend to write programs for mathmatical or physics modelling,which
    often involve lots of floating point calculation.
                             
    	Basic is very easy to learn and programs can be written quickly.C
    on the other hand is harder to learn and program developement is
    longer.
    
    	Assembler is the hardest to learn and also has a much bigger
    developement time and is completely machine specific.
    
    	If I take the trouble to learn to learn to program in C,Would there
    be any advantage for me over Basic.
    	Comparing programs written in Basic or C,what makes one  better
    than the other,bearing in mind a user doesn't know what language was
    used.
         To say C is a language for programmers,why?.Could any C
    programmers tell me why they have chosen C over other languages.
    
    	Thanks
    		Brian.
              
    
939.16and on the PCs, Turbo Pascal 5.5 made a new record for product sold in first monthNORGE::CHADFri Aug 17 1990 13:0422
>         To say C is a language for programmers,why?.Could any C
>    programmers tell me why they have chosen C over other languages.
 
Because that is what we are "told" is right.

I have chosen Pascal to do work in.  Granted on the ST I don't program anymore.

monologue on pascal:

UNITERM, the great term-emulator for the ST, is written in Pascal (the European
version of CDD Pascal on which Personal Pascal is based).

Also a note:  The original Mac stuff was written in Pascal - a flavor called
object Pascal.

VAX Pascal is used in a lot of companies to develop software.  In Germany at 
the Uni-Hamburg they are doing all sorts of complex graphics doing medical
imaging -- all in VAX Pascal.

Not every one uses C

Chad
939.17Why 'C' ??????COMICS::HOGGANNo, I am not kidding !!!Fri Aug 17 1990 13:1635
    Hi,
    
    As to advantages of knowing C over gfa basic, one answer could be that
    you won't always have an ST (The power supplies seem to have a half
    life of a couple of years!). Seriously though, the day may come when
    you wish to move on to another machine; a portable language language
    will save a lot of hair pulling. 
    
    As to why I use C (I don't profess to be a C programmer - merely have a
    knowledge in it) it is hard to say. I spent five years on basic, and
    around five on pascal. I've an understanding of 68000, prolog.... but C
    has struck me as being the most versatile. C is the ideal language for
    the "write bad code very fast" syndrome and also the concept of
    pointers must be understood before 'serious' coding can be done. 
    
    As already stated, the opinion of a language is, in part, formed by the
    ease of use of the compiler. Take Prospero C; reasonable to learn with,
    but oh so painfully slow to compile; the final code is also
    inefficient. Take a compiler like Turbo C. It enforces the concept of
    prototyping, casting etc... Initially this seems a waste of time, but
    it can stop so many problems cropping up at a later date. Compiled code
    is very efficient and compilation is fast. The user environment is
    good; double click on the error message and it'll take you straight to
    the offending line, for example.
    
    A good book to use as reference is the K&R C book. At 25 quid cheap it
    ain't, but you'll never need another book! It is however, not easy to
    learn from; ideally a (patient) friend with experience in C is needed.
    
    If you're interested in maths applications, would APL be suitable - I
    believe it's a mathematical language.
    
    Dave.
    
    
939.18Stick with BASICBAGELS::FELDMANJerry Feldman DTN 227-3279Fri Aug 17 1990 14:5214
    If you already know BASIC, try to program using the ANSI model as much as
    possible with your BASIC, then your code will be somewhat more portable.
    Note the True Basic is available on most platforms. John Kemeny, the
    original designer of BASIC, is one of the principals in True Basic.
    Also, True Basic is a compiled BASIC with a reasonably good workbench.
    Although I am a heavy C programmer, before I got Laser C, I used True Basic  for  
    for most of my quick and dirty type programs. With a good BASIC such as
    GFA and TRUE BASIC, you can write good structured, and reasonably portable
    code. My advice is to stick with BASIC, and although it was originally
    designed for beginners, most of the good BASICS can produce
    applications which perform as well as if they were written in other
    languages.
    
    Jerry
939.19C is preferred by programmersBAGELS::FELDMANJerry Feldman DTN 227-3279Fri Aug 17 1990 15:0727
    RE: 16
    >     Because that is what we are "told" is right.
    
    I totally disagree with this sentence. I am proficient, and have been
    paid to program in COBOL, FORTRAN, Pascal, FORTH, BASIC, ADA, C,
    and several other languages. C is the language of choice for many reasons.
    1. It is extremely flexible. The progammer can perform nearly all tasks
       in that language, where many other languages have restrictions.
    2. It is structured, and can be very easy to read and debug if one
       structures one's code properly. In this are, Pascal and Modula II
       are certainly superior.
    3. It generates reasonably efficient code so that performance and memory
       utilization is better than other high level languages. Also note that
       this is a generalization, and is not always true.
    4. C programmers are currently in demand, and I earn my living as 
       a contract software engineer. (eg. In this case, I bow to Chad's
       statement).
    
    I also pay credence to the fact that the application may dictate the use of
    a language. For heavy number cruching, FORTRAN or BASIC, would be my
    languages of choice. The bottom line, though, is to get the job done
    properly. If C may be the best choice for writing an application, but
    it means that you would have to learn it, use one of the languages
    that you know. 
    
    
    
939.20Stick with what you know ?????COMICS::HOGGANNo, I am not kidding !!!Fri Aug 17 1990 15:2416
    hi,
    
    Sticking with a language purely because it is what one knows is, to  my
    mind, a little limiting. If I had not decided to start learning C a few
    weeks ago, I would have lost out on (don't cringe) an enjoyable
    learning experience. Programming Gem in Pascal is not the easiest thing
    to do and using C has helped me in  that I don't have to reinvent the wheel
    every time I have a problem.
    
    I am not conversant with modern day basics and therefore willnot say
    that sticking with it is wrong, BUT don't take 'stick with what yo
    know' too literally as you would never become more than proficient!
    
    Dave.
    
    
939.21religionNORGE::CHADFri Aug 17 1990 15:4518
>    >     Because that is what we are "told" is right.
    
>    I totally disagree with this sentence. I am proficient, and have been
>    paid to program in COBOL, FORTRAN, Pascal, FORTH, BASIC, ADA, C,
>    and several other languages. C is the language of choice for many reasons.

I know a lot of really good software engineers who don't choose C unless
politics demand it. (I also know a lot of really good engineers who choose 
it themselves).  It is really a religious issue.

Anyway, if you don't like C, don;t use/learn it.  If you'd like the challenge,
learn it.  It can;t hurt in todays world to have C experience.  Though it is not
my choice, I plan on becoming very proficient at it because it is becoming the
default language and experience is becoming a must if you work in software.

Good luck

Chad
939.22Good LuckCOMICS::HOGGANNo, I am not kidding !!!Fri Aug 17 1990 16:077
    C, a challenge ? It certainly is!
    
    Whatever you decide though, good luck! A programmer is not the language
    they use, a programmer writes programs.
    
    Dave.
    
939.23use the language you're familiar withMGOI03::FALKENSTEINso many girls, so little time...Mon Aug 20 1990 13:5141
I learned Pascal and 68xx(x) Assembler during my time at university but
although I do not program very much anymore I stuck to GFA-Basic which
I learned on my own. Meanwhile I bought version 3.5 and still be in the
process of learning all the goodies hidden in that language.
You have direct access to the OS, GEM-programming is a piece of cake if
you know the commands and for timecritical things routines of C, Pascal
or Assembler may be used.
The first compiler-language I had on my ST years ago was ST-Pascal, which
I found very complex in programming GEM-things. For this the decicion to 
choose a language specially designed for ST's graphic environment was easy
for me. As a result of using GFA-Basic I found out that the outcoming
code was smaller and the programs were faster than the same in ST-Pascal.
I tried to learn C in my leisure time, but after some weeks of reading
books and typing on my keyboard I started to think it over, maybe because
it needs some time to see the first acceptable results. I would need months
if not years to become as familiar with C as I be now with GFA-Basic just
learning it in my spare time. Because I'm no professional programmer and
do not earn any money for it, GFA-Basic is good enough for me and my
programs which do not exceed 50-100kB of commented source code. Besides I
couldn't find a problem so far which could not be solved by GFA-Basic.
For GEM-things you got specially designed commands and the RCS as well.
So my advice is: use the language you know and try to become more perfect
in it by the time and write programs which you know are working after an
acceptable time rather than learning a new, probably very good but hard to
learn language like C if you just use the programs on your own spending
your leisure time programming them. You would need a lot of time learning,
debugging, understanding compiler options and getting familiar with the
language itself. If you're out for quick results and not heading for the
challenge to learn a new language just for the fun of it (say hobby), the 
language you know best is the way to go.
(Things look different for professional programmers who get money for their
work, they should use C because it's becomming standard on most machines)
By the way, I do not think that porting a program to another computer is
easy in any language as soon as a graphic environment is involved. I can't
believe that just "editing the resource file" is it. Try to get a Pascal
program designed for MS-DOS GEM changed to work on a ST or the other way
around... (and Pascal is said to be a portable standard language).

Bernd