Time has finally come to introduce something that we’ve been working on for a few months. We call it Hyperloop.
For example, let’s take a real simple example for Objective-C and iOS.
@import("UIKit"); @import("CoreGraphics"); var view = new UIView(); view.frame = CGRectMake(0,0,100,100);
The above code will tell the compiler to import the UIKit framework and use it to resolve any variables not specifically declared in JS scope using the native APIs. In this case, UIView is an interface defined in the Objective-C UIKit framework. Also, CGRectMake is a normal C function defined in the framework CoreGraphics. Notice for both, you are using a very familiar JS syntax to declare and use them. However, unlike JS, this code is compiled into native code (in this case, Objective-C) by the Hyperloop compiler.
Like most compiler designs, Hyperloop is split into a front-end and a back-end. The front-end is responsible for turning parsed HJS into an Abstract Syntax Tree (AST) representation and doing certain source-to-source optimizations. The back-end is responsible for turning this AST into native code, depending on the target language and platform.
With the current developer preview, we’re supporting Objective-C and iOS. However, we are concurrently working on supporting Android and Windows and will support many other back-ends in due time. Of course, as any initial preview, this code is very experimental and very raw and shouldn’t yet be used in production.
So what does Hyperloop have to do with Titanium?
We are re-building Titanium, something we are calling Ti.Next, using the new Hyperloop compiler architecture. The new Titanium API will be built entirely in HJS and compiled down into pure native code using the Hyperloop compiler. This will give us tremendous execution performance as well as a more flexible architecture for exposing new APIs and integrating Titanium with existing native applications. This will also allow us to re-think how you extend Titanium. Currently, you build native modules to extend the Titanium API. With Hyperloop, we will introduce a more flexible way to build native modules or integrate third-party code directly into your Titanium applications.
Can I use Hyperloop for other types of platforms like desktop APIs or Node.js?
In fact, yes, that’s the goal. But to really expand your thinking, how about with something like V8 and Node.js? One of the target opportunities I believe is to go beyond Titanium with Hyperloop. Think about taking the power of the HJS syntax to writing native Node modules. Instead of having to write in lower-level C against a system API, use Hyperloop to write your native node module. To make this happen, we would simply target a different compiler backend for Node. While this isn’t supported today, that’s where we’re headed.
Can I use Hyperloop without Titanium?
Yes, while Titanium will depend on Hyperloop, Hyperloop has no dependencies on Titanium and you can build native apps using Hyperloop without having to do anything related to Titanium.
What about Ti.Current and Modules?
We are experimenting with a compiler command that will allow you to target Ti.Current modules. The idea is that you can build your Ti.Current modules using HJS and Hyperloop compile and package them as modules that would work with your applications today. Again, this isn’t supported right now, but something we hope to deliver soon. This would give you a great way to start using the benefits of Hyperloop with modules today, without having to wait for Ti.Next. In fact, we’re experimenting to see if this is viable in the short-term to use for new APIs we’re adding to Titanium 3.2.0.
Are you going to make it easier to do an abstraction around the different APIs?
Not at present. Since Hyperloop isn’t meant to be a cross-platform toolkit, that’s what Titanium is for, we won’t likely be adding this to Hyperloop anytime soon (if ever). However, since Hyperloop supports the Node.JS require module system API, it should be easy to do this yourself. There’s no reason you can’t create your own abstractions and load them using require.
Does that mean I have to learn the native system APIs?
Yes, Hyperloop is specifically meant to be a way to program native APIs and get native, compiled performance. However, like Titanium Module SDK development is today, you need to understand the system APIs. If you can’t learn enough of how to call the system APIs, then Hyperloop won’t be able to help you much either.
When will this be stable? When is Ti.Next available?
We don’t have a specific timeline just yet. While we’ve made considerable progress in stabilizing the current target, it’s far from being something that’s ready to ship. We need to make progress on Windows and Android backends before we can start the work of re-building the Ti.Next platform. However, we’ve done enough early work on Ti.Next APIs in our R&D phase, that we’re confident we’ll be able to go fast once we get Hyperloop to that stage. I can’t commit to any dates just yet, but our hope is to have all three first class platforms (iOS, Android and Windows) stable enough by the end of the year we can start working in earnest on Ti.Next APIs. As you can imagine, we have a lot of other considerations for Ti.Next beyond just APIs such as CLI, Studio, testing, QA, etc. that will greatly impact the Ti.Next release date. All of those considerations haven’t yet been fully flushed out and won’t until we can get Hyperloop to a point that we have a definitive idea how long it will take to complete the Ti.Next API work.
So, what can you do with it? Any examples?
Yes, glad you asked. We have built a number of examples that are currently available in the Github repo and we’re always adding them every few days. Some are more tests than full examples, but looking through the source code, you should be able to get an idea of how powerful Hyperloop will be.
How can I help?
Hyperloop is open source and we’re grateful that we’ve already had a number of pull requests come in before it’s full even public. Like Titanium, Hyperloop is licensed under the Apache Public License. So, feel welcome to fork and send us your pull requests. If you haven’t already signed a CLA, please do so before sending a pull request.
Is there a discussion list to talk about Hyperloop?