Pascal is a programming language its syntax is more oriented toward the software developer (especially beginners). It looks less cryptic and the chances of program crashes are less than in C. Borland Pascal was once very popular. Programs written in Pascal are less portable to different operating systems and to different hardware than C.
There is the free pascal compiler https://www.freepascal.org/ emerge fpc and an ide emerge fpc-ide and the full blown featured IDE for gui applications and delphi lazarus http://www.lazarus-ide.org/ emerge lazarus. Since fpc is a compiler, executable binaries are created that run directly.
Simple applications can be compiled directly on the command line as:
fpc<myprogram>
.pas
or
fpc -Tlinux<myprogram>
.pas
to let it know that Linux is the target. To include units (in the example, units that are in the directory units next to the directory holding the pas file) that are in an other location run
fpc -Tlinux -Fu <../unit>
<myprogram>
.pas
To run fpc-ide type fp and a text based window as good old turbo pascal appears. To debug there is option mode debug and
compile options for the debugger. However there are many issues that fp has
with gdb and so debugging fails. So the hard way comes, compile the file
with -g option to have debug
info fpc -Tlinux -Fu<../unit>
-g <myprogram>
.pas
and start it with gdb in the console.
lazarus should just be used for gui applications (similar to borland delphi). Console applications however can be created via Project -> New project from file, where Program can be selected to get a console application. lazarus creates a project with many files, this might be an overkill for small pascal programs.To Debug gdb has to be selected in the menu. However lazarus does not show a console window when debugged.
For the non Pascal expert, the following includes the standard library crt that deals with cursor movements in the console (similar to ncurses):
uses crt;
If you want to use graphics by uses graph; You might get a -lvga error, this is since the vga library from http://www.svgalib.org/ is missing since it does not come with lazarus. Check the svgalib section in this document on how to install and setup this library.
An graph initialization for pascal VGA mode with 16 colors would look as follows:
var gd,gm:SmallInt; begin gd := D8bit; gm := m640x480; initgraph(gd,gm,'');
There is also gnu pascal it uses http://grx.gnu.de/ for the graph unit (that uses svgalib) and there are also various IDE as http://www.bloodshed.net/devpascal.html (this should work for both the gnu pascal and the free pascal complier and has gdb and insight debugging support) and http://www.rhide.com/ and http://fjf.gnu.de/peng/ however those packages are quite old.
Finally there is pascaline a pascal plugin for eclipse:https://sourceforge.net/projects/pascaline/.