-
Notifications
You must be signed in to change notification settings - Fork 788
Providing IO utilities
clojure.java.io
offers a standard way of doing I/O for Clojure JVM programs. As the ClojureScript ecosystem grows, there is demand for similar capabilities. I/O is inherently platform dependent and it is likely impossible to offer a drop-in-replacement of clojure.java.io
for any JavaScript environment. Then, it is necessary to define the desired behavior of an IO library for ClojureScript in each target platform. There are at least two distinct paths:
Java's I/O is built around I/O Streams, a concept based on a set of interfaces: Closable .close
, DataInput .read
, DataOutput .write
. Those interfaces can be implemented over many Java classes: e.g., InputStream
, File
, URI
, URL
, Socket
, and String
.
Node.js has both a Stream API and a File System module. The File System API supports creating streams from Files.
Browsers don't offer Stream APIs and have other I/O needs: files are not common and most I/O is associated to XHR and Websockets. Websockets API follow message-passing conventions and I'm not sure if Streams are a good fit.
We can embrace each platform's concept of I/O and provide without attempting to recreate clojure.java.io
functionality. For example, Node provides a File System module. The problem with FS is that is based on strings as file representations with no concept of reified files.
- Rationale
- Quick Start
- Differences from Clojure
- [Usage of Google Closure](Google Closure)