Hyperlambda - Do More With Less
Hyperlambda - Do More With Less
In this post, a developer discusses an open source markup language he created and the benefits in terms of development speed and lines of code it brings to projects.
Join the DZone community and get the full member experience.Join For Free
Hyperlambda is kind of like YAML. YAML is a markup language, and it means "Yet Another Markup Language." YAML has many interesting traits, it's most important being the ease of declaring tree structures. However, it is also unnecessarily complex, and contains too many syntactic elements - at least for my taste - so I created Hyperlambda. At its core, there are only two syntactic basic elements in Hyperlambda.
A colon separates the name of a tree node from its value.
Two consecutive spaces beneath any node declare a children node collection.
Maybe you're asking what's the use-case for yet another markup language? Well, one of these use-cases is the ability to dynamically declare your HTML elements, and associate Ajax event handlers with them. Below is an example from my previous article.
/* * Creates a modal window. */ create-widgets micro.widgets.modal:my-modal widgets h3 innerValue:This is a header p innerValue:This is a paragraph div class:right widgets button innerValue:Close onclick // Closes modal window. delete-widget:my-modal
Even if you have never created a single line of code in your entire life, the above snippet is probably easily understood. It creates a modal window, with an H3 element, a paragraph, and a right aligned div that contains a single button. As the button is clicked, the modal window is deleted. Below is a screenshot of how it'll look if you "evaluate" the above Hyperlambda through "Hypereval" from Phosphorus Five.
By creating a server-side alternative to declaring your HTML and DOM structure, we have effectively created an invisible and magical "bridge" between your frontend code, and your backend business logic. Compare the above easy syntax with creating something similar in, for instance, Bootstrap CSS, and the arguments in favor of Hyperlambda literally unfold by themselves.
According to research into the subject, the amount of energy you need to apply to create and maintain an application is directly proportional to the number of lines of code your application contains. This suggests that developing and maintaining an application with 200 lines of code is 10 times as demanding as developing and maintaining an application with 20 lines of code.
According to Paul Graham, you should "always choose the highest level of abstraction that is possible to choose according to your needs." There are a lot of things which require low-level abstractions to adequately function. For instance, I probably wouldn't recommend anybody to create a first-person shooter polygon rendering function in Hyperlambda. However, 80% of any "enterprise application" consists of stuff such as retrieving form data, storing that data in some database on the server side, and evaluating some simple piece of business logic in the process - and maybe giving some sort of feedback to the user in the process.
"What would it mean to you as a developer, and your employer, if you could create your enterprise applications 10x faster? What would be the value of that?"
Below is a video demonstrating a web-based IDE, entirely created in Hyperlambda. The code for Hyper IDE is exactly 6,200 lines of code. The Bootstrap DateTimePicker is 2,636 lines of code. The Bootstrap DateTimePicker allows you to pick dates. Hyper IDE is a fully fledged IDE, with plugin support, shell integration, support for more than 100 programming languages, multiple tabs, syntax highlighting, autocomplete, etc., etc., etc. - and it's 2.5 times the codebase - and, in fact, roughly 50% of Hyper IDE's codebase consists of comments. This implies that Hyper IDE and the Bootstrap DateTimePicker are roughly equal in size.
In addition, the DateTimePicker example page, will, according to Google Chrome, consume 250KB of initial bandwidth. My Hyper IDE example page will only consume 124KB of initial bandwidth. This implies that a DateTimePicker created with Bootstrap CSS will steal twice the amount of initial bandwidth as a fully fledged IDE that was created with Hyperlambda. I think the numbers here speak for themselves.
Opinions expressed by DZone contributors are their own.