Deno: Standart library

Created on 27 Jun 2018  路  10Comments  路  Source: denoland/deno

Hi all,
What do you think about having community driven standart library. One good example is Go with great standart library https://golang.org/pkg/.

I'm afraid what Deno can face the same problem as Node modules with thousands of small few line modules. In my node_modules folder I always find hundreds of small modules, few examples:

  1. https://github.com/sindresorhus/has-flag
  2. https://github.com/jonschlinkert/for-in
  3. https://github.com/iarna/has-unicode
  4. And ~1000 more

Standart library imports could look like this:

import { md5 } from 'deno/crypto';
import { http } from 'deno/net';
import { gzip } from 'deno/compress'; 

Benefits:

  1. Better overall quality (unit tests, code reviews, perf benchmarks)
  2. Better security (trusted code, less 3th party malicious libraries)
  3. Less dependencies
  4. You got it

Most helpful comment

@AgentME I probably miss something but what exact goal of browser compatibility is because even if I use deno.writeFileSync it is no longer browser compatible. If you want your code yo be browser compatible then you can always use common sense. As an example Lodash library is both node and browser compatible because it doesn't use specific node apis which doesn't work on browsers.

All 10 comments

I don't come from the node world so I don't understand why people have done this. Is there a good reason why people use extremely narrow utility modules instead of a good quality library? Like, I'd imagine that there is a great general purpose CLI library that would have has-flag. Is it to cut down on code size or something?

@robbym check this out.

@gillchristian Thanks for the link. I guess I'm just so used to the fact that whenever I needed to do something specialized usually there would be some sort of "convention" or "snippet" on stack overflow or something that I could just copy and paste. This seems to be really modularizing at all levels of resolution. Will definitely have to meditate on this.

It's an approach that evolved with JavaScript, facilitated by how easy it's to publish & consume stuff from npm. But I think the reason is because there's no standard library (i.e. like Go's one).

I would definitely consider having an standard library in deno.

@anjmao Can't agree more.

https://github.com/ry/deno/blob/7bbf7943aec6f7560cddfe6f17b653fbd746ebca/Roadmap.md

Deno will export a single flat namespace "deno" under which all core functions are defined

Do 'core functions' include the standard library?

Having a rich standard library (ie having more than necessary for I/O) seems against Deno's goal of browser compatibility.

IMO if people want a rich standard library, then they should convince the javascript standards groups, or solve the problem in userland (make a normally-imported library, and if there's practical issues with having it as a 3rd-party library, then make proposals to the standards groups to make 3rd-party libraries easier to use).

@AgentME I probably miss something but what exact goal of browser compatibility is because even if I use deno.writeFileSync it is no longer browser compatible. If you want your code yo be browser compatible then you can always use common sense. As an example Lodash library is both node and browser compatible because it doesn't use specific node apis which doesn't work on browsers.

Having a standard library will really be helpful. +1 for me

Yes, deno will have a standard library. But this is too broad of an issue to be useful. Closing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

doutchnugget picture doutchnugget  路  3Comments

ry picture ry  路  3Comments

JosephAkayesi picture JosephAkayesi  路  3Comments

watilde picture watilde  路  3Comments

zugende picture zugende  路  3Comments