garden

ag 2016-10-11T01:01:21.000022Z

Hey guys, I just tried Garden… I am probably not the first one asking this: but can someone “sell" it to me? I do like hiccup syntax and we use it a lot for html, but using Garden feels kinda strange (compared to SASS for example). I dunno, maybe I just need to play with it a bit more. Still, even if I get used to use it and like it, I'm gonna need to sell it to my colleagues. How do I convince them?

shaun-mahood 2016-10-11T04:00:52.000023Z

@ag: Selling it to colleagues may be a bit harder than selling it to you, but I find that there are 2 huge benefits for me. 1) same hiccup syntax means no difficulty in jumping back and forth between clojure on the server, clojurescript in the browser (with reagent), and garden. 2) there are many more options in Garden than in CSS or SASS for dealing with variables, control flow, logic, and any other concerns that make more sense in a full programming language - I've found the ability to deal with variables and namespaces in Garden has had an amazingly simplifying effect on some of my stylesheets, even compared with Sass. Hope those are a bit of help, happy to clarify tomorrow if you want more specifics.

niamu 2016-10-11T04:31:54.000024Z

The biggest advantage of Garden in my opinion is that it sits inside of the Clojure language. So you no longer have to deal with limitations of a pre-processor. You can write functions that will generate styles on demand within React components as the user changes dials which is something much easier to accomplish with Garden compared to LESS or SASS.

niamu 2016-10-11T04:32:38.000025Z

garden.color is also magical and incredibly powerful.

2016-10-11T05:31:25.000026Z

another selling point is that you can share code between clj and cljs. i was recently integrating a JS lib (chartist) which uses media queries for some features. i was delighted when i realized i could literally use the same named breakpoints for chartist that i use to compile my CSS, with exactly the same semantics and no code duplication/maintenance headaches.

2016-10-11T05:35:26.000027Z

re: garden vs sass/less, when my team picked garden, i did an evaluation comparing feature sets. the only thing sass had that garden didn't was "extend-only selectors", which i implemented trivially (for trivial cases) in a few hours in clojure. my team now maintains a (less trivial) implementation (https://github.com/reup-distribution/espalier) which we use in production. implementing a feature like this for sass would require knowing the sass internals (ruby) and working with how it parses and compiles its own DSL... whereas garden operates on plain clojure datastructures

2016-10-11T05:38:17.000029Z

(for anyone reading source, clearly there is some knowledge of garden internals involved, because the full implementation essentially embeds a multi-pass compilation step into a single-pass compiler; but the fact that it's a real language rather than a DSL makes reasoning about the problem so much easier)

ag 2016-10-11T20:40:06.000030Z

thank you guys for good write-up @niamu @shaun-mahood @eyelidlessness this is cool. Now, we have a sass-lib (build by our non-clojure team) and I’m gonna have to use mixins from that thing. Is there a way? If I find a way - I’ll just switch to Garden

niamu 2016-10-11T20:41:28.000031Z

I believe the next release of Garden will be able to read in existing CSS files as Garden data structures which would allow you to do that I assume. But as of right now nothing in Garden itself facilitates that.

ag 2016-10-11T20:42:49.000032Z

😞 do you know when next release comes? I think I’m already liking the idea of having everything in symbolic expressions

shaun-mahood 2016-10-11T20:44:38.000033Z

@ag: How many mixins have you got, and how complicated are they? I've not done much with mixins (and I'm the only developer so I only have to convince myself), but it seems like it would be pretty easy to recreate and stay in sync with SASS if there weren't too much of it.

ag 2016-10-11T20:46:32.000034Z

that’s the thing… I’m not in control of that lib. it’s built by another team, and I have no way of not using it (bureaucracy).

ag 2016-10-11T20:48:38.000035Z

if I could build some sort of a bridge that would allow me to use those mixins… they have bunch of mixins. for example something like this: get-color(gray, darker)

ag 2016-10-11T20:49:27.000036Z

and whenever "their definition” of darker gray changes it would change in my app too

shaun-mahood 2016-10-11T20:52:27.000037Z

Ahh, that makes it a bit trickier. Do you think you could write something in Clojure to read those mix-ins? If you can do it in Clojure then it should be easy to pass it into Garden.

niamu 2016-10-11T21:10:40.000038Z

It’s not exactly mature or well-documented right now, but you might want to toy around with this for an evening: https://github.com/noprompt/thorn

noprompt 2016-10-11T21:29:12.000040Z

@niamu i wouldn't recommend using that at all.

noprompt 2016-10-11T21:30:00.000041Z

what i might recommend is looking for a real sass parser written in java and write code against that.

noprompt 2016-10-11T21:30:20.000042Z

thorn uses jruby and an older version of the sass gem. it's really hacky.