Fork me on GitHub
#garden
<
2016-10-11
>
ag01:10:21

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-mahood04:10:52

@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.

niamu04:10:54

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.

niamu04:10:38

garden.color is also magical and incredibly powerful.

eyelidlessness05:10:25

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.

eyelidlessness05:10:26

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

eyelidlessness05:10:17

(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)

ag20:10:06

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

niamu20:10:28

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.

ag20:10:49

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

shaun-mahood20:10:38

@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.

ag20:10:32

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).

ag20:10:38

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)

ag20:10:27

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

shaun-mahood20:10:27

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.

niamu21:10:40

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

noprompt21:10:12

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

noprompt21:10:00

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

noprompt21:10:20

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