Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Changes for AOT compilation
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  12 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Rich Hickey  
View profile  
(9 users)  More options Nov 13 2008, 1:43 pm
From: Rich Hickey <richhic...@gmail.com>
Date: Thu, 13 Nov 2008 10:43:38 -0800 (PST)
Local: Thurs, Nov 13 2008 1:43 pm
Subject: Changes for AOT compilation
We're coming around the other side of the few breaking changes I
wanted to get done before release 1.0.

The changes are:

New regex format:

http://groups.google.com/group/clojure/msg/eddd7f0d292da683

Uniform binding syntax using vectors:

http://groups.google.com/group/clojure/browse_frm/thread/55213f2eb203...

And ahead-of-time (AOT) compilation (SVN 1094+)

There is now an AOT compiler that can compile .clj files to .class
files on disk. This can be used to save startup time, deliver
applications without source, interop with bytecode-based tools etc.

The main structural change related to AOT is that the mapping between
a Clojure namespace and a Java package has changed. Where it was ns
maps to package:

my.fancy.lib ==> my/fancy/lib/lib.clj

it is now ns maps to class:

my.fancy.lib ==> my/fancy/lib.clj, when compiled, my/fancy/lib.class

Just lift your files up a directory to accommodate this change. Note
that this implies that all namespaces should have at least 2 segments,
and following the Java package name guidelines, e.g.
com.mydomain.mylib, is recommended.

Accordingly, the clojure ns has been renamed clojure.core. Any
explicitly qualified references will need to be changed. boot.clj has
been renamed core.clj.

The only other source-level change here was a small one to load - you
no longer should supply the .clj extension, in keeping with load's new
ability to load from .class files.

The latter is the only functional difference AOT brings to existing
code - load will load from a .class file if it is newer than the .clj.
Both files need to be in the classpath, using a directory structure
corresponding the the Java package as per above. Once compiled, .clj
files need not be present at all if .class files are supplied.

The unit of compilation is the lib. To compile a lib, simple say:

(compile 'my.fancy.lib)

The source must be in the classpath, in my/fancy/lib.clj Compilation
output will go under the path designated by *compile-path*, which
defaults to the "classes" directory under cwd. Output will go to
*compile-path*/my/fancy/lib.class, and the subdirectories will be
created if needed. *compile-path* is bound in the repl and can be set!
or bound with binding. The *compile-path* directory must also be in
the classpath.

Compilation occurs under a same-world model, i.e. compiling a file has
the effect of loading it as well. As each file/fn is compiled, it is
loaded using the standard class lookup (thus the *compile-path* in
classpath requirement above). This is so that definitions can see and
utilize the definitions and macros that preceded them. While
compiling, a *compile-files* flag is set. This will cause nested load/
require/uses to compile as well, if needed. If your file has some def
initializers you don't want to run at compile-time, you can
conditionalize them like this:

(def foo (when-not *compile-files* (my-runtime-init)))

in which case foo will be nil at compile time.

A .class file will be produced for every file loaded. This file
defines a class called my.fancy.lib, which will have a static void load
() method (this name is likely to change). Calling this method has the
same effect as loading the original .clj would.

Namespaces defined in multiple files are supported. Simply (load "lib-
helper-file") for any helper files at the bottom of your ns-
defining .clj file. Note that classes will be created for these files
as well, even though they are not namespaces, and are not intended for
standalone use

In addition to the class file per .clj file, there will be a .class
file for every function. These will be named my/fancy/lib
$myfun__xxxx.class. They too are not intended for standalone use.
There will be many of these, so please use jar files for distribution.

The clojure.contrib and tools folks are working on getting in sync
with these changes. For minimal disruption, please stick with the SVN
rev they support (say, 1088), or lend a hand in testing their patches.

Still to come is a folding of genclass functionality into AOT, making
for a much smoother process.

Those of you who've used Clojure for a while know such breaking
changes are few and far between. AOT compilation is an important, non-
trivial, and often requested feature. Please be patient during the
transition.

As always, feedback and bug reports welcome.

Thanks,

Rich


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stephen C. Gilardi  
View profile  
 More options Nov 13 2008, 2:21 pm
From: "Stephen C. Gilardi" <squee...@mac.com>
Date: Thu, 13 Nov 2008 14:21:10 -0500
Local: Thurs, Nov 13 2008 2:21 pm
Subject: Re: Changes for AOT compilation

On Nov 13, 2008, at 1:43 PM, Rich Hickey wrote:

> The clojure.contrib and tools folks are working on getting in sync
> with these changes. For minimal disruption, please stick with the SVN
> rev they support (say, 1088), or lend a hand in testing their patches.

I've updated my contribs and others that hadn't yet been updated to  
minimal compatibility with the AOT compilation change. Minimal  
compatibility means that they've been updated so they reside at the  
proper path (pulled up from their individual directories) and that  
they load into Clojure. Please test any that you use and report any  
problems.

For the contrib files I updated, I did an "svn cp" so Subversion  
history should be preserved over the transition. I also left the old  
versions at the old locations (appropriate for Clojure SVN 1088 and  
below) in place for a transitional period. I plan to delete my  
contribs at their old locations in a couple of days. I recommend other  
contrib authors do the same. Folks who want to have clojure-contrib as  
it was for Clojure SVN 1088 should use clojure-contrib SVN 235.

The new changes to Clojure look great! I look forward to exploring them.

--Steve


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wilkes Joiner  
View profile  
(2 users)  More options Nov 13 2008, 2:32 pm
From: Wilkes Joiner <wilkesjoi...@gmail.com>
Date: Thu, 13 Nov 2008 11:32:05 -0800 (PST)
Local: Thurs, Nov 13 2008 2:32 pm
Subject: Re: Changes for AOT compilation
On Nov 13, 12:43 pm, Rich Hickey <richhic...@gmail.com> wrote:

> We're coming around the other side of the few breaking changes I
> wanted to get done before release 1.0.

Is there a roadmap published anywhere?

Thanks,
Wilkes


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stuart Sierra  
View profile  
 More options Nov 13 2008, 5:06 pm
From: Stuart Sierra <the.stuart.sie...@gmail.com>
Date: Thu, 13 Nov 2008 14:06:29 -0800 (PST)
Local: Thurs, Nov 13 2008 5:06 pm
Subject: Re: Changes for AOT compilation
On Nov 13, 1:43 pm, Rich Hickey <richhic...@gmail.com> wrote:

> We're coming around the other side of the few breaking changes I
> wanted to get done before release 1.0.
> New regex format:
> Uniform binding syntax using vectors:
> And ahead-of-time (AOT) compilation (SVN 1094+)

Wow, cool!  I haven't had a lot of time to follow the list lately, but
I'm excited by these developments.

-Stuart


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
walterc  
View profile  
 More options Nov 14 2008, 2:22 am
From: walterc <weih...@gmail.com>
Date: Thu, 13 Nov 2008 23:22:13 -0800 (PST)
Local: Fri, Nov 14 2008 2:22 am
Subject: Re: Changes for AOT compilation
does this mean that writing android application in clojure is
possible?  if not, what else needs to be done to make it happen?

On Nov 14, 2:43 am, Rich Hickey <richhic...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Parth Malwankar  
View profile  
 More options Nov 14 2008, 4:21 am
From: Parth Malwankar <parth.malwan...@gmail.com>
Date: Fri, 14 Nov 2008 01:21:00 -0800 (PST)
Subject: Re: Changes for AOT compilation

On Nov 13, 11:43 pm, Rich Hickey <richhic...@gmail.com> wrote:

> We're coming around the other side of the few breaking changes I
> wanted to get done before release 1.0.

> The changes are:

> New regex format:

> http://groups.google.com/group/clojure/msg/eddd7f0d292da683

> Uniform binding syntax using vectors:

> http://groups.google.com/group/clojure/browse_frm/thread/55213f2eb203...

> And ahead-of-time (AOT) compilation (SVN 1094+)

Thanks very much Rich. All these changes are very exciting.
I look forward to using them.

Does this mean that at some point clojure.jar would
contain precompiled class files for clojure code?
I suppose that would mean faster startup of the
repl.

Parth


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Zak Wilson  
View profile  
(1 user)  More options Nov 14 2008, 4:51 am
From: Zak Wilson <zak.wil...@gmail.com>
Date: Fri, 14 Nov 2008 01:51:22 -0800 (PST)
Local: Fri, Nov 14 2008 4:51 am
Subject: Re: Changes for AOT compilation
It's currently possible to compile the files and rebuild the jar. It
does result in a faster startup time.

There doesn't seem to be a way to generate precompiled class files
with main methods at this point. Is there any reason such
functionality can't be added? Right now, if I want an executable
precompiled jar, I have to make a wrapper with gen-and-save-class or
Java.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rich Hickey  
View profile  
 More options Nov 14 2008, 7:29 am
From: Rich Hickey <richhic...@gmail.com>
Date: Fri, 14 Nov 2008 04:29:30 -0800 (PST)
Local: Fri, Nov 14 2008 7:29 am
Subject: Re: Changes for AOT compilation

On Nov 14, 4:21 am, Parth Malwankar <parth.malwan...@gmail.com> wrote:

That's just a matter of adding precompiling to the ant script.

Patch welcome.

Rich


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rich Hickey  
View profile  
(1 user)  More options Nov 14 2008, 7:30 am
From: Rich Hickey <richhic...@gmail.com>
Date: Fri, 14 Nov 2008 04:30:33 -0800 (PST)
Local: Fri, Nov 14 2008 7:30 am
Subject: Re: Changes for AOT compilation

On Nov 14, 4:51 am, Zak Wilson <zak.wil...@gmail.com> wrote:

> It's currently possible to compile the files and rebuild the jar. It
> does result in a faster startup time.

> There doesn't seem to be a way to generate precompiled class files
> with main methods at this point. Is there any reason such
> functionality can't be added? Right now, if I want an executable
> precompiled jar, I have to make a wrapper with gen-and-save-class or
> Java.

Support for main (and the other features of genclass) is coming.

Rich


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
MikeM  
View profile  
 More options Nov 14 2008, 9:53 am
From: MikeM <michael.messini...@invista.com>
Date: Fri, 14 Nov 2008 06:53:21 -0800 (PST)
Local: Fri, Nov 14 2008 9:53 am
Subject: Re: Changes for AOT compilation

> Just lift your files up a directory to accommodate this change. Note
> that this implies that all namespaces should have at least 2 segments,
> and following the Java package name guidelines, e.g.
> com.mydomain.mylib, is recommended.

I notice that the user namespace is still one segment "user". Will
this remain a one-segment namespace or be changed to two segments at
some point?

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
islon  
View profile  
 More options Nov 14 2008, 11:30 am
From: islon <islonsche...@gmail.com>
Date: Fri, 14 Nov 2008 08:30:51 -0800 (PST)
Local: Fri, Nov 14 2008 11:30 am
Subject: Re: Changes for AOT compilation
These are great changes!!
I see a bright future ahead.

Thanks Rich.

On 14 nov, 11:53, MikeM <michael.messini...@invista.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stuart Sierra  
View profile  
 More options Nov 14 2008, 12:28 pm
From: Stuart Sierra <the.stuart.sie...@gmail.com>
Date: Fri, 14 Nov 2008 09:28:33 -0800 (PST)
Local: Fri, Nov 14 2008 12:28 pm
Subject: Re: Changes for AOT compilation
On Nov 14, 4:51 am, Zak Wilson <zak.wil...@gmail.com> wrote:

> It's currently possible to compile the files and rebuild the jar. It
> does result in a faster startup time.

I can confirm -- precompiling the core classes cuts startup time in
half:

WITHOUT precompiling:
real 4.489
user 6.612
sys 0.441

WITH precompiling
real 1.934
user 2.361
sys 0.236

(Averaged over ten trials.)
java version "1.6.0_05"
Intel Mac, Darwin Kernel Version 9.5.0

-S


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google