Skip to main content

Why We're Building a Programming Language for Cloud Development in the AI Era

ยท 9 min read
Shai Ber

Why should we invest in developing a new programming language (for humans) today, when AI is rapidly advancing and taking over more coding tasks?

I often encounter this question in various forms:

  1. Won't AI eventually write machine code directly, rendering programming languages obsolete?
  2. Can a new language introduce features or capabilities that AI cannot achieve using existing languages? (e.g., why create a cloud-portable language when AI can write code for a specific cloud and then rewrite it for another?).
  3. Is it worthwhile to create tools for developers who might soon be replaced by AI?

Firstly, I must admit that I cannot predict the pace of AI advancement. Reputable experts hold differing opinions on when, or if, AI will replace human developers.

However, even if AI does eventually replace human developers, it may not necessarily write machine code directly. There's no need to burden AI with larger, more complex tasks when smaller, simpler ones can yield faster, higher-quality results. Thus, it could be more practical for AI to rely on proven abstraction layers and compilers, allowing it to efficiently focus on the unique aspects of the business it serves rather than reinventing the wheel for each app.

Having covered the more distant future, I now want to focus on the more immediate future in the remainder of this post.

I believe that, given human limitations and psychology, change will likely be gradual despite AI's rapid progress, leading to a significant transitional period with humans remaining in the loop. For instance, it's hard to imagine organizations not desiring a human to be accountable for the AI's output. In cases where things go awry and the AI cannot automatically resolve the issue, that human will probably want the ability to dive into the code.

Therefore, I believe that for the forseeable future there is room for tools that make it easier for both humans and AI to write quality code swiftly, collaborate effectively, and test more rapidly. Such tools will allow us to enhance the quality and speed of our application delivery.

The Key: Reducing Cognitive Load and Accelerating Iterationโ€‹

Whether you're an AI or a human developer, reducing cognitive load and iterating faster will result in better applications developed more quickly.

So, what can be done to make these improvements?

Working at a Higher Level of Abstractionโ€‹

Utilizing a higher level of abstraction offers the following benefits for both human and AI coders:

  1. Reduces cognitive load for human developers by focusing on the app's business logic instead of implementation details. This enables developers to concentrate on a smaller problem (e.g., instructing a car to turn right, rather than teaching it how to do so), deal with fewer levels of the stack, write less code, and minimize the surface area for errors.
  2. Reduces cognitive load for AI. This concept may need further clarification. AI systems come pre-trained with knowledge of all levels of the stack, so knowing less is not a significant advantage. Focusing on a smaller problem is also not a substantial benefit because, as long as the AI knows how to instruct the car to turn, it shouldn't have an issue teaching it how to do so instead of just telling it to turn. However, allowing the AI to write less code and reducing the chance for it to make mistakes is highly beneficial, as AI is far from infallible. Anyone who has witnessed it hallucinate interfaces or generate disconnected code can attest to this. Furthermore, AI is constrained by the amount of code it can generate before losing context. So writing less code enables AI coders to create larger and more complex parts of applications.
  3. Accelerates iteration speed because it requires writing less code, reducing the time it takes to write and maintain it. While it might not seem intuitive, this is equally important for both human and AI coders, as AI generates code one token at a time, similar to how a human writes.
  4. Improves collaboration between human and AI coders. A smaller code base written at a higher level of abstraction allows human developers to understand, modify and maintain AI-generated code more quickly and easily, resulting in higher quality code that is developed faster.

Faster Deployment and Testingโ€‹

Currently, deploying and testing cloud applications can take several minutes. Multiply this by numerous iteration cycles, and there's significant room for improvement.

Running tests locally is also challenging, as it requires mocking the cloud environment around the tested component.

Moreover, it's impossible to use the same tests locally and in the cloud.

By writing tests that can run both locally and in the cloud, and executing them quickly, we can vastly improve iteration speeds, regardless of whether the code is written by an AI, a human, or a collaboration between them.

So, how can we make this happen?

Introducing Winglangโ€‹

Winglang is a new programming language for cloud development that enables both human and AI developers to write cloud code at a higher level of abstraction, and comes with a local simulator that lets them test it super quickly.

Quantifying the Improvementโ€‹

We're talking about a 90%-95% reduction in code and a 100X increase in testing speeds.

Let's See Some Codeโ€‹

Here's an example of a small app that uploads a file to a bucket using a cloud function.

This is the code in Wing:

bring cloud;

let bucket = new cloud.Bucket();

new cloud.Function(inflight () => {
bucket.put("hello.txt", "world!");
});

As you can see, either a human or an AI coder that writes Wing code is working at a high level of abstraction, letting the Wing compiler take care of the underlying cloud mechanics, such as IAM policies and networking (don't worry, it is customizable and extensible, so you don't lose control when needed).

Unlike human and AI coders, the compiler cannot make mistakes. It is also faster, deterministic and doesn't lose context after a while. So the more work we delegate to it over either human or even AI the better.

By the way, the code can be compiled to any cloud provider, and its output is Terraform and JavaScript, which can be deployed with existing tools.

Now let's take a look at the same code in the leading cloud development stack today - Terraform + JavaScript.

main.tf:

terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
}
}

provider "aws" {
region = "us-west-2"
}

locals {
lambda_function_name = "upload_hello_txt_lambda"
}

resource "aws_s3_bucket" "this" {
bucket = "my-s3-bucket"
acl = "private"
}

data "archive_file" "lambda_zip" {
type = "zip"
source_file = "index.js"
output_path = "${path.module}/lambda.zip"
}

resource "aws_lambda_function" "this" {
function_name = local.lambda_function_name
role = aws_iam_role.lambda_role.arn
handler = "index.handler"
runtime = "nodejs14.x"
filename = data.archive_file.lambda_zip.output_path
timeout = 10

environment {
variables = {
BUCKET_NAME = aws_s3_bucket.this.bucket
}
}
}

resource "aws_iam_role" "lambda_role" {
name = "lambda_role"

assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRole"
Effect = "Allow"
Principal = {
Service = "lambda.amazonaws.com"
}
}
]
})
}

resource "aws_iam_role_policy" "lambda_policy" {
name = "lambda_policy"
role = aws_iam_role.lambda_role.id

policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
]
Effect = "Allow"
Resource = "arn:aws:logs:*:*:*"
},
{
Action = [
"s3:PutObject"
]
Effect = "Allow"
Resource = "${aws_s3_bucket.this.arn}/*"
}
]
})
}

output "bucket_name" {
value = aws_s3_bucket.this.bucket
}

output "lambda_function_name" {
value = aws_lambda_function.this.function_name
}

index.js:

const AWS = require('aws-sdk');
const S3 = new AWS.S3();

exports.handler = async (event) => {
const bucketName = process.env.BUCKET_NAME;
const key = 'hello.txt';
const content = 'Hello world!';

const params = {
Bucket: bucketName,
Key: key,
Body: content,
};

try {
await S3.putObject(params).promise();
return {
statusCode: 200,
body: JSON.stringify('File uploaded successfully.'),
};
} catch (error) {
console.error(error);
return {
statusCode: 500,
body: JSON.stringify('Error uploading the file.'),
};
}
};

As you can see, we have to write 17X more code and dive deeply into lower layers of the cloud stack.

You might be wondering if there are newer solutions against which Wing's gains are less significant, or if the same results can be achieved through a library or a language extension. You can see how Wing compares to other solutions and why it's a new language rather than some another solution here.

Testing with Wingโ€‹

Wing comes out of the box with a local simulator and a visualization and debugging console.

These tools enable developers to work on their code with near-instant hot-reloading and test cloud applications very easily without having to mock the cloud around them.

This is a short video of the experience.

You can play with it yourself with zero friction in the Wing Playground.

Conclusionโ€‹

Although Wing introduces significant improvements in cloud development, we understand that migrating to a new language is a substantial undertaking that may be hard to justify in many cases.

Weโ€™ve gone to great lengths to make adopting the language as easy as possible with the following features:

  • Easy to learn because it is similar to other languages.
  • Works seamlessly with your existing stack and tools (especially deployment and management).
  • Mature ecosystem - import any NPM module or Terraform resource into your code.
  • Integrates into existing code bases - write runtime code in other languages and reference it with Wing.

Furthermore, we believe that in the era of AI, adopting a new language like Winglang is easier for humans as AI assists in writing code in unfamiliar languages and frameworks and simplifies the migration of existing code to new languages.

As we move toward a future where AI plays a more significant role in code development, the creation and adoption of languages like Winglang will ensure better collaboration, faster development, and higher-quality applications for both human and AI developers.

To get a glimpse of the future and experience writing code in Wing and testing it instantly, you can visit our playground.