Fork me on GitHub
#admin-announcements
<
2015-12-15
>
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!

heow02:12:35

hey guys

monjohn02:12:18

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

d-t-w03:12:19

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.

d-t-w03:12:45

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

d-t-w03:12:49

(pprint
  (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")])

seancorfield03:12:37

@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

seancorfield03:12:24

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.

seancorfield03:12:52

You might like http://4clojure.com 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.

seancorfield03:12:13

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.

monjohn03:12:00

@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: http://www.amazon.com/Web-Development-Clojure-Build-Bulletproof/dp/1937785645

kyle_schmidt03:12:12

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

dave04:12:10

@joshua.d.horwitz: http://learnyouahaskell.com/ 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

dave04:12:23

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

ian08:12:49

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!

ian08:12:06

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

mostr08:12:50

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

cjmurphy08:12:16

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

sveri08:12:01

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

cjmurphy08:12:08

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

mostr08:12:51

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

cjmurphy08:12:06

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

mostr08:12:12

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

dnolen12:12:22

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

dnolen12:12:38

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

mostr12:12:42

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

mostr12:12:02

will give it a try

mostr12:12:15

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

dnolen12:12:25

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

Tim17:12:03

I thought splice would be used for something like that

jaen18:12:07

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

bridget19:12:20

I just finally remembered to support Clojars on bountysource: https://salt.bountysource.com/teams/clojars In case anyone else was meaning to and needed a reminder. simple_smile

bridget19:12:56

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.

tcrawley19:12:38

thanks bridget!

sveri22:12:11

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.

jaen22:12:29

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

sveri22:12:24

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

jaen22:12:46

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

sveri22:12:28

Thanks... I will look at it tomorrow.

jaen22:12:47

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

sveri22:12:34

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

jeff22:12:59

no, the client side of chord uses the browser APIs

jeff22:12:09

server to server websockets don’t really make sense

jeff22:12:13

just use a regular socket

jeff23:12:18

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.

sveri23:12:54

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

jeff23:12:17

ah, an external websocket service.

jeff23:12:25

I don’t know of any clojure clients

jeff23:12:17

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

sveri23:12:15

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

danielcompton23:12:31

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