Fork me on GitHub
#clojure-uk
<
2019-12-09
>
folcon00:12:09

Is there an ascendancy of shadow-cljs and decline of figwheel that I missed?

seancorfield01:12:08

That's certainly the impression I get as an outsider to the whole ClojureScript ecosystem. I don't know how real that is...

seancorfield01:12:59

According to State of Clojure 2019 https://www.surveymonkey.com/results/SM-S9JVNXNQV/ Figwheel had over 65% of the "market" last year compared to Shadow's 21%.

seancorfield01:12:06

(Shadow wasn't even mentioned in 2018's survey)

dominicm08:12:38

I personally don't think it's significantly better than figwheel. It's equal maybe. Better npm support, but an alternative compiler meaning you have an extra layer to search for bugs in.

dharrigan08:12:44

I think the documentation around Figwheel - the website, the tutorials etc. is fantastic.

👍 8
dharrigan08:12:56

And that, really really helps a n00b like moi!

Ben Hammond08:12:09

(and we are all n00bs)

seancorfield09:12:09

@dominicm Yeah, that aspect of Shadow does make me uneasy...

dominicm09:12:57

It's not like clojurescript is the most stable foundation in the world to begin with. So anything that exemplifies that is a problem.

4
4
folcon09:12:44

@seancorfield For projects that I’ve gotten into some stable point but still want to update, there is some sense that I do have to now work out how this new system works…

folcon09:12:55

Which certainly has a old man shakes fist at an ever changing world vibe, but at the same time that cost isn’t nothing… 😞

dominicm09:12:35

My personal opinion is that figwheel and browserify is a beautiful pairing for clojurescript with npm.

👍 4
folcon09:12:09

I’ve not really used browserify

folcon09:12:17

Any docs on how they work together?

folcon09:12:26

Lots of figwheel + re-frame on my side

dotemacs09:12:30

One thing to consider, the author of shadow.cljs is not only super supportive, but makes fixes to any issues that come up in a very short time, in few hours from the things I’ve seen in the past. I’m not saying that he’s super human and on PR fixes like mad, but this is a pattern I’ve seen from him quite a lot..

👍 4
rickmoynihan13:12:40

This has definitely been my experience too, and the same for other people on our team.

folcon09:12:59

no the maintainer is pretty awesome, don’t get me wrong, but for example last night I was tinkering with rot-js

folcon09:12:39

Something I was expecting to just work by importing it in npm (I was using calva which has a mention of shadow-cljs), but trying to work out how to import stuff correctly or interop with this thing I just imported was just painful. I’ve got to get a lot closer to cljs side of things than I’m used to, which is a bit frustrating as I’m usually trying to wrap that up…

dominicm09:12:24

He's definitely responsive! But good luck reproducing your strange compilation error outside your project. It's very rare I can reliably reproduce that stuff in order to bug report it.

👍 8
alexlynham10:12:44

ime if you work in cljs and aren’t prepared to get p close to js, let alone the cljs ecosystem you’re soon going to have a bad time:tm:

Conor10:12:41

ime if you work...js...bad time

Conor10:12:43

Sounds about right

alexlynham10:12:50

besides which as much as I think re-frame is ace, given that I don’t really use repl driven development in cljs land I’m still a little meh on whether I would just use JS for my next project. the tooling is good, you can enforce consts only via linter, etc

Conor10:12:38

I mean, the purest form would be "work...bad"

dominicm10:12:28

I think the fact I don't do much at the repl in clojurescript means I'm doing something wrong.

folcon10:12:32

I do get that suspicion…

folcon10:12:12

I’ve been really trying on and off to better integrate my experience with it, but it’s surprisingly fiddly to do seamlessly…

mccraigmccraig11:12:35

@alex.lynham sure you can lint, but you can't lint your way around basic sensible immutable-datastructure fp being awfully painful in js

alexlynham11:12:16

sure, but the tooling in js for “doing some stuff in the browser” is better, and lower friction

alexlynham11:12:10

like, I’ve made my bed with cljs for now, but I do miss things about JS in terms of just getting stuff done

alexlynham11:12:24

it does require a bunch more discipline to not shoot yourself in the foot tho

dharrigan11:12:27

Man, gotta say again, doing development, whilst repling away is totally awesome

dharrigan11:12:50

being able to try out a function, tweak it, then show it works, and be confident it will work in code is sooo good.

dharrigan12:12:01

For me, it's the "fun" part 🙂

dharrigan12:12:02

Say I have a text file that contains multiple json documents, unfortunately, not separated in any way, except like this:

dharrigan12:12:22

{
 document 1...
}
{
document 2...
}

dharrigan12:12:47

Is there a way to process that, with each document being held separately?

dharrigan12:12:58

I'm trying to use cheshire, and I don't think it's quite doing it.

dharrigan12:12:24

Anyone handled something like that before?

dharrigan12:12:44

actually! w00t! cheshire.core/parsed-seq seems to work!

dharrigan12:12:01

parses the document lazily, which will work for my usecase

dharrigan13:12:08

Which do people perfer (foo.Bar. baz) or (new foo.Bar baz)? - for interop

dharrigan13:12:28

I'm leaning towards the new form, since it is easy to miss the . at the end of the Class, Bar in this case.

rickmoynihan13:12:54

I much prefer the former. I think if you miss the . you’ll quickly realise what you did… Class is not a function errors, I’d expect.

💯 4
👍 4
Wes Hall13:12:04

Hey chaps and chapesses, so a few weeks ago in here I was talking about the "stop the presses" process in agile manufacturing at places like Toyota, where people can press a button and stop things to find improvements. Somebody told me the official Japanese word for this, and I have forgotten it. Anybody got it to mind, colleague asking for the name.

Wes Hall13:12:41

Never mind, found it. Andon.

dharrigan14:12:30

I'm struggling with trying to read in a compressed inputstream atm.

dharrigan14:12:36

I'm getting stream closed

Ben Hammond14:12:15

? lazyness at work?

Ben Hammond14:12:36

how are you decompressing your inputstream?

Ben Hammond14:12:06

we need snippets

dharrigan14:12:45

I think I've got it

dharrigan14:12:52

here you go anyway:)

dharrigan14:12:13

(defn compressed-object->json-seq
  [object]
  (let [{:keys [Body ContentLength]} object]
    (when (> ContentLength 0)
      (with-open [gzipped-data (new GZIPInputStream (io/input-stream Body) ContentLength)
                  raw-data (new InputStreamReader gzipped-data StandardCharsets/UTF_8)]
        (json/parsed-seq (new StringReader (slurp raw-data)) true)))))

dharrigan14:12:29

it's S3 data, so Body == InputStream

dharrigan14:12:42

feels a bit icky

Ben Hammond14:12:05

ah right, so the GZipInputStream gets closed as the function returns

Ben Hammond14:12:21

but since its a lazy seq, you have'nt read any data at that point

dharrigan14:12:58

(defn compressed-object->json-seq
  [object]
  (let [{:keys [Body ContentLength]} object]
    (when (> ContentLength 0)
      (with-open [gzipped-data (new GZIPInputStream (io/input-stream Body) ContentLength)]
        (json/parsed-seq (io/reader (new InputStreamReader gzipped-data StandardCharsets/UTF_8)) true)))))

dharrigan14:12:21

Looks like I have read the entire thing in, then get lazy on it

Ben Hammond14:12:35

the worst of all worlds

Ben Hammond14:12:56

(except the world where you want things to actually work)

dharrigan14:12:56

I'll keep playing with it, see if I can make it better

dharrigan14:12:05

working == good in my world 🙂

Ben Hammond14:12:22

could be a suitable candidate for IReduceInit

Ben Hammond14:12:11

depends on how much json you are expecting really

Ben Hammond14:12:43

(when (pos? ContentLength)

dharrigan14:12:51

ah, much better

dharrigan14:12:57

I like the code review 😉

simple_smile 4
dharrigan14:12:16

got it smaller now

dharrigan14:12:17

(defn compressed-object->json-seq
  [object]
  (let [{:keys [Body ContentLength]} object]
    (when (pos? ContentLength)
      (with-open [gzipped-data (new GZIPInputStream (io/input-stream Body) ContentLength)]
       (json/parsed-seq (new StringReader (slurp gzipped-data :encoding "UTF-8")) true)))))

dharrigan14:12:26

no need for the intermediate inputstreamreader 🙂

dharrigan14:12:39

thank you Ben! 🙂

Ben Hammond14:12:24

can you (io/reader instead of (new StringReader ?

dharrigan14:12:27

It's great being able to try this out in the repl

dharrigan14:12:05

no, doesn't work - dumps out the entire contents

dharrigan14:12:06

Tis okay, I can move on now - another little bit of the puzzle solved

dharrigan14:12:19

This utility doesn't have to be quick

dharrigan14:12:22

it just has to work 🙂

Ben Hammond14:12:18

(doc jio/reader)
-------------------------
<http://clojure.java.io/reader|clojure.java.io/reader>
([x & opts])
  Attempts to coerce its argument into an open java.io.Reader.
   Default implementations always return a java.io.BufferedReader.

   Default implementations are provided for Reader, BufferedReader,
   InputStream, File, URI, URL, Socket, byte arrays, character arrays,
   and String.

  * If argument is a String, it tries to resolve it first as a URI, then
   as a local file name.  URIs with a 'file' protocol are converted to
   local file names.*

   Should be used inside with-open to ensure the Reader is properly
   closed.
=> nil

alexlynham15:12:55

fwiw it does occur to me @mccraigmccraig based on mucking around I’ve had to do today that having language constructs like atoms just available is maybe a more convincing argument for expressiveness in a UI-focussed world :thinking_face: tho idk

alexlynham15:12:55

obv not arguing that immutable first is more foolproof way of catching bugs, but thinking mainly of expressivity/productivity which is often a function of lang and tools & it’s there where the tradeoff is maybe (?) more interesting

alexlynham15:12:06

thoughts

practicalli-johnny15:12:06

Hello all, if anyone would like to organise a ClojureBridge London event in future, all the details you need are documented, so anyone can do it. I am happy to advise anyone who wants to organise / host an event. There is an investment in time, especially if you do this well, but the mechanics are not complicated. https://clojurebridgelondon.github.io/organise-clojurebridge-london/ I will be focusing most of my efforts on https://practicalli.github.io/ weekly 1 hour Clojure tutorials via YouTube and the free online books. Thank you.

practicalli-johnny15:12:33

I might get a job too 🙂

dharrigan16:12:46

Oh, I wouldn't mind helping out! Let's talk about it offline John - how about tomorrow? I'll be about on Slack

👍 8
gcaban21:12:30

I'd be happy to help too, loop me in

practicalli-johnny21:12:14

there is a #clojurebridge-london channel that is useful to discuss specifics about organising and planning events. Thats probably as looped in as it gets 🙂 If no one has started organising something by the end of January, I may start gently nudging people. For everything else there is GitHub 🙂