Op Tue, 20 Feb 2007, schreef Patrick Leslie Polzer:
Show quoted text 8 lines
Dear FreePascal adepts,
when I was younger (about seven years ago), I wrote several programs
in Borland's Turbo Pascal version 7 (IIRC).
I then learned C and haven't looked much at Pascal ever since.
However, I'm still fond of Pascal's clear syntax, so I would like
to know more about its advantages.
Please try it. There is no better way to learn about its advantages than actual programming. This can better explain it to you than I can do in 1000 words. For many C programmers, getting into Free Pascal is a very enjoyable experience.
Show quoted text 6 lines
I would be very grateful if you could answer the following questions,
loosely based on the "Advantages" section of the FreePascal homepage.
1) "No Makefiles"
...and yet you ship a Makefile generator with FPC. Why?
Since the compiler is able to find the dependencies of files automatically, do this is not something you need a Makefile for. However, there are several other things, like creating a tar or zip of your program, installing it and some more things. A makefile is one way to provide this functionality, which we make easy and user friendly by providing a makefile generator.
Still we are going to kick fpcmake, since makefiles are hard to port. As C programmer you probably know this, to be able to execute a configure script on Windows you need an Unix emulator like Cygwin or Msys.
Building the compiler using fpcmake on Windows requires people to several Unix utilities, like cp, mv. In near the future we will move to a build tool which doesn't depend on external tools to copy files etc., increasing the portability of the compiler.
2) "Pascal compilers are Fast with a big F [...]"
Why is that?
The main reason for this is the unit system. If a C program uses a library, all header files need to be loaded and parsed, for each source file again. A Pascal compiler can simply load a unit from disk, so it doesn't need to parse headers. Further, once loaded, the unit remains in memory, so if the next file is compiled, it is ready to be used again.
Some C-compilers provide pre-compiled headers to provide some of the same advantages, but since the content of a header can change with a simple define, this is limited; until now this has not been very successfull in obtaining similar performance to Pascal compilers.
3) "Great integration with assembler"
Is being able to use Assembler easily inline really that much
better as opposed to having the code in separate object files?
Assembler at the Pascal level frees you from the trouble to access parameters. If you would write pure assembler you need to work with offsets on the stack that need to match what the compiler uses. This is very error prone.
Further, you can access any Pascal symbol directly from your assembler routines, which saves you all kinds of cubersome imports in your assembler files.
4) "Smartlinking"
Ah, I think you can have that one in C with some obscure linker
flags, too.
Recently it has become possible to do real smartlinking with gcc. FPC has done this since the late 90's; while gcc could only remove unused files, FPC could remove individual variables and procedures.
Still, it works better. Try to statically link a hello world in C and then smartlink a hello word in FPC. Compare the executables.
5) Why use Pascal instead of Ada?
Ada is a good language. Pascal is good language too, and modern Object Pascal might be even more advanced than Ada. For certain is that Pascal has better development tools, a much larger treasury chest of existing code and libraries and is much better documented due to the libraries of book been written on it.
6) Can I have run-time range checking of arrays/strings and *still*
use functions that accept arrays of any length?
Yes. We call this open arrays.
Thank you so much in advance for helping me.
You're welcome :)
Daniël Mantione