Smart Pascal
   HOME

TheInfoList



OR:

Smart Pascal is an
Object Pascal Object Pascal is an extension to the programming language Pascal (programming language), Pascal that provides object-oriented programming (OOP) features such as Class (computer programming), classes and Method (computer programming), methods. T ...
programming language A programming language is a system of notation for writing computer programs. Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
that is derived from Delphi Web Script and is adapted for Smart Mobile Studio for generating commercial
JavaScript JavaScript (), often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. Ninety-nine percent of websites use JavaScript on the client side for webpage behavior. Web browsers have ...
machine code In computer programming, machine code is computer code consisting of machine language instructions, which are used to control a computer's central processing unit (CPU). For conventional binary computers, machine code is the binaryOn nonb ...
. As a
rapid application development Rapid application development (RAD), also called rapid application building (RAB), is both a general term for adaptive software development approaches, and the name for James Martin's method of rapid development. In general, RAD approaches to ...
(RAD) language, it contains a library of classes and components. The Smart Pascal compiler is a source-to-source compiler generating server-independent applications which are compliant with
HTML5 HTML5 (Hypertext Markup Language 5) is a markup language used for structuring and presenting hypertext documents on the World Wide Web. It was the fifth and final major HTML version that is now a retired World Wide Web Consortium (W3C) recommend ...
. Compiled Smart applications can be executed in a modern
HTML5 HTML5 (Hypertext Markup Language 5) is a markup language used for structuring and presenting hypertext documents on the World Wide Web. It was the fifth and final major HTML version that is now a retired World Wide Web Consortium (W3C) recommend ...
-capable browser. A compiled program is then typically embedded within a DIV container element or alternatively set to occupy the entire display.


History

Smart Mobile Studio, designed by Jon Lennart Aasenden and Eric Grange, is published by software company Optimale Systemer. It uses Delphi Web Script, an
open-source Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use and view the source code, design documents, or content of the product. The open source model is a decentrali ...
scripting engine, for syntax verification and parsing. On 18 May 2012, Optimale Systemer disclosed that it had acquired the rights to a custom code generator written by Eric Grange, the maintainer of Delphi Web Script, from his company, Creative IT. Eric Grange introduced anonymous classes in Smart Pascal starting from version 1.0.


Prototype

The first prototype was released on 20 December 2011. The project received full two-page coverage in ''Blaise Pascal Magazine''. The run-time library grew to include support for Remobjects SDK and Embarcadero Datasnap. From version 2.0, Smart Pascal also supported NodeJS, Web Workers and the Espruino microcontroller platform.


Linguistic differences


''Property'' expressions

In Object Pascal, a ''property'' is an exposed value that can either be linked to a class-field or a class-member method. The consumer does not know if the property is explicitly linked to a field or a writer method. Smart Pascal introduces a technique called "property expressions". It allows the user to program reader and writer logic as a part of property declarations. The Smart Pascal IDE built
object-oriented Object-oriented programming (OOP) is a programming paradigm based on the concept of '' objects''. Objects can contain data (called fields, attributes or properties) and have actions they can perform (called procedures or methods and impleme ...
, modular applications designed to live in an HTML document. Separate windows can be populated with controls, and code events can be connected to these to respond to user activity. Smart Mobile Studio does come with a visual form designer and ''property'' editor. The Smart Pascal run-time library has full support for creating CSS3 styles, "
tweening Inbetweening, also known as tweening, is a process in animation that involves creating intermediate frames, called inbetweens, between two keyframes. The intended result is to create the illusion of movement by smoothly transitioning one image in ...
", display redraw synchronization, GPU-powered 2D and 3D sprites and
WebGL WebGL (short for Web Graphics Library) is a JavaScript Application programming interface, API for rendering interactive 2D and 3D graphics within any compatible web browser without the use of plug-in (computing), plug-ins. WebGL is fully integra ...
.


Database access

The engines WebSQL, IndexedDB and WebStorage API are supported. The Smart IDE also allows access to Embarcadero DataSnap, which is a remote-data-access framework. Using these import libraries allows Smart Pascal applications to read, write and update remote datasets. Smart Pascal is itself written in
Embarcadero Delphi Delphi is a general-purpose programming language and a software product that uses the Delphi dialect of the Object Pascal programming language and provides an integrated development environment (IDE) for rapid application development of desktop ...
. The run-time library includes classes for RemObjects SDK, a remote procedure call framework along the lines of Microsoft RPC. JSON RPC and
WebSocket WebSocket is a computer communications protocol, providing a full-duplex, simultaneous two-way communication channel over a single Transmission Control Protocol (TCP) connection. The WebSocket protocol was standardized by the Internet Engineering ...
s are likewise part of the class library. Array operations were added to the Smart Pascal syntax to better adapt to JavaScript. Smart Pascal has a ''built-in'' for all arrays, as long as the datatypes match.


Anonymous classes

In traditional Object Pascal, all classes inherit from a root type called ''TObject''. This was also the case for Delphi Web Script. To import JavaScript classes, the dependency on TObject as the root of all class types needed to be modified. This allows the user to define a class as ''external'', and classes written in JavaScript that match the interface can thus be created and used alongside those written in Pascal. Anonymous classes can also be used as lightweight objects.


Limited support

The anonymous method was introduced in Smart Pascal as a means to improve compatibility with JavaScript. Under native Pascal, users have ''class procedures'' and ''ordinary procedures''. The only difference between these two is that if the user wants to reference a class method, they must append "of object" to its declaration. The compiler does not allow you to reference an object method without "of object" being clearly defined. Partial classes are yet a feature that has not made it into the Object Pascal standard. Smart Pascal supports two declaration formats of partial classes. The RemObjects Oxygene Pascal syntax and also the "type mytype = partial class(ancestor type)" variation. In Pascal, a ''set'' is a collection of elements of the same type. The Smart Pascal syntax currently supports only sets of enumerations with the "in" operator and "include(aSet, aValue)" or "exclude(aSet, aValue)" methods. Smart Pascal does not support generics. The original syntax of Delphi Web Script Smart Pascal derives from was compatible with Delphi 7.
Run-time type information In computer programming, run-time type information or run-time type identification (RTTI) is a feature of some programming languages (such as C++, Object Pascal, and Ada) that exposes information about an object's data type at runtime. Run-time ...
is inpart supported by DWScript, including the ability to enumerate properties and class members. RTTI is implemented by the Smart Pascal JavaScript compiler if the "Emit RTTI information" is defined in the Project's Compiler options.


Sources


The Delphi Web Script source repository

Programming blog of Jon Lennart Aasenden

Website of Eric Grange


External references


Article on how to use Smart Pascal with Cordova (previously: Phonegap)
{{JavaScript HTML5 Programming languages