Another DrJava User Site: University of Western Ontario

I found another university that uses DrJava in its CS curriculum: The University of Western Ontario teaches CS 1026: Computer Science Fundamentals I using DrJava.

The course is based on Mark Guzdial’s and Barbara Ericson’s Media Computation textbook. Having had Georgia Tech as clients has certainly been most beneficial for DrJava.

I have added UWO to the list of DrJava user sites.

Share
Posted in DrJava | Leave a comment

Print This Post Print This Post  

Back from GPCE 2010

After a rather long return journey and more than enough time at the Amsterdam-Schiphol airport, I’m back from my trip to GPCE 2010 in Eindhoven. It was fun.

Eddy and I presented a tutorial on DSL implementation in Mint. Of course, I don’t have a picture of that, but Eelco might. But here’s Sukyoung Ryu presenting her tutorial on Fortress.

Sukyoung Ryu's GPCE 2010 Tutorial on Fortress

Sukyoung Ryu's GPCE 2010 Tutorial on Fortress

The auditorium for GPCE was nice, but it didn’t have power outlets. After 10 years in Texas, I guess that’s how I generally feel about Europe: quaint, a bit cramped and underpowered ;-)

GPCE Auditorium in Eindhoven

GPCE Auditorium in Eindhoven

Also very European: Train, bike, landscape with canals.

Train, bike, landscape with canals

Train, bike, landscape with canals

Some more pictures from the trip:

Eindhoven train station, for a quick escape

Eindhoven train station, for a quick escape

Landscape from the train

Landscape from the train

Ready to leave Amsterdam-Schiphol airport

Ready to leave Amsterdam-Schiphol airport

And here are some more pictures that Eddy took. Proof that I exist!

At the Amsterdam-Schiphol airport train station

At the Amsterdam-Schiphol airport train station

"Looking very European" with my scarf

"Looking very European" with my scarf

Share
Posted in Mint, Pictures | Leave a comment

Print This Post Print This Post  

Benoît Mandelbrot Died at Age 85

Just after Eddy and I used the Mandelbrot set as benchmark in our DSL tutorial, Benoît Mandelbrot died. The Franco-American mathematician, who is most well-known for popularizing fractal geometry, died at the age of 85.

Thank you for giving us such a visually appealing way of demonstrating our optimization for embarrassingly parallel loops.

Share
Posted in Mint | Leave a comment

Print This Post Print This Post  

Tutorial Lecture: Agile and Efficient Domain-Specific Languages using Multi-stage Programming in Java Mint

Agile and Efficient Domain-Specific Languages using Multi-stage Programming in Java Mint (PowerPoint, PDF, view embedded)

Tutorial Proposal
(PDF, view embedded)
Source code (ZIP file)

Mathias Ricken, Edwin Westbrook and Walid Taha

A tutorial lecture presented at the

Ninth International Conference on
Generative Programming and Component Engineering (GPCE’10)

October 10-13, 2010
Eindhoven, The Netherlands

Abstract

Domain-specific languages (DSLs) are a powerful productivity tool
because they allow domain experts, who are not necessarily programming
experts, to quickly develop programs. DSL implementations have unique
constraints for programming languages because they must be efficient,
in order to ensure high productivity, but they must also be agile, in
order to meet the rapidly changing demands of their domains. In this
tutorial we show how multi-stage programming (MSP) can be used to
build staged interpreters, which combine the agility of interpreters
with the efficiency of compilers. The tutorial is conducted in Java
Mint, an multi-stage Java based on recent work incorporating MSP into
imperative object-oriented languages. In the first half of
the tutorial, we introduce MSP by demonstrating how to write a staged
interpreter for a number of basic language constructs, such as
recursive functions, conditionals, and let expressions. In the second
half, we extend our staged interpreter to take advantage of several
well-known compiler optimizations, including type inference, constant
folding, and static parallel loop scheduling. We highlight the opportunities
afforded by using MSP with object-oriented design to quickly create
efficient DSL implementations.

Presenter Biographies

Mathias Ricken is a doctoral candidate in the Programming Languages
Team at Rice University and one of the principal developers of the
DrJava integrated development environment. His research interests
include concurrent programming, extending the Java language, and
computer science education. He is the developer of the Concutest
concurrent unit testing framework and has created various experimental
extensions of Java to address, for instance, programming with
meta-data. Currently, Mathias is contributing to Java Mint, a
multi-stage extension of Java that allows safe and expressive
statically typed program generation and specialization in an
imperative language setting.

Edwin Westbrook is a post-doctoral researcher at Rice University. His
primary interests are in developing techniques for implementing and
verifying properties of domain-specific languages (DSLs). He has
worked on a number of projects in this area, including: Cinic, a type
theory for building machine-checked proofs of properties of DSLs using
a new approach to higher-order abstract syntax; Java Mint, a
multi-stage version of Java used for efficient implementations of
DSLs; and Acumen, a DSL for designing cyber-physical systems.

Walid Taha is an professor at Halmstad University. His current interest is in modeling and simulation of cyberphysical systems. He was the principal investigator on a number of research awards and contracts from the National Science Foundation (NSF), Semi-conductor Research Consortium (SRC), and Texas Advanced Technology Program (ATP). He received an NSF CAREER award to develop Java Mint. He is the principle designer Java Mint, Acumen, MetaOCaml, and the Verilog Preprocessor. He founded the ACM Conference on Generative Programming and Component Engineering (GPCE), the IFIP Working Group on Program Generation (WG 2.11), and the Middle Earth Programming Languages Seminar (MEPLS). In 2009, he chaired the IFIP Working Conference on Domain Specific Languages (DSLs).

Share
Posted in Publications | 1 Comment

Print This Post Print This Post  

Another Image Processing Example in Our Staged DSL

Last night, we implemented a Mandelbrot example in the image processing DSL that we created for our GPCE tutorial. Here’s a screenshot.

Screen Capture of Mandelbrot in our Staged DSL

Screen Capture of Mandelbrot in our Staged DSL

Share
Posted in Mint | 1 Comment

Print This Post Print This Post  

GPCE’10 Tutorial Slides

The slides for our GPCE 2010 tutorial presentation “Agile and Efficient Domain-Specific Languages using Multi-Stage Programming in Java Mint” are available now as PowerPoint and PDF file.

The zip file with the source code for our GPCE 2010 tutorial is available too.

The simplest way to experiment with Mint is to download the latest version of DrJava with Mint.

(Re-posted from The Java Mint Blog.)

Share
Posted in Mint | 1 Comment

Print This Post Print This Post  

GPCE’10 Tutorial Source

Here is a zip file with the source code for our GPCE 2010 tutorial.

The simplest way to experiment with Mint is to download the latest version of DrJava with Mint.

(Re-posted from The Java Mint Blog.)

Share
Posted in Mint | Leave a comment

Print This Post Print This Post  

Rice Graduate-Undergraduate Research Mixer

I’m glad that I went to the Graduate-Undergraduate Research Mixer organized by the SA and GSA at Rice with my poster today: I was the only computer scientist there.

Rice Grad/Undergrad Research Mixer Java PLT Poster

Rice Grad/Undergrad Research Mixer Java PLT Poster

Rice Grad/Undergrad Research Mixer

Rice Grad/Undergrad Research Mixer

The Central Quad started to fill up a little after 6 PM, and I had interested students standing by my poster and asking questions for about an hour. I was able to do some good advertisement for computer science in general and the programming languages group in particular. I think making DrJava a centerpiece of several research projects, which Corky and I have begun to do, is a good strategy. I told students they can work on DrJava and use COMP 402 to fulfill their BS CAP requirement and get involved in Habanero Java, for example, if they are interested in parallel programming.

Hopefully we’ll have some undergraduates in our production programming class next semester, or students interested in independent study.

Share
Posted in DrJava, Pictures, Research | Leave a comment

Print This Post Print This Post  

Poster: Java Programming Language Team

Research Summary: Java Programming Language Team

Where: Rice University Undergraduate-Graduate Research Mixer 2010
When: October 7, 2010

This poster shows a summary of my work in the Java Programming Languages Team in the Department of Computer Science at Rice University. Generally, my efforts can be grouped into the four categories of (1) testing concurrent programs, (2) multi-stage programming, (3) computer science education, and (4) developing DrJava. The poster also shows how these four areas are interconnected.

Share
Posted in Publications | 1 Comment

Print This Post Print This Post  

Gaussian Blur Implemented in Our DSL

Sexy!

Gaussian Blur in DSL Screenshot

Gaussian Blur in DSL Screenshot

A screenshot showing an original image of random grayscale values, and a blurred version of the image, with the source code in our example DSL for the GPCE tutorial in the background.

Share
Posted in Mint | Leave a comment

Print This Post Print This Post  

System.out.print Flood Makes DrJava Hang

I just filed a bug report for a serious problem with DrJava that we need to look at. It’s possible to make DrJava hang, or at least slow it down so much that it appears unresponsive, by printing out very long lines without line breaks.

This is related to the problem that Jarred noticed a while back in the DrJava/HJ meeting. Back then, we considered limiting the number of lines stored in the Interactions and Console documents.

I think that’s still a worthwhile idea to pursue, but the problem is more subtle. The same amount of data spread out across several lines, with line breaks inserted, does not make DrJava hang.

This program is bad and causes DrJava to become unresponsive:

[cc_java]public class FloodDrJava {
public static void main(String[] args) {
for(int i=0; i<10000; ++i) { System.out.print("Hello "+i+" "); } } }[/cc_java] This program makes DrJava a bit slow, but it never makes it seem to hang: [cc lang="java"]public class FloodDrJava { public static void main(String[] args) { for(int i=0; i<10000; ++i) { System.out.println("Hello "+i+" "); } } }[/cc] Note that the only difference is [cci]println[/cci] instead of [cci]print[/cci] in line 4. We should actually be sending more characters because of the line breaks.

It may be Swing’s word wrapping or something like that. It really seems to have to do with the length of the lines, and appending at the very end of it. It’s unlikely that simply limiting the number of lines would make a difference here.

Share
Posted in DrJava | Leave a comment

Print This Post Print This Post  

Power_Let Was Wrong

I just did some experiments with Mint, because we ran into some problems with using HJ inside DrJava, and I wanted to make sure we didn’t have those problems. That’s when I noticed that our Power_Let example had been wrong. One of our undergrads had written it as x^0 = x, and no one had noticed…

Embarrassing… But at least the unstaged code was equally wrong, so the benchmark is valid ;)

Share
Posted in Mint, Ramblings | Leave a comment

Print This Post Print This Post  

Demo of DrJava/HJ

In today’s DrJava/Habanero meeting, Vincent, Jarred and I presented a demo of DrJava/HJ to Jack Dennis of MIT. Generally, we were quite pleased how we could just re-build Habanero Java and DrJava, and get a working version with the newest features from both packages.

We also noticed a few problems, of course. Perhaps most critically, when using the HJ compiler from within DrJava, the compiler uses the wrong directories when it generates class files for classes not in the default package.

I fixed part of that bug. The compiler adapter was ignoring the destination directory passed to the HJ compiler adapter. Now, if you create a project and set a build directory, the class files will end up in the right place. I have committed this fix into the DrJava trunk and also into the drjava-hj branch.

I didn’t fix the problem (a) if there is no build directory set, or (b) if we are not in project mode. This is something that I think should be fixed in the HJ compiler, because it doesn’t behave the same way javac behaves: If you invoke javac and don’t give it a destination directory, it will generate the class files in the same directory where the source files are. The HJ compiler generates the class files in the current directory.

Example:

[cci]javac src/HelloWorld.java[/cci] generates the class file src/HelloWorld.class.
[cci]hjc src/HelloWorld.hj[/cci] generates the class files HelloWorld.class, HelloWorld$0.class, and HelloWorld$Main.class. in the current directory, not in src.

I hope the HJ team will agree this is a change that should be made in the HJ compiler.

Furthermore, we noticed again that compiler error messages aren’t displayed in DrJava’s Compiler Output pane. We also noted that we cannot call methods directly from the Interactions pane: We have to use the [cci]hj[/cci] or [cci]run[/cci] commands, otherwise the class loader isn’t properly set up. We should at least come up with a better error message than throwing an exception:

[ccN]Welcome to DrJava. Working directory is /Users/mgricken/bin/hj.release/examples
> new FibFuture().fib(10)
java.lang.NullPointerException
at hj.lang.Runtime.here(Runtime.java:317)
at hj.lang.Object.(Object.java:44)
at FibFuture.(FibFuture.hj)[/ccN]

Interestingly, we can call Mint methods from the Interactions pane, we just cannot use the new syntax elements in Mint, brackets and escape.
[ccN]Welcome to DrJava. Working directory is /Users/mgricken/Documents/Research/Mint/java-mint/trunk/langtools/mintTest
> import edu.rice.cs.mint.runtime.*
> Code c = DrJavaInteractions.makeCodeInt(5)
> c
<| ((5)) |>
> Code cTo10 = DrJavaInteractions.spower(c, 10)
> cTo10
<| (((5)) * (((5)) * (((5)) * (((5)) * (((5)) * (((5)) * (((5)) * (((5)) * (((5)) * (((5)) * (1))))))))))) |>
> cTo10.run()
9765625[/ccN]

Share
Posted in DrJava, Mint | Leave a comment

Print This Post Print This Post  

New Mint Release: r15858

I made a new release of Mint and DrJava with Mint yesterday: September 29, 2010 (r15858). The latest release is, as always, available from the Mint implementation page:

We have added the [cci lang=”java”]edu.rice.cs.mint.runtime.CodeFree[/cci] interface and the [cci lang=”java”]edu.rice.cs.mint.runtime.CheckedExceptionInCode[/cci] exception class.

The [cci lang=”java”]CodeFree[/cci] interface provides a different, more transparent way of specifying separable classes that can be used for non-local assignments and CSP. When a class is declared to implement the [cci lang=”java”]CodeFree[/cci] interface, the class is guaranteed to be code-free, provided a number of static checks are passed:

  1. All field types and method return types are code-free, either using the old definition that required the types to be [cci lang=”java”]final[/cci], or by themselves implementing the [cci lang=”java”]CodeFree[/cci] interface.
  2. The same applies to all subtypes of types implementing the [cci lang=”java”]CodeFree[/cci] interface. It is an error to extend a class declared to be code-free using the [cci lang=”java”]CodeFree[/cci] interface and then to add a field containing or a method returning code.

This new rule makes it simpler to work with non-primitive types since the classes do not have to be [cci lang=”java”]final[/cci] anymore. In the past, lifting had to be done instead of using CSP; that is not necessary anymore. Consider the old code with the required [cci lang=”java”]lift[/cci] method and its application instead of straight-forward CSP:

[cc lang=”java”]public abstract class Value {
public separable int intValue() { throw new WrongTypeException(); }
public separable boolean booleanValue() { throw new WrongTypeException(); }
public separable abstract boolean valueEq(Value other);
public separable abstract Code lift();
}

public class IntValue extends Value {
private int _data;
// …
public separable Code lift() {
final int lfData = _data; // hack to help the Mint compiler
return <| (Value) new IntValue(lfData) |>;
}
}

public class BooleanValue extends Value {
private boolean _data;
// …
public separable Code lift() {
final boolean lfData = _data; // hack to help the Mint compiler
return <| (Value) new BooleanValue(lfData) |>;
}
}

// …

public class Val implements Exp {
private Code _value;
public Val(final Value value) {
_value = value.lift(); // lifting here
}
// …
}[/cc]
and the new code that doesn’t require the [cci lang=”java”]lift[/cci] method anymore:

[cc lang=”java”]public abstract class Value implements CodeFree, Serializable {
public separable int intValue() { throw new WrongTypeException(); }
public separable boolean booleanValue() { throw new WrongTypeException(); }
public separable abstract boolean valueEq(Value other);
}

public class IntValue extends Value {
private int _data;
// …
}

public class BooleanValue extends Value {
private boolean _data;
// …
}

// …

public class Val implements Exp {
private Code _value;
public Val(final Value value) {
_value = <| value |>; // straight-forward CSP
}
// …
}
[/cc]

Please note that a class used in CSP still needs to be serializable if the code object it is used in is to be saved using [cci lang=”java”]MintSerializer.save[/cci]. That means that whenever you implement [cci lang=”java”]CodeFree[/cci], you should consider also implementing the [cci lang=”java”]java.io.Serializable[/cci] interface.

The second change involves the way checked exceptions are thrown inside a code object. In the past, checked exceptions were not allowed, because the [cci lang=”java”]Code.run()[/cci] method did not have a [cci lang=”java”]throws Throwable[/cci] clause.

We still didn’t add such a clause, because it would essentially require a try-catch construct around every call to [cci lang=”java”]Code.run()[/cci]. Instead, checked exceptions are caught and rethrown wrapped in a [cci lang=”java”]edu.rice.cs.mint.runtime.CheckedExceptionInCode[/cci] unchecked exception. Here is an example:

[cc lang=”java”]public static separable void m() throws IOException {
new File(“/this/is/a/bad/path”).createNewFile(); // throws IOException
}

// …

SafeCode c = <| { m(); } |>;
try {
c.run();
}
catch(CheckedExceptionInCode ce) {
Throwable cause = ce.getCause();
// …
}[/cc]

We also improved error checking for calls to separable methods and fixed a bug that required [cci lang=”java”]SafeCode[/cci] in too many places.

The version of DrJava with Mint is based on the current trunk (and therefore is newer than the updated stable release of DrJava that was recently made available).

(Re-posted from The Java Mint Blog.)

Share
Posted in Mint | Leave a comment

Print This Post Print This Post  

Presentations: Agile and Efficient Domain-Specific Languages using Multi-stage Programming in Java Mint (Practice Talk 2)

Agile and Efficient Domain-Specific Languages using Multi-stage
Programming in Java Mint

(PowerPoint, PDF, view embedded)

Mathias Ricken, Edwin Westbrook and Walid Taha

Where: Rice University Computer Science Department, Habanero Research Group Meeting
When: September 24, 2010

Domain-specific languages (DSLs) are a powerful productivity tool
because they allow domain experts, who are not necessarily programming
experts, to quickly develop programs. DSL implementations have unique
constraints for programming languages because they must be efficient,
in order to ensure high productivity, but they must also be agile, in
order to meet the rapidly changing demands of their domains. In this
tutorial we show how multi-stage programming (MSP) can be used to
build staged interpreters, which combine the agility of interpreters
with the efficiency of compilers. The tutorial is conducted in Java
Mint, an multi-stage Java based on recent work incorporating MSP into
imperative object-oriented languages. In the first half of the
tutorial, we introduce MSP by demonstrating how to write a staged
interpreter for a number of basic language constructs, such as
recursive functions, conditionals, and let expressions. In the second
half, we extend our staged interpreter to take advantage of several
well-known compiler optimizations, including type inference, constant
folding, and static parallel loop scheduling. We highlight the
opportunities afforded by using MSP with object-oriented design to
quickly create efficient DSL implementations.

It is an early practice talk for a tutorial to be held at GPCE’10.

Share
Posted in Publications | Leave a comment

Print This Post Print This Post  

Presentations: Agile and Efficient Domain-Specific Languages using Multi-stage Programming in Java Mint (Practice Talk)

Agile and Efficient Domain-Specific Languages using Multi-stage
Programming in Java Mint

(PowerPoint, PDF, view embedded)

Video recording available on vimeo.

Mathias Ricken, Edwin Westbrook and Walid Taha

Where: Rice University Computer Science Department, COMP 600 Graduate Seminar
When: September 20, 2010

Domain-specific languages (DSLs) are a powerful productivity tool
because they allow domain experts, who are not necessarily programming
experts, to quickly develop programs. DSL implementations have unique
constraints for programming languages because they must be efficient,
in order to ensure high productivity, but they must also be agile, in
order to meet the rapidly changing demands of their domains. In this
tutorial we show how multi-stage programming (MSP) can be used to
build staged interpreters, which combine the agility of interpreters
with the efficiency of compilers. The tutorial is conducted in Java
Mint, an multi-stage Java based on recent work incorporating MSP into
imperative object-oriented languages. In the first half of the
tutorial, we introduce MSP by demonstrating how to write a staged
interpreter for a number of basic language constructs, such as
recursive functions, conditionals, and let expressions. In the second
half, we extend our staged interpreter to take advantage of several
well-known compiler optimizations, including type inference, constant
folding, and static parallel loop scheduling. We highlight the
opportunities afforded by using MSP with object-oriented design to
quickly create efficient DSL implementations.

It is an early practice talk for a tutorial to be held at GPCE’10.

Share
Posted in Publications | Leave a comment

Print This Post Print This Post  

Rear-Ended

A friend and I got rear-ended tonight. Not our fault, but our backs and necks hurt, and the car is probably totaled.

I think the moral of the story is: You could be killed any time, so if someone offers you ice cream, you should accept the offer.

Update

Damn subhumans driving without insurance should be shot like the dangerous stray animals that they are.

Share
Posted in Uncategorized | Leave a comment

Print This Post Print This Post  

Silent Hudson Failure

Our Hudson server failed, because it couldn’t connect to the web server. However, I didn’t find out about it just now, because it also failed to connect to the SMTP server to tell me about it.

It’s really not a major issue. There seems to have been an NFS problem in the department network; I ran into it on my work desktop on Friday and rebooted. I suspect it’s the same issue here, and rebooting the Hudson server will probably solve the problem.

I didn’t find out about it, though, because there’s some kind of SSL certificate problem that prevented Hudson from accessing the SMTP server using SSL. This is a bit more serious. I tried to figure out how to add the certificate to the JRE key store, but gave up when i received the nice informative output

keytool error: java.lang.NullPointerException

I just ended up disabling SSL for SMTP. I’m surprised that it still works, but it does.

Share
Posted in Ramblings | Leave a comment

Print This Post Print This Post  

Problem in DrJava Applet Viewer

I just read the following thumbs-down review for DrJava on the SourceForge website:

There is a severe defect. The HelloWorld Java applet (http://download.oracle.com/javase/tutorial/deployment/applet/getStarted.html) crashes in the Applet Viewer invoked by DrJava. Still it runs smootly both in IE8 and FireFox. It also runs OK in the Applet Viewer started separately, without DrJava.

There really is a problem. The HelloWorld applet throws an exception.

[cc]Welcome to DrJava. Working directory is D:\Documents\Dev\Java
> run HelloWorld
Exception in thread “AWT-EventQueue-0″ java.lang.Error: Cannot call invokeAndWait from the event dispatcher thread
at java.awt.EventQueue.invokeAndWait(Unknown Source)
at javax.swing.SwingUtilities.invokeAndWait(Unknown Source)
at HelloWorld.init(HelloWorld.java:10)[/cc]

The problem is that we already execute the [cc_java inline=”true”]Applet.init()[/cc_java] method in the event thread, and calling [cc_java inline=”true”]invokeAndWait[/cc_java] in the event thread would cause a deadlock.

[cc_java]import javax.swing.JApplet;
import javax.swing.SwingUtilities;
import javax.swing.JLabel;

public class HelloWorld extends JApplet {
//Called when this applet is loaded into the browser.
public void init() {
//Execute a job on the event-dispatching thread; creating this applet’s GUI.
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
JLabel lbl = new JLabel(“Hello World”);
add(lbl);
}
});
} catch (Exception e) {
System.err.println(“createGUI didn’t complete successfully”);
}
}
}[/cc_java]

Arguably, this applet is implemented in a strange way. [cc_java inline=”true”]invokeAndWait[/cc_java] should run the code immediately if it is already running in the event thread. I’ll see what I can do to fix this.

I would have preferred it if the reviewer had just filed a bug report and given us the opportunity to fix this first.

Share
Posted in DrJava, Ramblings | Leave a comment

Print This Post Print This Post  

New Mint Release: r15772

We have just made a new release of Mint and DrJava with Mint: September 16, 2010 (r15772). The latest release is, as always, available from the Mint implementation page:

We have added the [cci lang=”java”]edu.rice.cs.mint.runtime.MintSerializer[/cci] class to it that can write code object, including CSP data, to a jar file (or whatever stream you like), and then restore it again. Here is a very simple example:

[cc lang=”java”]Code c = <|123|>;
File f = new File(dir, “IntegerCode1.jar”);
MintSerializer.save(c, “IntegerCode1”, f);

Integer s = MintSerializer.load(f);
System.out.println(s);[/cc]

The version of DrJava with Mint is based on the current trunk (and not on updated stable release of DrJava that was made available this week).

(Re-posted from The Java Mint Blog.)

Share
Posted in Mint | Leave a comment

Print This Post Print This Post