Fork me on GitHub
#clojure-uk
<
2016-12-28
>
yogidevbear07:12:10

(str "mor" "n" "ing")

jasonbell07:12:46

Keep this going for too long and we’ll be (def greeting “Afternoon”)

otfrom07:12:16

we all seem to like the UGT joke too much for that 😉

yogidevbear08:12:44

Ha good to know 😉

agile_geek08:12:11

A thought just struck me....but I slapped it back.

agile_geek08:12:05

I never consider myself a good developer but I do think that I write in a disciplined manner & produce reasonably readable code. I never come up with smart solutions to problems but I can apply other people's ideas.

agile_geek08:12:51

I think my weakness as a developer who is not particularly inovative is a strength in a team. Because I'm not the best coder I have to structure code, follow ideoms, cover it with tests etc. otherwise I can't read it 10 mins later.

jasonbell08:12:59

If into-array gives me a nice Object[]

jasonbell08:12:36

How do I get that to a String[] instead? (into-array String v)` gives me an object array with a string.

agile_geek08:12:00

See my comment above about not being good developer! I'd need a repl and not just my phone to answer that.

jasonbell08:12:17

@agile_geek we’re on the same page pal, don’t worry 🙂

jasonbell08:12:04

user> (def v ["#mything"])
#'user/v
user> (type v)
clojure.lang.PersistentVector
user> (into-array String v)
#object["[Ljava.lang.String;" 0x3a01db6 "[Ljava.lang.String;@3a01db6"]
user> (.toArray v)
#object["[Ljava.lang.Object;" 0x697bf377 “[Ljava.lang.Object;@697bf377”]

jasonbell08:12:08

@agile_geek if it’s any consolation I’ve only learned about a thing that was kicking around in Java 1.5 as I’ve never seen anyone using it up until last night.

jasonbell08:12:18

So I thought my Java Interop calls were stuffed, turns out it was right and I was wrong. I’d just ever come across varargs in Java as I’d never seen anyone use them ever.

agile_geek08:12:02

That looks like a String array?

jasonbell08:12:15

Yours does, mine comes in as persistent vector.

jasonbell08:12:21

user> (type v)
clojure.lang.PersistentVector
user> (into-array String v)
#object["[Ljava.lang.String;" 0x3a01db6 “[Ljava.lang.String;@3a01db6”]

agile_geek08:12:31

That's jjust the way the REPL prints it

jasonbell08:12:48

handy to know.

agile_geek08:12:48

Call type or class on that

jasonbell08:12:10

gotcha, nice catch, thanks

agile_geek08:12:50

PS I've used varargs a bit but its not that common TBH

jasonbell08:12:07

Well someone had the bright idea of forking the onyx twitter plugin as it wasn’t suitable for what I wanted it to do.

jasonbell09:12:06

but in the twitter4j API is public void thing(String… thing) and I’d never seen ... before. More odd was Google was pretty useless.

agile_geek09:12:25

It works a bit like & in Clojure. Returns an array of args but I rarely see a need for it.

jasonbell09:12:26

Still doesn’t work, throws an NPE, which is fine I can root around where I need to.

jasonbell09:12:01

Thanks for the heads up @agile_geek

agile_geek09:12:12

Are you trying to call a method with a varargs signature?

agile_geek09:12:30

It will expect a number of String arguments not an array

agile_geek09:12:17

i.e.` thing("a", "b")`

agile_geek09:12:40

Cool, just checking! 😉

jasonbell09:12:58

So the real question all along was how to get a persistent vector to an & 😕

jasonbell09:12:14

Glad I’m on holiday and just messing about

otfrom09:12:41

jasonbell apply

jasonbell09:12:07

Thanks @otfrom, wondering if can force the java method name in the apply (apply .mymethod thing)

jasonbell09:12:37

going to try 🙂

otfrom09:12:11

jasonbell though it looks like agile_geek & I might be wrong if this is true: http://stackoverflow.com/questions/11702184/how-to-handle-java-variable-length-arguments-in-clojure

agile_geek09:12:45

Interesting. Never called a vararg using an array in Java. Not something you'd ever need to do as it's more likely you'd pass objects.

agile_geek09:12:42

Maybe varargs in Java are a compile time trick?

agile_geek09:12:49

Like generics?

jasonbell09:12:09

more than likely

agile_geek09:12:25

I.e. underlying method expects an array and the compiler turns multiple args into one

jasonbell09:12:42

If it was introduced in 1.5 (which it was) then it’s going to fall into the autoboxing/generics introductions.

agile_geek09:12:46

The more I think about it the more likely it's exactly what's happening. Not sure Java could do this any other way given it's runtime characteristics

jasonbell09:12:47

Ah well. It’s not a huge problem, if it’s not going to work then I’ve got Onyx flow predicates as a fallback but I refuse to take a whole stream of data when I can tell the API at source what to return.

jasonbell09:12:09

@agile_geek well it’s nice to know it’s not me being thick.

agile_geek09:12:09

I don't think many Java devs would know this as we don't often have to think about runtime characteristics other than for generics.

agile_geek09:12:25

Should be easy enough to pass a String array if you need to.

agile_geek09:12:48

Just looked it up. It's just syntactic sugar over an array. I think it's mearly an extension of autoboxing.

jasonbell09:12:56

Okay, well I can wrangle it all being well. I did try (into-array String thing) and that gave me the NPE so something strange is going on probably compile time, I’d expect it to work.

jasonbell09:12:14

Obviously I can’t mention Onyx when @tcoupland is about 😉

tcoupland09:12:48

go forth with your new magic hammer, the last one worked out so well!

jasonbell09:12:17

I should really pitch to O’Really for the book deal 🙂

agile_geek09:12:43

@tcoupland do you only get to wield the magic hammer if you're worthy?

tcoupland09:12:49

sadly, it doesn't 😄

agile_geek09:12:56

@jasonbell this works so not sure what your NPE is.

(java.text.MessageFormat/format "Hello {0}" (into-array ["Chris"]))

jasonbell10:12:04

@agile_geek okay, thanks for that. Not sure where the NPE is coming from either but I have a rough idea. Not a huge concern was just scratching an itch and all that.

otfrom10:12:56

agile_geek troll

benedek10:12:13

@agile_geek comparison blog post?

agile_geek10:12:55

@benedek maybe although I'd need to use Cursive for a lot longer as I have my own biases

benedek10:12:43

nothing better than a biased blog post 😉

otfrom11:12:19

agile_geek you can always point out your biases in the post

agile_geek11:12:13

@otfrom I would but I think to give Cursive a fair shot I should probably use it for a week in work. I suspect it has benefits when refactoring and possibly debugging.

benedek11:12:02

well, you need to use the clj-refactor and cider-debugger in emacs to make that comparsion fair

agile_geek15:12:00

Of course I always have clj-refactor and cider-debugger in emacs anyway!

benedek15:12:00

ha sorry, what was i thinking… 😉

benedek15:12:32

do we miss any feature in cljr/cider cursive has?

jasonbell17:12:55

and merged! 🙂

seancorfield17:12:10

I think there’s a huge subjective element about IDEs / editors — I was happy with Eclipse/CCW for a while years ago (and Eclipse in general) but could never get on with IntelliJ. Tried a few things, switched to Emacs full-time back in … 2012? 2013? Used LightTable for about six months full-time but went back to Emacs. Recently shifted to Atom / Proto REPL and I’m liking that (more than Emacs now) so that’s where I’ll stay for the foreseeable… I agree with @agile_geek that IntelliJ just has too much “stuff” on the screen, IMO.

seancorfield17:12:27

(but I didn’t feel that way about Eclipse at the time)

jasonbell17:12:36

When doing Java I was an Eclipse advocate (when I was JDJ section editor I gave it an editor award), wasn’t paying actual money for IntelliJ IDEA at the time and Netbeans was a disaster.

jasonbell17:12:52

Now I’ve deleted the lot, don’t do Java and do Clojure from Emacs only.

benedek17:12:23

sure @seancorfield i think in clojure we are lucky to have a wide selection of (fairly good) choices. i watched the proto repl talk (from clj conj) and was pretty impressed. tbh i watched that first and then the talk on sayid and i was thinking, man i want this in emacs and it turns out sayid was written with built in elisp support 😉

seancorfield17:12:31

Yup, and Jason just released an alpha of Sayid support in ProtoREPL that looks awesome (using D3 for visualizing call trees etc).

benedek17:12:05

yeah that was very impressive in the talk (suppose he was showing off the unreleased version)

benedek17:12:45

my only pro emacs argument (although i do agree with you on this being subjective) that with emacs you are writing a lisp with a tool which is itself written in a lisp. but again this could be really important for some ppl while quite insignificant for others

korny20:12:36

I’m a big cursive fan - mostly for cross-language support; when I need to debug into Java code (or indeed just explore Java code), or need to edit some JavaScript or HTML or Python, it’s nice to have a smooth experience. Emacs can do all of those (except Java, people tell me it is better at Java but I don’t really believe them) - but in Emacs, each language is like learning a whole new IDE, keybindings change, tools change. And the built-in help is, well, at least it’s usually there, but it’s slightly less useful than IntelliJ’s.

korny20:12:06

If I were editing just Clojure all the time, and never really needing to look at the underlying Java[Script], I’d be happy with emacs.

korny20:12:31

Also, of course, as a conslutant I need something that’s easy for client devs to pick up; even if I get a clojure gig I have the option of saying “Here, let’s learn clojure, open up your familiar IDE” or saying “Here, let’s learn clojure, but first, let’s learn emacs” 🙂