ModernPascal

ModernPascal
Original author(s) 3F, LLC.
Developer(s) ModernPascal
Initial release 2000 (2000)
Stable release 2.0 / July 3, 2015 (2015-07-03)
Development status Active
Written in C, Object Pascal, Free Pascal, Turbo Pascal
Operating system OS X, Linux, Solaris, FreeBSD, OpenBSD, Microsoft 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. programming language. 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.

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 complete rewrite from scratch focusing on performance. 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.

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

program class_Example;

Uses
   strings;

Type
   HookRec=Record
      Name:String;
      Value:TStringArray;
   End;
   TSlim=Class
      Version:String;
      Container:String;
      Apps:TStringArray;
      Name:String;
      Middleware:String;
      Error:String;
      notFound:String;
      hooks:Array [0..5] of HookRec;
      Mem:Pointer;
      MemSize:Longint;
   End;
   TNotSoSlim=Class(TSlim)
      AnotherVar:String;
   End;
   TSomeOther=Class
      Happy:Boolean;
      Name:String;
   End;

procedure TSlim.Free;
begin
   with Self do begin
      FreeMem(Mem, MemSize);
      Writeln('Free: ',MemSize);
   End;
end;

procedure TSlim.Init; // constructor does not need to be published.
begin
   with Self do begin
      MemSize:=2048;
      GetMem(Mem,MemSize);
      Container:='none';
      Version:='2.6.1p';
      hooks:=[ ['slim.before',[]],
              ['slim.before.router',[]],
              ['slim.before.dispatch',[]],
              ['slim.after.dispatch',[]],
              ['slim.after.router',[]],
              ['slim.after',[]] ];
      TMethod(@Free):=[@TSlim.Free, @Self];
   end;
end;

procedure TNotSoSlim.Free; override;
Begin
   inherited;
   Writeln('AnotherVar layer: ',AnotherVar);
end;

procedure TNotSoSlim.Init; override;
begin
   inherited;
   TMethod(@Free):=[@TNotSoSlim.Free, @Self];
end;

procedure TSomeOther.Free;
begin
   // nada
end;

procedure TSomeOther.Init;
begin
   Self.Happy:=True;
   TMethod(@Free):=[@TSomeOther.Free, @Self];
end;

var
   inst:TSlim;
   inst2:TSlim;
   inst3:TNotSoSlim;
   inst4:TSomeOther;

begin
   Writeln('Testing...',1,2,3,' ',4);
   inst.Init;
   inst2.Init;
   inst3.Init;
   inst4.Init;
   inst3.AnotherVar:="Cool!";
   inst2.Version:='3.0';
   Writeln('v',inst.Version);
   Writeln('v',inst2.Version);
   Writeln('v',inst3.Version);
   Writeln('cont:',inst.Container);
   Writeln('a:',inst3.AnotherVar);
   Writeln('h:',inst4.Happy);
   inst.Free;
   inst2.Free;
   inst3.Free;
   inst4.Free;
end.

OUTPUT

Testing...123 4
v2.6.1p
v3.0
v2.6.1p
cont:none
a:Cool!
h:True
Free: 2048
Free: 2048
Free: 2048
AnotherVar layer: Cool!

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.

Hello World

ModernPascal be coded as a brief Pascal "Hello World".

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, 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

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.

Alternatives

Modern Pascal is close enough in syntax to consider the following as alternatives:

Languages

External links

Wikimedia Commons has media related to ModernPascal.
This article is issued from Wikipedia - version of the Monday, January 25, 2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.