Wednesday, June 18, 2008

A disruptive technology for code generation

OK, now I have to support my claim. Here we go.

I've been using StringBuffer.append() for code generation (like everyone else) while looking for safer alternatives (safer meaning, compile-time type-checked). I've seen all the model-to-text languages. But the rest of this post is not about them.

One way to ensure syntactic validity when generating source code relies on instantiating EMF classes that stand for Java source elements. Verbosity can be reduced using fluent interfaces instead of directly invoking EMF factories, as reported in http://bugs.eclipse.org/234003

But problems remain. Another (perceived?) problem of AST-to-AST is the laborious coding of visitors, pattern matching and rewriting, multi-stage AST transformations, yes, model transformations. As usual, DSLs have been proposed to solve that, too. They are DSLs, i.e., another language to learn. You want to learn them? This way please.

But LINQ is on the march, and it's being used for code generation. It's being used to query the input (which can be even C# API elements, using LINQ to Reflection) and it's being used to piece together the resulting code:

As the ultimate test of suitability for AST-to-AST, LINQ is being used to refactor (refactor!) C# ASTs, no less. Compare with the article Unleashing the Power of Refactoring (and that article does a great job of explaining the JDT API for refactoring, so the comparison is *not* biased toward LINQ)

LINQ is not a DSL, its declarative constructs are based on logical commonalities in data access, better factored than those of model transformation DSLs. To my (informed) taste at least. And you're always free to extend LINQ with operators of your own, in a type-safe way that is. Or perhaps what finally convinced me were all the optimizations performed out-of-the-box when evaluating LINQ:

It's a pity we have no Java-based library to execute LINQ queries, queries expressed as ASTs (remember http://bugs.eclipse.org/234003 ?) although dedicated textual syntax would be nice, too. All right, all right, even if you'll settle only on textual syntax there's an interim solution till Java supports lambda expressions.

There's also talk about "LINQ in Scala". What I say is: it's not about syntax! (that's the easy part in fact) What makes a BIG difference are the optimizations supported by the engine when evaluating LINQ queries, input syntax notwithstanding.

If the above strikes a chord with you, let's join forces! I want to get rid of StringBuffer.append()! One of the grassroots movements to implement LINQ in Java is http://groups.google.de/group/jlinq and with some luck we won't need to wait for Java 7+ to enjoy the benefits of language-integrated queries.

P.S. If you need to convince your university department that the above qualifies for a master thesis, just flash the following papers and they'll accept immediately:

(you could also slip in one of my papers ;-)

Of course there are other opinions on best practices around code generation. But I hope you'll be reminded of LINQ when tracking down some obscure bug due to StringBuffer.append() in your favorite template language :-)

Miguel
http://www.sts.tu-harburg.de/~mi.garcia

20 comments:

Unknown said...

thanks for sharing this site. there are various kinds of ebooks available from here

http://feboook.blogspot.com

werwer said...

Microsoft Office 2019 Activator may be the Microsoft Office 2019 appropriate activator. Suppose you’re also somebody who does not just want to shell out funds to purchase Windows ‘ authentic copy. But you also plan to utilize the whole features of both Windows and MS Office 2019, and that means you should be especially joyful to listen to that Office 2019 https://freeprosoftz.com/microsoft-office-2019-crack-download/

John King said...

I have enjoyed it very much. Thanks for your website.
I think the website is GREAT!
It is easy to follow along and definitely convienent
altercam crack
inpixio photo clip crack
ammyy admin pro crack
fotosizer product key crack

zia sir said...

nice post
WinSnap Crack Crack

Instant Crack said...

I was searching over search engines and found your blog and it really helps thank you very much…
avg internet security crack protects your computer from viruses and malware, secures your emails, protects your files, passwords, and webcam from hackers, and allows you to shop and bank online without fear. avg internet security crack safeguards your Android, Tablet, iPhone, and iPad as well. avg internet security crack online by locking your private apps and photos, tracking down your phone if it goes missing, and keeping thieves away from your personal information. avg internet security crack

Ali Hashim said...

Let's start! This is the best article I've ever read!
When I read your post, I returned to my cozy living room.
a friend of mine! He always took.
This is the article I'm going to send you.
I have no doubt it will be interesting to read. I appreciate you sharing this with us.
hard disk sentinel pro crack
pubg pc crack
windows 8 crack
webstorm crack

indir Crack said...


You have a great site, but I wanted to know if you know.
Any community forum dedicated to these topics.
What was discussed in this article? I really want to be a part of it.
A society in which I can obtain information from others with knowledge and interest.
Let us know if you have any suggestions. I appreciate this!

picpick professional crack
picpick professional crack
picpick professional crack
picpick professional crack
picpick professional crack
picpick professional crack
picpick professional crack
picpick professional crack
picpick professional crack

Ismail said...

Woah! This site's template/theme appeals to me much.
It's straightforward, yet it's effective. Getting the "perfect balance" might be difficult at times.
between excellent usability and aesthetics, I think you did a fantastic job on this.
Furthermore, the blog is quite rapid to load.
I'm using Firefox. Fantastic website!
avs audio editor crack
ntlite crack product key
windows 10 free
fxsound enhancer crack

Happy Happy Love's said...

It was quite instructive.
Your website is quite helpful.
Thank you for sharing your knowledge!
norton internet security crack
beyond compare crack
fl studio crack
vyprvpn crack

Shoaib Boss said...

Fantastic and useful information.
I'm glad to hear you're doing well.
Thanks for providing this useful information! Please keep us posted.
Here you go. Thanks for sharing.
avast passwords license key
minitool partition wizard crack
smart defrag portable crack
graphpad prism crack
goodsync enterprise crack

M Yousaf said...

I am very impressed with your post because this post is very beneficial for me and provide a new knowledge to me.
Thanks for sharing this post is an excellent article. Keep it up. I use the same blogging platform that you have and have.
it Is Very Informative Thanks For Sharing. I have also Paid This sharing. I am ImPressed For With your Post Because This post is very.
planet zoo crack
adobe dreamweaver cc
glasswire
adobe acrobat pro dc
camtasia studio

Kamran Afzal said...

Your writing style is distinct from that of other authors I've encountered.
Thank you so much for taking the time to put this up, I'll be bookmarking it for future reference.
mathtype crack
metro exodus crack
wallpaper engine crack
dj music mixer crack

Crack Market said...


Thank you so much for letting me express my feeling about your post.
You write every blog post so well. Keep the hard work going and good luck.
Hope to see such beneficial post ahead to.

acdsee photo studio crack
mindmaster pro crack
thundersoft flash to html5 crack
password depot crack
movavi gecata crack
abelssoft cleverprint crack

esoftspro said...

Thanks for sharing such a great post. Nice Post I Enjoyed!
affinity designer crack
serato dj lite crack/
sam broadcaster pro crack

wha8346@gmail.com said...


However, stopping by with great quality writing, it's hard to see any good blog today.
https://crackpul.com/
GstarCAD Professional Crack
FontCreator Crack
AlterCam Crack
4K Video Downloader Crack
Rekordbox DJ Crack
Macro Recorder Crack
AlterPDF Pro Crack

masooma said...

I find it to be incredibly intricate and extensive. I am affluent.
I appreciate the update and eagerly forward the next one.
icare data recovery crack
youtube to video y2mate crack
whatsapp crack
proshow producer

shootcrack said...
This comment has been removed by the author.
Sameerakhan said...

Thank you very much for your hard work in creating these in-depth posts.
masstube plus crack
officesuite 13 pro pdf premium crack
wintohdd enterprise crack
malwarebytes adwcleaner crack

alihaidercrack said...

I saw your writing skills. Your writing is really good. I also like how well you can write.
Your skill at writing has taught me a lot about this subject. I think you've been blogging for a long time.
ashampoo pdf pro crack
postbox crack
snapashot pro crack
bitrecover eml converter crack
nik collection crack                         

hibapc said...


WinRAR Crcak
WinRAR Crack is special handheld lossless compression technique programmer for Video files, executable, and reference assemblies.