Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread Marko Topolnik
On Thursday, February 21, 2013 10:49:42 PM UTC+1, David Nolen wrote: > > On Thu, Feb 21, 2013 at 4:55 AM, Marko Topolnik > > > wrote: > >> Whatever the final performance achieved, the fact remains that the >> original Java code was much cleaner, simpler, and more comprehensible than >> the big

Re: Module For COM Objects

2013-02-22 Thread Carlos Ungil
You can also use jawin. For example: (ns reports.pdf (:import org.jawin.DispatchPtr org.jawin.win32.Ole32)) (defn merge-pdfs "Combines all the input-files into a single output-file." [input-files output-file] (Ole32/CoInitialize) (let [app (DispatchPtr. "AcroExch.App") doc1

ANN: Lambda Jam - July 8-10 - Chicago

2013-02-22 Thread Alex Miller
Lambda Jam (http://lambdajam.com) is a new conference for commercial functional programmers, specifically languages like Erlang, Clojure, Scala, Haskell, F#, etc. Lambda Jam will take place in Chicago July 8-10 and will feature a new format: sessions in the morning, workshops and "jams" in the

Re: documentation for clojure core extension points - multimethods and protocols?

2013-02-22 Thread Andrew Sernyak
I guess you should just grep clojure core source for defprotocol, defmulti and so on. -- -- 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 -

Re: Redefinition of datatypes

2013-02-22 Thread Christophe Grand
I have,'t looked much into it but my hunch is that it's the same bytecode but loaded by two different classloaders. So a double loading rather than a double compilation. Christophe On Fri, Feb 22, 2013 at 8:26 AM, Ambrose Bonnaire-Sergeant < abonnaireserge...@gmail.com> wrote: > Hi, > > I don't

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread Phillip Lord
Marko Topolnik writes: >> Christophe's version also has the advantage that it can pretty much >> compile down to efficient JavaScript via ClojureScript and probably an >> efficient ClojureCLR program as well. This may or may not matter to you. >> > Apparently even Cristophe broke quite a bit of

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread Marko Topolnik
Perhaps it's time to hit the decompiler :) AOT compile and apply javap; do the same for a comparable Java version. This will be a time-consuming and frustrating experience and it won't bring you lasting insight into performant Clojure because things will change around in the next release. On Fr

Re: a bit mystified by unchecked-multiply

2013-02-22 Thread John Lawrence Aspden
So, something like: (type 23) the reader makes a list of a symbol and a primitive, the evaluator evals to get a generic function and a primitive, then tries to apply the generic function to the primitive, can't find a primitive version, so boxes the primitive to an object and tries again, and t

Re: documentation for clojure core extension points - multimethods and protocols?

2013-02-22 Thread Dave Sann
I did this. There are actually not many protocols. Likely because most of the original underlying implementation in terms of java interfaces. Few multi-methods beyond print-method stood out. I can post the output if anyone is interested. Dave On Friday, 22 February 2013 21:51:06 UTC+11, Andre

Re: documentation for clojure core extension points - multimethods and protocols?

2013-02-22 Thread Akhil Wali
Please do post :) On Feb 22, 2013 7:08 PM, "Ambrose Bonnaire-Sergeant" < abonnaireserge...@gmail.com> wrote: > Yes please. > > On Fri, Feb 22, 2013 at 9:37 PM, Dave Sann wrote: > >> I did this. >> >> There are actually not many protocols. Likely because most of the >> original underlying implemen

Re: documentation for clojure core extension points - multimethods and protocols?

2013-02-22 Thread Dave Sann
This is for 1.4.0. Multi methods. (Filenames come after) (the two methods in dispatch are: simple-dispatch, code-dispatch add -A 1 option to the grep to see this) $ find . -name "*.clj" -exec grep "defmulti" \{\} \; -print -printf "\n" (defmulti (defmulti ./src/clj/clojure/pprint/dispatch.cl

Re: documentation for clojure core extension points - multimethods and protocols?

2013-02-22 Thread Dave Sann
1.4.0 protocols $ find . -name "*.clj" -exec grep "defprotocol" \{\} \; -print -printf "\n" (defprotocol Reflector (defprotocol TypeReference ./src/clj/clojure/reflect.clj (defprotocol ClassResolver ./src/clj/clojure/reflect/java.clj (defprotocol ^{:added "1.2"} Coercions (defprotocol ^{:added "

Re: a bit mystified by unchecked-multiply

2013-02-22 Thread Michał Marczyk
The reader always returns objects, it's the compiler that sometimes decides to unbox literal numbers. As for type, it's just a regular Clojure function which takes a single object argument (so the 23 will be passed to it in a Long box). Here it happens to delegate to class and ultimately (.getClas

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread Phillip Lord
I'd look at it the other way around. It would be good if someone did this, so that it would change around in the next release, and I won't have to have any lasting insight into the performant Clojure. I wasn't the OP, BTW, although I suspect he and I share a profession. String matching algorithms

Re: a bit mystified by unchecked-multiply

2013-02-22 Thread Herwig Hochleitner
There is no evaluator in clojure (other than the one in the JVM) and certainly no retries. Clojure is a compiled language. All regular function are called via the IFn interface, which takes objects. Function arguments and return values can be type hinted to be primitive. Normally such primitives ar

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread Marko Topolnik
That would exactly be my point, too: I want to write idiomatic Clojure and have the underlying runtime make it perform; that's what I get with Java. I don't want to twist the compiler's arm into producing the bytecode that I can get from straightforward Java code. Incidentally, it happens that

Automatically looking up and adding dependencies

2013-02-22 Thread Adam Clements
Hi, I made a thing: https://github.com/AdamClements/latest-clojure-libraries It's an emacs command which when you do M-x insert-latest-clojure-library will ask you for the name of a library on clojars. It will then pull the clojars page, look at the latest version and insert the text e.g. [cong

[ANN] clj-elasticsearch, a native wrapper for Elasticsearch

2013-02-22 Thread Nils Grunwald
clj-elasticsearch is a fast and complete Clojure wrapper around the native Java Elasticsearch library. It allows some nifty things such as embedding the server directly inside your app, and is extensively documented. You can find some explanations on how and why the library was build at http://

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread David Nolen
On Fri, Feb 22, 2013 at 3:43 AM, Marko Topolnik wrote: > > My 5-year experience with Clojure (since 0.9) hasn't helped me to see it > that way. > I've been doing Clojure for about 5 years as well. Optimizing Clojure in the early days was pretty tough stuff, and resorting to Java was pretty much n

Why is java.io/do-copy defined private

2013-02-22 Thread Jürgen Hötzel
Hi, I implemented (defmethod (var-get #'io/do-copy) [Path Path] [#^Path input #^Path output opts] ...) for fast NIO2 io, but had to do the var-get workaround because do-copy is defined private. Jürgen -- -- You received this message because you are subscribed to the Google Groups "Clojur

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread Marko Topolnik
> > It's right there in the docstring of deftype, but OK. ...followed by several sentences of big fat warnings, including that they are present only to facilitate the building of higher level constructs, such as Clojure's reference types, in Clojure itself. Other than that, you are right, it

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread David Nolen
On Fri, Feb 22, 2013 at 2:06 PM, Marko Topolnik wrote: > > Fair enough. My point was simply that Clojure implementations have a small >> learnable subset that performs well when performance is desired - >> primitives, loops, arrays, deftypes, etc regardless of host. It's >> unfortunate that the ho

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread David Nolen
Er re: assigning stack based locals. Forget wasting time making a tuple type, probably best to just do that with a small mutable array. This worked ok for us when porting some Java persistent data structure code to ClojureScript. On Friday, February 22, 2013, David Nolen wrote: > On Fri, Feb 22,

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread Marko Topolnik
On Friday, February 22, 2013 8:23:38 PM UTC+1, David Nolen wrote: > > > >> I'll give you one specific item that I keep tripping upon: the lack of >> reassignable, stack-based locals. Without them I can't efficiently get more >> than one value out of a loop. Another item is that I can get zer

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread Marko Topolnik
On Friday, February 22, 2013 8:44:30 PM UTC+1, Marko Topolnik wrote: > > > >> * implement efficient tuple type which uses mutation for multiple value >> return >> > > Basically, this is the ^:unsynchronized-mutable that we just mentioned :) > This is much better, but still it's not stack-base

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread David Nolen
On Friday, February 22, 2013, Marko Topolnik wrote: > > > Annoying *and* slower than Java's locals, unfortunately. Most of the time > it won't make a huge dent in the performance, but I just happen to have an > inner loop that iterates between zero and three times only, zero being by > far the most

Clojure 1.5 RC 17 wending through the maven pipes

2013-02-22 Thread Stuart Halloway
Only change from RC 16 is http://dev.clojure.org/jira/browse/CLJ-1168. Please test for regression. Stu -- -- 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

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread Marko Topolnik
On Friday, February 22, 2013 9:04:31 PM UTC+1, David Nolen wrote: > On Friday, February 22, 2013, Marko Topolnik wrote: >> >> >> Annoying *and* slower than Java's locals, unfortunately. Most of the >> time it won't make a huge dent in the performance, but I just happen to >> have an inner loop t

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread Marko Topolnik
On Friday, February 22, 2013 8:41:15 PM UTC+1, David Nolen wrote: > Er re: assigning stack based locals. Forget wasting time making a tuple > type, probably best to just do that with a small mutable array. This > worked ok for us when porting some Java persistent data structure code to > Clojur

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread David Nolen
OK, though threading one 3 element object array into the loop with one double cast doesn't really seem that problematic or slow to me. On Fri, Feb 22, 2013 at 3:27 PM, Marko Topolnik wrote: > On Friday, February 22, 2013 8:41:15 PM UTC+1, David Nolen wrote: > >> Er re: assigning stack based loca

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread David Nolen
Oh right, sorry, you don't want to pay for boxing the double. Yeah this is the case where you'd want to go with a tuple. If this really was common in my own code I would probably write a mutable tuple macro. But I totally understand why someone else might just write the Java if they just want perfo

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread Marko Topolnik
It wouldn't be a first for me, either; I'm already accustomed to writing macros for performance. For example, unrolling writer.append loops, using "jassoc" as a Java HashMap replacement for assoc, and many similar tricks. On this particular occasion, where the performance-critical code segment

Clojure & JSR-331 - Puzzles

2013-02-22 Thread Oscar Riveros
Hello everyone ... I am an amateur of Computer Science ... and I have a blog where I include some of my personal work ... now I have a project to create a version of some puzzles that I found on the www in Clojure & JSR-331, and I would share it with you ... sorry for any mistakes please... :

how do I include a single class file from someone else's library?

2013-02-22 Thread larry google groups
I am ignorant of the JVM, and of Java, so I am sure this is a dumb question. I need to post to the Omniture API. They offer some sample code here: https://developer.omniture.com/en_US/blog/calling-rest-api-in-java That code depends on a Base64Coder class which they offer in a zip file. I downl

Re: how do I include a single class file from someone else's library?

2013-02-22 Thread larry google groups
When I just do something obvious, like in mpdv.core: (ns mpdv.core (:gen-class) (:import (Base64Coder)) and then call its static methods I get: Exception in thread "main" java.lang.NoClassDefFoundError: Base64Coder (wrong name: com/omniture/security/Base64Coder), compiling:(mpdv/core.c

Re: Why is java.io/do-copy defined private

2013-02-22 Thread Stuart Sierra
Hi Jürgen, Things are declared :private usually because the author of the library didn't want to commit to a public API function in future releases. The var-get trick works fine (you can also write @#'io/do-copy) but there's no promise that `do-copy` will stay the same between releases. As long

Re: how do I include a single class file from someone else's library?

2013-02-22 Thread larry google groups
Ah, I see. This is a "polygot" project, which Leiningen describes here: https://github.com/technomancy/leiningen/blob/stable/doc/MIXED_PROJECTS.md That worked for me. Leiningen saves the day again. On Friday, February 22, 2013 4:25:04 PM UTC-5, larry google groups wrote: > > When I just do so

Re: how do I include a single class file from someone else's library?

2013-02-22 Thread larry google groups
Maybe I spoke too soon. I have now stepped into the Twilight Zone. Changes I make to files do not get built when a try to run lein. Just to get some kind of reaction from Leinengen I just put random garbage in the ns clause of my core.clj: (ns lkjlkljlkjlkj mpdv.core (:gen-class) (:import

Re: how do I include a single class file from someone else's library?

2013-02-22 Thread larry google groups
I see this sentence: "Having one source root contain another (e.g. src and src/java) can cause obscure problems." but I have: src/ java/ mpdv/ Which I assume is what Leinengen is asking for. On Friday, February 22, 2013 5:23:28 PM UTC-5, larry google groups wrote: > > Maybe I spoke

Re: how do I include a single class file from someone else's library?

2013-02-22 Thread larry google groups
At least if I put random junk in the project.clj, Leinengen dies with an error: (defproject mpdv "0.1.0" :dependencies [[org.clojure/clojure "1.4.0"] [ring "1.1.5"] [ring/ring-jetty-adapter "1.1.5"] [org.clojure/data.json "0.2.0"]

Re: how do I include a single class file from someone else's library?

2013-02-22 Thread Marko Topolnik
No, src is root for all Clojure. That means that your java root is under the Clojure root. Move java to top-level. On Friday, February 22, 2013 11:28:17 PM UTC+1, larry google groups wrote: > > I see this sentence: > > "Having one source root contain another (e.g. src and src/java) can cause > o

Re: how do I include a single class file from someone else's library?

2013-02-22 Thread larry google groups
Hmm, okay. Seems to be working with: :source-paths ["src"] :java-source-paths ["src_java"] The example on the Leiningen site might be clear to those who know the JVM, but it was not clear to me. But now I have the earlier problem: Caused by: java.lang.RuntimeException: No such names

Re: how do I include a single class file from someone else's library?

2013-02-22 Thread AtKaaZ
use fully qualified name for that class, I think? On Fri, Feb 22, 2013 at 11:50 PM, larry google groups < lawrencecloj...@gmail.com> wrote: > Hmm, okay. Seems to be working with: > > :source-paths ["src"] > :java-source-paths ["src_java"] > > The example on the Leiningen site might be c

Re: how do I include a single class file from someone else's library?

2013-02-22 Thread larry google groups
I don't get it. Whats the fully qualified name of a standalone file that i have locally? On Friday, February 22, 2013 6:03:13 PM UTC-5, AtKaaZ wrote: > > use fully qualified name for that class, I think? > > > On Fri, Feb 22, 2013 at 11:50 PM, larry google groups < > lawrenc...@gmail.com > wrote:

Re: how do I include a single class file from someone else's library?

2013-02-22 Thread larry google groups
this: (:import (Base64Coder)) gets me: Caused by: java.lang.RuntimeException: No such namespace: Base64Coder this: (:import (src_java Base64Coder)) gets me: Exception in thread "main" java.lang.ClassNotFoundException: src_java.Base64Coder, compiling:(core.clj:1) On Friday,

Re: how do I include a single class file from someone else's library?

2013-02-22 Thread Marko Topolnik
You must know the package name of your class. Is it really in the default package? That would be almost impossible since you can't even refer to such a class from another class in a normal package. On Saturday, February 23, 2013 12:20:15 AM UTC+1, larry google groups wrote: > > this: > > (:imp

Re: how do I include a single class file from someone else's library?

2013-02-22 Thread larry google groups
Oh, I see, the file declared a package. This worked: (com.omniture.security Base64Coder)) The Java stuff still confuses me. Thanks for all the help. On Friday, February 22, 2013 6:20:15 PM UTC-5, larry google groups wrote: > > this: > > (:import >(Base64Coder)) > > gets me: > > Cause

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread Korny Sietsma
Isn't that always the way, though? Build your program in a powerful, expressive language, then profile it, find the critical parts, and optimise them - where possible in the same language, and where that's too ugly/painful, drop down a layer to a lower level language. I did lots of this in the lat

ANN: MPEdn, an EDN reader/writer for OS X and iOS

2013-02-22 Thread Matthew Phillips
Hello all, just letting anyone who might be interested know that I've posted MPEdn, an EDN reader/writer implementation for OS X and iOS: https://github.com/scramjet/mpedn It's in active use in a project of mine, so I'm going to go ahead and claim it's a stable and useful 1.0 release. Feedba

Domina API: value vs. text

2013-02-22 Thread nchurch
I've been playing around with Domina; I'm curious why there are different functions for getting the value of forms and of text nodes, (value ) and (text ) respectively. (I realize this comes from JQuery, and I'm a comparative Web noob.) I also noticed that the various set! functions operate on pl

Re: nREPL + Emacs: How to get new definitions to load reliably?

2013-02-22 Thread vemv
Being *x* is the function you use for switching between buffers, one can add a hook to *x* that will perform a nrepl-eval-ns-form, or more sophisticated stuff like adding a :reload clause, sending the ns form to the nrepl console as well, etc. -- -- You received this message because you are s