Fork me on GitHub
#ldnclj
<
2016-02-08
>
practicalli-john06:02:52

@agile_geek: how are we doing for ClojureBridge attendee sign-ups? Do we need to do another reminder? Did anyone contact the LJC about the event? Thanks.

agile_geek07:02:59

@jr0cket: don't think anyone contacted LJC but last time I looked we had 31 sign ups out of 40 and I know of at least one other who is thinking about it.

agile_geek08:02:22

Oh, and Good Morning to everyone.

paulspencerwilliams08:02:35

I’ve an early morning question about typical clj/cljs development workflow. Is lein figwheel or lein ring server or other more typical? I ask as I’m currently converting https://github.com/paulspencerwilliams/reframeonheroku/blob/master/project.clj to support uberjar deployment to learn the process.

paulspencerwilliams08:02:30

I get confused as the reframe template suggests lein figwheel as dev mode, and lein cljsbuild for prod build, where I’m presuming I should move this difference to lein profiles, invoking figwheel / cljsbuild implicitly? Then lein ring server or lein uberjar would run dev version, or compile production version?

agile_geek09:02:25

Question for the day: Should an organisation with a number of Clojurescript teams try and make a 'registry' of components that can be reused?

agile_geek09:02:36

My personal answer is that whenever I've seen this kind of reuse in the 'micro' attempted it costs more than it saves as the components tend to be different enough from one use case to another to diverge and the effort in determining a component exists already and learning how to use it is often greater than the effort to write it from scratch.

agile_geek09:02:33

@paulspencerwilliams: Bearing in mind I only have toy projects.. I tend to start two repls, start the server in one and start figwheel in the other.

agile_geek09:02:05

For instructions on how to start figwheel REPL using nREPL see here: https://github.com/bhauman/lein-figwheel/wiki/Using-the-Figwheel-REPL-within-NRepl

agile_geek09:02:30

I raised the reuse in components question because my current client is trying to do this and I think it's not useful.

paulspencerwilliams09:02:09

@agile_geek: Reusable software is, as idiomatic in Clojure, done as abstract, small libraries that know nothing of usage problem domain. eg Ring, Korma etc. They are reusable as aren’t related to business.

paulspencerwilliams09:02:58

@agile_geek: My opinion is the only way to make ‘reusable business software’ is to use a SOA / microservices where the code isn’t reused, rather a published service is reused.

thomas09:02:27

that worked quite well for me so far.

agile_geek09:02:29

@paulspencerwilliams: I think exactly the same

paulspencerwilliams10:02:20

So here’s a question… if I use lein ring uberjar, should this pick up the :uberjar lein profile? Specifically, lein ring uberjar is not compiling my cljs as I would have expected:

:uberjar {:aot :all
            :omit-source true
            :source-paths ["src/clj"]
            :ring {:handler reframeonheroku.handler/handler}
            :prep-tasks ["compile" ["cljsbuild" "once"]]
            :cljsbuild {:builds [{:source-paths ["src/cljs"]
                                  :jar true
                                  :figwheel false
                                  :compiler {:optimizations :advanced
                                             :main ^{:skip-aot true} reframeonheroku.core
                                             :output-wrapper false
                                             :asset-path "js/out"
                                             :output-to "target/classes/public/js/app.js"}}]}})

paulspencerwilliams10:02:03

oh, think I’ve found the issue. :uberjar was not in :profiles Opps.

mccraigmccraig10:02:36

dyu not have to chain lein tasks like lein do cljsbuild, uberjar to get both a cljsbuild and an uberjar ?

paulspencerwilliams10:02:40

@mccraigmccraig: I’m not sure. It didn’t work but CLJS compilation did happen. Lots...

paulspencerwilliams10:02:00

reframeonheroku willlein ring uberjar
Compiling reframeonheroku.core
Compiling reframeonheroku.handler
Compiling reframeonheroku.core
Compiling reframeonheroku.handler
Compiling ClojureScript...
Compiling "target/classes/public/js/app.js" from ["src/cljs"]...
Successfully compiled "target/classes/public/js/app.js" in 8.714 seconds.
Compiling ClojureScript...
Compiling ClojureScript...
Compiling ClojureScript...
Compiling ClojureScript...
Compiling ClojureScript...
Compiling ClojureScript...
Created /Users/will/src/reframeonheroku/target/reframeonheroku-0.1.0-SNAPSHOT.jar
Created /Users/will/src/reframeonheroku/target/reframeonheroku-0.1.0-SNAPSHOT-standalone.jar
Narnia:reframeonheroku will$ java -jar target/reframeonheroku-0.1.0-SNAPSHOT-standalone.jar 
2016-02-08 10:08:39.674:INFO::main: Logging initialized @2361ms
2016-02-08 10:08:43.815:INFO:oejs.Server:main: jetty-9.2.z-SNAPSHOT
2016-02-08 10:08:44.083:INFO:oejs.ServerConnector:main: Started [email protected]{HTTP/1.1}{0.0.0.0:3000}
2016-02-08 10:08:44.084:INFO:oejs.Server:main: Started @6772ms

mccraigmccraig10:02:45

if cljs compilation happened, i guess the uberjar task has cljs knowledge baked in then

paulspencerwilliams10:02:22

@mccraigmccraig: that doesn’t sound plausible though does it?

paulspencerwilliams10:02:26

@mccraigmccraig: actually, I think it is supported as there’s the :jar true and :hooks [leiningen.cljsbuild] https://github.com/emezeske/lein-cljsbuild/issues/213

mccraigmccraig10:02:30

curiously i've never tried to distribute cljs output in an uberjar - i've always served it from elsewhere for production

paulspencerwilliams10:02:39

@mccraigmccraig: there’s also :prep-tasks ["compile" ["cljsbuild" "once"]]

paulspencerwilliams10:02:08

@mccraigmccraig: this is only a small application without need for scaling.

mccraigmccraig10:02:21

there's scaling - but also that the cljs part of an app often changes without any api changes, so it's convenient to be able to just push some js to S3 or something without having to re-deploy the uberjar

agile_geek10:02:14

@mccraigmccraig: I like the scaling idea..I can see having independent deployment mechanisms for client and server being useful

malcolmsparks10:02:50

@agile_geek: I think re-use is a pull thing, not a push thing. All management should be doing is creating the right environment for re-use to happen. All attempts to 'curate' a blessed area of 'reusable' components/libraries completely fails, because it's push

malcolmsparks10:02:45

@agile_geek: therefore, it's quite appropriate for an org to adopt something like GitHub (public or firewall-install), and wait for re-use to happen

malcolmsparks10:02:00

Clojure development today would be unimaginable without re-use, we're doing it all the time. If the organisation has some specific aspects (e.g. a specific security or single-sign-on technology) it makes sense for people not to have to write everything from scratch

paulspencerwilliams10:02:06

@malcolmsparks: agree on the pull thing. I also believe in the 3rd time rule.

malcolmsparks10:02:18

With all attempts to standardize you should never adopt a zero-tolerance approach but only coax people towards the standard and allow those who resist the chance to do their own thing - balance between diversity (which is a form of research, continually seeking out the next thing to standardize on)

malcolmsparks10:02:38

and standards/conventions/idioms (which are valuable too)

malcolmsparks10:02:05

too much 'optionality' leads to balkanisation, too little leads to paralysis

malcolmsparks10:02:33

@paulspencerwilliams: 3rd time rule? is that a DRY thing?

paulspencerwilliams10:02:41

@malcolmsparks: yeah, only on the 3rd time of reusing a thing do you accumulate sufficient knowledge to make it A Thing.

malcolmsparks10:02:22

I think that's a minimum, I heard a similar thing on Drunk and Retired where Charles Lowell said '4-5'

malcolmsparks10:02:39

And there's a school of thought that says making it 'a thing' is a bad idea anyway: http://number-none.com/blow/john_carmack_on_inlined_code.html

paulspencerwilliams10:02:39

yep, inlining is my favourite refactor. I really liked that clojure article maybe 6 months ago about inlining, to avoid having to name things.

malcolmsparks10:02:42

and inlining isolates you from someone changing the (common) function and breaking your code simple_smile

malcolmsparks10:02:54

it doesn't isolate you from someone 'refactoring' your inlining though 😞

malcolmsparks10:02:23

and de-duplication also increases coupling - that's bad too!

agile_geek10:02:26

@malcolmsparks: I agree. I think what's disturbing me about the org I'm talking about (who are using React.js not cljs BTW) is the size of component reuse and the 'enforcement'. They are talking about building reusable UI components across multiple teams and as this will be pushed on them I suspect it will end in teams spending a lot of effort looking for a component to find the one that's close but not quite what they need. That will lead to them spending a lot of time changing the original component and regression testing or they write their own anyway.

malcolmsparks10:02:41

@agile_geek: yeah - I think unless re-use happens 'naturally' it is to be avoided, even discouraged

malcolmsparks10:02:50

natural re-use is the only kind worth having

malcolmsparks10:02:11

but you have to make sure your environment isn't simply putting up obstacles to natural re-use

malcolmsparks10:02:16

and thereby starving it

agile_geek10:02:50

Cool. Glad to have opinions on this. I suspect they will bulldoze the top down approach anyway but I want to make them aware of the dangers.

glenjamin11:02:55

Agreed on the no-top-down thing

glenjamin11:02:05

It has to be easier to re-use than not, or what’s the point?

glenjamin11:02:26

Principles & guidelines are useful to centralise

glenjamin11:02:06

I think of it a bit like standards. The standards body specs & may provide a reference implementation - but as long as a consumer meets the spec, implementation is up to them

paulspencerwilliams11:02:20

So I think I’m progressing in my uberjar exploration. Am I right in thinking that uberjar copies all source into the target jar file, as well as compiled stuff?

paulspencerwilliams11:02:03

And further, where is the idiomatic place for resources? where are these typically deployed to, as what I need to do is copied static files (index.html + css), and merge with the compiled cljs -> js output..

paulspencerwilliams20:02:39

So, I purchased and read the first chapter of Web Development with Clojure and I'm impressed. I've created a few ring/compojure sites/services, and had a play with Re-frame but not linked it all up together well. This book seems to line everything up, and use the repl far more than I typically do. I'd not really considered using it to start server. I've typically been too short lived process / tdd over how I do things coming from ruby/java/c#.

xlevus21:02:22

@paulspencerwilliams how up to date is the book?

paulspencerwilliams21:02:34

Not greatly, 2 years old so useful for principles, overarching approach rather than library reference etc.

mccraigmccraig21:02:55

it's all about the repl !

paulspencerwilliams21:02:28

Yeah, i've used repl for playing around with code but not as the centre of my workflow. This books shows the power.

mccraigmccraig21:02:04

@paulspencerwilliams: i'm using @jarohen 's yoyo atm to support this, though i'll port to https://github.com/jarohen/bounce as soon as i get a moment... it/they give you start! stop! and reload! functions which you can use from the repl to start/stop/reload your app... https://github.com/stuartsierra/component gives you something similar (though i don't like the way way its protocols infect everything)

paulspencerwilliams21:02:39

I've not tried components yet though it's on the radar. I get so little time to play :-/

xlevus21:02:52

I stumbled across an article ages ago that covered the idea of "repl driven development"

xlevus21:02:01

haven't been able to find it it since.

mccraigmccraig21:02:49

my process is repl driven,.. when things have solidified a bit i go and backfill with some tests, but i find starting with tests a bit like treacle wading

mccraigmccraig21:02:44

i would really like some static analysis too. bring on https://github.com/LuxLang/lux