Smart Mobile Studio
  • News
  • Forums
  • Download
  • Store
  • Showcases
    • Featured demos
    • The Smart Contest 2013, Round 1 – Graphics
  • Documentation
    • Get the book
    • System requirements
    • Prerequisites
    • Getting started
      • Introduction
      • Application architecture
      • The application object
      • Forms and navigation
      • Message dialogs
      • Themes and styles
    • Project types
      • Visual project
      • Game project
      • Console project
    • Layout manager
    • Networking
      • TW3HttpRequest
      • TW3JSONP
      • Loading files
  • About

Category Archives: News and articles

New features, Smaller updates, Smart Mobile Studio, CSS, Animations, HTML5, Javascript, General programming

SPNG: Be informed when values change

Posted on 08.04.2017 by Jon Lennart Posted in Developers log, News, News and articles 2 Comments

There are many new and powerful features in the upcoming release of Smart Mobile Studio (also refered to as Smart Pascal, Next Generation: SPNG in short): One of the most powerful is the ability to be notified when a value or object changes with a single line of code.

So far TVariant has just been a helper class for dealing with typical tasks. Well, perhaps not just typical because under Smart Pascal, variants can map directly to a javascript object (of any type) and allows you direct access to its prototype. The Handle property that all visual controls have is an example of this. The type TControlHandle is actually a reference to the visual element inside the DOM (document object mode). So by accessing that directly in your code, you can change styles, attributes and properties of that element. You are not bounds to only use our pre-fabricated solutions.

In the next update TVariant have a lot of new members. Two that stands out as important: watch() and unwatch().

As their name imply they will warch something for you. In this case you wil be notified whenever a single property, a whole object or indeed – a property deep within an object is altered. It may sound trivial but it’s actually one of those features that lays the foundation for responsive, data-aware controls.

But you can use it for many other things as well. For example you can now attach an event directly to a string. And whenever that string changes (either by your code, the user, or some other script) you can act on it directly. That is pretty cool and very helpful!

  // create an empty javascript object
  var MyValue: Variant := TVariant.CreateObject();

  // Set a default value
  MyValue.NewProperty := 12; // add a property and set a value

  // We want to know when the object changes
  TVariant.Watch(MyValue, "NewProperty", procedure ()
    begin
      showmessage("You changed the value!");
    end);

In this snippet we setup a javascript object and place a named-property inside that object. We then listen for changes to that property (by name even). So if you change that value further down in the code, or by calling some procedure elsewhere – the event will fire and show the message dialog.

This is of-cource just a tiny fragment of the new code that has been added, not to mention the changes and fixes. Some of these features are presently in alpha stage and is being tested. We will post more and more news in the days and weeks ahead – and we are sure you will be pleased with some the fantastic new things you can now code!

Here is an example of the new desktop and windowing applications you can write (picture below): The smart desktop!

The Smart desktop

We decided to update the uartex Media Desktop, an example initially made for touch based embedded environments – and turned it into a fully functional desktop environment!

Both the desktop itself, the filesystem, the IO drivers and windowing toolkit is written in Smart Pascal. You can create kiosk software designed to run on embedded devices, advanced applications designed to run on your intranet – or full cloud systems. So it can run a Smart application inside each Window if you like. But you have full control over windows, file access, directly listings, menu items and can sculpt both the desktop and applications to suit your needs.

The desktop can be coupled with a node.js backend that handles multi-user login and file access. It gives your users access to designated home-folders (again under your control). So each user can have their own work files just like a thin client, and each user can run different applications from a fully working desktop environment.

Below you are seeing Quake II compiled from C/C++ to LLVM bitcode. This is in turn compiled to JavaScript via asm.js. This means the browser will compile the javascript into machine code after loading. So Quake II runs at native speed, all JavaScript, inside our desktop window.

Create windowed applications with Smart Desktop

Create windowed applications with Smart Desktop

You will also be happy to head that x86 Linux and ARM kiosk distros have been created. So once happy with your desktop you can in fact boot straight into it in fullscreen. No Linux desktop or shell — just your desktop running. Both Firefox and Chrome can be used as presenter.

Have a great easter!

announcement code demo HTML5 javascript Object Pascal OP4JS release Smart Mobile Studio Upcoming features

Compiler options explained

Posted on 09.04.2016 by Smart Mobile Studio Team Posted in Developers log, News and articles 1 Comment

CompilerOptionsIn the forums there was a post about a detailed description of the compiler options. Since there are currently no in-depth information available this post tries to clarify the topic a bit.

Continue reading→

Compiler options

Source map clean-up with Cordova

Posted on 05.04.2016 by Smart Mobile Studio Team Posted in Developers log, News and articles

Source maps are a very powerful way to support the debug process of HTML5-based web-apps. It actually maps the JS code to the higher level language (in this case Object Pascal). While this is very handy, especially in combination with obfuscation, it also reveals how the software is build internally. Thus you probably don’t want it to be shipped to customers.
Continue reading→

build script clean-up Cordova node.js Source maps

Writing Node.js command-line tools

Posted on 23.01.2016 by Smart Mobile Studio Team Posted in Developers log, News and articles

NodeSmartIn the last article we have focused on how to use Cordova to build hybrid web applications with Smart Mobile Studio. In this article we focus about writing Node.js command-line tools (like Cordova) itself in Smart Mobile Studio.

Continue reading→

command-line node.js npm tool

Hybrid Web-Apps with Cordova

Posted on 19.01.2016 by Smart Mobile Studio Team Posted in Developers log, News and articles

CordovaAbout two years ago a detailed article about how to use Cordova has been published here. As times are changing quickly, an update for this becomes necessary. This article is about building hybrid web-apps with Cordova with Smart Mobile Studio.

Continue reading→

Android Chromium Cordova Hybrid Web-App icons node.js w3C

Nullable types

Posted on 16.01.2016 by Smart Mobile Studio Team Posted in Developers log, News and articles

JavaScript – in contrast to Object Pascal – is a dynamic language. Beyond dynamic type checks, this also means that it can be extended at runtime. Thus, variables and with this fields of prototypes may only be present (accessible) when they have been set first. In external JavaScript libraries, these are typically initialized or set, but not necessarily. And sometimes it is even intentional to leave them unset.

Continue reading→

DSharp DWScript javascript Nullable types Object Pascal

Using external JS libraries with Smart Mobile Studio

Posted on 15.01.2016 by Smart Mobile Studio Team Posted in Developers log, News and articles
Neuron groups, ZEISS-Microscopy, CC

Neuron groups, ZEISS-Microscopy, CC

In the forums there was a discussion about how to wrap existing libraries transparently and with a minimum of overhead. In that discussion an example was given about how to wrap the neural network library brain. To avoid posting the same text here as well, this blog post is about translating another neural network library called ‘Synaptic‘.

Continue reading→

HTML5 javascript Neuronal Networks Object Pascal

Global rename function

Posted on 17.02.2012 by Jon Lennart Posted in Developers log, News and articles 6 Comments
Global rename done

Global rename done

Being able to rename a unit via the project treeview is commonplace in mid to high range editors today. There are a lot of javascript editors out there, some more evolved than others – but the number of object pascal editors is sadly very limited. You have Delphi of-course which is great (and the most advanced object pascal editor on the marked), then there is Lazarus which is the free and open version written in freepascal – and while there are other alternatives, none of them even comes close to the original “Delphi” look and feel.

Believe it or not but this time Smart Mobile Studio actually got something Delphi doesn’t (Delphi 7 was our initial model): global renaming. When you rename a unit under Smart, it doesn’t just alter the source-code for the unit in question – it alters all references to that unit in the entire project. No need to backtrack and update the uses declaration elsewhere, they are all changed in a single sweep.

We can actually map the use of a class or method throughout a whole project, and it’s super quick as well!

Database mapped RTL

But we have more tricks up our sleeve. I took the time to make a recursive database indexer for our RTL files. So the first time you run Smart it will parse and extract every inch of information about the RTL and store it in a database table. This table is kept in memory and used to speedup extraction of data regarding classes, methods and properties.

It also has the benefit of giving me instant access to things like class ancestors, data types, fields, scope, interfaces and all those tiresome look-up chores that makes a mess of a codebase. So armed with a TClientDataset map (what did you expect? No self respecting Delphi app is complete without at least one instance of TClientDataset) of the RTL, it is now super easy to beef up and compliment the compiler. On top of my head here are a few things i’m gunning for:

  • Complete class at cursor
  • Rename class at cursor
  • Add interface to class
  • Merge classes
  • Support for documentation remarks above methods
  • Mouse-over information about symbols

I doubt we will be able to stuff all the goodies into version 1 of Smart Mobile Studio, but rest assured that I will do my best to get as much features into Smart as I can.

Globals

And now that the indexing and background compile is up to speed, the time has come to finish the globals feature. Globals allows you to edit a list of object (of any class) that should be created automatically by TApplication. Very handy if you have a database connection or some game logic you want to be created on startup.

These are exciting days!

Smart Mobile Studio Upcoming features

What can Javascript do?

Posted on 10.02.2012 by Jon Lennart Posted in News and articles
Would you believe its 1k of source?

Would you believe its 1k of source?

A lot has changed since the average programmer had a stab at javascript. As a Delphi developer I played around with it roughly 10 years ago (when everyone was doing scrollers, pop-up windows and the “dark side” of javascript) but a couple of years ago I realized that browser technology had come of age. And thus Smart Mobile Studio was born.

To give people a taste of what modern javascript can do I want to share a link to the JS1K website, which holds a “yearly” competition for the best javascript demos (using the canvas tag). The rules are simple: stuff as much graphical bliss as you can into 1k of source-code. The best effect and technique get’s the price.

My favorite is without a doubt: http://js1k.com/2010-first/demo/171 but all the demos on the website are really spectacular. Especially considering the size of the sourcecode.

So head over to JS1k and have a look!

And who needs webGL when we have hardware acellerated 3d transformation in webkit? Check out Sprite3d (note: requires a webkit browser, like Safari or Chrome) which we aim to wrap for Smart Mobile Studio in v1.2. Here is Mario Cart written in javascript and HTML5.

javascript

Understanding smart

Posted on 08.02.2012 by Smart Mobile Studio Team Posted in News and articles
Compiler technology

Compiler technology

First, we are extremely grateful for all the positive feedback and questions regarding Smart Mobile Studio! We cannot underline enough how the enthusiasm really makes us work that much harder to deliver a knockout product that will serve the community for a long time. It is indeed clear that we have hit “bulls eye” and a serious gap in the modern programming model can now be filled. We are equally excited to that the emails stem from every corner of the software developing world, from the Delphi community, the C# community and believe it or not -the javascript community itself.

This is quite possibly the most significant Pascal
development to be watching right now, and brings
the wonderful Pascal language to the world of
Internet development! -Simon Stuart, Delphi developer via Google+

Since so many people have asked more or less the same questions, it would be a good idea to outline just what Smart is and what it does, so that people can appreciate even further the depth and broad application of what we are building and what we hope to achieve.

The compiler

Like all code generating systems, the Smart compiler knows only a handful of things. It knows how to handle units (source files), procedures, classes, enumerations, assignments and other important language features. But on it’s own the compiler have no “built in knowledge” of neither what a browser is or what a control looks like. A compiler and code generator is a very complex piece of software that is able to take your source-code, break it down and transform it into something else. Which is javascript in our case. But it could equally have been machine code or C#.

Beginners will discover a language that has withstood
the test of time with unparalleled elegance.

This is where Smart differs radically from a lot of the other products on offer, namely that its built from the ground up to be “real”. Where other HTML5 products out there have a fixed set of classes, and knowledge of what you are allowed to do is pre-determined by the vendor – Smart has more in common with a classical C++ or Object Pascal environments where you are in charge.

The VJL

Just like in Delphi

Just like in Delphi

As you should expect, all the components and classes that ship with Smart was actually coded in Smart itself. We also ship the source units for our RTL (called the visual javascript library, or VJL in short) so that people can examine, learn and also make changes if they want to.

The underlying [RTL] work must have been tremendous -Michael Thuma, Delphi developer via Google +

You could in fact replace the entire RTL with your own version if you so desired. And that is something that no other mobile development studio on sale today can match. They all come with a predefined set of classes, and in the majority of cases these are closed API’s. Meaning that you dont have access to the source.

Smart blows this to pieces just like Borland Delphi once did. While the list of classes you get for free out of the box is to large for this document, the most noteworthy are:

  • TW3Component and TW3CustomControl
  • Full implementation of HTML5’s canvas
  • CSS animation classes
  • Font and bitmap handling, both on-screen and off-screen
  • Buffer classes and buffer-view classes, painstakingly implemented from the WC3 standard
  • Form classes, TApplication and smooth scrolling when navigating between forms
  • Timers, style mapping and much much more

And of-course, with a real compiler you can create as many classes and components as you wish. And you don’t have to be a javascript guru to do so. All you need is some basic understanding of object pascal and you are set to go.

Boundless possibilities

Just like you can create anything under the sun with Delphi, C++ builder or C# due to the fact that these environments have a real compiler – you can create anything you like with Smart Mobile Studio. Smart both compiles to and can interface directly with javascript – which means that whatever javascript can do, Smart can do.

Cool! I created my first OP4JS control: a DHTMLX grid
-André Mussche, Delphi developer via Google +

Smart Mobile Studio, early Alpha

Smart Mobile Studio, early Alpha

It is by definition impossible to say what people will use Smart for. So far people have created games with it, connected to remote web-services, displayed database grids, added control bindings, created fantastic fractal explorers and much, much more. Just like Embarcadero ignited a firestorm of creativity on the Windows platform – our aim is carry that fire into the next frontier which just happens to be the browser.

So the question is not really if Smart Mobile Studio can support feature X. If you can sculpt it in either JavaScript or Object Pascal, then Smart can support it. We will provide you with the Visual Component Library and all the tools you need to create and interact with HTML5 and the latest web developments. We will also work hard to provide you with a standard set of components – but also give you the option to extend our technology with your own packages and components.

Nothing is impossible

Smart Mobile Studio is a vision and an idea. An idea brought to the table by Jon Lennart Aasenden, and embraced by the management at Optimale Systemer AS and a some key developers in the Delphi community. It was by many said to be impossible, if not heretical. When we presented the concept for the general public back in December 2010, it was met by applaud from the few and ridicule by the many. To make it a reality we have worked extremely hard, considering the technical difficulties involved.

Right before Christmas we shipped the first Alpha version, and some smart programmers of the Delphi community immediately created some stunning demos and thus proved the concept right.

And now, in February of 2012, the product has matures further, and we can proudly say that the vision has become a reality.

This tool should really get a place be in every Delphi developers toolbox.

 

Sincerely

The Smart Mobile Team

HTML5 javascript Pascal Smart Mobile Studio

What can smart offer me?

Posted on 06.02.2012 by Jon Lennart Posted in News and articles

Smart Mobile Studio has a lot to offer modern developers. If you are looking for a way to maximize the potential of the HTML5 platform then Smart has a recipe unlike any other on the market. No matter what industry or field of expertise you focus on – Smart provides benefits that saves time. It makes technological and financial sense.

Beginners will discover a language that has withstood
the test of time with unparalleled elegance.

Advertising

You need an edge in what you do

You need an edge in what you do

The world of advertising and content production operates with high demands. The market is constantly changing and the tools of the trade you have relied on for years – might not even be there tomorrow. Some vendors have consciously banned technologies like Adobe Flash in favour of HTML5 – which means you better start looking for a new method. A method which enables you to deliver quality content, on time, according to your clients expectations. Customers are simply not interested in flash banners any more.

Smart Mobile Studio allows you to take your HTML5 code to the next level. We provide a rich set of visual components ready for use out of the box. No fiddling with styles to get that native look, no experimental hacks to get it working and no shortcuts. This means you can spend your time focusing on delivering rich content and lasting impressions straight away.

As a bonus all your web skills remains relevant as ever before. Smart can interact with other frameworks and you can easily add your own, native javascript code.

With Smart Mobile Studio you finally have a tool that can deliver HTML5 friendly advertising with no dependencies. No plugins, no custom browser extensions needed. What you get is cutting edge javascript which runs incredibly fast.

Entertainment and multimedia

With touch based devices like the iPad (or the rapidly expanding Android based market) almost everywhere these days, the future of tablet based gaming and multimedia is golden. But moving code from a classical programming environment to the web requires time, patience and money. Javascript is a fantastic language that commands great power and potential, but compared to C# or Object Pascal you will find yourself cutting corners.

Browser games are getting more and more advanced

Browser games are getting more and more advanced

Smart Mobile Studio means you don’t have to cut corners. You get all the missing pieces of a real programming language, like actual object inheritance, variants, var parameters and interfaces. This means that converting already existing code from Visual Studio, Flash or C# to HTML5 is radically faster.

Finally you can focus on getting your game or multimedia app out there. Need an off-screen bitmap? No problem. Need a high speed drawing surface? No problem.

With Smart, creating online games becomes far easier because all the boring stuff is already done. You have classes for drawing graphics, both on-screen and off-screen. You get classes for communicating with your web service and you get a native looking GUI skin out of the box. Altering the look of your GUI is just a matter of editing a CSS style-sheet.

Business software

No matter if you are focusing solely on the mobile market or want to create dynamic browser applications, Smart will help you get started straight away. As a modern developer with a background in C#, C++, object pascal or java – first contact with the alien landscape of javascript is often a culture shock. It has been said that going from Delphi or Visual Studio to javascript is almost like trading in your PC or Mac for a Commodore 64.

Javascript can now deliver serious applications

Javascript can now deliver serious applications

As a language javascript has no support for OOP in the true sense of the word, no virtual methods, no abstract methods, no interfaces and absolutely no var parameters. These restrictions alone makes it very difficult to create and maintain large scale applications in native javascript. When we add the fact that you must create, or buy, a GUI framework on top of this, the financial aspects involved in “going native” can hardly be justified.

Smart Mobile Studio removes 2/3 of the challenge straight away. You get a language which is very popular, has a massive code-base the world over, is easy to learn (especially if you have OOP background) and which supports modern concepts like interfaces, classes, inheritance and other “must have” features. So instead of spending months learning in-depth javascript, circumventing it’s pitfalls through trial and error, buying a ton of books and basically re-inventing the wheel — You can pick up Smart and deliver a killer app in no time.

Smart will take your object pascal code (the same flavour as made popular by Delphi and Free-pascal) and compile it into cutting edge javascript. The compiler even sculpts the missing language features, like interfaces and inheritance, in javascript itself. So the generated code have no dependencies. You don’t need a plugin or browser extension at all. It will run “as is” in any webkit based browser (Chrome, Safari, Safari Mobile and more).

Further reading

  • What is Smart Mobile Studio
  • Understanding Smart
  • Take advantage of classical programming
  • Tired of handcrafting your javascript apps?
  • Documentation and sourcecode examples
HTML5 javascript Pascal Smart Mobile Studio

Tired of handcrafting your Javascript apps?

Posted on 01.02.2012 by Jon Lennart Posted in News and articles

Before we started developing Smart Mobile Studio we did a survey of the alternatives for developing mobile apps. That’s actually where the initial idea and motivation came from. During this survey we must have tested at least 14 different “app” machines, languages and “rapid” development environments. We tested the serious players like C++, object pascal, C# and Java – to the outright scams which usually include the phrase “create your app in a day” (but the app you get is just a template with no real value what so ever).

The result of our survey was disappointing to say the least. At the time, using Free-pascal to work with iOS was a bit of a black art so while that was our initial choice – any substantial information regarding cross compilation was virtually non existent, so we decided to go for C# in developing our iOS apps. This involved learning a new language, a new platform and to some extent a whole new way of thinking.

But one thing we did notice was that Javascript had come a long way. While all the native systems were struggling to get aboard the iOS and Android bandwagon – javascript was all over the place. Doing things it’s not supposed to do in classical terms. Everything from silky smooth animations to action packed platform games.

This is a snapshot from a game written in BlitzBasic which demonstrates what modern Javascript can do. We are old fans of Mark Sibly at Optimale Systemer!

Javascript can now do amazing things

To make a long story short we continued working in C# and object pascal, but as the idea behind cross compilation and using javascript as a medium began to grow, we found ourselves seeking out like-minded people, putting our ideas to the test. Unlike the “app machines” however, we did it properly from the ground up.

So the question is not if javascript works. The question is how to use that power properly.

Working with ordinary web technologies

When we took the time to look at javascript with new eyes, three things became apparent. First, browsers are not just page readers anymore but rather fully fledged multimedia environments. Secondly, Javascript has grown and can make use of the browser in a whole new way. And last but not least: javascript’s lack of structure is both it’s strength and it’s downfall.

Take something simple like a visual component. When you dig into the complexities of this simple task it turns out it’s not that simple after all. As of writing there exist no single standard between the different javascript frameworks on the marked. It is also highly unlikely that it ever will – because it’s not financially beneficial for these companies to work together. They would lose their uniqueness if they did, not to mention the technical difficulties getting two javascript frameworks talking to each other. When you use a framework you stick to it, mixing two different systems could in theory work – but in real life it quickly becomes a mess.

Classic remake of capcom streetfighter using gameQuery JS framework

Classic remake of capcom streetfighter using gameQuery JS framework

Encapsulation and portability of source is also an issue, not in terms of browser compatibility – but in terms of programmers sharing solutions. There are several ways a javascript developer can create the same thing – and the lack of a common approach (which classical languages solve by syntax, classes and a common foundation like the VCL) makes it extremely time consuming.

After we created a small demo/game in Javascript, testing out ideas and playing around with the multimedia features, it became crystal clear that it simply takes to much time to hand-craft large projects in javascript. You can use one of the many ready-made frameworks out there, but the amount of source code you need to write for a large game or application is ridicules.

So what is the alternative?

HTML5The alternative is not to ignore javascript, but rather to use javascript as a medium. What we did with Smart Mobile Studio was to transform a disadvantage into an asset. Javascript is the proverbial “wax that takes many forms”. We projected the rigid and time proven structure of object pascal onto the “everything goes” landscape of javascript. The end result is that you can now use the power of object pascal, it’s encapsulation, it’s class hierarchy, it’s true object inheritance and (thanks to our super clever compiler guru Eric Grange) even fancy concepts like interfaces, closures and var parameters. So not only do you get the power of javascript – you also gain the wisdom and experience of more than 18 years of pascal evolution (not to mention the object pascal community which is a living genius factory).

With a few hundred lines of pascal code you can achieve what it would require thousands – if not tens of thousands lines of javascript to match. But the central strength of pascal is that of scope and size. A large object pascal code-base can be maintained due to the architecture of the language. The same project in “native” javascript terms would be nearly impossible to keep track of. The time and cost involved in developing and maintaining a 200.000 lines long javascript project cannot be justified when you can achieve the same with 20.000 lines of pascal. Object pascal was designed to handle large projects. Javascript was not.

So. Are you tired of spending days hand-crafting javascript that could be delivered in hours?

javascript Pascal Smart Mobile Studio

Taking advantage of classical programming

Posted on 31.01.2012 by Jon Lennart Posted in News and articles
10.000 lines of javascript can be hard to maintain

Javascript can be hard to maintain

Let’s face it, Javascript is both a powerful and flexible language, but developing and maintaining large scale projects in a dialect not really designed for it is frustrating. The reason javascript libraries like jQuery, jQTouch and Sencha have remained more or less unrivaled for years now – is first and foremost because of the monumental effort involved.

The key factor itself have to do with the actual language. Javascript is a fantastic language, but sadly it lacks many of the traditional programming concepts native to languages like C++ and object pascal. Concepts like classes, true object inheritance, interfaces and type casting – techniques and technology created exactly for the purpose of making large frameworks manageable and robust.

Changing the game

With Smart Mobile Studio however you can take full advantage of these classical concepts. This is because our product allows you to write ordinary, classical object pascal (made famous by Delphi, Free-pascal or other incarnations of the language) and it’s instantly converted into super charged javascript.

The compiler at the heart of Smart generates javascript in a way that implements all the aforementioned technologies. So even if javascript itself doesn’t support concepts like interfaces, it is crafted by the compiler in javascript itself. And if you are worrying about speed – you will find that even with all these powerful and classical technologies – Smart Mobile Studio can run with the best of them. To make it plain: Smart does for the browser what Delphi did for the Windows platform.

You also get an IDE (integrated development environment) specifically designed for Smart programming

Write pascal, compile to javascript

Write pascal, compile to javascript

Easy to use, easy to learn and very rewarding

If you haven’t used pascal before then don’t worry. It was designed to be taught in school to students of object oriented software development. Chances are you have already used it yourself or have heard about Delphi or Free-pascal from a co-worker. Object pascal is responsible for hundreds of thousands of applications in the Windows world – and it’s still knocking out killer apps today.

Easy to use doesn’t make it a lightweight in terms of features however. Object pascal is fast, dynamic, robust and can do pretty much everything C++ can do.

With Smart you can now take your knowledge of classical programming one step further – into the domain of super fast HTML5 web applications. You can also use third party products like Phonegap and compile your generated web app into a real, binary executable program – ready for app-store. In fact, only hours after Smart was released to it’s testers, demo projects made it’s way onto the Android marketplace (!)

So what would you rather maintain? 10.000 lines of javascript code or 1000 lines of pascal code to achieve the same thing? Object pascal is a proven, tested by time and established language designed to handle large scale projects. Javascript is not. The benefits of using a compiler that generates javascript are just to great to ignore.

HTML5 javascript Pascal Smart Mobile Studio

Control complexity and mobile resource management

Posted on 04.10.2011 by Jon Lennart Posted in News and articles 2 Comments
This is not just a picture, but actually the background set for a picture

This is not just a picture, but actually a multi layered view. The buddha is a background for an image placeholder. Quite dynamic and neat

Products like Embarcadero Delphi comes with a rich set of controls ready for use in your applications. If we compare the resource demands of these controls today (Delphi XE or XE2) to those that once shipped with Delphi 1 – or Delphi 7 even, the amount of resources a well designed form consumes has grown exponentially over the years.

As the operative system was grown more complex both in terms for functionality, responsiveness, mobility and the developers need for modern features, the amount of methods and auxiliary classes connected to a single control has become very large. As a result, the amount of memory and CPU requirements have grown with it.

The mobile scene

One of my primary concerns when we sat down to talk about OP4JS control library was simply that it would be over-kill to even attempt to emulate the VCL under javascript. In my notes the primary points were:

  • The amount of JavaScript generated would exceed the restrictions of these devices
  • The HTML5 architecture is incompatible with classical VCL programming
  • The controls would be to slow for practical use

Thankfully my worries were unfounded on all accounts, because we have more or less built a VCL clone. It is and has been quite a challenge. As you may know HTML5 introduces a high-level interface onto ordinary html. It is different not so much in terms of syntax, but rather in philosophy, inspired no doubt by the MVC (model view controller) paradigm imposed on the world by Apple computers. In short, the CSS styling represents the “view” part, the actual html tags the “model” and Javascript the controlling factor. Javascript is what provides behavior to otherwise empty, stateless constructs.

Getting these things to even resemble the VCL has been, well, let’s just say I havent played with my kids in a few weeks.

Doing the math

CSS transitions and events

CSS transitions and events

Luckily, the complexity versus efficiency argument is turning in our favour. Delphi developers like myself have a tendency to over-think the actual needs of our customers, and inside our own heads we are always trying to outsmart other programmers that may – or in most cases – may not be going over our code with a fine tooth comb. This can either drive us to excel at what we do or into obsessive nerds that polishes a piece of code so long – that the platform is dead if he ever finishes.

So, once in a while it’s wise to do a sanity check on your code-base (and your own expectations). Fact is that mobile apps are for the most part quite lightweight. If we for sake of argument say that a mobile app has 10 forms (or views if you prefer) and each of these views is populated by 20 controls. Some controls are composite, meaning that they have child controls (like a toolbar which uses a buttons) while other are vanilla, run of the mill stuff like labels and lists. You may also have a database running under the hood as well.

Adaptable and suitable

So an app consisting of 200 javascript objects is really not that huge. It would result in quite a bit of generated code of-course, but the browser chews through this like it was nothing at all. And you wouldn’t even be close to the limitations set down by Apple or Google regarding size. Strange as it may seem – my test app written in Op4JS both loads and executes faster than it’s native counterpart written in C# (which compiles to a single binary on iOS). The only exception being complex graphics (which you would normally use a DIB library for) and heavy-duty number crunching. But those are things you don’t want to have on your phone anyways. It’s possible of-course, but not practical.

To me at least, mobile development is about information and communication and presentation. It’s about getting or storing data and presenting it on a portable device in a practical manner. It’s also about using the format in a way that makes sense to the consumer.

External resources

  • Model View Controller – Wikipedia article
  • C# Mono Touch – Xamarin website
  • HTML5, A vocabulary and associated APIs for HTML and XHTML, WC3 reference
  • Embarcadero Delphi website
HTML5 javascript Smart Mobile Studio

The elegance of Javascript

Posted on 24.09.2011 by Jon Lennart Posted in News and articles

Two year ago I used to laugh at Javascript, but the more I play with it these days, I find myself enjoying the experience. It cant be compared to Delphi on any level, but there are some features that just blows your mind. I find myself spending a lot of time in Besen, a javascript interpreter and bytecode compiler written in Delphi – just for the sheer fun of it.I like the way dynamic parameters (what we would call array of const) are implemented and that they remain hidden to the entrypoint. This allows you to do do a form of undercover overloading. Unless the method is aware of _the calling interface_ (not the other way around like we are used to) then it could support only a sub-set of the intended functionality. By patching the original function and chaining to it you basically can “emulate” overloading based on condition rather than explicit call. This opens up for some clever API designs.I love the ability to pick values based on conditions, but compacted into a single line without having to invoke a equating entity:[sourcecode language=”javascript”]someValue = (backwards ? (100-percent) : (percent-100)) + "%";[/sourcecode]Having said that there are some aspects of javascript that makes me ponder the collective wisdom of W3C. As a fail-safe i usually add an “if” section to thoughts like this, because otherwise mother nature will go out of her way to disprove me. I can only imagine the work of cleaning up after Netscape and Microsoft, trying to play ball with Opera while Webkit came sneaking in the back door.

Media mayhem

The factors are many, yet the organization of the latest HTML5 multimedia functions is neither fish nor foul. It’s not truly object(ive) in the C++/Delphi sort of way, nor is it linear like basic or old school pascal. It’s both, and none of them at the same time . which makes it difficult to set up generic rules that would apply everywhere in our object model. The only solution is to let go of what the W3C has marked as “legacy features”. Which is hard to do when they produce results so easily 🙂

Threading, security and overkill

Another feature that seems like overkill, is the javascript notion of threads (read: blue threads), referred to as web-workers in the W3C specs for HTML5 (actually better info on Apple’s docs for safari). Im not sure what i was expecting, but i was sort of hoping to use threads to crunch pixel data. You can do that, but you are unable to hook the reference since it runs in a different context.

  • All communication between a worker and the DOM is through a message pipe
  • The only datatype you can pass to and from is a blob
  • All bindings are late-binding
  • Worker code cannot reside in the main document

Thankfully I found a “loophole”, I’ll document it later – but it wont make it into OP4JS because it’s basically a hack. You can use TW3GlobalStorage (one of our classes) as a mirror cache for the data – and it’s actually faster than creating, populating and moving a blob into the thread context. Although it does require initialization ofcourse. But i suspect that loophole will be closed in the next release.

External references

  • Besen – SourceForge project page 
  • Web workers – W3C documentation
javascript

Pages

  • About
  • Feature Matrix
  • Forums
  • News
  • Release History
  • Download
  • Showcases
    • The Smart Contest 2013, Round 1 – Graphics
  • Store
  • Documentation
    • Creating your own controls
    • Debugging, exceptions and error handling
    • Differences between Delphi and Smart
    • Get the book
    • Getting started
      • Introduction
      • Local storage, session storage and global storage
      • Application architecture
      • The application object
      • Forms and navigation
      • Message dialogs
      • pmSmart Box Model
      • Themes and styles
    • Layout manager
    • Networking
      • Loading files
      • TW3HttpRequest
      • TW3JSONP
    • Prerequisites
    • Real data, talking to sqLite
    • System requirements
    • Project types
      • Visual project
      • Game project
      • Console project

Archives

  • December 2019
  • December 2018
  • November 2018
  • July 2018
  • June 2018
  • February 2018
  • September 2017
  • April 2017
  • November 2016
  • October 2016
  • September 2016
  • April 2016
  • March 2016
  • January 2016
  • October 2015
  • September 2015
  • July 2015
  • April 2015
  • January 2015
  • December 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • June 2014
  • March 2014
  • February 2014
  • January 2014
  • December 2013
  • November 2013
  • October 2013
  • August 2013
  • July 2013
  • June 2013
  • May 2013
  • April 2013
  • March 2013
  • February 2013
  • January 2013
  • December 2012
  • November 2012
  • August 2012
  • July 2012
  • June 2012
  • May 2012
  • April 2012
  • March 2012
  • February 2012
  • January 2012
  • November 2011
  • October 2011
  • September 2011

Categories

  • Announcements (25)
  • Developers log (119)
  • Documentation (26)
  • News (104)
  • News and articles (16)

WordPress

  • Register
  • Log in
  • WordPress

Subscribe

  • Entries (RSS)
  • Comments (RSS)
  • 1
  • 2
  • Next
© Optimale Systemer AS