Building Lightning apps and are annoyed with how little information is out there on this topic? Congratulations! You are not alone. Being such a niche technology in the web ecosystem makes Lightning quite difficult for beginners. Web developers are normally used to detailed documentation or blog posts on the web technology they use. If you are new to Lightning, then you probably already experienced finding more information on the Salesforce framework instead.

Unfortunately, we can only hope that the people behind the framework will invest in making it more approachable to people across the industry. In this blog post, however, I would like to share some of the things that I have found interesting while researching this technology.

In this first post for my Lightning.js themed blog, I want to explore the building blocks of Lightning.

What is Lightning?

Lightning is essentially a UI framework in JavaScript. Where it differs from other frameworks, such as React, is that Lightning is meant to run on Smart TVs and Set-top boxes. It makes certain design choices so that it can excel in doing that.

A big difference here is that, in Lightning, you do not write HTML and CSS. Instead it has its own templating system. It might seem a bit cumbersome— but what you get out of this apparent drawback is very smooth UI on devices that have low CPU and memory.

Another huge aspect of this framework is how it actually renders the UI on these boxes. It uses a technology called WebGL which is essentially a way to use the GPU to draw elements on the screen. By leveraging the GPU on the devices, the framework lets you focus on the user experience.

https://lightningjs.io/articles/how-does-lightning-compare-to-html5/

https://lightningjs.io/articles/how-does-lightning-compare-to-html5/

First commit

While it is not very clear when and how it all began, we can find some leads scattered across the internet on the people and technology behind the framework. A good place to look at is the GitHub repository. If you dig deep enough, you can find some of the first lines written for the project.

From what we can see, an incredibly smart person called Bas Van Meurs magically dropped ten thousand lines of code. At this point we can see that a lot of the core elements of the framework are already there. We can surmise that a chunk of the work for this project began behind closed doors.

While he does not seem to be part of the project since 2019— he is still the number one contributor to the framework. I personally would love to hear his side of the story: the motivation, the challenges and the effort to get this far. We can still see his commits littered all around the codebase.

Screenshot 2023-03-02 at 9.16.47 PM.png

RDK

While Lightning is, in fact, a JavaScript UI framework— it would not be my first choice in regular web browsers. Lightning shines most brightly in performance constrained set-top boxes and here we can trace its origins. In particular, you would commonly find Lightning apps in platforms that run RDK software.

Reference Design Kit is an “open source” software platform for, among other things, set-top boxes. It is “open source”, but fair warning— there is also a license. RDK has genius embedded engineers who build very awesome software from their basements. Jokes aside, I was very impressed with the things they are doing.

What concerns us is their RDK-V or RDK4. Frankly, I am not well versed with all the acronyms but this is essentially the software that runs on the set-top boxes. The STB(set-top box) vendors can ship their Linux boxes with this software and benefit from the ecosystem created by big players in the industry.

WPE

All of the above is cool and important but what we really care about is what browser our app is running on. That would typically be rdkbrowser2. To simplify this to the point of being wrong— it is essentially a version of Safari meant for your 190MB(memory) STB. I know web developers love Safari so I had to start with that.

The browser engine in question is Web Platform for Embedded— another piece of the puzzle. I will try to explain the jargon as best as possible so bear with me. WebKit is the browser engine for Safari— among other things. WPE(Web Platform for Embedded) is a version of this engine tailor-made for embedded Linux boxes. It is an upstream port which means we can expect it to be close to WebKit but not exactly WebKit. You can learn a lot more from their website but I will keep this specific to Lightning.