Archive

Archive for May 6, 2015

Angular JS + BootStrap and why it’s all bull

May 6, 2015 10 comments
Hype is the number of the beast when it comes to development

Hype is the number of the beast when it comes to development

Web designers and web “architects” as they like to call themselves, are into bling. Their job is after all to help bussinesses sell whatever product they have; be it a perfectly valid product or a completely useless piece of droppings. But with a good designer at your disposal you can to some degree ensure your product will sell. At least at first. So when designers and bling-doctors set out to create their tools of the trade, it’s pretty much natural that they will make it look like the greatest thing since the discovery of the wheel. And people swallow it, hook line and sinker.

JQuery

Take JQuery for instance. It’s a simple little library to collection (query) information about the DOM (document object model). It allows you to set properties on collections rather than single items and it also have a handful of helper functions for effects, css and dealing with JSON and REST.

Eh.. no thanks!

Eh.. no thanks!

Yet when you read the documentation or hear people talk about it – it sounds so fantastic. You can cure cancer with JQuery, did you know that? It’s hype. It’s just spin and you should know that by now.

Angular.js

Angular is, seen from the JS developer’s viewpoint, a fantastic library. It allows you to define content in one place, controller code in another place and Angular gives you the tools to glue those two parts together. The controller is the part which has code, meaning that you access the controller to perform operations on the model (the data) – which is reflected in the view (the html). But wait just one minute! Havent we heard all that before? You have data separated from functions, functions separated from the display — yet they all come together to form a single entity? Yes. You have heard it all before. What I have just described is how a normal class works. The reason it’s divided into controller, model and view has nothing to do with better, next generation or any of that crap — it has to do with the fact that JavaScript doesnt have classes, or inheritance, or polymorphism or any of the fundamental features real programmers expect to find. So if you are a JS programmer Angular is fantastic, because it allows you to break down a presentation (read: component) into logical parts, deal with callbacks and display sequences in an orderly fashion and so on. But for a programmer coming from C++, Delphi or C# — Angular is a childish toy. There is no reason to break these elements apart, that’s why God invented VMT’s (virtual method tables).

Yeah yea, bla bla bla bla, hype

Yeah yea, bla bla bla bla, hype

I mean, have you heard some of these presentations on youtube about angular? Wow. It even get’s me going for a while there. The mental image they paint is that angular is going to solve everything! If you can just use angular, then your website will scale, dance, sing and even click it’s own likes. But when you start coding with angular you realize that it’s just a non-productive way of emulating OOP through objective thinking. It’s technical masturbation. You isolate your data in one place, your procedures in another place and your visual appearance a third place. This is exactly what OOP was created to solve. It may be a step forward for JavaScript, but compared to Delphi, Smart Mobile Studio, C++ or any “real” programming language with OOP — it’s a gigantic step backwards.

Components is MVC

MVC (model view controller) is a programming pattern, or style, which has become very popular lately. It was initially hyped by Apple to get people onboard their Objective C wagon for iOS and OS X development. Picked up by other languages, especially JS which is the mother of all bling, it has become almost the norm. Both in the world of nodeJS and DOM programming in general.

Oh but you can change things easier and use the same controller with different views, or have different controllers for the same view. So? Thats what inheritance is all about:

type

//baseclass for database read values
TBaseDBStorage = Class(TW3Object)
end;

//filtered database values, inherits from base
TFilteredDBStorage = Class(TBaseDBStorage)
end;

//basic display widget
TBaseDisplay = Class(TW3CustomControl)
private
  FData: TBaseDBStorage;
protected
  function getDBStorage:TBaseDBStorage;virtual;abstract;
End;

// display optimized for desktop
TDesktopDisplay = Class(TBaseDisplay)
protected
  function getDBStorage:TBaseDBStorage;override;
end;

// display optimized for mobile devices
TMobileDisplay = Class(TBaseDisplay)
protected
  function getDBStorage:TBaseDBStorage;override;
end;

I mean, the above OOP code allows you to fetch data from a server, and also specialize it as needed. We also roll out two display controls, one for mobile and one for desktop, and we give them different display and layout rules. This is faster and easier than writing two controllers, two data structure profiles, two html segments and two CSS rulesets. Same result, except the code above can be expanded indefinitely without messing up existing models.

So there!

So there!

What people fail to notice is that MVC is just plain old TCustomControl. An ordinary TCustomControl has data (fields), which is a model — methods and implementations which is the controller, and a view (surface, canvas or operative-system viewport). And just like under MVC the code is there to act on the data and control the visual output. What angular does is essentially to rip OOP apart under the assumption that this will make things better. But it doesnt make things better, it makes things worse (!)

Mutation events

Now if you’re a JS programmer feeling you have to defend angular, please relax. I know all about the data binding layer – because just like angular Smart Mobile supports mutation event handling as well. And we do it through proper OOP with full inheritance. Mutation events is just a fancy phrase for “tell me whenever anything changes in the DOM”. So a mutation listner can be created and set to listen to changes on either the whole DOM or a particular piece of the DOM (like your panel or a button for that matter). Whenever a property change, an attribute or a CSS style — you get a callback event with the change data. Using this system Google has made a neat system for binding data changes to visual tags. For instance, whenever you change the value of a variable – you can hook that variable up to a section and have it display the change “live”. You can also bind visual input, like from a textbox, to a variable, another field or whatnot. Sounds familiar?  Delphi Visual Live bindings anyone? Angular creates the illusion of being black magic; and to the JS punters and kids it probably is. But sadly the only spell it casts is one of blinding hype.

Bootstrap JS

Bootstrap has to be, with the exception of jQuery, the biggest disappointment of them all. And I dont write this just to be negative or anything like that. I am genuinely disappointed at how such a small library, containing nothing particular interesting at all, can get so popular so fast. Bootstrap.js is essentially a theme engine. That’s it. Yes you read right, a plain old vanilla theme engine, like we have had in Delphi and C++ for decades now. Bootstrap allows you to define simple constructs, like a panel. It will then automatically align and position your input controls and DIV’s according to a 12 point grid. Does this sound familiar? It should because every Delphi control has an align property, and TLayoutPanel has been shipping with Delphi since 2006. If you add some clever CSS styling on top of that — you essentially have bootstrap.js

Final verdict

In this post I have told you the truth about some very, very big and popular javascript libraries. They are popular and famous because for a JS developer, which doesnt have the luxury of OOP like we do – these libraries is heaven sent. But for everyone who has OOP, like Smart Mobile Studio, there is absolutely no benefit to using angular, bootstrap or jQuery at all. In fact the RTL was designed in such a way that there should not be any unknown tags in the DOM. Hence jQuery is useless because what exactly should you use it for? TW3CustomControl encapsulates the uber-hyped MVC of Angular, our web units outperforms and outweigh the angular toolbox by a factor of 10 — so again there is absolutely nothing angular provides which has any value to a seasoned and professional Smart Pascal programmer. He would make angular.js himself within days (!). Not because he is so clever, but because OOP and inheritance makes it possible. Modern OOP was designed to better help you deal with problem solving, spanning recursively through a well written and designed architecture. This is why OOP rules the world and procedural and objective programming is a thing of the past.

A better and far more powerful way

Over the next six months I will be presenting my web technology. This means that the tools you will get – through smart mobile studio – and the classes you will also get, will help you create web applications that knock the boots of all these 3 libraries. So far Smart Mobile Studio has only been for mobile application development. Well that is about to change (slowly) as we begin to add more and more support for full-on “page” designs. You can naturally create websites today, but webpages demonstrates a slighly different behavior – both in terms of scaling, scrolling and general navigation. You want to create awesome websites with little code? Sure you do! You want to use your Delphi skills to create fantastic HTML5 user-controls which no other language delivers? Sure you do! And you want to connect to databases, REST API’s and your own nodeJS based service layer? Hell yes you do! Well, let’s teach these JS kids how real programmers solve these things 😉

Why Amiga is cooler than .net and the perfect embedded environment

May 6, 2015 7 comments

I know, you probably think I’m just another fanboy trying to convince you to use a 30 year old, 16 bit operative-system. Or perhaps I’m just a lunatic with fond memories of my childhood gaming experiences.

No, I’m actually talking serious stuff here. Ok, here it goes:

Unless you have been living under a rock for the past 10 years, computing is heading full stream ahead into virtualization. Companies like VMWare have been doing this for well over a decade now, and before that there were thin-clients and multi-account Windows installations that was all the rage (or Linux, Or OS X for that matter).

Point is: companies are tired of getting boxed into a particular piece of hardware or processor.

MorphOS is an Amiga clone, but it's bound to outdated PPC hardware

MorphOS is an Amiga clone, but it’s bound to outdated PPC hardware

The solution is two-fold: You can go the way of VMWare and emulate a whole machine, from the bios to interrupts to USB triggers. An absolutely astounding piece of engineering if you ask me.

The other route is what Microsoft have been doing, namely to ensure that their programming tools are platform abstracted. The .net framework is more than just a framework or coding standard. It’s a virtual assembly language for a virtual processor which you implement in software. What happens is that the first time you run those bytecode assembly instructions, the JIT compiler assembles them into real, processor bound OP-Codes which run natively.

Have you heard anything like that before?

Amiga, really?

Now switch over to UAE and do a comparison: The UAE platform is, give or take it’s dependence on the host – a complete self-sustaining virtual hardware environment. It’s designed in much the same way as the .net HAL (hardware abstraction layer) is, and it has the benefit of running on a tiny kernel.

So while people may feel that Amiga-OS is long gone and dead, it’s actually now coming back as a perfect virtual environment. Why perfect? Because Windows 10 is still 800 megabytes (embedded preview) while AmigaOS 3.9 or 4.0 + linux kernel + bootstrap is less than 50 megabytes (!) And that’s the full OS with all bells and whistles.

A quick visit to AmiWeb to grab your assembler, your blitzbasic and your C++ compiler and you have a pretty awesome portable, virtual platform running on cheap x86 parts.

I sincerely hope there is a good coder out there that can revive Amithlon as an open-source system.

What the hell is Amithlon?

AmigaOS running on x86 without Windows or a dedicated host OS

AmigaOS running on x86 without Windows or a dedicated host OS

Amithlon is a tiny version of Linux which is designed to boot only one thing. In fact it’s just the bare bones of Linux, no applications, no X server or anything like that (just drivers, bash and rendering via the framebuffer). So it has just the ability to boot into a very small and compact setup. The boot-sequence does one thing and one thing only: boot into a custom-built Amiga Emulator. A JIT based environment which treats mc68k assembler as (drumroll) bytecodes (!)

Amithlon allowed you to install Amiga OS 3.9 on ordinary x86 PC hardware. So finally you could take advantage of cheap and powerful x86 parts and run AmigaOS at high speed using a custom JIT engine.

Where is Amithlon now?

For some insane reason Haage & Partner, which seem to have shipped this system a few years back, just shelved it. I don’t know why so many stupid decisions seem to haunt the Amiga, but this one really is the frosting on the cake. A fully working system which allowed Amiga to run fully abstracted on cheap x86 hardware! And they fu**** shelved it!

I would really like to see that system go open-source. Who has the code? Where did it go? It worked brilliantly yet H&P shut it down — why?

If you have the source, please please give me a PM and I’ll compile it, setup a SVN repository and GIT node and generally make it available to the masses.