Skip to content

Remove pure JS (non native) io functions from Deno namespace #9795

Closed

Description

@lucacasonato

I propose we remove the following APIs from the Deno namespace, and move them to std:

Types:

  • Deno.Reader
  • Deno.Writer
  • Deno.ReaderSync
  • Deno.WriterSync
  • Deno.Closer

Functions:

Timeline

I suggest we mark all the APIs we want to remove with @deprecated, and add a deno lint diagnostic for when these APIs are used. In Deno 2.0 we can then remove these APIs.

Reasoning

Code which does not actually require native syscalls should not use Deno namespace APIs as this makes the code incompatible with browsers, even though there is no need for that to be the case. An example of this: https://deno.land/std@0.90.0/io/streams.ts. This uses Deno APIs, even though no native calls are preformed, making this code unusable in a web browser for no good reason.

Activity

  1. added
    public APIrelated to "Deno" namespace in JS
    suggestionsuggestions for new features (yet to be agreed)
    breaking changea change or feature that breaks existing semantics
    on Mar 15, 2021
  2. kitsonk commented on Mar 15, 2021

    @kitsonk
    Contributor

    Why move the types? They are referred to by other built ins that are returned, are they not?

  3. kitsonk commented on Mar 15, 2021

    @kitsonk
    Contributor

    Buffer is also mentioned in #9588, we should maybe close that?

  4. lucacasonato commented on Mar 15, 2021

    @lucacasonato
    ContributorAuthor

    Why move the types?

    Same reason as to move the functions. Code using Reader / Writer etc does not work when lib is dom instead of deno.ns. IMO if it doesnt need to be a binding (or a type for those bindings) because it can work just fine in the browser, it should not be part of the Deno namespace.

    They are referred to by other built ins that are returned, are they not?

    The builtins never explicitly return or take a reader/writer after these changes as far as i'm aware. They only return types that implement Reader or Writer. Instead of using implement in the d.ts, we can just specify the read / write methods no the interfaces directly. This would make them implicitly implement Reader / Writer (just like interfaces work in Go).

  5. timreichen commented on Apr 26, 2021

    @timreichen
    Contributor

    @lucacasonato in addition to that: would you be open to rename
    Deno.iter -> Deno.iterator
    Deno.iterSync -> Deno.iteratorSync
    for aligning with the js name like in Symbol.iterator?

  6. lucacasonato commented on Apr 26, 2021

    @lucacasonato
    ContributorAuthor

    No. They are both in the process of being deprecated and will be removed. No reason to rename.

  7. added
    featnew feature (which has been agreed to/accepted)
    and removed
    suggestionsuggestions for new features (yet to be agreed)
    on Apr 26, 2021
  8. ry commented on Jul 5, 2021

    @ry
    Member

    I'm in agreement. It's very painful to let web streams (ReadableStream/WritableStream) win over go streams (Reader/Writer). Go streams is plainly more general and vastly simpler. But we must have web streams because of fetch. And having two different and incompatible stream abstractions is worse than having one shitty one.

    One of the original intentions of Deno was to correct the abysmal streams implementation in Node. I think Go provides a very elegant and complete solution with a beautiful library of combinations.

  9. MierenManz commented on Jul 5, 2021

    @MierenManz

    We just have to hope that there will be a webstream2 at some point in the future that is based on go streams :/

  10. nayeemrmn commented on Jul 6, 2021

    @nayeemrmn
    Contributor

    Just to clarify, this issue was about a purely symbolic refactor to remove the explicit type definitions of Reader and Writer in favour of just defining the read() and write() methods on their implementers. This is logical because there are no stable built-ins that accept these interfaces, only ones that return them. A one sided protocol so to speak. Since they do have consumers in std, it would be more appropriate to have the definitions there.

    Why @ry mentions above is the result of more recent discussion to remove even the concrete read() and write() methods in favour of web stream APIs. We should continue in #11018 for that.

  11. added this to the 2.0.0 milestone on Sep 17, 2021
  12. kt3k commented on Dec 22, 2022

    @kt3k
    Contributor

    We're removing the usages of Deno.Reader, Deno.Writer, ... from std in denoland/std#3030

  13. iuioiua commented on Aug 25, 2023

    @iuioiua
    Contributor

    Types:

    • Deno.Reader
    • Deno.Writer
    • Deno.ReaderSync
    • Deno.WriterSync
    • Deno.Closer

    Perhaps, 2.0 is a good time to deprecate these interfaces. A counterargument is fast streams implementations are still in progress, and I wouldn't expect people to be happy with the deprecation unless the performance of the alternative was on par or better.

  14. kt3k commented on Aug 25, 2023

    @kt3k
    Contributor

    What to do about Deno.Seeker and Deno.SeekerSync?

  15. kt3k commented on Sep 13, 2023

    @kt3k
    Contributor

    There seem a few concerning points to this move:

    • There seem no alternative way to support synchronous I/O using ReadableStream based APIs.
    • The support of seek behavior will be awkward though it's still possible to perform with mixed usage of ReadableStream and existing seek() method
  16. kt3k commented on Sep 14, 2023

    @kt3k
    Contributor

    sync behavior might be implemented as FileSystemSyncAccessHandle in the future

    seek is available in FileSystemWritableFileStream, but I couldn't find a way to seek during reading in Web APIs

  17. iuioiua commented on Dec 28, 2023

    @iuioiua
    Contributor

    Update: std/log no longer depends on Deno.Writer. See: denoland/std#4021

  18. iuioiua commented on Jan 29, 2024

    @iuioiua
    Contributor

    What to do about Deno.Seeker and Deno.SeekerSync?

    What do we think about this? Best to come to a decision before Deno v2. Related: Deno.seek() and Deno.seekSync() were deprecated in Deno 1.40.

  19. bartlomieju commented on Aug 31, 2024

    @bartlomieju
    Member

    All of these APIs are no longer available as of #25213 and Deno 2.0.0-rc.0.

  20. iuioiua commented on Sep 10, 2024

    @iuioiua
    Contributor

    We'll be also moving Deno.Seeker[Sync] into @std/io/types of the Standard Library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

breaking changea change or feature that breaks existing semanticsfeatnew feature (which has been agreed to/accepted)public APIrelated to "Deno" namespace in JS

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions