Skip to content

Commit

Permalink
update WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
boyney123 committed Dec 4, 2024
1 parent 3ac26ca commit 50b7967
Show file tree
Hide file tree
Showing 6 changed files with 274 additions and 0 deletions.
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,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!
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
title: Installation and setup
id: installation
slug: /Installation
keywords: [Wing contributors, contributors]
---

Now that we have some background on Wing and cloud computing, we are ready to create our first Wing application.

1. [Install Wing](#installing-wing)
2. [Setup Wing Project](#setup-your-wing-project)
3. [Creating Hello World API](#creating-a-hello-world-api)

## Installing Wing

First thing we need to do is install Wing on your computer. You can do this running the command below

```bash
npm install -g winglang
```

Once Wing has finished installing you can verify the installation with this command:

```bash
wing --version
```

Now you have Wing installed, let's build our first application.

## Setup your Wing project

Create an empty directory for your project:

```bash
mkdir hello-world-wing
cd hello-world-wing
```

Next we will use the [Wing CLI](/docs/api/cli#compile-test-and-run-wing-programs) to bootstrap our new project. Use the `new` command to create the project.

```bash
wing new empty
```

Running the command generates the following files in your new folder:

```bash
hello-world-wing/
├── main.w
├── package-lock.json
└── package.json
```

#### File descriptions
- **`main.w`**: The main file where your Wing application logic resides.
- **`package-lock.json`**: Automatically generated file that locks the versions of dependencies for consistent installs.
- **`package.json`**: Defines your project configuration, including dependencies and metadata.

Your `main.w` file will contain a very basic Wing application.

```js
bring cloud;
bring expect;

// Cloud function to return hello world
let fn = new cloud.Function(inflight () => {
return "hello, world";
});

// Testing your cloud function
test "fn returns hello" {
expect.equal(fn.invoke(""), "hello, world");
}
```

This example shows how you can create a function and test the output of that function.

In the next step, we will change this and add a new [API](/docs/guide/cloud-primitives#-apis) and [storage](/docs/guide/cloud-primitives#%EF%B8%8F-storage).

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: First Wing application
id: first-wing-app
slug: /first-wing-app
keywords: [Wing]
---

# Creating the Hello World API

What we will do now is create our first API. This API will:

- Have a GET route to return information from storage (bucket)
- Have a POST route to store data into a storage (bucket)
- Have a health endpoint for our API.

### 1. Creating an API and a bucket

The first step is to create a new [API](http://localhost:3000/docs/guide/cloud-primitives#-apis) and [Bucket](http://localhost:3000/docs/guide/cloud-primitives#%EF%B8%8F-storage) in your Wing application.

This is done using the [Wing Cloud Library](/docs/api/category/cloud).

```js
bring cloud;

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

// Create the storage
let storage = new cloud.Bucket();
```


:::info What is the Wing Cloud Library?
The Wing Cloud Library provides a collection of cloud primitives that you can use in your applications.
These primitives include APIs, buckets, functions, queues, and more. Learn more about them [here](/docs/api/category/cloud).
:::

Let's add a simple endpoint on our API that returns some static data.

```js
bring cloud;

let api = new cloud.Api();
let storage = new cloud.Bucket();

api.get("/hello", inflight() => {
return cloud.ApiResponse {
status: 200,
body: "world"
};
});
```


## Putting it all together
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
label: First Wing application
collapsible: true
collapsed: true
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 50b7967

Please sign in to comment.