Archive for March, 2018

Smart Mobile Studio 3.0 and beyond

March 20, 2018 Leave a comment

cascade_03With Smart Mobile Studio 3.0 entering its second beta, Smart Pascal developers are set for a boost in quality, creativity and power. We have worked extremely hard on the product this past year, including a complete rewrite of all our visual controls (and I mean all). We also introduced a completely new theme engine, one that completely de-couples visual appearance from structural architecture (it also allows scripting inside the CSS theme files).

All of that could be enough for a version bump, but we didn’t stop there. Much of the sub-strata in Smart has been re-implemented. Focus has been on stability, speed and future growth. The system is now divided into a set of name-spaces (System, SmartCL, SmartNJ, Phonegap, and Espruino), making it easier to navigate between the units as well as expanding the codebase in the future.

To better understand the namespaces and why this is a good idea, let’s go through how our units are organized.


The RTL is made to expand easily and preserve as much functionality as possible

  • The System namespace is the foundation. It contains clean, platform independent code. Meaning code that doesn’t rely on the DOM (browser) or runtime (node). Focus here is on universal code, and to establish common object-pascal classes.
  • Our SmartCL namespace contains visual code, meaning code and controls that targets the browser and the DOM. SmartCL rests on the System namespace and draws functionality from it. Through partial classes we also expand classes introduced in the system namespace. A good example is System.Time.pas and SmartCL.Time.pas. The latter expands the class TW3Dispatch with functionality that will only work in the DOM.
  • SmartNJ is our high-level nodejs namespace. Here you find classes with fairly complex behavior such as servers, memory buffers, processes and auxillary classes. SmartNJ draws from the system namespace just like SmartCL. This was done to avoid multiple implementations of streams, utility classes and common functions. Being able to enjoy the same functionality under all platforms is a very powerful thing.
  • Phonegap is our namespace for mobile devices. A mobile application is basically a normal visual application using SmartCL, but where you access extra functionality through phonegap. Things like access to a device’s photos, filesystem, dialogs and so on is all delegated via phonegap.
  • Espruino is a namespace for working with Espruino micro-controllers. This has been a very low-level affair so far, due to size limitation on these devices. But with our recent changes you can now, when you need to, tap into the system namespace for more demanding behavior.

As you can see there is a lot of cool stuff in Smart Mobile Studio, and our codebase is maturing nicely. With out new organization we are able to expand both horizontally and vertically without turning the codebase into a gigantic mess (the VCL being a prime example of how not to implement a multi-platform framework).

Common behavior

One of the coolest things we have added has to be the new storage device classes. As you probably know the browser has a somewhat “limited” storage mechanism. You are stuck with name-value pairs in the cache, or a filesystem that is profoundly frustrating to work with. To remedy this we took the time to implement a virtual filesystem (in memory filesystem) that emits data to the cache; we also implemented a virtual storage device stack on top of it, one for each target (!).

In short, if a target has IO capability, we have implemented a storage “driver” for it. So instead of you having to write 4-5 different storage mechanisms – you can now write the storage code once, and it works everywhere.

This is a pretty cool system because it doesn’t limit us to local device storage. We can have device classes that talk to Google-Storage, One-Drive, Dropbox and so on. It also opens up for custom storage solutions should you already have this pre-made on your server.

Database support, a quick overview

Databases have always been available in Smart Mobile Studio. We have units for WebSQL, IndexDB and SQLite. In fact, we even compiled SQLite3 from native C code to asm.js, meaning that the whole database engine is now pure JavaScript and no-longer dependant on W3C standards.


Each DB engine is implemented according to a framework

Besides these we also have TW3Dataset which is a clean, Smart Pascal implementation of a single table dataset (somewhat inspired by Delphi’s TClientDataset). In our previous beta we upgraded TW3Dataset with a robust expression parser, meaning that you can now set filters just like Delphi does. And its all written in Smart Mobile Studio which means there are no dependencies.


And ofcourse, there is also direct connections to Embarcadero Datasnap servers, and Remobjects SDK servers. This is excellent if you have an already existing Delphi infrastructure.

A unified DB framework

If you were hoping for a universal DB framework in beta-2 of v3.0, sadly that will not be the case. The good news is that databases should make it into v3.2 at the latest.

Databases looks simple: table, rows and columns right? But since each database engine known to JavaScript is written different from the next, our model has to take height for these and be dynamic enough to deal with them.

The model we used with WebSQL is turning out to be the best way forward I feel, but its important to leave room for reflection and improvements.

So getting our DB framework established is a priority for us, and we have placed it on our timeline for (at the latest) v3.2. But im hoping to have it done by v3.1. So it’s a little ahead of us, but we need that time to properly evolve the framework.

Smart Desktop [a.k.a Amibian.js]

The feedback we have received on our Smart Desktop demos have been pretty overwhelming. It is also nice to know that our prototype is being used to deliver software to schools and educational centers. So our desktop is not going away!


Fancy a game of Quake at 60+ fps? Web assembly rocks!

But we are not rushing into this without some thought first. The desktop will become a project type like I have written about many times before. So you will be able to create both the desktop and client applications for it. The desktop is suitable for software that requires a windowing environment (a bit like Sencha or similar frameworks). It is also brilliant for kiosk displays and as a remote application hub.

Our new storage device system came largely from Amibian, and with these now a part of our RTL we can clean up the prototype considerably!

Smart assembler

It may sound like an oxymoron, but a lab project we created while testing our parser framework (system.text.parser unit) turned into an exercise in compiler / assembler making. We implemented a virtual machine that runs instructions represented by bytecodes (fairly straight ahead stuff). It supports the most common assembler methods, vaguely inspired by the Motorolla 68k processor with a good dose of ARM thrown in for good measure.


Yes that is a full parser, assembler and runtime model

If you ponder why on earth this would be interesting, consider the following: most web platforms allow for scripting by third-party developers. And by opening up for that these, the websites themselves become prone to attacks and security breaches. There is no denying that any JS based framework is very fragile when potentially hundreds of unknown developers are hacking away at it.

But what if you could offer third parties to write plugins using more traditional languages? Perhaps a dialect of pascal, a subset of basic or perhaps C#? Wouldnt that be much better? A language and (more importantly) runtime that you have 100% control over.

While our assembler, disassembler and runtime is still in its infancy (and meant as a demo and excercise), it has future potential. We also made the instructions in such a way that JIT compiling large chunks of it is possible – and the output (or codegen) can be replaced by for example web assembly.

Right now it’s just a curiosity that people can play with. But when we have more time I will implement high-level parsers and codegens that emit code via this assembler. Suddenly we have a language that runs under node.js, in the browser or any modern JS runtime engine – and its all done using nothing but Smart Mobile Studio.

Well, stay tuned for more!

Facebook, this must change

March 14, 2018 2 comments

Facebook has grown to be more than just a social platform where friends meet. You have groups and communities of every conceivable type, where people of every convictions engage and debate anything you can think of. Groups where people have opinions, are passionate and put ideas to the test.

It has been grand, but lately a negative trend (or technique) has evolved; and sadly Facebook don’t seem to get the full scope of its impact. For them that is.

Childish games

College student looks at sign on classroom door: Blame Shifting 101.

We did this as kids!

It reminds me of behaviour you could see in highschool, where someone would do something illegal, and then point the finger at those who tried to stop the act (also known as blame shifting). Today this has evolved into a type of “revenge” tactics, where individuals who lose an argument (regardless of what it may be) get back at others by falsely reporting them.

At first glance this looks silly enough. Go ahead and report me, I have nothing to hide right? Well it would be silly if Facebook actually took such complaints serious and actually looked at what was written with human eyes. Sadly they don’t, and without any consequences involved for people who maliciously report users out of sheer spite – the stage is set of the worst of trolls to do what they do best: cause mischief and mayhem for upstanding members.

This has reached such heights that we now see the proverbial “drive-by” reporting of people they don’t like or disagree with (especially in political and economic forums) and it goes un-checked by Facebook.

This is a very negative trend for the platform and has already caused considerable damage; To Facebook that is. Why? Well people just move on when the format puts trolls, group campers and reporting snipers (call them what you will) at equal odds with honest, responsible adults that engage in debate.

Group campers and trolls

I was just informed that I had been “reported” and consequently expelled for 7 days due to a violation of terms. I was quite shocked to read this, so I took the time to go through these terms. I was at a complete loss of which of their standards I had violated. And as it turned out, I had broken none of them. I would never dream of posting pornography, I have not made racist remarks (quite the opposite! In 2017 I kicked a total of 46 members from Delphi Developer for rubbish like that), nor am I a member of the anti-christ movement and I don’t go around looking for fights either.

What I had done however, was to catch two members of a group using fake profiles. And in debate with one of these, telling the individual that his trolling the group is neither welcome nor decent – his revenge was to report me (!).


Not all sayings translate well to English

What really surprised me was how Facebook seem to take things at face value. There is no way that a human being could be behind such a ruling; at least not people fluent in Norwegian.

First they seem to employ a simple word check, no doubt looking for curse and swear items (using google translate or some other lookup service). If you pass that, they seem to check for references to a person or individual in conjunction with negative phrasing. Which, let’s be honest, is a somewhat grey area considering their services covers a whole planet with hundreds of cultures.

In this case the only conceivable negative phrase in my post was “Go troll under a bridge“, which is not an insult but an expression with roots in Norwegian folklore. In Norwegian lore trolls typically lived either up in the mountains or under a bridge. And you had to pay the troll not to eat you (a somewhat fitting description considering the situation).

This goes to character. Namely when the person (or fake profile) here did nothing but post statements designed cause problems for other members, then that is the very definition of a net-troll. So telling such an individual to troll under a bridge is the same as saying “stop it and get out” [loosely translated]. I could have just banned him, but I tend to give people the benefit of the doubt.

Facebook as a viable platform

I hope Facebook wakes up, because this type of “tactics” has grown and is being used more and more. And if you score a single point on the above criteria, regardless if the person who reported the incident is also the source — you are just banned for 7 days. Surely, the act of reporting someone who has not violated the terms should carry equal weight? But that is where Facebook just hides behind a wall of Q&A without any opportunity for actual dialog. They don’t seem to care if the report was false or a pure act of revenge – they just blindly accept it and moves on.

The result of this? Well, it’s sort of self-evident isn’t it? People will have to deploy the same tactics in order to survive and protect themselves from such attacks; and voila – you have the extreme rise of fake profiles which has just exploded on Facebook.


Viable platform? I am really starting to question this

Well im not going to create a false profile, because I have some terms of my own; commonly known as “principles“. I run several large groups on Facebook and have been nothing but an asset to their growth. And if they want to lose 7 days of high activity, that is their loss. I am also starting to question if FB is a viable platform at all when a guy running 3 large groups and two businesses there (with a 15 year membership history) can be so easily barred by a fake profile.

But sadly I will stop talking to people who get into arguments and just report + kick them from whatever group they are in. Its sad, but those are the results of the absolutely absurd practices of Facebook. So until their filters employ some logic to them, that’s the way things are.

You cannot run a business on kindergarten rules

I sincerely hope you put some effort and thought into how to solve problems like these. For example, scanning the past 3 notes posted by the reporter to see if there is grounds to ignore the report – or in fact ban the reporter for creating the situation to begin with.

All of this can be solved with a simple strike and value system. If you falsely report someone that’s a strike. If you camp in a group and get multiple reports (within a time-frame), you get automatically banned from that group. If you persistently ban someone (a.k.a bullying) that is another strike. Enough strikes and you get a 7 day warning (or harder depending on the violation).

It wouldn’t require much work to create a system where long-standing, responsible members who benefit the platform – are recognized over trolls that do nothing but ruin this. Seriously. I cannot believe that a planet wide social platform with millions of users, are deploying social rules from the late bronze age.

My thoughts go to the Monty Python sketch “She’s a witch!” set in the darkness of medieval europe. If someone says you are a witch, well then you must be one (sigh). Way to go Facebook, just way to go.

Oh well, I meant to brush up on my Google+ work anyways 🙂