ModernPascal

ModernPascal
Original author(s) 3F, LLC.
Developer(s) Modern Pascal Solutions, LLC
Initial release 2000 (2000)
Stable release
2.0 / July 3, 2015 (2015-07-03)
Written in Pascal, Object Pascal, Free Pascal, Turbo Pascal
Operating system OS X, Linux, Solaris, FreeBSD, OpenBSD, Windows DOS/32
Type CLI Server Scripting networking
License Proprietary
Website modernpascal.com

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

Modern Pascal provides a blocking I/O 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 IIS.

History

Modern Pascal was invented in 2000 by Ozz Nixon while also co-developing DXJavaScript with Alexander Baronovski. Ozz was inspired by the 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. Modern Pascal v1.1 was capable of running most Turbo Pascal (DOS) syntax. This was the last version using Variants internally as variable and code instances. Version 1.1 introduced support for built-in RTL units, allowing developers to extend the language grammar to support CRT/Display and TCP/IP Socket calls.

In 2005, Version 1.2 was released. Modern Pascal v1.2 was available for 64bit platforms, with native 64bit binaries and internal support for 64bit numbers and memory addresses.

In 2007, Version 1.3 was released. Modern Pascal v1.3 added cross-platform support for dynamic libraries, .so, .dylib, .DLL. This was the first version capable of developing native Windows GUI Applications, along with Linux Qt GUI Applications. By supporting external libraries the language was no longer limited to the command line or web server script engine role.

In 2008, Version 1.4 was released. Modern Pascal v1.4 had a fork internally called DECLAN DEC(isioning) LAN(gauge) for use in the credit and financial industry. Version 1.4 also introduced TDataset compatibility with the Borland Delphi compiler along with the ability to connect to databases via built-in ODBC support. This allows Modern Pascal to leverage almost all SQL database engines for Command Line and Web solutions.

In 2009, Version 1.5 was released. Modern Pascal v1.5 was a redesign of the parser phase Lexicon. This is the first version where Modern Pascal started to incorporate syntax from other popular languages like +=, -=, *-, /= from C/JavaScript. Version 1.5 was now available as a native Apache Module for Windows, Linux and OS X.

In 2010, Version 1.6 was released. Modern Pascal v1.6 incorporates more built-in RTL units: Ciphers, Compressions, Hashs. This version truly focused on migrating applications to web and needed built in support for common ciphers, hashes and compression algorithms used by RESTful applications.

In 2011, Version 1.7 was released. Modern Pascal v1.7 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 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 called Chaining in a slightly more modern style.

In 2013, Version 1.8 was released. Modern Pascal v1.8 introduced support for Delphi-like Classes, Smart Records, Unions and Self Instantiation. Version 1.8 was the first version where Modern Pascal started to truly become its own Pascal Dialect.

In 2014, Version 1.9 was built but not released to the public. Modern Pascal v1.9 was used to develop DevelopIP, a large scale public web site.

In 2015, Version 2.0 has begun. Modern Pascal 2.0 is a fork of lape. While previous versions were fast and efficient, they were not fast enough for some of the larger customers. Current benchmarks show v2.0 is processing over 100 million instructions a second - roughly 8 times faster than version 1.9, and much faster than Alternative Pascal script engines. July 2015, Modern Pascal 2.0 enters its final private Beta cycle. The team is actively porting code snippets and old applications to 2.0 and publishing the code on Github.

In 2017, Version 2.0 has been released to the public, it now includes native dBase III+, IV, V, VII, Clipper and FoxPro support. During the past 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.

Overview

Modern Pascal Command Line Interface allows you to create and run DOS like applications, using Pascal and the decades of free pascal source code, you can implement and run a wide range of business classes, and command utilities.

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

Modern Pascal CodeRunner allows you to create standalone networking tools, including web servers, email servers, chat servers. CodeRunner manages TCP communications for your code, even TLS/SSL. As a developer you simply focus on what happens after a connection is established.

Code Sample[3]

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

Because we can run Turbo Pascal syntax, the Hello world program of ModernPascal be coded the same as normal Pascal "Hello World".

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

ModernPascal also supports Brief Pascal, so you can execute statements without all the formality.

Writeln('Hello, World!');

Built-in Units

In Pascal speak, a reusable collection of methods is referred to as a Unit, other languages often call these modules or libraries. Modern Pascal has built-in units to handle display, environment calls like file system I/O, sockets for networking TCP, binary data (buffers), classes and objects, cryptography functions, data streams, regular expression, collections, logging, configuration files using ini, csv or sdf (similar to csv) formats, databases through ODBC, built-in dBase, Clipper and FoxPro, and other core functions.

Dependencies

Modern Pascal operates without requiring any third-party libraries. Modern Pascal 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 OS X 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 itself 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 highly 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, however, Modern Pascal has been tested on a base Dell laptop handling over 50,000 concurrent connections/scripts.

References

  1. "Modern Pascal | Public Wiki". WardCunningham. Retrieved 28 March 2016.
  2. "Evolution of Modern Pascal | Public Blog". All Nu.de. Retrieved 28 March 2018.
  3. "Code Samples | Modern Pascal Solutions, LLC". Modern Pascal Solutions, LLC. Retrieved 18 March 2018.
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.