On 15 August 2014 19:23, Sean Corfield <s...@corfield.org> wrote:

> Could you elaborate on this Colin?
>

Sure. IntelliJ uses an IoC container, and you declare your implementations
of their extensions in an XML file, like this
<https://github.com/go-lang-plugin-org/go-lang-idea-plugin/blob/bd81fdc71cd4c6cb261788dd6670fadff99ae8ec/src/META-INF/plugin.xml#L305-709>.
They do this, amongst other reasons, so they only load extensions for a
particular plugin when those extensions are actually required. This
drastically cuts down the number of classes loaded and speeds load time.
Unfortunately, my only means of participating in this process is a) use
gen-class, or b) use Java:

   1. I AOT everything, so I could use deftype or defrecord to implement
   the extensions that are interfaces since they create a named class, but
   until CLJ-1208 <http://dev.clojure.org/jira/browse/CLJ-1208> is
   implemented I can't do that because there's no way to require the relevant
   namespaces when needed.
   2. Many of the extensions are abstract classes. There's really no good
   way to implement these from Clojure at all, unless I use gen-class.
   3. I use proxy all the time but performance is occasionally a concern, I
   have to ignore reflection warnings when I call protected superclass methods
   and I think I've only used the dynamicity that it provides once - mostly I
   just want a class.

gen-class is what might charitably be called "idiosyncratic". Given better
editor support, ability to add Javadoc etc it's just easier to use a Java
shim - it's worth noting that the Cognitect guys do this too. I've added
support to Cursive so that I get navigation and completion from RT.var(),
API.var() and friends, so it's actually relatively painless, but I'd rather
be using Clojure for this.

When I first started working on Cursive I just created the extension points
eagerly and implemented them manually, but that means that Cursive loads
around 4k classes at startup whether the user ever opens a Clojure file or
not - for reference, their Javascript implementation loads around 100
classes, Python loads 250, it's a little embarrassing. The Jetbrains guys
actually contacted me about this, they're worried about Cursive's impact on
IntelliJ startup time.

What would really help here would be two new forms, similar to reify and
deftype, that are explicitly for interop, also allow class extension and
optionally initialise their namespaces on class init. I spoke to Rich about
this at EuroClojure and he seemed open to the idea, but I haven't had time
to implement a patch for this.

I don't feel like this is a really crazy thing to want to do - anyone
creating Clojure implementations of Spring beans for example will have to
do something similar. And we really need a better way of extending abstract
classes - it's one thing to discourage inheritance in new Clojure code but
Clojure idiomatically exposes the host platform, and the host platform uses
them extensively.


> --
> Sean A Corfield -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
> World Singles, LLC. -- http://worldsingles.com/
>
> "Perfection is the enemy of the good."
> -- Gustave Flaubert, French realist novelist (1821-1880)
>
> --
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to