Mastering the Art of Lightning Application Development
Tags: javascript, lightning, ctv, rdk
Published: 2023-05-14 12:45:04

Original post [here](https://imtiaz101325.notion.site/Mastering-the-Art-of-Lightning-Application-Development-91eda44f21894d56ac0d6369d94d542f)

Developing a reliable Lightning application often feels like navigating an intricate labyrinth due to the multiple layers of complexities involved. This blog post aims to serve as a comprehensive guide for both new and experienced developers, intending to illuminate the nuances of this process.

[Lightning](https://lightningjs.io/), at its core, is a UI library designed to build speedy user experiences for hardware-constrained systems. It functions akin to a game engine. Like all engines that composite graphics, Lightning employs a [SceneGraph](https://en.wikipedia.org/wiki/Scene_graph), representing a hierarchical structure of graphical objects. One of the primary benefits of Lightning is its faster rendering capability compared to the standard [DOM](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Introduction). It achieves this by utilizing a more streamlined subset of features, enabling the implementation of shortcuts and caching mechanisms in the update loop to enhance its speed.

Essential skills for creating a Lightning UI application:

- Proficiency in building [modern JavaScript applications](https://www.sitepoint.com/anatomy-of-a-modern-javascript-application/).
- Familiarity with [Lightning](https://github.com/rdkcentral/Lightning) and associated libraries such as [Lightning-SDK](https://github.com/rdkcentral/Lightning-SDK), [Lightning-UI](https://github.com/rdkcentral/Lightning-UI-Components), [Metrological-SDK](https://github.com/Metrological/metrological-sdk), etc.
- Understanding the trade-offs between well-written code and fast performing code.
- Awareness of hardware impact on the code.
- Ability to optimize for an excellent user experience in hardware-constrained environments.

The realm of [video playback](https://www.smashingmagazine.com/2018/10/video-playback-on-the-web-part-1/), often the application's core, is the next layer to explore. This area heavily relies on browser-based tools like the [native video tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video), [Media Source Extension](https://web.dev/media-mse-basics/), and [libraries](https://github.com/shaka-project/shaka-player) implementing streaming protocols over these primitives.

Relevant skills:

- Understanding how browsers handle video playback natively.
- Knowledge about why we use streaming protocols and the implications of delivering video and audio over the network.
- Awareness of hardware constraints on native playback and streaming.
- Basic understanding of media encoding and availability for browser playback.


🔗 ProTip read these awesome posts: [https://web.dev/media/](https://web.dev/media/)

The stage for these operations is a sandboxed browser environment, which, despite its controlled nature, can occasionally present unexpected challenges. Therefore, it's essential to understand the specific browser your code operates on, the underlying engine, and its unique limitations.

Required skills:

- Insight into JavaScript engines, their operations, and expectations from different engines.
- Familiarity with [WebKit](https://webkit.org/) and the reasons behind its popularity among developers. 🙂
- Understanding of hardware and software constraints on the browsers.

Interestingly, these browsers function not on standard computers and operating systems but on performance-optimized Linux distributions or other proprietary software solutions tailored to specific hardware. These systems have their own peculiarities, as different providers modify the hardware and software configurations. Understanding these configurations and the imposed limitations is an essential aspect of a developer's skillset.

For this and following blogs, the focus will be on the [RDK ecosystem](https://rdkcentral.com/).

Skills:

- Knowledge of hardware specifications— hardware encoder/decoder, RAM, CPU, GPU.
- Understanding the firmware that operates on these hardware pieces.

Due to security considerations, production boxes often become quite restrictive. As a result, developers tend to use development versions of the hardware, which may behave differently from their production counterparts. Furthermore, the global distribution of these systems necessitates a robust networking setup to effectively test apps across different providers.

Skill:

- Familiarity with various development environments.
- Understanding of [developer tools](https://developer.chrome.com/docs/devtools/) offered by the environment.
- Insight into the nuances of different platforms and their geographical distribution.

In essence, becoming proficient in Lightning application development requires a holistic understanding of these layers and their interdependencies. Though it's undoubtedly a challenging endeavour, unraveling each layer brings you one step closer to maturing into a skilled Lightning developer.