Ben Sargent: Build a Web Page in Multiple Programming Languages

By Niklas Nordlof on Monday, March 24, 2014

Ben Sargent: Build a Web Page in Multiple Programming Languages
At the 2014 Responsive Web Trends conference in San Francisco, Ben Sargent spoke about the benefits of developing on the Moboom platform. He concluded the talk by demonstrating one benefit that’s sure to amaze even the most skeptical developer: the ability to code in multiple, normally incompatible, languages on the same webpage.

First, Ben described how development works on the Moboom platform. As he explained, Moboom separates code into widgets: “The anatomy of a webpage from Moboom’s perspective is to use a bunch of different widgets.” Each element—navigation menus, images, and even text—is a separate widget.

So to develop for Moboom, you create widgets. But what about more complicated concepts like forms, streaming videos, CSS animations, and so on? According to Ben, “Really, anything that can be parsed and rendered by a web browser can be a widget.”

A unique rendering engine

Next he explained the difference between what a visitor sees and what’s happening in Moboom’s rendering engine: “And then behind the scenes, the widgets are being rendered by what we call providers. The widget is what appears on the webpage. The provider is what executes the code that generates the HTML.”

By providers, Ben is referring to separate services (or “microservices” as Ben calls them) that separately execute each widget’s code. Next, the Moboom rendering engine concatenates the output HTML, building  the page that visitors see.

Running each widget separately has several benefits. Some of which Ben demonstrated later in his talk, and David Penner, Moboom’s VP of Engineering, talked about other benefits in his talk: Rendering the Sites of the Future

Ben also mentioned some development technologies that are integrated into the platform. These include technologies like LESS CSS, Moboom’s own server-side media queries (which allow you to detect specific devices—not just screen width), and various built-in JavaScript libraries. 

Coding in different languages

While Moboom has a modern development platform with some useful additions, the really impressive part of Ben’s talk began once he started demonstrating the power of the Moboom rendering engine by live coding a few widgets—each in a different language.

First he built a Handlebars widget. If you’re not familiar with Handlebars, it’s a JavaScript-based templating system. Ben just wrote a basic widget that displayed a thumbnail image. Next, Ben showed how to create an image gallery using the Handlebars #each tag. So the Moboom platform supports development in Handlebars, which is neat, but sometimes you want the fine-grained control of a real programming language.

So next, Ben created a PHP widget that also acted as an image gallery, but this time he made a few calls to the Moboom API. So here, Ben is showing that while Moboom supports Handlebars development, the platform also supports PHP development. And Moboom gives developers the ability to interact with the platform using a RESTful API.

While explaining PHP development, Ben also demonstrated how Moboom handles content. According to Ben, “There’s static content, which is images, text, and settings that people punch directly into the studio. Moboom also has content sets. This is dynamic content. This could be content that’s created in another part of the studio or XML feeds, JSON feeds, etc.”

Basically, Moboom allows users to separate content and design. But as Ben explains, this isn’t something you need to worry about when developing a widget: “If you’re developing a widget, and you’re wondering ‘how do I handle dynamic content’ and ‘how do handle static content,’ the truth is that widgets don’t care. Widgets don’t care about the source of content.”

That is a powerful concept, because, according to Ben, “that means that you as a developer are not querying a database… Moboom actually pushes the content into the widget. So from the widget’s perspective, it’s just content.”

Next, because a page running Handlebars and PHP wasn’t enough, Ben added a calendar widget written in C#. As Ben put it, “On this page I’ve got code that was rendered in Handlebars. I’ve got code that was rendered in PHP. I’ve got code that was rendered in ASP. It doesn’t matter—it all just works.”

It all just works, because as Ben mentioned earlier, each microservice renders each widget separately, and then the rendering engine sticks the generated HTML together to create a webpage.

While Ben’s example used three programming languages on one page, he made it clear that based on how Moboom renders widgets, “there’s no reason that we can’t build providers that run any programming language that can concatenate strings. And I’m pretty sure there aren’t any.”

While most developers won’t develop in several different languages, Ben’s demo shows that developers on the Moboom platform don’t have to switch to a new language that they might not be completely comfortable in. 

So with one webpage, Ben demonstrated that to develop for Moboom you just have to familiarize yourself with the API—you don’t also have to commit to learning a new language.

For more video, watch Ben's entire presentation, and check out Jerome Petazzoni on scaling big with Docker, and David Penner's talk on website rendering.

DevKit Templates

Find the website template you want in the Moboom Market