Fork me on GitHub
Josh Horwitz01:12:01

I'm working my way through the clojure for the brave and true and as a Java developer it's just very hard to grasp the recursion and functional programming, very frustrating!


hey guys


@joshua.d.horwitz: It's definitely a different way of thinking. Stick with it and it will eventually click.

Josh Horwitz02:12:51

What’s the best way that you guys have learned? What’s the recommended books etc..


Hey @joshua.d.horwitz I worked with Java for about 15 years, have been purely Clojure the last 2. I found just coding it the best way to learn, rather than reading, but if you're not lucky enough to work on real-world Clojure projects I also find that if I ever need to work in Java these days I always have a REPL open - it's invaluable, anything you want to test in Java is readily available to you.


e.g. I wanted to check how messages being written to kafka were partitioned:


  (let [partitioner (DefaultPartitioner. (VerifiableProperties.))]
    (map (fn [[key val]] [key (map first val)])
      (group-by second (map (fn [mta-host]
                              (let [k-part (.partition partitioner mta-host 3)]
                                [mta-host k-part]))
                         ["mta1101" "mta1102" "mta1103"
                          "mta1201" "mta1202" "mta1203"
                          "mta3101" "mta3102" "mta3103"
                          "mta3201" "mta3202" "mta3203"])))))
=> ([2 ("mta1101" "mta1203" "mta3102" "mta3201")]
    [0 ("mta1102" "mta1201" "mta3103" "mta3202")]
    [1 ("mta1103" "mta1202" "mta3101" "mta3203")])


@joshua.d.horwitz: I really liked The Joy of Clojure but it’s not recommended as an introductory book. I did some FP back in college before a career of C, C++, and lots of Java. I’d been doing recursion ever since I was doing assembler back in the 80’s tho’ so that probably helped simple_smile


As @d-t-w says, keep a REPL open and experiment a lot. Try out every piece of code you see. Try solving problems in the REPL using Clojure even if you’re going to use Java for the actual problem later.


You might like as a set of interactive puzzles with easy / medium / hard levels.

Josh Horwitz03:12:32

Thanks @seancorfield and @d-t-w , I appreciate the help! I’m in the position where I’m wondering if I should just focus on learning Java as much as I can and all the frameworks, or to learn Clojure. I really like Clojure and the community.


I’m not sure I’d recommend Clojure as a learning experience if your goal is making a website for a nonprofit — there are definitely easier tools for building websites (esp. pure content-based sites) — but learning Clojure to become a better programmer overall is certainly reasonable.

Josh Horwitz03:12:09

I was already learning Clojure, the website just came along out of nowhere so I thought it might be a good project to practice on.


@joshua.d.horwitz: Another option would be to go through something this this, building a website and getting a feeling for Clojure along the way:


^ highly recommend this book if you want to get your job done but it isn't for those wanting to learn the fundamentals.

Josh Horwitz03:12:26

Really? Maybe I will check that out

Josh Horwitz03:12:24

I do have that book, through my company we have a safari online account.


@joshua.d.horwitz: was my introduction to functional programming. it's a great book not just for learning haskell, but it also does a great job of teaching functional programming concepts in an easy-to-understand way


learning clojure after having read it was a breeze

Josh Horwitz04:12:48

Thanks @dave , I have access to that book as well. Maybe I will try that first


this has nothing to do with clojure, but holy cow does Go really upset me. I know I should just take some time to learn the basics, but I don't want to. I want to use a project written in Go but I can't even freaking figure out how to build it!


why shouldn't I just be able to download a couple of .go files anywhere and just go build or something?


Any Cursive users around? Trying to force myself to stick to structural editing as much as possible (still being Clojure beginner), I know I can wrap stuff in parens just by selecting it and hitting (, but what if I want to do the opposite? E.g. I have fiddled with parens and ended up with sth like this (((str “Hello “ “World”))). How can I get rid of these redundant form parens (I have “standard” Cursive keybindings over MacOSX 10.5+ set)?


I just highlight then use the delete key. Quite a hassle really and I'm sure that's not the right way.


@cjmurphy: @mostr I do it the same way, using cursive for almost over a year already 😄


I have a feeling we are supposed to think in a 'parenedit' way, but I could be completely wrong, prolly am.


I feel like hacking Cursive way by just using “Delete” simple_smile But looks like it’s way to go from what you say simple_smile


We s/be in #C0744GXCJ by the way...


oh, facepalm haven’t checked if channel existed before posting, joining.


@mostr: there’s a command for that, “Raise"


if ^ is the cursor (^(foo 1 2)) Raise -> (foo 1 2)


thanks, will check it too. We got “Splice” working (on #C0744GXCJ) in this particular case (I mean remove redundant parens pair)


will give it a try


yeah, this is IT, looks like it’s also special case for “Splice” too, thanks!


things I find essential - Raise, Splice, Split, and Sexpr aware Kill


I thought splice would be used for something like that


For me splice also seems more natural than raise to achieve this.


I just finally remembered to support Clojars on bountysource: In case anyone else was meaning to and needed a reminder. simple_smile


I hate to think of what would happen if there was a sustained Clojars outage. Many thanks to tcrawley for all of his work, and, of course, xeqi, too.


thanks bridget!


Hi, anybody knows a clojure library for websockets? I tried gniazdo, but this seems to break my project with classpath issues. Sente seems to be only able to open a client on cljs side.


@sveri: how would you want to do a server on the client side though?


@jaen i want to connect to a websocket on server side. So from server to server.


Ah, I must have misunderstood you. Yeah, unfortunately sente doesn't have a client.


Thanks... I will look at it tomorrow.


Yes, I'm aware of this library, but that doesn't answer @sveri's use-case, does it?


@jaen @shinych at least in the readme i cannot find an example.


no, the client side of chord uses the browser APIs


server to server websockets don’t really make sense


just use a regular socket


http-kit has client and server APIs, but not client-side websockets. That would most likely be a substantial amount of work, although if you needed this for some reason you could probably do it.


@jeff what do you mean exactly with "just a socket"? What i want is to connect to a websocket endpoint from clojure side. Which "socket" implementation should i use for that?


ah, an external websocket service.


I don’t know of any clojure clients


if you have control of both client and server, than I meant a plain TCP socket


Ah... Now i get what you mean. No, i don't have control, only an external endpoint.


@sveri: you could copy the wrapper parts of gniazdo into your own projects, or use the jetty Java library directly