Skip to main content

Inflight Magazine no. 6

· 8 min read
Revital Barletz
Head of Community
Elad Ben-Israel
Co-Founder & CEO at Wing Cloud
Uri Bar
Director of Engineering

The 6th issue of the Wing Inflight Magazine.

Hey folks!

We are back with another issue of the Wing Inflight Magazine and excited to share some updates about the Winglang project.

An open source programming language for the cloud

Winglang is an open-source programming language for the cloud. It combines infrastructure and runtime into a single programming model, making it easy for any developer to build serverless cloud-native applications without having to become a DevOps expert.

Winglang code compiles to Terraform + JavaScript and can be deployed on AWS, GCP and Azure (see support matrix).

Winglang is designed to be a familiar and friendly language to learn for developers who come from modern object-oriented background, so it will take you 5 minutes to learn.

Check out our getting started tutorial or hit the Wing Playground for an online experience.

In today's issue

Introducing custom platforms

An integral part of Wing's power comes from the use of platform providers. Platform providers are libraries which specify how and where your application is deployed. They determine both the cloud environment (e.g. AWS, GCP, Azure) and the provisioning engine (e.g. Terraform, CloudFormation) that the application will be deployed with.

Today, Wing is shipped with the following built-in platforms:

  • sim - runs your entire app on a single machine. Used for development with the Wing Console or for unit tests with wing test.
  • tf-aws, tf-azure, tf-gcp - deployes your app to AWS, Azure or GCP using Terraform.
  • awscdk - deploys your app to AWS using the AWS CDK (CloudFormation).

Platform providers can also hook into the compliation process to perform any type of "bellow the abstraction" customization during preflight, either on the construct nodes or directly on the output Terraform our CloudFormation.

Built-in platforms look the same as our previously supported targets:

wing compile -t tf-aws
wing compile --platform tf-aws

Platform providers can also be composed together:

wing compile --platform tf-aws --platform tf-aws-soc2

Check out our documentation about platforms for more details.

❤️ Hasan Abu-Rayan ❤️

Singletons, the Wing way

There are situations where it makes sense for a certain resource to have only a single instance within a Wing application. To facilitate that, we are now making it easy to access the root node of the app through Node.of(this).root. Then, with tryFindChild() you can get to singleton nirvana:

A common use cases for singletons in Wing is to add a Terraform provider only once. Other examples could be a shared resource such as a VPC that other resources across the app can use.

Check this out:


class SingletonBucket {
pub static of(scope: std.IResource): cloud.Bucket {
let uid = "SingletonBucket";
let root = std.Node.of(scope).root;
let rootNode = std.Node.of(root);
return unsafeCast(rootNode.tryFindChild(uid)) ?? new cloud.Bucket() as uid in root;
}
}

let q1 = new cloud.Queue() as "q1";
let store1 = SingletonBucket.of(q1);

test "singleton" {
store1.put("hello", "world");
}

❤️ Elad Ben-Israel ❤️

String interpolation syntax is getting a face lift

We decided to change the syntax of string interpolations from ${foo} to {foo}. It's a stylistic choice which also offers better ergonomics in the IDE (you can just select a portion of the string and click { to get that portion interpolated).

Unsurprisingly, this change stirred a major emotional response in our team, and we would love to hear what people think about it.

let s1 = "hello";

// Before
let s2 = "${s1}, world";

// After
let s3 = "{s1}, world";

❤️ Yoav Steinberg ❤️

Constructors are now called new() instead of init()

Another stylistic choice (this one with much less pushback) was to change the name of class constructors to new() instead of init():

class Nice {
isNice: bool;

new() {
this.isNice = true;
}
}

❤️ Elad Ben-Israel ❤️

http.fetch() response body is not optional anymore

To streamline the interaction with HTTP responses, we've changed the body field of HttpResponse (returned from http.fetch(), http.get(), etc) to return a non-optional str instead of str?. If there is no body, the body will an empty string ("").

This means that, for example, you can simply call Json.parse(response.body) or Struct.parseJson(response.body) and move on with your life.

bring http;

test "wingly" {
let response = http.get("https://someapi.org");
let jsonBody = Json.parse(response.body);
// 💝
}

❤️ Chris Rybicki ❤️

Down-casting from cloud.* to aws.*

Winglang now supports a way to cast down an abstract cloud.Bucket or any Wing Cloud Library resource into its AWS counterpart. This makes it easy to access AWS-specific attributes (such as ARNs) given a cloud resoufce.

For example, let's say we want to obtain the ARN of an S3 Bucket:

bring cloud;
bring aws;

let bucket = new cloud.Bucket();
if let b = aws.Bucket.from(bucket) {
let bucketArn = b.bucketArn;
}

Notice that aws.Bucket.from() returns an optional (str?), which will be nil in case the casting failed. This makes it easy to write code that's conditional on the target platform.

❤️ Marcio Cruz ❤️

Sourcemaps and Stacktraces

We've added source maps to the generated JavaScript output. These are used, for example, to show .w files in stack traces emitted in errors.

As an example, the except.equal() call fails (because 5 != 8) and the stack trace ion the error only showed the compiled JavaScript code, now you'll see the .w files:

bring expect;

let x = 2;
let y = 3;
expect.equal(x + y, 8);

Here's how this looks now:

sourcemaps_and_stacktraces_after

❤️ Mark McCulloh ❤️

Upcoming Events

🔥 Workshop: Wing + Amazon Bedrock = ❤️ - January 3rd @4:30 - 6pm IST Get your hands dirty Eyal Keren as we build together an application that allows you to load any PDF file and ask questions about it using one of Amazon Bedrock's generative AI models. Reserve your spot.

The Wingly Update

The Wingly Update is our weird biweekly stream where we share the latest developments of the project, chat with folks from the cloud industry, geek out and celebrate the beauty of the cloud.

If you haven't been able to catch our show, you can find the complete stack of all our episodes here.

Here are a few segments from the previous shows we thought might be interesting to check out:

Community Meetings

If you are looking to interact more directly with the Wing team, we are hosting a bunch of reccuring meetings. Feel free to pop in any time and hang out with us:

Winglang Community Meeting is our bi-weekly gathering where members of our community showcase cool apps, demos, and other projects! The upcoming session is scheduled for Tuesday, December 19th, at 2:30 PM UTC. We look forward to seeing you there!

Monday Office Hours is our bi-weekly opportunity for you to share your feedback, thoughts, concerns, or simply drop by to say hi.

You can find details for all our events in the Wingnuts calendar! We'd love to see you at one or all of them :)

Summary

That's it for this edition!

If you're not already, stay updated on the latest changes in our repo.

You'll find us regularly on Discord, so feel free to say hello! Give winglang.io a visit and take Wing out for a spin.

Catch you in the next update!