Fork me on GitHub
#beginners
<
2015-06-23
>
sveri06:06:04

@gary: I admit, that coupling is bad, didn't think of that one, I am too often to pragmatic

sveri06:06:17

Did you see that the selmer "for" tag adds variables like "counter" "counter0" to the context? You may add an if statement on them and insert a row conditionally if it mod = 0

gary06:06:29

@sveri well it works for now so I guess it's just a little technical debt I'll have to pay back later.

sveri06:06:37

@gary: I know that feeling, I'd do this too, if it was a hobby project, but for a "serious" one that you want to deliver or go to production, fix it now 😉

sveri06:06:09

Btw.you may make that partition-all approach configurable of course, by passing in a parameter for n

escherize07:06:49

You could show people who are resistant to using hiccup http://hiccup.space

escherize07:06:53

I hope it can show people the beauty of hiccup

andrut08:06:24

@escherize: that's a nice comparison but it's not fair... HTML is not indented, so it looks really ugly; do the same to clojure and you'll get a similar result simple_smile

escherize09:06:59

sure, except that html is a string and hiccup is a data structure

thefox09:06:00

still not a fair comparison - clojure source code is string too, and (X)HTML can be considered to be XML and be structured too.

thefox09:06:13

but it is a nice project.

escherize09:06:58

Sure, so i guess it comes down to the differences regarding difficulties of reasoning and manipulation

thefox09:06:41

but anyway - working with the HTML expressed as clojure source code is "nicer".

escherize09:06:09

I think it's more expressive and simpler, even though afterall it's just another DSL

srigi13:06:17

Guys how do you fiddle w/ your code? I instantly throw-away workflow edit code, save, rebuild, inspect result by (println) Now I'm using LightTable w/ instarepl, thats OK. But I feel that best for me will be REPL in console with some kind of watcher/auto-rebuild after I save the file in the editor.

sveri13:06:09

srigi: Are you talking about clojure or clojurescript?

sveri13:06:04

and what kind of application are you working on, web app? library? some other gui app?

srigi13:06:46

Just the simplest app created by lein and the app template

sveri13:06:31

ok, so, for trying things out I would stick with lighttable and it's insta REPL, I found this to be the most helpful IDE when I was starting out with clojure

srigi13:06:50

OK, thanks. I was so pleased with watcher of clojure-script, so I wanted same thing with clojure.

sveri13:06:37

There are similar things, depending on the context, but why make it more complicated when it can be as easy as using LightTable simple_smile

escherize14:06:09

srigi, I use emacs, and i put something like (def *r request)

escherize14:06:31

then I can inspect inside of *r

escherize14:06:49

like (-> *r keys), (-> *r :params)

escherize14:06:18

It's better than a print statement, ime

escherize14:06:37

and if you're dealing with something big and hideous, it works great!

escherize14:06:50

and requests sure used to seem big to me

akiva14:06:54

@escherize, any reason why you’re using a threading macro for just one function call?

escherize14:06:57

because usually I end up wanting to inspect something a few layers deep

escherize14:06:33

and wind up with

(-> *thing :large-report (get "datething") keys)

akiva14:06:58

Right on. Just curious.

escherize14:06:17

I almost changed them because by themselves they dont seem legit / necessary

escherize14:06:42

but when you do them 1 after another it's pretty useful

akiva14:06:03

Never thought about using -> in place of get-in which, to me, always looks messy.

escherize14:06:32

i really love -> since if you have some gnarly data like

{:a [1 2 "i break addition" 4]}
you can do (-> *gnar :a (filter number?)) or something like access the string with (-> *gnar :a (nth 2) as I'm sure you're aware

akiva14:06:10

Yeah, I use it often as well but only when I’ve multiple function calls.

escherize14:06:49

dont wanna be pedantic, but they are all function calls

akiva14:06:19

Of course. This is more of a stylistic issue for me.

akiva14:06:35

(:some-key some-data) vs. (-> some-data :some-key).

escherize14:06:02

oh yeah, I'm with you if you're saying for a single function it's better to ditch the threading macro

akiva14:06:09

Yeah, that’s what I meant.

escherize14:06:56

The time when I do use it is in the repl, when exploring some bizarre response, like the kind Australia Post sends back when you try to request a shipment

akiva14:06:15

I think I might start doing that too.

escherize14:06:18

so it'd be like using them in sequence

escherize14:06:56

(-> *auspost-sucks :packages)
';;=> map with way too many packages to read
(-> *auspost-sucks :packages count)
';;=> 5
(-> *auspost-sucks :packages keys)
';; => [:some :useful :keys :in here]
(-> *auspost-sucks :packages :some)
';; => the thing i actually wanted

akiva14:06:32

Hah, yep, that was the scenario I was imagining.

escherize14:06:00

my company's respected partner btw

sveri15:06:07

@gary: looks better simple_smile

gary15:06:34

thanks, once I had some hammock time it all just came together

escherize15:06:42

is there a way to cache output streams?

escherize15:06:18

or like seralize/deserialize them to a data structure/blob?

escherize16:06:13

that is much easier to grok, @gary

escherize16:06:39

you really reduced some incidental complexity there

gary16:06:01

it's also nice since (partition-all 4 [1 2 3 4 5 6]) => [(1 2 3 4) (5 6)] I don't have to worry about having the number of products hardcoded

escherize16:06:41

it's a shame though, that you are stuck without mapping functions

gary16:06:02

before I had the inner for loop I was doing {% for p1,p2,p3,p4 in partitioned-products %}

gary16:06:40

so when I got a list that didn't have 4 products I would just get blanks and I had to do some if statements and it was gross

escherize16:06:30

yes, it's a shame you couldn't use map so that the number of items didn't matter. Though the way you did it acheives the same thing

meow19:06:16

I just had a funny duh! moment when I changed some code from #(inc %) to just inc -- doh!!! simple_smile

arrdem19:06:39

eastwood! run it! 😛

meow19:06:48

and to think, I used to love object-orientation... 😉

akiva19:06:51

kibit is good too.

meow19:06:16

now I'm in love with functions

sveri19:06:28

object orientation aint bad

akiva19:06:33

I haven’t written a line of true OO code in years. Don’t miss it.

meow19:06:17

oo in python is nice, but I'm really starting to enjoy clojure

arrdem19:06:24

OO and inheritance ain't all bad, there are some problems it solves nicely. Unbounded mutation and inherited mutability... that gets messy 😛

sveri19:06:48

yea, no question. I am thinking of other things here...like a lot of developers "can" handle OO which makes it so widely used

sveri19:06:13

I just wonder all the time why lisp lost the "war" against SmallTalk

arrdem19:06:58

TL;DR testing truly OOP code is hard because you have to test the cross product of your methods on your implementations, you can't assume that inherited implementations are safe.

arrdem19:06:27

Good paper tho. One of the better ones we read in that class...

sveri19:06:12

cool, didn't know that one, apart from that, testing OOP code is not something I would describe "hard", rather it's one of the worst things to do in OOP land -.-