Development in any local environment is pretty simple and straightforward. We do it all the time.
It’s only when we transition to the cloud that things get messy.
And I don’t think this is entirely a programmer’s fault.
Cloud developments are indeed complex.
Teams have to:
Write code to make their applications work on AWS, Azure, and Google Cloud.
Handle three different providers, thereby requiring expertise in all three.
Today, I want to tell you about Winglang, an open-source language specifically designed to build cloud applications.
More specifically, in this post, I will:
Discuss the challenges with existing cloud providers.
Explain how Winglang solves them and streamlines the entire cloud development with a standard provider-agnostic API.
Do a practical demo of Winglang and build an OpenAI integration.
Share my opinion about Winglang.
Let’s begin!
The Problem
Consider a “Bucket” in the cloud, which are containers that store data.
Every cloud provider (Google, Azure, AWS, etc.) has a Bucket entity:
Google has → Cloud Storage buckets.
Azure has → Blob storage.
AWS has → S3 buckets.
Now, if you think about it, their individual implementation/design could vary, but the underlying concept is the same in every case — they store data.
The same thing applies to executable entities like functions:
Google has → Cloud functions.
Azure has → Azure functions.
AWS has → Lambda functions.
Yet again, the underlying concept is the same — a function.
So, practically speaking, while the underlying objective of these infrastructural components is the same, how we interact with these providers varies significantly because each provider offers its own set of APIs, interfaces, etc.
This leads to several challenges like:
It requires us to learn and adapt to different paradigms and APIs when switching between cloud providers.
It can lead to vendor lock-in. It happens when the app and ML model running on the backend can become tightly coupled to a specific cloud provider’s ecosystem. This makes it difficult to migrate to another provider if needed.
The above pain points are especially concerning for people in AI/ML because, typically, their core work does not revolve around managing cloud infrastructure.
What is Winglang?
Winglang is an open-source programming language that abstracts away the differences between cloud providers by defining a standard infrastructural API.
In other words, Winglang provides an API that’s common to all providers.
For instance, when defining a data storage bucket in Winglang, there’s nothing like “S3 Bucket” or “Blob storage” or “Google Cloud Storage” we specifically tailor the application code to.
Instead, there’s a common abstraction called “Bucket
,” and we implement the application code specific to this “Bucket
” class. This can then be compiled and deployed to any cloud provider.
The same abstraction is available for all cloud-specific entities like functions, queues, compute units, etc.
After developing the app in Winglang, the entire application code and the infrastructure we defined can be compiled to any cloud provider in a one-line command, and Winglang takes care of all backend procedures.
This way, one can just focus on the application logic and how their app interacts with the infrastructural resources rather than the specificities of a cloud platform.
Isn’t that cool?
Let’s get into some programming details to understand how it works.
Demo
To get started, install Winglang.
We’ll use VS Code, so install Winglang’s VS code extension.
Now create a file named “main.w
”
Note: Winglang is not a Python library. It is a programming language. The file has “.w” extension.
The first step is to import the necessary cloud functionalities from the “cloud
” module of Winglang:
Next, press the Wing console button at the top right:
This opens the Wing console (shown below) where we can visualize and interact with our cloud application as it is being developed:
Let’s define a new Bucket:
As shown above, as soon as we create a Bucket
object, a new bucket pops up in the console.
Next, let’s create a Function
resource. Its purpose is to execute a piece of code, and in our case, we shall store a file in the Bucket created above.
This is demonstrated below:
First, we assign the Bucket to a variable (
myBucket
) so that we can interact with it later.Next, inside the function, we add a file “
hello.txt
” tomyBucket
with the content “Winglang Bucket
” (we’ll get back to this function syntax shortly).
Now the console also shows a Function
resource, and the edge depicts that the Function
interacts with the Bucket
.
Invoking this function from the console, as shown below, we notice that it creates a file “Hello.txt
” in the Bucket
with content “Winglang Bucket”.
What is Inflight and Preflight?
Now, if you notice closely, we specified inflight
during function definition, which brings us to a vital implementation design of Winglang.
Simply put:
Preflight
(which is also the default phase) is a phase where we define the infrastructure, including cloud resources such as buckets, counters, and other services.Inflight
is where we define the code that runs on the cloud. This code interacts with the infrastructure defined in thePreflight
phase.
One really cool thing is that we get a different API based on where we access a particular resource from.
For instance, as depicted below, the above Bucket has a different API based on where it is accessed from:
Compile code
Now that we have designed a basic app, let’s compile it. As discussed earlier, it just takes one command:
That’s it!
Compiling to AWS, for instance, provides the necessary files in the directory, which can then be deployed on that cloud provider.
OpenAI Demo
Next, let me show you how I integrated OpenAI with Winglang to build a simple Python code generator based on user input.
Get an OpenAI API key.
Here’s the workflow:
The user will enter the program they want to generate Python code for.
We shall invoke OpenAI with the prompt.
The output will be stored in a text file inside the Bucket.
To get started, we imported the necessary modules:
Next, we instantiate the OpenAI API object and define a Bucket:
Finally, we define the function (just like we did earlier), and the steps are pretty self-explanatory:
Download the code here: Winglang code demo.
Done!
Now we move to the console and invoke the function. When we check the Bucket, we see a file with the response returned by OpenAI.
Pretty cool and simple, isn’t it?
A departing note
Honestly, I learned about Winglang pretty recently. After exploring it for a few minutes, I wondered if it aligned with the overall theme of this newsletter.
But as I explored more and got an opportunity to talk to the founders, I realized how game-changing this could be for AI applications (and software apps too) in the cloud, which appears daunting to most people.
The level of abstraction is quite similar to what many Python libraries offer.
Cloud portability lets ML engineers focus more on models and less on tailoring their cloud apps specific to a provider.
One use case that comes to my mind is using Winglang to set up an automated AI workflow that can read information from the database or is triggered when a new file is added to an existing S3 Bucket.
Of course, it’s a new programming language, so there can be some friction when getting started. But the good thing is that Winglang is pretty low-code and has an intuitive syntax.
Winglang also has a Typescript SDK if you know it and don't want to learn new syntax. But it’s a bit more code than using Winglang.
Their documentation is super easy to follow, and it only took me a few hours to get familiar with the necessary stuff.
One good thing is that they do not intend to replace the Python ecosystem.
Instead, they are currently building native Python integrations because that’s where the AI/ML practitioners/researchers primarily work.
This would allow programmers to write some of the code in Wing and some in Python.
What I also learned from them is that they see this whole project as a community effort.
So, just like anyone can build and publish libraries in Python, they can do it with Winglang too (instructions). It would be good to see some cool developments in a language dedicated to cloud developments.
If you want to learn more about the motivation behind Wing, check these out:
That said, I kept the newsletter beginner-friendly, so I have not covered everything I know about Winglang.
If building cool cloud tech interests you, I can do part two of Winglang. Maybe I can share a more comprehensive ML-specific demo soon. Please mark your interest below:
While drafting this issue, I found the following video super helpful:
🙌 A big thanks to the Wing team, who very kindly partnered with me on this newsletter issue and let me share my thoughts openly.
Do give them a star on GitHub to support what they are building: Wing GitHub.
👉 Over to you: Based on this demo, where do you think Winglang can be useful in your project?
Thanks for reading!
I’m wondering how winglang compares to Pulumi, a powerful and multi-language Infrastructure as Code tool .
If you’re curious about pulumi, I explored it in a previous issue to automate the creation and deployment of a cloud function that summarizes YouTube videos.
It’d be awesome if you had a look at it 😉
https://thetechbuffet.substack.com/p/summarize-youtube-videos-with-cloud-functions
Really detailed article, thanks, Avi!