This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-28
Channels
- # ai (1)
- # beginners (190)
- # boot (24)
- # cider (43)
- # cljsjs (3)
- # cljsrn (29)
- # clojars (6)
- # clojure (310)
- # clojure-dev (6)
- # clojure-nl (6)
- # clojure-russia (11)
- # clojure-spec (66)
- # clojure-uk (95)
- # clojurescript (103)
- # clojurewerkz (2)
- # core-async (9)
- # cursive (4)
- # datomic (5)
- # hoplon (163)
- # lein-figwheel (52)
- # off-topic (6)
- # om (6)
- # onyx (42)
- # perun (8)
- # re-frame (16)
- # reagent (10)
- # ring (7)
- # ring-swagger (1)
- # rum (1)
- # slack-help (2)
- # uncomplicate (1)
- # untangled (80)
(str "mor" "n" "ing")
Ha good to know 😉
Morning
A thought just struck me....but I slapped it back.
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.
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.
How do I get that to a String[] instead? (into-array String v
)` gives me an object array with a string.
See my comment above about not being good developer! I'd need a repl and not just my phone to answer that.
@agile_geek we’re on the same page pal, don’t worry 🙂
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”]
@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.
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.
That looks like a String array?
user> (type v)
clojure.lang.PersistentVector
user> (into-array String v)
#object["[Ljava.lang.String;" 0x3a01db6 “[Ljava.lang.String;@3a01db6”]
That's jjust the way the REPL prints it
Call type
or class
on that
No problem
PS I've used varargs a bit but its not that common TBH
Well someone had the bright idea of forking the onyx twitter plugin as it wasn’t suitable for what I wanted it to do.
but in the twitter4j API is public void thing(String… thing)
and I’d never seen ... before. More odd was Google was pretty useless.
It works a bit like &
in Clojure. Returns an array of args but I rarely see a need for it.
Still doesn’t work, throws an NPE, which is fine I can root around where I need to.
Thanks for the heads up @agile_geek
Are you trying to call a method with a varargs signature?
It will expect a number of String arguments not an array
Just like &
i.e.` thing("a", "b")`
Cool, just checking! 😉
Thanks @otfrom, wondering if can force the java method name in the apply (apply .mymethod thing)
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
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.
Maybe varargs in Java are a compile time trick?
Like generics?
I.e. underlying method expects an array and the compiler turns multiple args into one
If it was introduced in 1.5 (which it was) then it’s going to fall into the autoboxing/generics introductions.
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
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.
@agile_geek well it’s nice to know it’s not me being thick.
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.
Should be easy enough to pass a String array if you need to.
Just looked it up. It's just syntactic sugar over an array. I think it's mearly an extension of autoboxing.
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.
Obviously I can’t mention Onyx when @tcoupland is about 😉
@tcoupland do you only get to wield the magic hammer if you're worthy?
@jasonbell this works so not sure what your NPE is.
(java.text.MessageFormat/format "Hello {0}" (into-array ["Chris"]))
@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.
@agile_geek comparison blog post?
@benedek maybe although I'd need to use Cursive for a lot longer as I have my own biases
@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.
well, you need to use the clj-refactor and cider-debugger in emacs to make that comparsion fair
Of course I always have clj-refactor and cider-debugger in emacs anyway!
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.
(but I didn’t feel that way about Eclipse at the time)
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.
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 😉
Yup, and Jason just released an alpha of Sayid support in ProtoREPL that looks awesome (using D3 for visualizing call trees etc).
yeah that was very impressive in the talk (suppose he was showing off the unreleased version)
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
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.