TRANSCRIÇÃOEnglish

Rust on the web is starting to look quite good.

24m 59s4,942 palavras735 segmentsEnglish

TRANSCRIÇÃO COMPLETA

0:00

As someone who loves to develop

0:01

software, building web applications has

0:03

always been a bit of a mixed bag. On the

0:06

one hand, the web itself is probably the

0:08

best platform when it comes to

0:10

distribution. There's no easier way to

0:12

ship your applications in 2026. However,

0:15

when it comes to actually building for

0:16

the web, well, for myself, this isn't as

0:19

enjoyable as an experience, mostly

0:21

because of the main programming language

0:23

that's actually used, JavaScript, and

0:25

its derivatives such as TypeScript. Now,

0:28

to be fair, these languages aren't

0:30

exactly terrible. In fact, I'd argue

0:32

that they've helped to usher in an era

0:34

of fantastic developer experience.

0:36

Whether it's through frameworks such as

0:38

React, Vue, or SolidJS, or through

0:40

fantastic tooling such as VIT. However,

0:43

as somebody who learned code in C++ and

0:46

who very much likes working with more

0:47

systems level languages, then building

0:49

for the web and subsequently writing

0:51

JavaScript/TypeScript has always been

0:53

something I just haven't really enjoyed.

0:56

Fortunately, I'm not the only one, and

0:58

there's been a number of attempts to

0:59

abstract the need to build web

1:01

applications using either of these

1:03

languages. These include frameworks or

1:05

libraries such as HTMX, Alpine.js, Data

1:08

Star, and even Hyperscript. All of which

1:11

bring a unique perspective into building

1:12

web applications without the need to

1:14

write JavaScript or TypeScript. Whilst

1:16

each of these have their own strengths

1:18

and weaknesses and are definitely worth

1:20

learning in my opinion when it came to

1:21

my own experience of using these to

1:23

build more than a non-trivial project, I

1:25

still ended up needing to write

1:26

JavaScript, but in a less maintainable

1:29

way than had I done so using something

1:30

like React. Now, this could very much

1:34

have been a skill issue on my own

1:35

behalf. But ultimately, I decided that

1:37

these solutions just weren't for me.

1:39

Fortunately, there is another solution

1:40

out there that can allow one to build

1:42

modern web applications without the need

1:44

to write either JavaScript or TypeScript

1:46

or any of its other derivatives. That

1:48

solution is web assembly or WOM, which

1:51

allows you to write code in other

1:52

programming languages that can then be

1:54

compiled for use in the web. One such

1:56

language is Rust, which also happens to

1:58

be the language that I'm exclusively

2:00

using in 2026 for things such as my

2:03

agentic AI video editor, but also when

2:05

it comes to writing code for the web, of

2:07

which, in my opinion, Rust is actually

2:09

quite good. So, what makes this the

2:12

case? Well, beyond the fantastic

2:15

ergonomics of the language itself,

2:16

there's a good few reasons as to what

2:18

makes Rust on the web not only viable,

2:20

but also an enjoyable experience for

2:22

building web applications. For starters,

2:24

there's actually rather decent tooling,

2:26

allowing you to develop, iterate, and

2:28

deploy your applications in a way that

2:30

feels similar to using something like

2:31

Vit. Although, I will say it's nowhere

2:34

near as mature, but it's definitely

2:35

starting to get there. In addition to

2:37

tooling, the actual ecosystem behind

2:39

Rust on the web is looking pretty good

2:41

as well. Whether it's through native

2:43

crates, those that allow you to

2:44

interrupt with JavaScript, or even

2:46

desktop frameworks that allow you to

2:48

publish straight to web assembly. For

2:51

example, here I have a game of snake

2:52

that I wrote entirely using Rust using

2:55

the iced desktop framework that has been

2:57

published to the web. However, perhaps

2:59

the biggest reason as to why Rust on the

3:01

web is starting to look so good is

3:02

because there are now multiple viable

3:04

frameworks for building either front

3:06

end, backend, or even full stack web

3:08

applications. All of which provide a

3:10

developer experience that's reminiscent

3:12

of some of the more popular JavaScript

3:14

front-end frameworks. Therefore, to give

3:17

a highle look at what Rust on the web

3:18

looks like, let's begin by taking a look

3:20

at some of the popular web frameworks

3:22

for the language. Beginning with one

3:24

that I've been playing around with

3:25

recently called U, spelled YW. U is a

3:29

front-end framework for building

3:31

interactive single page web applications

3:33

that are client side rendered by

3:34

default. The framework itself is heavily

3:37

inspired by React, both when it comes to

3:39

developer experience, but also the

3:41

underlying architecture. This is because

3:43

under the hood, U uses a virtual DOM

3:46

when it comes to rendering and also

3:47

employs a component-based model both for

3:49

defining view logic and also when it

3:51

comes to managing state. To show what I

3:53

mean, here I have an example web

3:55

application that I've built with you

3:57

which defines a single label

3:58

representing a counter and a couple of

4:00

buttons to modify the value either by

4:02

incrementing or decrementing which as

4:05

you can see works. If we take a look at

4:07

the actual code, you can see it's very

4:09

similar to how one would create the same

4:11

application in React uh but just written

4:14

using Rust. To start here, we're

4:16

defining a function called app, which

4:18

we're specifying as a component by using

4:20

the following macro. Inside of this

4:22

component is both where our counter

4:23

state and view logic lives. We're

4:26

creating this state using the use state

4:28

hook, passing in a closure that returns

4:30

the value of zero. Then when it comes to

4:32

both our increment and decrement

4:33

actions, we're defining a closure for

4:35

each that modifies the counter state

4:36

internally. As for the components HTML

4:39

view, here we're using the HTML macro,

4:42

which allows us to define both our HTML

4:44

tags as well as any interpolation of the

4:46

counters value. Additionally, we're also

4:48

passing in the callbacks that we defined

4:49

for the onclick handlers. Very cool. As

4:52

for how to actually run this code, well,

4:54

this is where some really nice Rust

4:56

tooling comes into play. The first thing

4:58

we need to do is add the WAM 32 unknown

5:01

unknown target to Rust up which is

5:03

achieved using the following command.

5:05

Once the target is added, we're then

5:07

able to compile our Rust code to web

5:09

assembly. However, rather than doing

5:10

this using cargo build, let's instead

5:13

make use of another approach, one that

5:15

will allow us to serve our code locally.

5:17

This is through a tool called trunk

5:20

which is a bundler/build tool for womant

5:22

based applications of which u is

5:25

basically you can think of trunk as

5:27

playing a similar role to what vit does

5:29

when it comes to javascript and

5:30

typescript frameworks. To install trunk

5:33

you can do so using the following cargo

5:35

install command which just to be warned

5:38

does take quite a bit of time. In my

5:40

case on the new M5 Max MacBook Pro this

5:42

took about 2 and 1/2 minutes.

5:44

Fortunately, Trunk does provide binaries

5:46

that you can instead install using

5:48

either the cargo bin install command or

5:50

by using something like Nyx, which is

5:52

the approach I personally like to take

5:53

through the use of Nyx Darwin. Once

5:56

installed, in order to run this code,

5:57

you can then use the trunk serve

5:59

command, which will compile the

6:00

application into WOM and then serve an

6:02

index.html with the web assembly

6:04

injected in at localhost at80. If I head

6:08

on over to this address, you can see our

6:09

code is now running. Very cool. As well

6:12

as supporting application development

6:13

and serving our code, Trunk is also able

6:15

to build and bundle our application for

6:17

deployment, which is something we'll

6:19

take a look at shortly when we look at

6:20

how to deploy a Rust web application to

6:22

a server. Speaking of servers, as I

6:24

mentioned before, U by default is client

6:26

side rendered, which is defined by the

6:28

CSR feature inside of my cargo.l.

6:31

However, in addition to being client

6:33

side rendered, you also provide support

6:35

for serverside rendering, aka SSR, which

6:38

can be enabled using the following

6:39

feature. By doing so, it allows you to

6:42

create an application that supports SEO,

6:43

but still operates as if it was a single

6:45

page web application. This is again very

DESBLOQUEAR MAIS

Registe-se gratuitamente para aceder a funcionalidades premium

VISUALIZADOR INTERATIVO

Assista ao vídeo com legendas sincronizadas, sobreposição ajustável e controlo total da reprodução.

REGISTE-SE GRATUITAMENTE PARA DESBLOQUEAR

RESUMO DE IA

Obtenha um resumo instantâneo gerado por IA do conteúdo do vídeo, pontos-chave e conclusões.

REGISTE-SE GRATUITAMENTE PARA DESBLOQUEAR

TRADUZIR

Traduza a transcrição para mais de 100 idiomas com um clique. Baixe em qualquer formato.

REGISTE-SE GRATUITAMENTE PARA DESBLOQUEAR

MAPA MENTAL

Visualize a transcrição como um mapa mental interativo. Entenda a estrutura rapidamente.

REGISTE-SE GRATUITAMENTE PARA DESBLOQUEAR

CONVERSAR COM A TRANSCRIÇÃO

Faça perguntas sobre o conteúdo do vídeo. Obtenha respostas com tecnologia de IA diretamente da transcrição.

REGISTE-SE GRATUITAMENTE PARA DESBLOQUEAR

APROVEITE MAIS DE SUAS TRANSCRIÇÕES

Inscreva-se gratuitamente e desbloqueie o visualizador interativo, resumos de IA, traduções, mapas mentais e muito mais. Não é necessário cartão de crédito.