DEV Community

Cover image for Forget NodeJS! Build native TypeScript applications with Deno 🦖

Forget NodeJS! Build native TypeScript applications with Deno 🦖

Deepu K Sasidharan on February 20, 2020

Originally published at deepu.tech. Have you heard of Deno? If not you should check it out. Deno is a modern JavaScript/TypeScript runtime & s...
Collapse
 
artoodeeto profile image
aRtoo

Been waiting for deno they said production on version 1 will be ready last january. hehe. just excited for this. anyway I have question about a npm package that is built purely in typescript. Can deno still used it as a library? thanks.

Collapse
 
deepu105 profile image
Deepu K Sasidharan • Edited

Well its Open source and as an open source maintainer I know first hand how schedules go. People are doing it on their free time so nothing is guaranteed.

It doesn't matter if a package is built in TS or JS, what matters is how the module is bundled. If its bundled as an ES module then it should work like the Lodash package I showed in sample. Also Deno is building a node compatibility module to support non ES npm modules

Collapse
 
artoodeeto profile image
aRtoo

ohh. Its easy to migrate then by just changing tscofig. Thank you sir.

Anyway I watch the talk given by ryan dahl he said that "no, nodejs wont be compatible with deno" if he changed his mind this would be awesome. I can still use express.

Thread Thread
 
pratyushcrd profile image
Pratyush

I don't think its as easy as changing minds. NodeJs and Deno are built upon different architecture. The core module would be different and thus incompatible. Also, deno is supposed to use a different event-loop, with different kinds of stuff. Compatibility should be an issue here.

Thread Thread
 
deepu105 profile image
Deepu K Sasidharan

I don't think there is an issue with event loops, underneath its still V8 engine. The real issue is compatibility with existing nodeJS modules

Thread Thread
 
pratyushcrd profile image
Pratyush

Yup compatibility with node modules would be the issue. I was talking about event loops because the methods dependent on event loop in node might not be same as deno (of which I am not sure of) like process.nextTick or setImmediate. In that case compatibility might be issue. Basically if any underlying core packages change their API or its working its an compatibility issue.

Collapse
 
murkrage profile image
Mike Ekkel

Interesting to see how this pans out. I don't have enough experience with Node to form an opinion about this, but it's always nice to see different platforms moving the industry forward. Even if it doesn't end up being a success, it would definitely be great to see Node adopt the good parts of this.

That's what I like about TypeScript. Some of the really good things are being adopted by TC39 to go into the ES spec.

Collapse
 
deepu105 profile image
Deepu K Sasidharan

You are absolutely right

Collapse
 
deepu105 profile image
Deepu K Sasidharan

Unlike Coffescript, TS doesn't try to move sway from JS syntax and is backed by MS and Google who uses it extensively so its not gonna go away like CS. Also JS is taking inspiration from TS for features and since TS is syntax superset it would be easier to migrate to JS if required. Personally I don't think TS is going away any time soon.

Collapse
 
nitinreddy3 profile image
Nitin Reddy

After reading this, I feel I should definitely give it a try.

Collapse
 
deepu105 profile image
Deepu K Sasidharan

Try it, the experience is much nicer than Node

Collapse
 
artoodeeto profile image
aRtoo

There are no guarantees in life my friend, but I do know that coffeescript is so different from typescript. If you compare the syntax its much harder to start on coffeescript than typescript. I remembered when I was trying to learn both it took time to grasp coffeescript than typescript because of the way the syntax is implemented, while on typescript it was easy an hour of learning will get you going. I say this because I had the first hand experience on my onboarding at work we had to maintain a coffescript codebase it was a bit difficult.

Collapse
 
mx profile image
Maxime Moreau

Thanks for sharing, well written. But I think that Deno is somthing to watch and try for now, but I won't bet on it, I would love to see it grow but it's risky, the sad part for me is "Migrating existing NodeJS apps will not be easy due to incompatible API".

Collapse
 
randhomme profile image
randhomme

Anything on editors/ide support ?

Collapse
 
deepu105 profile image
Deepu K Sasidharan

All typescript supported IDEs should work perfectly fine like VSCode, IntelliJ

Collapse
 
randhomme profile image
randhomme

I mean, when you do import from URLs (remote or local) does auto-completion works?

Thread Thread
 
deepu105 profile image
Deepu K Sasidharan

I don't think that works

Thread Thread
 
navicsteinr profile image
Navicstein Rotciv

For now yes, but they should come up with a way of loading definition files from the remote source especially in the VSCode plugin

Collapse
 
cknight profile image
Chris Knight

For info, part of the Deno std library is a node polyfill which will allow npm modules to be run as part of deno. It's still in its infancy, but there is already support for some of the more common API functions in node. See more here: github.com/denoland/deno/tree/mast...

Collapse
 
deepu105 profile image
Deepu K Sasidharan

Yes and I hope it helps in Deno adoption

Collapse
 
jankapunkt profile image
Jan Küster

I have a question on the url based module loading. If I would require to build a pure offline application how would I load the modules? Are they loaded at dev time and then bundled into a large js file? Would I have to store a local copy, which is then bundled? Or something totally different?

Collapse
 
deepu105 profile image
Deepu K Sasidharan

Deno team recommends creative a lib.ts file which imports all needed libs so that you can bundle it with the app and use it offline as well. See this deno.land/std/manual.md#linking-to...

Collapse
 
felizrocks profile image
Fábio Penteado

Excellent article! Thanks for sharing! :D

Collapse
 
deepu105 profile image
Deepu K Sasidharan

You are welcome and thank you

Collapse
 
kapantzak profile image
John Kapantzakis

Very good article, thank you!! :)

Collapse
 
deepu105 profile image
Deepu K Sasidharan • Edited

You are welcome and thank you

Collapse
 
mzaini30 profile image
Zen

deno != node 😂

Collapse
 
deepu105 profile image
Deepu K Sasidharan

Indeed and I think the naming was intentional

Collapse
 
mzaini30 profile image
Zen

Founder of Node == founder of Deno 😂

Collapse
 
checkmatez profile image
Max • Edited

aaaand... Typescript team just shipped 3.8 with top level await

Collapse
 
deepu105 profile image
Deepu K Sasidharan

Cool

Collapse
 
wolfhoundjesse profile image
Jesse M. Holmes

Sweet! I've been waiting for this.

Collapse
 
theonlybeardedbeast profile image
TheOnlyBeardedBeast

I hope Deno will succeed, thanks for the article.