ArticleslgStudy

science

Smart Pascal

Smart Pascal is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Smart Pascal rather than just read about it. In short: Smart Pascal is an Object Pascal programming language that is derived from Delphi Web Script and is adapted for Smart Mobile Studio for generating commercial JavaScript machine code. As a rapid application development (RAD) language, it contains a library of classes and components.

Key takeaways

  • Smart Pascal belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Smart Pascal to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Smart Pascal from memory before moving on to harder problems.

Reference excerpt

Smart Pascal is an Object Pascal programming language that is derived from Delphi Web Script and is adapted for Smart Mobile Studio for generating commercial JavaScript machine code. As a rapid application development (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. Compiled Smart applications can be executed in a modern HTML5-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 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, 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", display redraw synchronization, GPU-powered 2D and 3D sprites and WebGL.

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. The run-time library includes classes for RemObjects SDK, a remote procedure call framework along the lines of Microsoft RPC. JSON RPC and WebSockets 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 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)

Worked examples

Example 1 — a first encounter with Smart Pascal

Start with the simplest possible case. Write down what Smart Pascal claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Smart Pascal before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Smart Pascal ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Smart Pascal

In research
Smart Pascal appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Smart Pascal in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Smart Pascal is common in secondary-school and first-year university syllabi. It links to neighbouring topics HTML5, Programming languages, so understanding it makes those chapters shorter.
In everyday life
Look for Smart Pascal outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Smart Pascal in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Smart Pascal means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Smart Pascal out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Smart Pascal in simple terms?

Smart Pascal is an Object Pascal programming language that is derived from Delphi Web Script and is adapted for Smart Mobile Studio for generating commercial JavaScript machine code. As a rapid application development (RAD) language, it contains a library of classes and components.

Why does Smart Pascal matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Smart Pascal?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Smart Pascal.

Tags

  • HTML5
  • Programming languages

Keep exploring