Author Topic: Free Pascal Compiler  (Read 960 times)

0 Members and 1 Guest are viewing this topic.

John

  • Hero Member
  • *****
  • Posts: 3249
Free Pascal Compiler
« on: March 09, 2018, 10:59:07 PM »
A 32/64/16-bit Pascal compiler for Win32/64/CE, Linux, Mac OS X/iOS, FreeBSD, OS/2, Game Boy Advance, Nintendo NDS and DOS; semantically compatible with Delphi, Borland Pascal and Mac Pascal (partially) with extra features, e.g. operator overloading.


Free Pascal 3.0.4 is currently available for the following platforms:
- Linux-i386
- Linux-x86_64 (amd64)
- Linux-powerpc
- Linux-sparc
- Linux-ARM
- Win32-i386 (2000/XP, WinNT or later)
- Win64-x86_64 (XP or later)
- Wince-ARM (cross compiled from win32-i386)
- FreeBSD-i386
- FreeBSD-x86_64
- Mac OS X/Darwin for PowerPC (32 and 64 bit)
- Mac OS X/Darwin for Intel (32 and 64 bit)
- iOS (ARM and AArch64/ARM64) and iPhoneSimulator (32 and 64 bit)
- OS/2-i386 (OS/2 Warp v3.0, 4.0, WarpServer for e-Business and eComStation)
- Haiku-i386
- GO32v2-i386
- Nintendo Gameboy Advance-ARM (cross compile from win32-i386)
- Nintendo DS-ARM (cross compile from win32-i386)
- Nintendo Wii-powerpc (cross compile from win32-i386)
- AIX 5.3 and later for PowerPC (32 and 64 bit)
- Java JVM (1.5 and later) and Android Dalvik (Android 4.0 and later)
- Android (ARM, i386, MIPS) via cross-compiling.
- MSDos-i8086 (cross compiled from win32-i386 or Linux)
- Amiga, MorphOS and AROS

- high speed compiler
- fully 16, 32 or 64-bit code
  - 32 bit compiler can be used on x86_64 Linux distributions to compile 32 bit applications
- language features:
  - almost fully compatible with Borland Pascal and Borland Delphi
  - ansi strings
  - wide strings
  - exception support
  - RTTI support
  - procedure overloading
  - generics (experimental)
  - operator overloading
  - COM, CORBA and raw interfaces support
  - dynamic array support
  - variant support
  - inlining
- code optimizer:
  - peephole optimizer (80x86 only)
  - jump optimizer
  - loading of variables into registers
  - assembler level dataflow analyzer (80x86 only)
  - stack frame eliminations
  - sophisticated register allocator
- integrated BASM (built-in assembler) parser
  - supports ATT syntax used by GNU C
  - supports Intel syntax used by Turbo Pascal (x86-only)
- can compile code into assembler source code for these assemblers:
  - GNU Assembler (GAS)
  - Netwide assembler (Nasm)
  - Microsoft Assembler/Turbo Assembler (Masm/Tasm)
  - Watcom assembler (wasm)
- internal assembler for ultra fast object file generation
- can call external C code
  - h2pas utility to convert .h files to Pascal units
- smart linking (also known as dead code stripping)
- support for the GNU debugger
- integrated development environment (disabled by default on Mac OS X)
  - powerful user friendly Wordstar compatible multi file editor
  - context sensitive help supports help files in HTML, Windows HLP and Borland TPH format.
  - debugger on most platforms
- can create binaries running natively under both DOS and OS/2 (EMX version)
- no need for Linux distribution specific binaries, programs you write run on all distributions
- high quality documentation


Repository

Open Source Project Web Site
« Last Edit: March 10, 2018, 12:09:50 AM by John »

John

  • Hero Member
  • *****
  • Posts: 3249
Re: Free Pascal Compiler - SQLite
« Reply #1 on: March 10, 2018, 02:43:02 AM »
My first test with FPC under Windows 7 32 bit.

The IDE reminds me of PBDOS.

The test.exe ballooned out to 300 KB.

Code: Pascal
  1. program test;
  2.  
  3. uses sqlite3,sqlite3db, strings,classes;
  4.  
  5. var
  6.   MySQL: TSQLite;
  7.   SQL: String;
  8.   i, j: Integer;
  9.   a: TStringList;
  10. begin
  11.   Writeln('Creating class');
  12.   MySQL := TSQLite.Create('test.db');
  13.   MySQL.BusyTimeout := 1000;
  14.  
  15.  // writeln(MySQL.Version);
  16.   Writeln('Creating table');
  17.   SQL := 'CREATE TABLE Test(No int, First varchar(32),Last varchar(32));';
  18.   MySQL.Query(sql, nil);
  19.   SQL := 'INSERT INTO Test VALUES(1,''John'', ''Spikowski'');';
  20.   if MySQL.IsComplete(sql) then
  21.     begin
  22.     Writeln('Inserting first row');
  23.     MySQL.Query(sql, nil);
  24.     end;
  25.   SQL := 'INSERT INTO Test VALUES(2,''Charles'', ''Pegge'');';
  26.   if MySQL.IsComplete(sql) then
  27.     begin
  28.     Writeln('Inserting second row') ;
  29.     MySQL.Query(sql, nil);
  30.     end;
  31.   Writeln('Selecting rows') ;
  32.  
  33.   SQL := 'SELECT * FROM Test;';
  34.   MySQL.Query(sql, nil);
  35.   writeln('Fields Names -------------------');
  36.   for i:=0 to MySQL.List_FieldName.count-1 do
  37.     writeln(i,' -> ',MySQL.List_FieldName.Strings[i]);
  38.   writeln('Fields -------------------');
  39.   for i:=0 to MySQL.List_Field.count-1 do
  40.       begin
  41.         a:=TStringList(MySQL.List_Field.items[i]);
  42.         write(i,' -> ');
  43.         for j:=0 to a.count-1 do
  44.           write(a.Strings[j],'  ');
  45.         writeln('');
  46.       end;
  47.  
  48. // Uncomment to remove table again.
  49. //  SQL := 'DROP TABLE Test;';
  50. //  MySQL.Query(sql, nil);
  51.   MySQL.Free;
  52. end.
  53.  


C:\FPC\3.0.4\examples\sqlite>test
Creating class
Creating table
Inserting first row
Inserting second row
Selecting rows
Fields Names -------------------
0 -> No
1 -> First
2 -> Last
Fields -------------------
0 -> 1  John  Spikowski
1 -> 2  Charles  Pegge

C:\FPC\3.0.4\examples\sqlite>

« Last Edit: March 10, 2018, 02:49:54 AM by John »

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3745
    • Oxygen Basic
Re: Free Pascal Compiler
« Reply #2 on: March 10, 2018, 03:49:44 AM »
I like the clarity of Pascal. And we have Oxygene, an OOP enhanced .net Pascal.

https://en.wikipedia.org/wiki/Oxygene_(programming_language)

I wonder if there are any features we might borrow? :)
« Last Edit: March 10, 2018, 04:00:54 AM by Charles Pegge »

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1856
Re: Free Pascal Compiler
« Reply #3 on: March 10, 2018, 05:46:39 AM »
https://en.wikipedia.org/wiki/Oxygene_(programming_language)
I wonder if there are any features we might borrow?

:o

You mean, besides the language name? ;)



(Actually, the situation looks somewhat, uhm, delicate to me.)  ::)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3745
    • Oxygen Basic
Re: Free Pascal Compiler
« Reply #4 on: March 10, 2018, 06:04:38 AM »
You mean Oxygene might deceive our prospective clients into buying their product? :D

with the formal name, OxygenBasic, there are no trademark conflicts.

But I have already purloined the Pascal := assignment operator!

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1856
Re: Free Pascal Compiler
« Reply #5 on: March 10, 2018, 06:45:19 AM »
;D ;D ;D ;D

But I have already purloined the Pascal := assignment operator!

Too much honor to that dynosaurus of a language. := has been part of official modern BASIC notation since the onset of MS Visual Basic. ;)
« Last Edit: March 10, 2018, 07:38:29 PM by Mike Lobanovsky »
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

John

  • Hero Member
  • *****
  • Posts: 3249
Re: Free Pascal Compiler - Hello World
« Reply #6 on: March 10, 2018, 11:36:31 AM »
It looks like 32 KB executables is the starting line.

Code: Pascal
  1. program hello;
  2.  
  3.   begin
  4.      writeln('Hello world');
  5.   end.
  6.  


C:\FPC\3.0.4\demo\text>fpc hello.pp
Free Pascal Compiler version 3.0.4 [2017/10/06] for i386
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling hello.pp
Linking hello.exe
21 lines compiled, 0.2 sec, 25296 bytes code, 1252 bytes data

03/10/2018  11:30 AM            31,232 hello.exe

C:\FPC\3.0.4\demo\text>hello
Hello world

C:\FPC\3.0.4\demo\text>


(SQLite Demo) - So much for the claim of dead code removal.
« Last Edit: March 10, 2018, 11:44:28 AM by John »

John

  • Hero Member
  • *****
  • Posts: 3249
Re: Free Pascal Compiler - Hello Linux 64
« Reply #7 on: March 10, 2018, 04:32:26 PM »
I know what I won't be using on Linux. 177 KB


jrs@jrs-laptop:~/fpc/demo/text$ fpc hello.pp
Free Pascal Compiler version 3.0.4 [2017/10/03] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling hello.pp
Linking hello
/usr/bin/ld: warning: link.res contains output sections; did you forget -T?
21 lines compiled, 0.1 sec
jrs@jrs-laptop:~/fpc/demo/text$ ls -l hello
-rwxrwxr-x 1 jrs jrs 176720 Mar 10 16:28 hello
jrs@jrs-laptop:~/fpc/demo/text$ ./hello
Hello world
jrs@jrs-laptop:~/fpc/demo/text$

chrisc

  • Guest
Re: Free Pascal Compiler
« Reply #8 on: March 10, 2018, 09:10:10 PM »
Pascal is a very old language! :-[

Why currently people are learning python?  I found nothing exiting about it as it
an interpretive language.

Josť Roca

  • Jr. Member
  • **
  • Posts: 78
Re: Free Pascal Compiler
« Reply #9 on: March 10, 2018, 10:14:05 PM »
Not older than C or Basic.

Aurel

  • Sr. Member
  • ****
  • Posts: 261
Re: Free Pascal Compiler
« Reply #10 on: March 10, 2018, 10:23:06 PM »
Quote
Why currently people are learning python?  I found nothing exiting about it as it
an interpretive language.

Is not problem because is interpreter ....problem is in promotion
it sucks on Windows - there is no winapi functions in windows version then you must use tcl/tk ..etc...
it is slow, all libs are in c++ ..mean oop.
pushed by big Google

>>>>>>>>>self.
there is a bright side ...
there are many examples around  and syntax is little bit similar to BASIC.
 ;D

Aurel

  • Sr. Member
  • ****
  • Posts: 261
Re: Free Pascal Compiler
« Reply #11 on: March 10, 2018, 10:43:37 PM »

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1856
Re: Free Pascal Compiler
« Reply #12 on: March 11, 2018, 03:00:09 AM »
Yet despite its age and unreasonably large executable size, Pascal is still pretty fast. Another plus is an amazing abundance of user controls "visual" Pascal usually offers OOTB. Had there been no VB6 that "spoiled" me back at the time, I would have probably chosen Delphi as my hobby dev platform.

That CodeTyphon thingy Aurel points to looks pretty decent for an IDE, I must admit.

IMO the ability to track user mods in real time and re-arrange transparently the project's existing code accordingly is what has always made the VB6 visual designer so attractive and outstanding amongst its competition. Could make a really worthy challenge for an indie developer to replicate that feature in their own implementations. :)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1856
Re: Free Pascal Compiler
« Reply #13 on: March 11, 2018, 03:48:12 AM »
... nothing exiting about it as it
an interpretive language.

That's a dangerous illusion. Stack-based byte code is almost as fast as unoptimized (or optimized for small size) static machine code emitted by C, C++, assembler & Co.

Another prominent feature of interpretative code is its ability to morph its own behavior in real time. Every decent interpreter features this or that variation of public run time Eval() function that's in fact an entry point to its entire "executable code" creation tool chain. Now imagine feeding an "appropriate" script via an internet connection to the user's box that has various Linuxoid interpreter Eval's all over the place. The script is able to easily morph an innocent looking "Hello world" sample into a monster roaming scot free on your private property.

It is not MS Windows that's prone, and susceptible, to virus writing. It is alien Linuxoid software packed with trojan backdoors up to its donkey ears that's in fact a menace to humanity on this planet. ;)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Aurel

  • Sr. Member
  • ****
  • Posts: 261
Re: Free Pascal Compiler
« Reply #14 on: March 11, 2018, 05:43:14 AM »
 
Quote
is not MS Windows that's prone, and susceptible, to virus writing. It is alien Linuxoid software packed with trojan backdoors up to its donkey ears that's in fact a menace to humanity on this planet. ;)

Yes MIke
I suspect that most malware is created on linux and distributed VIA linux scripts