Lambda the Ultimate

inactiveTopic Converting Common Lisp to Dylan
started 11/7/2003; 8:20:38 AM - last post 11/8/2003; 5:25:28 PM
Chris Rathman - Converting Common Lisp to Dylan  blueArrow
11/7/2003; 8:20:38 AM (reads: 7439, responses: 9)
Converting Common Lisp to Dylan
A translator recently posted by Peter Norvig:

This document is designed to help you convert code from Common Lisp to Dylan. The first part of the document lists problems to look out for; the second part documents a Common Lisp program called LTD (for Lisp To Dylan) that helps to automate the conversion.

[Historical note: I recently found this 8-year old code hidden in the attic. Some readers might find it useful as an example of (1) 40,000 lines of code in the Dylan language (almost), or (2) the powerful pretty-printing capabilities in Common Lisp. Not many people appreciate that you can produce nicely formatted output so easily -- here I produce Dylan code with nice indentation, to any specified column width, just by converting Lisp to a parse-tree syntax that is equivalent to Dylan, and then writing pretty-print directives for the parse-trees. All the rest is handled automatically.]

I have a soft spot for language translator tools, having written pascal-to-c and rpg-to-vb tools in the distant past. Unlike compilers, translators require that the resulting code be readable, maintainable and in the idiom of the target language - making it much more of a dark art (not to mention that you have to worry about library and OS calls). The downside to translation is that there's still a lot of hand crafting that has to be done when the tool generates the output.

Even though code makes for a description of solutions in a fairly objective language, the bottom line is that it makes for a poor repository of knowledge when that language becomes an endangered species. Language translation efforts seem to rarely succeed. I've had a few successes here and there, but an intense familiarity with both languages as well as the software is required.
Posted to general by Chris Rathman on 11/7/03; 8:34:26 AM

Ehud Lamm - Re: Converting Common Lisp to Dylan  blueArrow
11/7/2003; 2:25:25 PM (reads: 620, responses: 1)
Translating from one programming language to another, just as like natural language translation, requires a sense of style which is quite hard to mechanize.

Still, automatic conversion can reduce the translation effort, letting humans concentrate on idiomatic expression of various constructs. Alas, automatic tools usually produce code that is so awful, that the easiet way to tidy it up is simply to start from scratch...

Patrick Logan - Re: Converting Common Lisp to Dylan  blueArrow
11/7/2003; 7:46:47 PM (reads: 605, responses: 1)
I happen to be embarking on my first automated translation of a project from Java to C# tonight. I'll let you know how it goes. I wish it were CL and Dylan instead.

andrew cooke - Re: Converting Common Lisp to Dylan  blueArrow
11/8/2003; 8:27:33 AM (reads: 572, responses: 0)
Vaguely related - pretty printing can get quite far (at least with a C-like langauge) without full parsing. I had to pretty print some "CL" (the scripting language for IRAF - an old system for analysising astronomical data). CL is so old + crufty that the formal syntax is a nightmare (ie exists only as a mess of yacc code). However, by simply parsing comemnts, quotes and parntheses, I was able to do a pretty good job. The Python script is here (but not very interesting). I suspect it would produce useful results (once the comment syntax handling was modified) for C, Pascal, etc. Maybe even ML.

[edit: I think one reason this works, while the general problem is difficult, is that I'm tidying something that already has a lot of structure correct - statements start on new lines, for example]

Ehud Lamm - Re: Converting Common Lisp to Dylan  blueArrow
11/8/2003; 9:18:46 AM (reads: 575, responses: 0)
I happen to be embarking on my first automated translation of a project from Java to C# tonight. I'll let you know how it goes.

Great. I don't like Java..

Isaac Gouy - Re: Converting Common Lisp to Dylan  blueArrow
11/8/2003; 9:37:43 AM (reads: 537, responses: 1)
automated translation of a project from Java to C#
Worked fine on the small programs I tried.

Ehud: I don't like Java
Why?

(I can think of many reasons, curious about the specifics and the implied preference for C#)

Ehud Lamm - Re: Converting Common Lisp to Dylan  blueArrow
11/8/2003; 1:20:49 PM (reads: 545, responses: 0)
I don't have a "deep" explanation why I don't like Java. I find the syntax overpowering, the (original) lack of generics tragic, the feel of the language passe.

I don't think I can convince anyone about this, nor do I want to. This feeling is not the result of thorough analysis. It's just that looking at Java code never makes me smile in joy.

From what I now C# isn't much better, but from the little amount of code I've read I got the feeeling that from an aesthetic point of view, it's more appealing to me (and, thank god, they realized that generics are important quite early in the game).

Patrick Logan - Re: Converting Common Lisp to Dylan  blueArrow
11/8/2003; 2:17:04 PM (reads: 521, responses: 1)
Great. I don't like Java..

This system will be about the same in Java and C#.

In both cases, I will be accessing it via Scheme. The Java and C# code will just be libraries of functionality.

Patrick Logan - Re: Converting Common Lisp to Dylan  blueArrow
11/8/2003; 5:25:28 PM (reads: 513, responses: 0)
I'll let you know how it goes.

Not well. Two small library projects failed to convert with no more information than "failed to initiate the conversion process". Now do I dig through the documentation or just put the 4-8 hours into converting by hand (well, by Emacs)?

Why did I have to install VS.NET just to be able to download and install the conversion utility, BTW? (Rhetorical question.)

Ehud Lamm - Re: Converting Common Lisp to Dylan  blueArrow
11/9/2003; 12:25:37 AM (reads: 521, responses: 0)
Better and better...