other-languages

here be heresies and things we have to use for work
raspasov 2021-04-24T00:04:26.101800Z

Mutability will literally prevent you from doing good work in the long run, unless you have a constant + consistent mitigation strategy. Good luck enforcing that discipline. You’re much better off starting with the right tool for the job.

2021-04-24T00:29:10.112800Z

I think this is a good point, as soon as you require developer discipline, you've lost

2021-04-24T00:29:45.113800Z

As deadlines, pressure etc affect the work, things like mutability, tests, quality etc will go out of the window

Ruy Valle 2021-04-24T00:30:17.113900Z

I was wondering if there were experienced Clojurists that had experience with Go, and specifically with the Reader and Writer interfaces. I find them pretty interesting and they seem to be especially well suited to streaming data. The thing I find unfortunate is that they deal exclusively with bytes. For instance, encoding something to JSON and streaming it into an HTTP request looks like this:

reader, writer := io.Pipe()
gzipWriter := gzip.NewWriter(writer)

go func() {
  json.NewEncoder(gzipWriter).Encode(myThing)
  gzipWriter.Close()
  writer.Close()
}()

req, _ := http.NewRequest("POST", someURL, reader)
client := http.Client{}
<http://client.Do|client.Do>(req)
reader.Close()
In essence, the JSON encoding writes into the gzip writer which writes into the write end of the pipe, and writes into the pipe block until data is being read from the read end of the pipe, with data being transferred directly from the write to the read. We put the writing in a separate thread to avoid blocking the main thread. The HTTP client reads from the pipe when performing the request. When the encoding to JSON is done, we close the write end of the pipe which tells the reader that there is no more data, probably through an EOF. I’ve been using Go at work for a little over a year and have unfortunately not been able to use Clojure for much, other than writing little tools for myself and a compiler from a very small subset of Clojure to Go, written for a class. I was wondering if something like Clojure transducers could take the place or be used with something like the Reader/Writer interfaces from Go. Maybe they could be a protocol or family of protocols? This is still pretty hazy in my mind.

emccue 2021-04-24T00:44:29.114300Z

@ruyvalle Sounds roughly like InputStream and OutputStream

Ruy Valle 2021-04-24T00:47:05.115200Z

looking at InputStream now, that does look very similar, thanks!