Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Wing Guide for developers to go from zero to hero with Wing #1045

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@ const config = {
includeCurrentVersion: false,
}
],
[
"@docusaurus/plugin-content-docs",
{
id: "guide",
path: "guide",
routeBasePath: "docs/guide",
editUrl: (params) =>
`${winglangOrgUrl}/wing/tree/main/docs/api/${params.docPath}`,
breadcrumbs: true,
includeCurrentVersion: false,
}
],
[
"@docusaurus/plugin-content-docs",
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: Who is this guide for?
id: guide
slug: /
keywords: [Wing contributors, contributors]
---

Welcome to our comprehensive guide on building cloud applications using **Wing**! Whether you're a seasoned developer exploring the cloud or entirely new to deploying applications in the cloud, this guide will walk you through everything you need to know. By the end, you'll have the knowledge to build, deploy, and understand how to build cloud applications with Wing.

### Who is this guide for?

This guide is designed for:

- Developers who are new to deploying applications in the cloud and want to understand the foundational concepts and tools.
- Developers exploring Wing for the first time, seeking to learn what sets it apart in the cloud development ecosystem.

If you're already building cloud applications, this guide will highlight how Wing stands apart from other Infrastructure as Code (IaC) tools you may have used.

### What you will learn

This guide will take you on a journey through:

1. **Understanding Cloud Fundamentals**: Learn the core concepts and primitives that power cloud applications.
2. **Wing Basics**: Get hands-on with Wing and explore how it unifies infrastructure and application code into a single language.
3. **Building and Deploying Your First Wing Application**: Going beyond “Hello, World!” with a real-world project designed to teach you the aspects of the Wing programming language.

---

Let’s dive in! In the next section, we’ll look at the application we’ll be building.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: What does this guide cover?
id: cover
keywords: [a, b]
---

In this guide, we’ll walk through the step-by-step process of creating a **file-sharing application** using **Wing** for the backend and **React** for the frontend.

This project will give you hands-on experience building and deploying a real-world cloud application, showcasing Wing’s capabilities in a practical, accessible way.

### What are we building?

The application is a **single-page application (SPA)** powered by APIs, queues, and storage. It has two core components:

1. **Backend**: Built using **Wing**, responsible for managing the core business logic and integrating with cloud services.
2. **Frontend**: A **React**-based interface for users to interact with the application.

We will develop the application locally using Wing’s built-in tools and deploy it to the cloud once it’s complete.

### Application features

The file-sharing application will include the following functionality:

- **Temporary Spaces**: Users can create temporary “Spaces” to upload and share files with friends.
- **Time-Limited Access**: Spaces are only valid for 15 minutes, ensuring files are accessible for a short duration.
- **Messaging and Attachments**: Users can send messages and attach files for their friends.
- **Email Notifications**: Friends receive email notifications when they are sent files or messages.

### What you will learn

Throughout this guide, you’ll learn how to:

1. **Build backend logic with Wing**:
- Set up cloud infrastructure components such as APIs, queues, and storage.
- Simulate and test the application locally with Wing’s simulation tools.

2. **Creating a React frontend**:
- Develop an intuitive, user-friendly interface for the application.
- Integrate the frontend with the backend APIs.
- Connecting Wing to your frontend application

3. **Deploy to the Cloud**:
- Use Wing’s AWS platform to seamlessly transition the application from local development to a live cloud environment.


This project is a fantastic opportunity to explore Wing’s powerful development model while building a functional, engaging application.

---

Let’s start by setting up the application and diving into its backend with Wing!

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: How to get help
id: help
---

If you encounter any challenges while following this Wing Guide, the WingLang community is here to help! Join the WingLang team and fellow developers on Discord to ask questions, share your progress, and get support.

- [Join the Wing Discord](https://t.winglang.io/discord)
3 changes: 3 additions & 0 deletions guide_versioned_docs/version-latest/01-preface/_category_.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
label: Preface
collapsible: true
collapsed: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: What is cloud computing?
id: cloud-computing
slug: /cloud-computing
keywords: [Wing contributors, contributors]
---

Cloud computing is the on-demand delivery of computing resources—like servers, storage, databases, networking, and software—over the internet ("the cloud"). Instead of maintaining physical hardware or complex infrastructure, you simply use what you need, when you need it, and pay only for what you use.

Think of it like renting instead of buying:
- You don't need to build or maintain your own power grid to enjoy electricity at home—you just plug in and pay the power company.
- Similarly, with cloud computing, you don’t need your own data center; you just connect to the cloud provider and let them handle the heavy lifting.

## Why Cloud Computing?
- **Scalability:** Start small, and grow as your needs increase—no upfront investment required.
- **Flexibility:** Access your data and applications from anywhere, anytime.
- **Cost-Efficiency:** Pay only for what you use, and avoid the costs of owning and maintaining hardware.
- **Innovation at Your Fingertips:** Use cutting-edge tools, from AI to big data processing, without building them yourself.

## Examples in Everyday Life
- **Streaming Services** like Netflix and Spotify store and deliver their content using the cloud.
- **File Storage** platforms like Google Drive and Dropbox allow you to access your documents from any device.
- **Online Shopping** sites use the cloud to manage inventory, process payments, and deliver personalized recommendations.

In the next section, we’ll explore **cloud primitives**—the fundamental building blocks of cloud applications.

Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
title: Understanding cloud primitives
id: cloud-primitives
slug: /cloud-primitives
keywords: [Wing contributors, contributors]
---

# Understanding Cloud Primitives

To build cloud applications, it’s crucial to understand cloud primitives—the essential building blocks that represent the core capabilities of cloud computing. These primitives act like the bricks in a wall, forming the foundation for scalable, reliable, and efficient applications.

In this section, we’ll introduce some of the most common cloud primitives and explore their roles in cloud-based systems. This understanding will be valuable as you dive deeper into building applications with Wing later in this guide.

---

## 🚀 **Functions**

Functions are a way to execute specific tasks in the cloud. Often referred to as "serverless functions" in cloud contexts, they enable you to run code without worrying about managing the underlying infrastructure. Functions are:
- **Event-driven**: Triggered by specific events like a file upload, API request, or database update.
- **Stateless**: Each function execution is isolated, with no inherent memory of previous runs.
- **Scalable**: Automatically scales to handle the number of incoming requests.

Functions are ideal for microservices, automation, and APIs.

---

## 🗄️ **Storage**

Cloud storage primitives provide a way to persist data securely and at scale. There are several types of storage designed for specific use cases:
- **Object Storage**: Used for storing files, images, videos, or backups. Examples include storing user-uploaded profile pictures or large datasets.
- **Database Services**: Primitives like managed SQL or NoSQL databases for structured or unstructured data.

---

## 🔄 **Queues**

Queues are essential for managing communication between components in distributed systems. They help decouple services by storing and delivering messages between producers (senders) and consumers (receivers). Key benefits include:
- **Asynchronous Processing**: Tasks can be completed at a later time, improving system responsiveness.
- **Scalability**: Multiple consumers can process messages concurrently.
- **Reliability**: Ensures messages are not lost even if the receiving service is temporarily unavailable.

---

## 📡 **APIs**

APIs are interfaces that allow different systems to communicate. They enable applications to interact with each other, often exchanging data or triggering actions. Key features of APIs include:

- **Request Handling**: Facilitating interactions between clients (such as web or mobile apps) and services.
- **Authentication**: Enforcing access controls to ensure secure communication.
- **Monitoring**: Tracking usage metrics and ensuring optimal performance.

---

## 🛠️ **Infrastructure as Code (IaC)**

While not a specific primitive, Infrastructure as Code is a vital concept for defining cloud primitives programmatically. With IaC, developers can:
- Define resources like functions, queues, and storage using configuration files.
- Reproduce environments consistently across teams and deployments.
- Version-control infrastructure alongside application code.

:::tip Why Choose Wing When We Already Have Infrastructure as Code Options?
Wing takes a fresh approach to Infrastructure as Code by seamlessly integrating infrastructure and application logic into a single programming model.
With this hands-on guide, you'll discover how Wing stands apart from traditional IaC frameworks.
:::

---

## 🔒 **Identity and Access Management (IAM)**

IAM primitives ensure that resources are accessed securely and only by authorized entities. Key elements include:
- **Users and Roles**: Represent individuals or services that access the resources.
- **Permissions**: Define who can perform specific actions on particular resources.
- **Policies**: Granular rules that enforce access control.


:::tip How Does Wing Handle Permissions?
Wing simplifies permission management by analyzing your infrastructure and application logic. When deploying your application, Wing automatically determines and applies the necessary permissions.

Need more control? Wing also allows you to customize permissions to fit your specific requirements.
:::

---

## 🕸️ **Networking**

Networking primitives enable cloud resources to communicate with each other and the outside world. They include:
- **Virtual Private Clouds (VPCs)**: Isolated networks within the cloud for private resource communication.
- **Load Balancers**: Distribute incoming traffic across multiple services for high availability.
- **DNS Services**: Resolve domain names to IP addresses, making services accessible.

---

## Putting It All Together

By understanding and combining these cloud primitives, you can build cloud applications tailored to your specific needs. Whether you’re handling data, running services, or managing communication, these building blocks make it all possible.

In the next section, we’ll explore how to connect these primitives to create a complete cloud-based application. Ready to get hands-on? Let’s go!

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: What problems is Wing solving?
id: problems-wing-solves
slug: /problems-wing-solves
keywords: [Wing]
---

Wing aims to address various pain points at both the developer and organization levels.

**Developer pain points:**

1. **Slow iteration cycles**: Long deployment times and difficulty testing and debugging cloud code hinder productivity and take developers out of their creative flow.
2. **Too many tools**: Numerous tools solve small problems but don't address the root cause of difficulties in cloud development.
3. **Lack of local development solutions**: There's a need for full simulation, visualization, and fast reloading in local development environments.
4. **Complex cloud mechanics**: Developers need to understand cloud mechanics, such as IAM policies and networking, to be effective, even though these mechanics don't have a direct impact on the value they create for users.

**Organization pain points:**

1. **Dev/ops friction**: Poor separation of concerns between development and operations teams can cause tension due to the mutual reliance of developers and DevOps on each other. Developers and operations teams need to be in sync and often have to wait for one another, as they are involved in each other's workflows. This interdependence can lead to miscommunication, delays, and frustration on both sides.
2. **Error-prone security/observability**: Ensuring security and observability can be challenging and prone to mistakes, as observability dashboards and IAM policies are often written by hand. Errors can occur, and the need for frequent updates whenever code changes exacerbate the problem. Additionally, those responsible for writing and updating these policies and dashboards are usually not the developers who write the code, which can contribute to misalignments and misunderstandings.
3. **Cloud vendor lock-in**: Reliance on a single cloud provider can limit flexibility and increase risk.
4. **Need for multi-cloud**: Organizations require the ability to deploy and manage applications across multiple cloud providers.

Wing aims to enhance the developer experience by treating the entire cloud as its target computer, bringing the benefits of compilers that handle lower stack levels to cloud development. This approach enables developers to focus on creating user value, enjoy greater independence, and experience instant feedback with faster iteration cycles, making cloud application development more enjoyable and efficient.

We'd like developers be able to write code with a "pencil" rather than a "pen," iterating quickly and learning from their mistakes. They could make a change and test it within milliseconds, even without WiFi.

---

With all that said, the best way to learn and understand Wing is by diving in and building something! Let’s get hands-on and create our first "Hello, World!" application.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
label: Introduction
collapsible: true
collapsed: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
---
title: What is Wing?
id: what-is-wing
slug: /what-is-wing
keywords: [Wing contributors, contributors]
---

Wing is a **cloud-oriented programming language** designed to simplify cloud development.

It empowers developers to build distributed systems that fully harness the power of the cloud, without the need to manage the underlying infrastructure.

Wing is best explained through an example:


```js example title="main.w"
bring cloud;

let queue = new cloud.Queue(timeout: 2m);
let bucket = new cloud.Bucket();
let counter = new cloud.Counter(initial: 100);

// Setup consumer for messages on the queue
queue.setConsumer(inflight (body: str) => {
let next = counter.inc();
let key = "myfile-{next}.txt";
bucket.put(key, body);
});
```

In this simple application, every message that goes into the [queue](/docs/guide/cloud-primitives#-queues) is written to
a new object inside a [cloud bucket](/docs/guide/cloud-primitives#%EF%B8%8F-storage). An atomic counter is used to generate an
incrementing and unique key for each object.

***But don't let the simplicity of this example fool you!***

When compiling this code, the Wing compiler will produce a bundle of artifacts
that are ready to be deployed to a cloud provider. This bundle includes
[Terraform] files which define the infrastructure resources required for this
application and [JavaScript] code to run on cloud compute resources.

When deployed to the cloud, this application can handle an infinite amount of
traffic, with no need for you to explicitly take care of scaling, load
balancing, security policies, or any other infrastructure-related concerns. For
example, when targeting AWS, Wing will use Amazon S3 for the bucket, Amazon SQS
for the queue, Amazon DynamoDB for the atomic counter, and AWS Lambda for the
handler. It will also render least privilege IAM security policies, wire up
environment variables and produce the code bundles needed for this to work on AWS Lambda.

In addition to targeting cloud providers, Wing applications can also be compiled
to run inside a local **Cloud Simulator**. This means that you can now iterate
on your code without having to deploy it to the cloud, write **unit tests** that
cover your complete cloud architecture and **debug** your code in a local
environment.

Every Wing installation includes access to the [Wing Console](/docs/tools/wing-console), a visual application-centric operations and management console that lets you interact with the cloud simulator.
Through the console you can view logs, inspect resources, and even run unit tests:

![Wing Console screenshot](./console-demo-1.png)

This is what we call **cloud-oriented programming**. It's a programming paradigm
which treats the cloud as a computer, and heavily relies on managed services and
distributed programming to build and deliver systems that are intrinsically
scalable, highly-available, and robust.

## Why you should consider Wing?

The cloud has evolved to become a ubiquitous platform for running many types of applications.
However, the cloud has also introduced a new set of challenges for developers.
Writing applications often requires understanding low-level details of cloud services, and barriers between the spaces of infrastructure and runtime code make it increasingly difficult to test and debug applications locally.

Wing addresses these challenges through several key pillars:

* **Iteration speed** - Wing applications can run in a local cloud simulator.
This allows developers to iterate at a much faster pace, and to see the
effects of incremental changes at milliseconds latency.
Unit testing in Wing can validate architectures end-to-end without requiring deployments or heavy mocking.
* **High-level cloud primitives** - The batteries-included Wing Cloud Library allows developers to leverage the power of the cloud
to its full extent through a set of rich, high-level and cloud-portable
resources. This allows developers to build complete cloud applications without
having to be infrastructure experts.
* **Distributed computing support** - Traditional languages are designed to tell a single machine what to do, but the cloud at its core is a big distributed system.
Wing allows cloud applications to be written more naturally through the concepts of [preflight and inflight code](https://www.winglang.io/docs/concepts/inflights), which allow infrastructure and runtime code to be interleaved while
giving developers the speed safety they expect from modern tooling.
* **Infrastructure as policy** - Infrastructure concerns such as deployment,
networking, security, and observability can be applied horizontally through
policies instead of inside the application code.

## This is a pre-release 🧪

We are working hard to make this a great tool, but there's still a pretty good
chance you'll encounter missing pieces, rough edges, performance issues and even,
god forbid, bugs 🐞.

Please don't hesitate to ping us on [Discord](https://t.winglang.io/discord) or
[file an issue](https://github.com/winglang/wing). We promise to do our best to
respond quickly and help out.

Our <a href="https://www.winglang.io/contributing/status">Project Status</a> page includes
more information about stability and roadmap 👷‍♀️

[Terraform]: https://www.terraform.io/
[JavaScript]: https://developer.mozilla.org/en-US/docs/Web/JavaScript

---

Now you know more background about Wing, let's create our first Wing application!
Loading
Loading