LWN.net Logo

Introducing Raven: An Elegant Build for Java (O'ReillyNet)

O'Reilly's OnJava.com looks at Raven, a build system for Java. "Raven is based on the Ruby dynamic language and its most prominent build tool, Rake. Don't worry, you don't have to know either to read this article or start using Raven, you can learn little by little, starting simple. Rake itself is a little bit like Ant, it lets you define tasks and the dependencies between them. Only its syntax is much sweeter."
(Log in to post comments)

Why do you need a language-specific build system?

Posted Dec 8, 2007 0:05 UTC (Sat) by stevenj (guest, #421) [Link]

Am I missing something? Why do Java developers need a language-specific build system, rather than a generic build system like "make" or one of its many derivatives (from automake to scons to cook to cmake to ...)?

Why do you need a language-specific build system?

Posted Dec 8, 2007 0:41 UTC (Sat) by vmole (guest, #111) [Link]

Because it's XML! (Well, Ant is, anyway. Which makes the comment that the "syntax is sweeter" sort of self-evident; it could hardle be worse...)

Why do you need a language-specific build system?

Posted Dec 10, 2007 7:23 UTC (Mon) by man_ls (subscriber, #15091) [Link]

Ant syntax is ugly, but still much better than make IMHO. For starters you usually know where your stuff is, because you don't have a bunch of similarly looking files spread everywhere. Then, any developer can use it; you don't need any shell sorcery and it is actually readable. And extending the framework (writing an Ant task) is quite doable.

Never mind the XML bit, you get used to it.

Why do you need a language-specific build system?

Posted Dec 10, 2007 7:50 UTC (Mon) by k8to (subscriber, #15413) [Link]

The recursive makefiles business isn't required, and is avoidable, so long as you aren't using
autofoo.  Shell is no more arcane than ant, and is more readable over time.  Ant is not
readable.  It's wilfully spiky and messy and verbose.  It's the opposite of readable without
going to extreme measures (befunge etc).

Ant has need of concepts like variables in order to manage large project, but can't fit them
into the xml, so instead they're unscoped meta thingies that you stuff values into.  

Ant is just terrible at the syntactic and organizational levels. 

Avoid.

Why do you need a language-specific build system?

Posted Dec 8, 2007 0:56 UTC (Sat) by robertm (subscriber, #20200) [Link]

Java also takes the idiosyncratic approach of mirroring language constructs onto the
filesystem.  As far as I can tell, most of the need for Java-specific build systems stems from
the fact that your source files are simply not allowed to be in the compiler's current working
directory, for all but the most trivial of projects.

It's just faster...

Posted Dec 8, 2007 2:22 UTC (Sat) by khim (subscriber, #9252) [Link]

Java programs are usually quite big and have thousands of files. Java compiler is written in Java (of course). This means that you can either start JVM from generic build system (which is slow and can be 10 slower then compilation itself) or you start JVM just once for Ant/Rake/etc and then call javac as class. Of course it all can be easily solved with powerfull build system (i.e.: not make) and distcc-like server, but... it'll not "Java way"...

It's just faster...

Posted Dec 8, 2007 9:59 UTC (Sat) by saffroy (subscriber, #43999) [Link]

Other languages can also be very very big. The Java compiler could well be started once per
build, and then given orders to build individual files, under the control of any build system
the user has to use in his big project (which might use other languages). It's a real waste of
time not to build on experience of existing (or future) tools for the task, or to tie a build
tool to a specific language.

AFAIK the only deep reason not to use make for Java is that make does not handle circular
dependencies; but maybe this is not a problem to everyone.

It's just faster...

Posted Dec 8, 2007 20:38 UTC (Sat) by aleXXX (subscriber, #2742) [Link]

> AFAIK the only deep reason not to use make for Java is that make does
> not handle circular dependencies; but maybe this is not a problem to
> everyone.

I would say that if there is a build which has circular dependencies that 
the build should be fixed to get rid of these dependencies, no matter 
whether the tool is able to handle them (how ?) or not.
Circular dependencies can be seen as a sign of a design problem.
Why should somebody need circular dependencoes ?

Alex

The question is how to avoid circular dependences - and it's not easy

Posted Dec 9, 2007 0:19 UTC (Sun) by khim (subscriber, #9252) [Link]

Circular dependences are quite common in C/C++ world (or actually any other languages) too. For example you can have pointer from Window to Application (to reach some properties in it) and Application have pointer to active Window too. Or you can have pointer to XMLDocument from Node - and of course XMLDocument has pointer to the top node. Examples are endless. In C/C++ it's handled by .h/.c split, but Java has no such thing...

Why do you need a language-specific build system?

Posted Dec 8, 2007 17:07 UTC (Sat) by lambda (subscriber, #40735) [Link]

Well, Raven isn't actually a Java-specific build system. It's based on the generic build system Rake, which is like make but built upon Ruby, so for complex rules you can use a real, general-purpose programming language. Raven is just some standard rules and helpful functions for making building Java code from Rake easier, taking care of some of the more annoying bookkeeping (like dealing with CLASSPATH and so on) that you would have to do by hand otherwise.

So, really, Raven is a much nicer solution than something like Ant, which really is pretty Java specific and involves building lots of obnoxious XML files to configure it.

Why do you need a language-specific build system?

Posted Dec 8, 2007 17:08 UTC (Sat) by rev (guest, #15082) [Link]

Hmmm..

Different beast, different characteritstics, different requirements, different problems
therefore different solution, maybe?

Makefiles tend to relies on shell utilities. Write a Makefile suite for your java application
and try to build it on a MS-Windows system. Good luck!

Why do you need a language-specific build system?

Posted Dec 8, 2007 17:21 UTC (Sat) by nix (subscriber, #2304) [Link]

Oh come on, anybody using Windows for any serious development has Cygwin 
installed...

... don't they?

Why do you need a language-specific build system?

Posted Dec 8, 2007 19:00 UTC (Sat) by chromatic (guest, #26207) [Link]

Sadly, no.  When building software for end-users on Windows, sometimes Cygwin is one
dependency too many or too complex to require.

Why do you need a language-specific build system?

Posted Dec 8, 2007 19:26 UTC (Sat) by nix (subscriber, #2304) [Link]

That was a somewhat tongue-in-cheek comment, but, um, Cygwin is too 
complicated for the people doing the *building*? Even mingw is too 
complicated? That seems... strange.

Why do you need a language-specific build system?

Posted Dec 8, 2007 20:32 UTC (Sat) by NAR (subscriber, #1313) [Link]

We're talking about Windows programmers :-) OK, this is half-serious, but I had a couple of
collagues who just never managed to use a shell properly - cygwin, mingw could be too
complicated to them.

Why do you need a language-specific build system?

Posted Dec 8, 2007 22:08 UTC (Sat) by alecs1 (guest, #46699) [Link]

This is not half-serious, this is completely serious, and you are right on the point. Most
Windows programmers I know don't know anything else than the build button from the Visual
Studio.

And this is serious stuff. No matter the situation, you want that any line of code that is
under your control to build at a press of button, and, if posible to step through it at other
few button clicks. More, you would be confortable to do the release build and the testing
builds in the same way. 
To be honest, though I work on Linux, have knowledge of cygwin, understand a bit of makefiles,
etc, I have no idea how to step through a program without the aid of an IDE.

So, you have a bunch of files and want to compile them. You want to open them as a project in
an IDE and have a look, then maybe press some button to compile, etc. I did this with Qt and a
few make programs: write all the program from KDevelop, and then on Windows just fire up the
compilation, not touching anything in the source code, except for, say, adding the 'binary'
option for opening files.

So, if use build system X, want IDE that understands build system X :).

Why do you need a language-specific build system?

Posted Dec 10, 2007 16:03 UTC (Mon) by nix (subscriber, #2304) [Link]

For stepping through a program without an IDE, look at the `step', `next', `finish' and
`continue' commands in GDB. (Also breakpoints, watchpoints, displays, and, hell, all the rest
of GDB excepting the assembler-stepping stuff.)

(The ability to execute arbitrary code while your program is paused via `print' is also a
killer feature that I have never seen in any IDE. Mind you the last IDE I used was back in the
Turbo C++ days, so things may have improved here.)

Why do you need a language-specific build system?

Posted Dec 14, 2007 18:19 UTC (Fri) by smitty_one_each (subscriber, #28989) [Link]

In a Visual Basic for Applications macro, you can go to the immediate pane (pain?) and execute
a Debug.Print with execution paused as well (for example, to acquire the ADODB.Command
ComandText that just failed), though I'd fall short of calling that a counter-argument.

Why do you need a language-specific build system?

Posted Dec 9, 2007 0:12 UTC (Sun) by rev (guest, #15082) [Link]

Sure.. that will work. No path separator issues.. no drive letter issues. Nope.

Getting back to the dawing board and come up with a solution that fixes problems rather than
adding complexity to make the problems go away does sound like a pretty sound approach to me.

There's nothing sacred about make. It may have proven to be useful for decades in certain
environments, that does not imply it is the best solution in another environment. Heck, that
does not even imply it is the best solution for the environments it is heavily used in. Make
and subdirectories? Phony targets.. what?

Why do you need a language-specific build system?

Posted Dec 8, 2007 20:47 UTC (Sat) by aleXXX (subscriber, #2742) [Link]

> Makefiles tend to relies on shell utilities. Write a Makefile suite for
> your java application and try to build it on a MS-Windows system.

Depends on your makefiles/your makefile generator.
E.g. cmake for which system it generates makefiles, so if you run it 
under windows, you will get makefiles which work under windows, e.g. 
using nmake.

Said that, cmake support Java, but the C/C++ support is more widely used. 
The habit of java to require that files are located in certain 
subdirectories due to class/package issues may be a bit tricky.

Alex

Why do you need a language-specific build system?

Posted Dec 8, 2007 20:34 UTC (Sat) by NAR (subscriber, #1313) [Link]

I had problems with dependency handling using make - usually it was safer to remove all class
files and rebuild the whole stuff.

Why do you need a language-specific build system?

Posted Dec 8, 2007 20:42 UTC (Sat) by aleXXX (subscriber, #2742) [Link]

The comparison here is slightly wrong.
scons and cook are kind-of derivates of make (i.e. they actually build 
stuff), automake and cmake don't.

automake prepares file for make (using autoconf in between).
cmake OTOH is not tied to make at all. cmake generates input files for 
your build system of choice: make (GNU, MS, Watcom, ...), XCode or MSVC 
project files.
If somebody wanted to, he could add e.g. ant or jam support to cmake.

Alex

Why do you need a language-specific build system?

Posted Dec 9, 2007 0:10 UTC (Sun) by stevenj (guest, #421) [Link]

It's true that automake uses 'make' as a back-end for portability reasons. On the other hand, it adds a lot of features that are rather painful to do properly in raw 'make', such as recursive builds, portable building of shared libraries (with the help of libtool), VPATH builds, and built-in support for 'make install', 'make dist', and other GNU-standard targets. Using automake is quite a different experience from using raw 'make'.

Put another way, you wouldn't say that C is not a programming language just because your compiler spits out assembler. As long as the back-end is Turing complete (and make+sh surely is), it's just an implementation detail, and doesn't make the front-end any less of a "build system".

Why do you need a language-specific build system?

Posted Dec 9, 2007 2:13 UTC (Sun) by nix (subscriber, #2304) [Link]

But automake lets you write raw make in Makefile.ams, and actually 
*requires* it for anything out of the ordinary.

I'd call C `not a programming language' if it provided loops but 
conditionals had to be written in raw assembler!

Why do you need a language-specific build system?

Posted Dec 10, 2007 18:35 UTC (Mon) by stevenj (guest, #421) [Link]

So C++ is not a programming language, because if you take out the C portions of the language it doesn't have looping constructs or basic arithmetic? Most people would say that significantly modified versions of programming languages are new programming languages.

Automake is an extension of 'make' syntax, no doubt about it, but it is such a substantial extension that not calling it a distinct build system from raw 'make' is a bit silly in my opinion.

Why do you need a language-specific build system?

Posted Dec 9, 2007 17:23 UTC (Sun) by josh_stern (guest, #4868) [Link]

The power of autoconf/make on unix piggybacks on the power of shell commands and related tools. Lots of folks find that setup to be not sufficiently cross platform and also the knowledge vs. power slope for mastery to be kind of steep. With Java there is the added problem that substituting JVM executions for shell executions slows things down a lot due to the large size and slow startup of the JVM.

Copyright © 2007, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds