Fireship · @fireship

Deno in 100 Seconds

Uploaded May 5, 2020 · Length 2:10

Deno in 100 Seconds

Summary

deno explained in 100 seconds: a new way to write server-side JavaScript with rust and typescript

  • deno
  • server-side javascript
  • rust
  • typescript
  • javascript engine
  • async programming

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    denim a brand new way to write

  2. 0:02

    server-side JavaScript it solves many of

  3. 0:04

    the same problems as nodejs and was even

  4. 0:06

    created by the same guy like node it

  5. 0:08

    uses the v8 JavaScript engine under the

  6. 0:10

    hood but the rest of the runtime is

  7. 0:12

    implemented in rust and typescript our

  8. 0:14

    journey into denna land begins in a

  9. 0:16

    single type script file in this file we

  10. 0:17

    have access to all the types in the

  11. 0:19

    runtime which means we can write

  12. 0:20

    strongly typed code and get

  13. 0:22

    documentation and intellisense directly

  14. 0:24

    in the IDE without ever needing to touch

  15. 0:26

    a TS config file the features in the

  16. 0:28

    runtime can be accessed from this demo

  17. 0:30

    namespace let's console.log the current

  18. 0:32

    working directory of the filesystem we

  19. 0:34

    can execute our script with demo run

  20. 0:36

    from the command line but you'll notice

  21. 0:37

    the throws an error and that's because

  22. 0:38

    demo is secure by default you the

  23. 0:41

    developer need to give permission to

  24. 0:42

    perform different actions in the runtime

  25. 0:44

    in this case we can use the allow read

  26. 0:46

    flag to allow this operation security is

  27. 0:49

    great but my favorite thing is how

  28. 0:50

    everything asynchronous is promise based

  29. 0:52

    we can make a network request using the

  30. 0:54

    fetch API just like we would in the

  31. 0:56

    browser and because it supports

  32. 0:57

    top-level wait we don't even need an

  33. 0:59

    async function here we can start

  34. 1:00

    resolving promises without any extra

  35. 1:02

    boilerplate code denno attempts to make

  36. 1:04

    your code as browser compatible as

  37. 1:06

    possible it contains a window object

  38. 1:08

    with lifecycle events that you can

  39. 1:09

    listen to allowing developers to more

  40. 1:11

    easily write code that can interrupt

  41. 1:12

    between browsers and servers not to

  42. 1:14

    mention it can also execute web assembly

  43. 1:16

    binaries but one thing that won't work

  44. 1:18

    in demo are your NPM packages instead

  45. 1:21

    you import packages using the modern yes

  46. 1:23

    module syntax with remote modules being

  47. 1:25

    referenced by their URL when you run

  48. 1:27

    your script for the first time it will

  49. 1:28

    download this code locally and cache it

  50. 1:30

    there's no package JSON and code can be

  51. 1:32

    referenced from any URL very similar to

  52. 1:34

    how things work in the browser demo

  53. 1:36

    provides a set of standard modules to

  54. 1:37

    solve common use cases for example we

  55. 1:40

    can import serve from the HTTP module we

  56. 1:42

    can use it to create a server that's

  57. 1:44

    treated as an async iterable we can then

  58. 1:46

    await every request from the server and

  59. 1:48

    respond to it accordingly and that's an

  60. 1:49

    awesome starting point for a server-side

  61. 1:51

    JavaScript app now then au 1.0 just hit

  62. 1:54

    release candidate 1 so if you start

  63. 1:55

    using it today

  64. 1:56

    consider yourself an early adopter do

  65. 1:58

    you think denno is the future of

  66. 1:59

    server-side JavaScript let me know in