Compile Object Pascal to JavaScript with Smart Mobile Studio

Here is an interesting project for Delphi developers: a compiler and IDE that takes your Object Pascal code and outputs HTML and JavaScript. 

image

Smart Mobile Studio, also known as OPJS (Object Pascal to JavaScript) is a project from Optimale Systemer AS, and supports not only the Object Pascal language. but also reusable components in true Delphi style. The goal is to bring Object Pascal programming to mobile platforms, using PhoneGap to wrap the generated code as a native application for iOS, Android or other platforms.

According to the developers, “The Smart object pascal dialect is more or less identical to Delphi 7”. That said, there are no pointers, and ASM blocks contain normal JavaScript instead of machine instructions. This enables use of JavaScript libraries such as JQuery from Smart Mobile code:

You can access native JS through an ASM section, create an instance of it to a variant, and then access its methods directly.

Smart Mobile Studio is currently in closed Alpha so not ready for most of us just yet. Note that there are other options for mobile development with Delphi, including Embarcadero’s official FireMonkey project which can be used with the Free Pascal iOS compiler. Embarcadero has promised its own compiler for IOS in a future version, as well as an Android option.

VN:F [1.9.18_1163]
Rate this post
Rating: 9.8/10 (4 votes cast)
Compile Object Pascal to JavaScript with Smart Mobile Studio, 9.8 out of 10 based on 4 ratings

Related posts:

  1. Adobe’s Falcon JS: Compile Flex code to HTML and Javascript
  2. Updated SQLite wrapper for Embarcadero Delphi (and Free Pascal)
  3. Visual Studio 2008 as a JavaScript editor
  4. Back to BASIC with NS App Studio for mobile
  5. Appcelerator has released Titanium Studio, IDE for cross-platform mobile development

7 comments to Compile Object Pascal to JavaScript with Smart Mobile Studio

  • Will Watts

    There’s more to be discovered about this technology (he writes lazily, hoping to encourage you to do the actual work ;-)).

    Here http://www.thedelphigeek.com/2012/01/first-steps-with-smart-mobile-studio.html is a longer article describing the system, which makes it clear that it is based on Eric Grange’s open source Pascal script interpreter DWScript http://delphitools.info/dwscript/

    As I am sure you know, Grange is the Brit writer of various interesting free Delphi tools, including an excellent sampling profiler, and he has done work http://delphitools.info/2011/12/29/synedit-performance-bragging-rights/ on the Synedit http://sourceforge.net/projects/synedit/ syntax highlighting editor, a fine Delphi component which suffers from a cobwebby SourceForge entry and no documentation. Presumably these other components also feed into Smart Mobile Studio.

    Meanwhile Elevate Software says it is independently working on something that looks similar http://www.elevatesoft.com/products?category=ewb The fragment that catches my eye on this page is: ‘This means that you can continue to leverage existing [Object Pascal] language skills and take advantage of the many optimizations that the compiler can provide over hand-coded Javascript solutions.’ Optimizations? What do they mean?

  • tim

    Excellent links, thanks Will.

    Tim

  • gary

    actually those offerings like quite primitive when compared to the likes of http://www.unigui.com and http://www.raudus.com both of which let you build an app which gets generated as a web app using the excellent extjs (now sencha) javascript UI framework.

    Gary

  • @Will: Brit? Me? ;-)

    @gary: different tech, unigui looks more like a form of desktop remoting, with the actual work still taking place on the server.

  • @gary: I think you are missing the point. Both raudus and unigui are server-side only. Which means you work in delphi and generate an .exe or .dll file which needs a server to actually do something. Smart generates javascript code that doesnt call the server. That is very, very different.

    There is also an infrastructure to think about, stuff like a runtime library, a component model and last but not least, an IDE that ties it all together. Eric has been doing his magic on the compiler side while i have done the RTL and the rest. People are already using it to code games, demos and put stuff on appstore.

    @eric: So brit eh? he he :)

  • Gary

    Understood guys but not sure why you want anything just client side. In nearly every scenario you are very soon going to need some form of a data persistence, i.e. a database so unless you have local storage its quite limiting.

    Unigui and Raudus are how you would build a webapp, you wouldnt do it solely with HTML, you would be using .net or php and leveraging server side data storage which is how all sites on the web operate.

  • We have local database support in the pipeline, using the built-in browser DB (sqlite). Remote databases are also in the pipeline, and connecting to a webservice is already done. So basically you can write an app using ordinary object pascal, with all the benefits that brings (typecasting, interfaces etc) and it spits out javascript.

    There are other factors involved also. The companies that have contacted us work with rich media, everything from e-book generation to web games and commercials. Coding a rich media banner using raudus/unigui is possible, but for a high-end website with tens of thousands of visitors per day – the server callbacks would quickly become the bottleneck.
    You want to animate and use all the effects of html5 without having to wait for the server to catch up.

    It is easier to add server support to a fully fledged javascript compiler and component model, than to add the latter to a server dependent system. People have avoided what we have done here because of the complexities involved. Coding a server based system would be much simples.

    And you can use php/.net/delphi or whatever server-side tech you wish. If you can send or accept JSon or XML, your home free.