Software:Modern Pascal

From HandWiki
Modern Pascal
Original author(s)Ozz Nixon
Developer(s)3F, LLC
Modern Pascal Solutions, LLC
Initial release2000; 24 years ago (2000)
Stable release
2.0 / February 26, 2020; 4 years ago (2020-02-26)
Written inPascal, Object Pascal, Free Pascal, Turbo Pascal
Operating systemmacOS, Linux, Solaris, FreeBSD, OpenBSD, Windows DOS/32
PlatformIA-32, x86-64
TypeCLI Server scripting networking
LicenseProprietary
Websitemodernpascal.com

Modern Pascal (sometimes stylized as ModernPascal) is a closed source, cross-platform, interpreter, compiler, and runtime system (environment) for command line, server-side and networking applications. Modern Pascal applications are written in Pascal and Object Pascal, and can be run within the Modern Pascal runtime on the operating systems Microsoft Windows, Linux, macOS, FreeBSD, Solaris and DOS/32. Its work is hosted and supported by the 3F, LLC and partner MP Solutions, LLC.

Modern Pascal provides a blocking I/O application programming interface (API) technology commonly used for operating system applications.

Modern Pascal CodeRunner contains a built-in library to allow applications to act as a Web server without software such as Apache HTTP Server or Internet Information Services (IIS).

History

Modern Pascal was invented in 2000 by Ozz Nixon while also codeveloping DXJavaScript with Alexander Baronovski. Ozz was inspired by the Borland Kylix project in 1999, where he met with Borland's Pascal Team and shared his programming language "Modern Pascal".[1] Ozz ported his commercial socket suite DXSock to Kylix then started developing Modern Pascal so he run pascal scripts on Microsoft Windows, Linux, and OS X.[2]

In 2002, version 1.1 was released. It could run most Turbo Pascal (DOS) syntax. It was the last version using Variants internally as variable and code instances. It introduced support for built-in RTL units, allowing extending the language grammar to support CRT/Display and TCP/IP Socket calls.

In 2005, version 1.2 was released. It was available for 64-bit platforms, with native 64-bit binaries and internal support for 64-bit numbers and memory addresses.

In 2007, version 1.3 was released. It added cross-platform support for dynamic libraries, .so, .dylib, .DLL. It was the first version able to develop graphical user interface (GUI) applications for native Windows, and Linux Qt. By supporting external libraries, the language was no longer limited to a command line or web server script engine role.

In 2008, version 1.4 was released. It had a fork internally called DECisioning LANguage (DECLAN) for use in the credit and financial industry. It also introduced TDataset compatibility with the Borland Delphi compiler along with the ability to connect to databases via built-in ODBC support. This allows leveraging almost all SQL database engines for command line and Web use.

In 2009, version 1.5 was released. It was a redesign of the parser phase Lexicon. It is the first version to begin including syntax from other popular languages like +=, -=, *-, /= from C and JavaScript. It was available as a native Apache Module for Windows, Linux, and OS X.

In 2010, version 1.6 was released. It incorporates more built-in RTL units: ciphers, compressions, hashs. It focused on migrating applications to web and needed built-in support for common ciphers, hashes, and compression algorithms used by representational state transfer (RESTful) applications.

In 2011, version 1.7 was released. It was a redesign of the Apache Module. From this release forward, Modern Pascal was no longer built into the Apache Module. Modern Pascal Celerity was introduced, inspired by the design of Adobe ColdFusion nTier back end to web servers. This means in a future release FastCGI, ISAPI, and even old CGI and NSAPI interfaces could be deployed. Version 1.7 also introduced an old Pascal 3.0 feature named Chaining in a slightly more modern style.

In 2013, version 1.8 was released. It introduced support for Delphi-like classes, smart records, unions, and self instantiation. It was the first version where Modern Pascal began to become a Pascal dialect.

In 2014, version 1.9 was built but not released. It was used to build DevelopIP, a large scale public website.[3]

In 2015, version 2.0 was begun. It is a fork of lape. While prior versions were fast and efficient, they were not fast enough for some larger customers. Benchmarks then showed v2.0 can process over 100 million instructions a second, roughly 8 times faster than version 1.9, and far faster than alternative Pascal script engines. July 2015, version 2.0 entered its final private Beta cycle. The team ported code snippets and old applications to 2.0 and published the code on GitHub.

In 2017, version 2.0 was released. It includes native dBase III+, IV, V, VII, Clipper, and FoxPro support. During the 24 months of development, 3F has ported to GitHub, Source to 17 BBSes (including QuickBBS, TPBoard, Hermes), BinkP (Fidonet) Protocol, multiple Tossers, Adventure Game Studio (1984), Custom Micro Solutions, Inc. Accounting and Point of Sale Software, Web RIA Applications. 3F also introduced transparent support for Extended ASCII, ANSI, and UTF8 graphics.

In 2018-2019, Included native access to Premier SQL Middleware server. Extended the video and communications unit to translate CodePage 437 8bit characters to UTF8 characters. Added support for ASPELL and deployed Linux, Mac and Windows binaries on github.

Overview

Modern Pascal Command Line Interface allows creating and running DOS-like programs, using Pascal and decades of free source code, for a wide range of business classes, and command utilities.

Modern Pascal Celerity allows creating programs similar to stand-alone middleware or a backend engine. Combined with the Apache Module, Celerity can be used to create a wide range of web script programs.

Modern Pascal CodeRunner allows creating standalone networking tools, including web servers, email servers, and chat servers. CodeRunner manages Transmission Control Protocol (TCP) communications for code, even Transport Layer Security (TLS, formerly Secure Sockets Layer (SSL)). For development, simply focus on what happens after a connection is established.

Code sample

Here is a code sample for the game Loot:[4]

program Game.Loot.Example;

uses Math;

const
MaxProbability=1000;

type
   LootType=(Bloodstone, Copper, Emeraldite, Gold, Heronite, Platinum,
             Shadownite, Silver, Soranite, Umbrarite, Cobalt, Iron, Nothing);
   Looter = Class
      Probabilites:Array[0..12] of Longint;
      Choose:private function:LootType of object;
      AsString:private function(l:LootType):String of object;
   End;

function Looter.Choose:LootType;
var
   Loop,randomValue:Word;

Begin
   randomValue:=Random(MaxProbability-1);
   Loop:=0;
   While Probabilites[Loop mod 13]<randomValue do Inc(Loop);
   Result:=LootType(Loop mod 13);
End;

function Looter.AsString(l:LootType):String;
Begin
   Case l of
      Bloodstone:Result:='Bloodstone';
      Copper:Result:='Copper';
      Emeraldite:Result:='Emeraldite';
      Gold:Result:='Gold';
      Heronite:Result:='Heronite';
      Platinum:Result:='Platinum';
      Shadownite:Result:='Shadownite';
      Silver:Result:='Silver';
      Soranite:Result:='Soranite';
      Umbrarite:Result:='Umbrarite';
      Cobalt:Result:='Cobalt';
      Iron:Result:='Iron';
      Else Result:='';
   End;
End;

procedure Looter.Free;
Begin
End;

// Must be listed after all other implementation //
procedure Looter.Init;
Begin
   Randomize;
   with Self do begin // used to link methods to instance!
      Probabilites[0]:=10;
      Probabilites[1]:=77;
      Probabilites[2]:=105;
      Probabilites[3]:=125;
      Probabilites[4]:=142;
      Probabilites[5]:=159;
      Probabilites[6]:=172;
      Probabilites[7]:=200;
      Probabilites[8]:=201;
      Probabilites[9]:=202;
      Probabilites[10]:=216;
      Probabilites[11]:=282;
      Probabilites[12]:=MaxProbability;
      // to avoid RTTI/VMT overhead:
      TMethod(@asstring) := [@Looter.AsString, @self];
      TMethod(@choose) := [@Looter.Choose, @self];
      TMethod(@free) := [@Looter.Free, @self];
   End;
End;

var
   loot:looter;
   n:longint;

begin
   loot.init;
   for n:=0 to 99 do Writeln(Loot.AsString(Loot.choose));
// for n:=0 to 99 do Writeln(Loot.choose); {this used built-in macro to convert Enum to String}
   loot.free;
end.

OUTPUT

Shows a random list of loot that could be found while navigating a maze/map game.

Replaced the original code sample with something that is easier to read/follow.

Hello World

Modern Pascal can run Turbo Pascal syntax. Thus, the Hello world program be coded as in normal Pascal "Hello World".

program HelloWorld;
 
begin
   Writeln('Hello, World!');
end.

Modern Pascal supports Brief Pascal, so statements can be executed with less formality.

Writeln('Hello, World!');

Built-in units

In Pascal nomenclature, a reusable set of methods is termed a Unit, other languages often call these modules or libraries. Modern Pascal has built-in units to handle display, environment calls like file system input/output (I/O), sockets for networking TCP, binary data (buffers), classes and objects, cryptography functions, data streams, regular expression, collections, logging, configuration files using ini, comma-separated values (CSV) or SDF (similar to CSV) formats, databases through Open Database Connectivity (ODBC), built-in dBase, Clipper and FoxPro, and other core functions.

Dependencies

Modern Pascal operates with no need for third-party libraries. It can optionally require OpenSSL to achieve TLS–SSL listeners and clients.

Files included

  • Modern Pascal Commercial Compiler: mpc (Windows: mpc.exe)
  • Modern Pascal Command Line Interface: mp2 (Windows: mp2.exe)
  • Modern Pascal RTL Engine (for compiled scripts): mpx (Windows: mpx.exe)
    • On macOS and Linux(es) the compiled script contains !#/bin/mpx to self run
  • Modern Pascal Celerity: celerity2 (Windows: celerity2.exe)
  • Modern Pascal Apache Module for Celerity: mod_pascal.so (Windows: mod_pascal.dll)
  • Modern Pascal CodeRunner: coderunner2 (Windows: coderunner2.exe)

Threading

Modern Pascal operates using a single thread model, using blocking I/O calls. Celerity and CodeRunner are self-threading engines allowing Modern Pascal to support tens of thousands of concurrent connections. The design of a single thread for each instance of code means it can be used to build reliable applications. The design goal of a Modern Pascal application is that any skill level of programmer should be able to operate without fear of memory leak, variable collision between threads, etc. This approach allows for scaling with the number of CPU cores of the machine it is running. The negative of this approach is the increase in thread switching contexts. Modern Pascal has been tested on a base Dell laptop handling over 50,000 concurrent connections or scripts.

References

External links