DEV Community

Alex Spinov
Alex Spinov

Posted on

Wing Has a Free API: A Programming Language Built for the Cloud

Wing is a programming language designed specifically for cloud development. It compiles to Terraform and JavaScript, letting you define cloud resources and application logic in a single file.

Why Wing Matters

Cloud apps split across two worlds: application code (TypeScript/Python) and infrastructure code (Terraform/CloudFormation). Wing unifies them. Cloud resources are first-class citizens in the language.

What you get for free:

  • Cloud resources as language primitives (buckets, queues, functions)
  • Compiles to Terraform + JavaScript simultaneously
  • Local simulator for testing cloud apps without deploying
  • Automatic IAM permissions from code analysis
  • Visual console for understanding cloud architecture
  • Deploy to AWS, GCP, Azure, or custom platforms

Quick Start

# Install
npm install -g winglang

# Create project
mkdir my-app && cd my-app
wing init

# Run in local simulator
wing it main.w

# Compile to Terraform
wing compile main.w --target tf-aws

# Deploy
terraform -chdir=target/main.tfaws apply
Enter fullscreen mode Exit fullscreen mode

Cloud Resources as Code

bring cloud;

// Cloud bucket — becomes S3 on AWS, Cloud Storage on GCP
let bucket = new cloud.Bucket();

// Cloud queue — becomes SQS on AWS, Pub/Sub on GCP
let queue = new cloud.Queue();

// Cloud function triggered by queue
queue.setConsumer(inflight (message: str) => {
  log("Processing: ${message}");
  bucket.put("processed/${message}.json", message);
});

// API endpoint
let api = new cloud.Api();

api.post("/items", inflight (req: cloud.ApiRequest): cloud.ApiResponse => {
  let body = req.body ?? "";
  queue.push(body);
  return cloud.ApiResponse {
    status: 201,
    body: "Queued for processing",
  };
});

api.get("/items/:key", inflight (req: cloud.ApiRequest): cloud.ApiResponse => {
  let key = req.vars.get("key");
  let data = bucket.get("processed/${key}.json");
  return cloud.ApiResponse {
    status: 200,
    body: data,
  };
});
Enter fullscreen mode Exit fullscreen mode

Preflight vs Inflight

bring cloud;

// PREFLIGHT: runs at compile time, creates cloud resources
let counter = new cloud.Counter();
let api = new cloud.Api();

// INFLIGHT: runs at runtime, executes on cloud
api.get("/count", inflight (): cloud.ApiResponse => {
  let current = counter.inc();
  return cloud.ApiResponse {
    status: 200,
    body: "Count: ${current}",
  };
});
Enter fullscreen mode Exit fullscreen mode

Schedules (Cron)

bring cloud;

let bucket = new cloud.Bucket();

// Run every hour
new cloud.Schedule(rate: 1h) as "hourly-backup" {
  inflight () => {
    let timestamp = datetime.utcNow().toIso();
    let data = makeBackup();
    bucket.put("backups/${timestamp}.json", data);
  }
};
Enter fullscreen mode Exit fullscreen mode

Testing (Local Simulator)

bring cloud;
bring expect;

let bucket = new cloud.Bucket();

test "bucket operations" {
  bucket.put("test.txt", "hello");
  let content = bucket.get("test.txt");
  expect.equal(content, "hello");

  let exists = bucket.exists("test.txt");
  expect.equal(exists, true);

  bucket.delete("test.txt");
  let gone = bucket.exists("test.txt");
  expect.equal(gone, false);
}
Enter fullscreen mode Exit fullscreen mode

Tests run against the local simulator — no cloud account needed.

Useful Links


Building cloud-native automation? Check out my developer tools on Apify for ready-made web scrapers, or email spinov001@gmail.com for custom solutions.

Top comments (0)