Oxygen Basic

Information => Open Forum => Topic started by: JRS on March 09, 2018, 10:59:07 PM

Title: Free Pascal Compiler
Post by: JRS 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 (https://sourceforge.net/projects/freepascal/)

Open Source Project Web Site (https://www.freepascal.org/)
Title: Re: Free Pascal Compiler - SQLite
Post by: JRS 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>

Title: Re: Free Pascal Compiler
Post by: Charles Pegge 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? :)
Title: Re: Free Pascal Compiler
Post by: Mike Lobanovsky 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.)  ::)
Title: Re: Free Pascal Compiler
Post by: Charles Pegge 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!
Title: Re: Free Pascal Compiler
Post by: Mike Lobanovsky 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 (https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/understanding-visual-basic-syntax). ;)
Title: Re: Free Pascal Compiler - Hello World
Post by: JRS 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.
Title: Re: Free Pascal Compiler - Hello Linux 64
Post by: JRS 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$
Title: Re: Free Pascal Compiler
Post by: chrisc 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.
Title: Re: Free Pascal Compiler
Post by: José Roca on March 10, 2018, 10:14:05 PM
Not older than C or Basic.
Title: Re: Free Pascal Compiler
Post by: Aurel 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
Title: Re: Free Pascal Compiler
Post by: Aurel on March 10, 2018, 10:43:37 PM
If you wish try pascal try this:
http://www.pilotlogic.com/sitejoom/index.php/codetyphon
Title: Re: Free Pascal Compiler
Post by: Mike Lobanovsky 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. :)
Title: Re: Free Pascal Compiler
Post by: Mike Lobanovsky 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. ;)
Title: Re: Free Pascal Compiler
Post by: Aurel 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
Title: Re: Free Pascal Compiler
Post by: JRS on March 11, 2018, 02:07:19 PM
Quote
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.

Unless I'm using a known library or application under Linux, it better come with source that I can review before compiling and putting it to use. I can't do that under Windows. You have to count on 3rd part virus / malware protection vendors to do their pattern matching magic to tell you you're screwed.

I'm not interested in being attached to the end of Microsoft's leash.

Title: Re: Free Pascal Compiler
Post by: Mike Lobanovsky on March 11, 2018, 05:16:28 PM
John,

I didn't really intend to hurt your feelings with my previous message. But let's face the things the way they actually are. Practically all malware that can physically appear on a law-abiding Windozer or Macophage's box these days actually comes through the backdoors of the Internet -- the lame and lagging Linuxoid world of slowpoke browsers, home brewed string based markup "languages", and real time interpreted code Eval's.

There are certain issues a language developer must always think about way ahead of their user base. I can work miracles in 32 bits with my FBSL and especially with some custom builds I compile from my sources to explore or verify some cool ideas of mine that are still coming to my mind from time to time as afterthoughts. But I have always been very picky about what I'd allow to appear in my public builds. It wasn't that pesky BCX affair that aroused my awareness as to what I was doing and who I was teaming up with. That was actually a piece of cake to handle without resorting to heavy artillery. What really scared me the moment it was brought to my attention by someone I can't unfortunately recollect now was this (https://download.adamas.ai/dlbase/Stuff/VX%20Heavens%20Library/vge00.html).