> On Sep 7, 4:27 pm, B Smith-Mannschott <bsmith.o...@gmail.com> wrote: [snip] >> >> Questions about how best to optimize clojure code to approach java >> performance have come up with fair regularity in the past. You might >> find some good ideas if you search through the archives a bit. >> >> That said, Clojure is a dynamic language with both the flexibility and >> overhead that this brings. It's a clever dynamic language: you can >> often find a set of type hints or other incantations such that the >> clojure compiler will produce byte code which the hotspot server vm >> will be able to optimize very well. >> >> This isn't always possible though, but that's where Clojure's Java >> interop and a little pragmatism comes in: You've got there a nice >> piece of Java code that does what you need and it's fast too. If you >> want that speed from your Clojure code, don't waste time optimizing >> the Clojure, just call the java implementation. >> >> (defn shorts-to-bytes [#^shorts src, #^bytes dst, words] >> (SomeClass/shortsToBytes src dst words)) >> >> (I guess I'm not much of a purist.) >> >> // Ben
On Mon, Sep 7, 2009 at 11:31, rivercheng<riverch...@gmail.com> wrote: > > Due to Clojure's extremely easy integration with Java, your suggestion > makes a lot of sense. But there's still a problem: > it requires everyone learns Clojure has to know Java (not only the > platform, but also the syntax). Moreover, > once we combine the compiled language and script language (just like > using C and Python together), we lose some advantages of > scripting. Every time we modified the Java code, we have to > recompile. > > If we hope Clojure to be an independent language (not just a scripting > tool of Java), it may be better that there's some way to obtain the > high performance without leaving the Clojure world, however complex it > is. For example, although the Haskell codes in shootout are neither > readable nor elegant, but at least Haskell people now can claim they > can achieve high performance without coding in C. > > Furthermore, I think these questions can help improve the compiler > (maybe not now because there are a lot of more important things to do, > but for the future when the language implementation is mature). Hence, > I think "just using Java" is an answer useful to the person who asked, > but may be not helpful to the improvement of Clojure language. +1 Very true. // ben --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---