Ejecutando TypeScript en WebAssembly en la Nube

Rate this content
Bookmark

Construye funciones sin servidor en TypeScript y luego compílalas a WebAssembly (Wasm) para ejecutarlas en la nube. Este es un modelo diferente al diseño original sugerido por Wasm, pero está demostrando ser un concepto poderoso. En esta charla, profundizaremos en el trasfondo de Wasm, luego analizaremos sus aplicaciones más amplias antes de examinar una forma novedosa de construir código TypeScript en un binario Wasm para su ejecución en la nube.

Matt Butcher
Matt Butcher
10 min
21 Sep, 2023

Comments

Sign in or register to post your comment.

Video Summary and Transcription

La charla de hoy discute cómo ejecutar TypeScript en WebAssembly en la nube utilizando el tiempo de ejecución de WebAssembly de Fermion. Fermion proporciona un entorno sin servidor llamado Spin que permite el desarrollo fácil de aplicaciones sin servidor en varios lenguajes. El proceso de creación de una aplicación sin servidor de TypeScript con Spin implica instalar Spin, crear una nueva aplicación utilizando la plantilla HTTP TS y probarla en localhost. Para implementar la aplicación, se utiliza el comando 'spin deploy' y Fermi en la nube se encarga del enrutamiento y hace que la aplicación sea accesible a través de una URL pública.

Available in English

1. Introducción a WebAssembly y Cloud Runtime

Short description:

Hola, soy Matt Butcher, uno de los fundadores de Fermion Technologies. Hoy vamos a hablar sobre cómo ejecutar TypeScript en WebAssembly en la nube. WebAssembly es una tecnología basada en el navegador que te permite compilar diferentes lenguajes a un formato de tiempo de ejecución neutral. Ofrece tiempos de inicio rápidos, tamaños de binario pequeños y soporte multiplataforma. Extraímos el tiempo de ejecución de WebAssembly del navegador y construimos un tiempo de ejecución en la nube.

Hola, soy Matt Butcher. Soy uno de los fundadores de Fermion Technologies, y hoy vamos a hablar sobre cómo ejecutar TypeScript en WebAssembly en la nube. Así que hay muchos términos que desglosar aquí.

Comencemos rápidamente con WebAssembly. Es posible que estés familiarizado con WebAssembly como una tecnología basada en el navegador. La idea original era construir un tiempo de ejecución en un formato binario en el que se pudieran compilar muchos lenguajes diferentes al mismo formato de tiempo de ejecución neutral y ejecutarlo dentro del navegador, junto con JavaScript. Por ejemplo, en el caso de alguien como Figma, utilizaron WebAssembly para tomar su código C++, compilarlo a WebAssembly y luego interactuar con él desde su JavaScript que se ejecuta en el navegador.

Ahora, en Fermion, analizamos WebAssembly, y vimos que las características del tiempo de ejecución de WebAssembly son perfectas para la nube. Tiene tiempos de inicio muy rápidos, tamaños de binario muy pequeños, el modelo de aislamiento de seguridad es excelente, y por supuesto, admite multiplataforma, arquitectura cruzada y múltiples lenguajes. Así que tomamos el tiempo de ejecución de WebAssembly, lo sacamos del navegador, lo colocamos en la nube, y comenzamos a construir un tiempo de ejecución en la nube.

2. Introducción a Serverless y Spin

Short description:

Fermion es un entorno serverless que te permite prescindir de configurar servidores y manejar código boilerplate. En serverless, el punto de entrada de la aplicación es el controlador de eventos, que recibe una solicitud HTTP, la maneja y devuelve una respuesta. Spin es una herramienta y plataforma de programación de código abierto que te permite crear aplicaciones serverless en varios lenguajes y ejecutarlas en la nube en un estilo serverless. Spin admite lenguajes de primer nivel como Rust, Go, Python, JavaScript y TypeScript, y se enfoca en proporcionar un estilo de desarrollo de programas simple y fácil en el entorno serverless.

Entonces, el segundo término que queremos definir es serverless. Fermion es un entorno serverless. Spin construye aplicaciones serverless, pero serverless en sí es un término que a veces se utiliza de manera poco clara. Quiero dejarlo muy claro a qué me refiero cuando hablo de serverless. ¿Qué es el servidor del que prescindimos? Bueno, para mí, es el servidor de software. Si estás acostumbrado a construir microservicios u otras tecnologías backend, sabes que el primer paso suele ser configurar algún tipo de servidor, algo que iniciará un servidor de sockets, abrirá un puerto, escuchará las solicitudes entrantes y las manejará. Terminas escribiendo todo tipo de código boilerplate como manejo de interrupciones y carga de certificados TLS y todo ese tipo de cosas. Entonces, en serverless, para mí, una aplicación serverless es aquella en la que podemos prescindir de todo eso. Donde el punto de entrada de la aplicación es el controlador de eventos. Hablaremos principalmente sobre HTTP, aunque esto también podría aplicarse igualmente a consumir algo de una cola de PubSub o lidiar con un disparador basado en el tiempo, pero en HTTP, el evento es una solicitud HTTP que llega. Obtienes esa solicitud, manejas la solicitud, devuelves una respuesta HTTP y cierras. Entonces, no hay configuración de un servidor, no hay configuración de certificados TLS, nada de eso. El entorno serverless dice que solo tienes que definir un controlador de eventos que reciba la solicitud y devuelva una respuesta. Así que queríamos tomar WebAssembly, ponerlo en el lado del servidor y construir un marco serverless. Para hacer eso, necesitábamos una herramienta, así que construimos Spin. Spin es una herramienta de programación de código abierto y, en cierto sentido, una plataforma que te permite crear aplicaciones serverless en varios lenguajes, compilarlas a WebAssembly y ejecutarlas en un estilo serverless en la nube. Spin admite como lenguajes de primer nivel a Rust, Go, Python y, por supuesto, JavaScript y TypeScript, aunque también admite varios lenguajes de segundo nivel. Estamos trabajando en todo tipo de herramientas para facilitar cada vez más la construcción de una aplicación potente con almacenamiento de clave-valor, base de datos e incluso inferencia de IA, pero que siga ese entorno de desarrollo simple, de baja configuración y casi sin operaciones y un estilo de desarrollo de programas muy fácil en el entorno serverless. Principalmente, hablaremos de eso.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Utilising Rust from Vue with WebAssembly
Vue.js London Live 2021Vue.js London Live 2021
8 min
Utilising Rust from Vue with WebAssembly
Top Content
Rust is a new language for writing high-performance code, that can be compiled to WebAssembly, and run within the browser. In this talk you will be taken through how you can integrate Rust, within a Vue application, in a way that's painless and easy. With examples on how to interact with Rust from JavaScript, and some of the gotchas to be aware of.
TypeScript and React: Secrets of a Happy Marriage
React Advanced Conference 2022React Advanced Conference 2022
21 min
TypeScript and React: Secrets of a Happy Marriage
Top Content
TypeScript and React are inseparable. What's the secret to their successful union? Quite a lot of surprisingly strange code. Learn why useRef always feels weird, how to wrangle generics in custom hooks, and how union types can transform your components.
Making JavaScript on WebAssembly Fast
JSNation Live 2021JSNation Live 2021
29 min
Making JavaScript on WebAssembly Fast
Top Content
JavaScript in the browser runs many times faster than it did two decades ago. And that happened because the browser vendors spent that time working on intensive performance optimizations in their JavaScript engines.Because of this optimization work, JavaScript is now running in many places besides the browser. But there are still some environments where the JS engines can’t apply those optimizations in the right way to make things fast.We’re working to solve this, beginning a whole new wave of JavaScript optimization work. We’re improving JavaScript performance for entirely different environments, where different rules apply. And this is possible because of WebAssembly. In this talk, I'll explain how this all works and what's coming next.
React's Most Useful Types
React Day Berlin 2023React Day Berlin 2023
21 min
React's Most Useful Types
Top Content
We don't think of React as shipping its own types. But React's types are a core part of the framework - overseen by the React team, and co-ordinated with React's major releases.In this live coding talk, we'll look at all the types you've been missing out on. How do you get the props type from a component? How do you know what ref a component takes? Should you use React.FC? And what's the deal with JSX.Element?You'll walk away with a bunch of exciting ideas to take to your React applications, and hopefully a new appreciation for the wonders of React and TypeScript working together.
Stop Writing Your Routes
Vue.js London 2023Vue.js London 2023
30 min
Stop Writing Your Routes
The more you keep working on an application, the more complicated its routing becomes, and the easier it is to make a mistake. ""Was the route named users or was it user?"", ""Did it have an id param or was it userId?"". If only TypeScript could tell you what are the possible names and params. If only you didn't have to write a single route anymore and let a plugin do it for you. In this talk we will go through what it took to bring automatically typed routes for Vue Router.
Making Magic: Building a TypeScript-First Framework
TypeScript Congress 2023TypeScript Congress 2023
31 min
Making Magic: Building a TypeScript-First Framework
I'll dive into the internals of Nuxt to describe how we've built a TypeScript-first framework that is deeply integrated with the user's IDE and type checking setup to offer end-to-end full-stack type safety, hints for layouts, middleware and more, typed runtime configuration options and even typed routing. Plus, I'll highlight what I'm most excited about doing in the days to come and how TypeScript makes that possible not just for us but for any library author.

Workshops on related topic

React, TypeScript, and TDD
React Advanced Conference 2021React Advanced Conference 2021
174 min
React, TypeScript, and TDD
Top Content
Featured WorkshopFree
Paul Everitt
Paul Everitt
ReactJS is wildly popular and thus wildly supported. TypeScript is increasingly popular, and thus increasingly supported.

The two together? Not as much. Given that they both change quickly, it's hard to find accurate learning materials.

React+TypeScript, with JetBrains IDEs? That three-part combination is the topic of this series. We'll show a little about a lot. Meaning, the key steps to getting productive, in the IDE, for React projects using TypeScript. Along the way we'll show test-driven development and emphasize tips-and-tricks in the IDE.
Best Practices and Advanced TypeScript Tips for React Developers
React Advanced Conference 2022React Advanced Conference 2022
148 min
Best Practices and Advanced TypeScript Tips for React Developers
Top Content
Featured Workshop
Maurice de Beijer
Maurice de Beijer
Are you a React developer trying to get the most benefits from TypeScript? Then this is the workshop for you.In this interactive workshop, we will start at the basics and examine the pros and cons of different ways you can declare React components using TypeScript. After that we will move to more advanced concepts where we will go beyond the strict setting of TypeScript. You will learn when to use types like any, unknown and never. We will explore the use of type predicates, guards and exhaustive checking. You will learn about the built-in mapped types as well as how to create your own new type map utilities. And we will start programming in the TypeScript type system using conditional types and type inferring.
Deep TypeScript Tips & Tricks
Node Congress 2024Node Congress 2024
83 min
Deep TypeScript Tips & Tricks
Top Content
Workshop
Josh Goldberg
Josh Goldberg
TypeScript has a powerful type system with all sorts of fancy features for representing wild and wacky JavaScript states. But the syntax to do so isn't always straightforward, and the error messages aren't always precise in telling you what's wrong. Let's dive into how many of TypeScript's more powerful features really work, what kinds of real-world problems they solve, and how to wrestle the type system into submission so you can write truly excellent TypeScript code.
Build and Deploy a Backend With Fastify & Platformatic
JSNation 2023JSNation 2023
104 min
Build and Deploy a Backend With Fastify & Platformatic
WorkshopFree
Matteo Collina
Matteo Collina
Platformatic allows you to rapidly develop GraphQL and REST APIs with minimal effort. The best part is that it also allows you to unleash the full potential of Node.js and Fastify whenever you need to. You can fully customise a Platformatic application by writing your own additional features and plugins. In the workshop, we’ll cover both our Open Source modules and our Cloud offering:- Platformatic OSS (open-source software) — Tools and libraries for rapidly building robust applications with Node.js (https://oss.platformatic.dev/).- Platformatic Cloud (currently in beta) — Our hosting platform that includes features such as preview apps, built-in metrics and integration with your Git flow (https://platformatic.dev/). 
In this workshop you'll learn how to develop APIs with Fastify and deploy them to the Platformatic Cloud.
Practice TypeScript Techniques Building React Server Components App
TypeScript Congress 2023TypeScript Congress 2023
131 min
Practice TypeScript Techniques Building React Server Components App
Workshop
Maurice de Beijer
Maurice de Beijer
In this hands-on workshop, Maurice will personally guide you through a series of exercises designed to empower you with a deep understanding of React Server Components and the power of TypeScript. Discover how to optimize your applications, improve performance, and unlock new possibilities.
 
During the workshop, you will:
- Maximize code maintainability and scalability with advanced TypeScript practices
- Unleash the performance benefits of React Server Components, surpassing traditional approaches
- Turbocharge your TypeScript with the power of Mapped Types
- Make your TypeScript types more secure with Opaque Types
- Explore the power of Template Literal Types when using Mapped Types
 
Maurice will virtually be by your side, offering comprehensive guidance and answering your questions as you navigate each exercise. By the end of the workshop, you'll have mastered React Server Components, armed with a newfound arsenal of TypeScript knowledge to supercharge your React applications.
 
Don't miss this opportunity to elevate your React expertise to new heights. Join our workshop and unlock the potential of React Server Components with TypeScript. Your apps will thank you.
Advanced TypeScript types for fun and reliability
TypeScript Congress 2022TypeScript Congress 2022
116 min
Advanced TypeScript types for fun and reliability
Workshop
Maurice de Beijer
Maurice de Beijer
If you're looking to get the most out of TypeScript, this workshop is for you! In this interactive workshop, we will explore the use of advanced types to improve the safety and predictability of your TypeScript code. You will learn when to use types like unknown or never. We will explore the use of type predicates, guards and exhaustive checking to make your TypeScript code more reliable both at compile and run-time. You will learn about the built-in mapped types as well as how to create your own new type map utilities. And we will start programming in the TypeScript type system using conditional types and type inferring.
Are you familiar with the basics of TypeScript and want to dive deeper? Then please join me with your laptop in this advanced and interactive workshop to learn all these topics and more.
You can find the slides, with links, here: http://theproblemsolver.nl/docs/ts-advanced-workshop.pdf
And the repository we will be using is here: https://github.com/mauricedb/ts-advanced