[antlr-interest] Q: opinions on ikvm + antlr3 ?

Johannes Luber JALuber at gmx.de
Fri Feb 6 01:03:11 PST 2009


> I've been asking myself what I would do if I needed to target parsers for
> .NET *and* needed to stay current with the latest from TParr.  This is not
> a
> troll.  It's a serious issue for me.  I've Googled a fair bit of
> misinformation.  So I've concluded that I should just ask the people who
> know best, who logically are among you who frequent this list.  And I seem
> to recall seeing some discussion of this months ago, before I appreciated
> its significance.
> 
> I'm very impressed with the C# target and the recent work to port the
> antlr
> tool to Visual Studio.  It's really amazing.  It also seems like an
> enormous
> effort for these projects to keep up with TParr's prodigious pace.

So far keeping up hasn't been a real problem.

>  So I
> was
> wondering what my experience might be like if I stuck to the "reference"
> Java target and used IKVM.NET to re-target my parser's Java bytecode to
> the
> CLI.  I have every intention of trying this out, but first I thought of
> some
> obvious pros and cons:
> 
> Pro: meets requirement of staying up-to-the-minute with TParr
> Pro: meets requirement of targeting .net
> Pro: allows access to arbitrary .net via java stubs created from
> assemblies,
> pretty cool but not required
> Pro: gives me an excuse to use java for real after all these years  :)
> 
> Con: adds another step to the build-chain, i.e. dependence on the
> stability
> of javac; maybe academic, but listed for completeness
> Con: at the mercy of the quality of ikvmc -- debugging is ugly if tests
> pass
> in java but fail in .net
> Con: possibly slow runtime performance -- I have to believe that the C#
> target is able to do more optimization than the two-step Java --> Bytecode
> --> CIL process
> Con: hours lost cursing classpath  :)

Con: I haven't checked it, but I believe that IKVM won't create the .NETisms like properties instead getters and setters. If true, your parser backend will be schizophrenic regarding the approaches.
Con: .NET-only additions like #pragmas to silence warnings won't be inlcuded.
> 
> Some of the con's might be mitigated by runtime profiling in combination
> with decompiling the CIL, but any hand-tuning on the .NET side would be
> hard
> to maintain unless accepted by the upstream ikvm developers, which might
> not
> be practical anyway.
> 
> These observations may be naive.  I'm interested in what the experts here
> have to say about what I should be prepared to face if I go this route.
> 
> This is in no way a comment on the incredible work discussed regularly on
> this list.  My requirements might push me in a slightly different
> direction,
> is all.
> 
> And I have to believe that some of you have tried ikvm or are using it and
> already know a lot that I need to learn.

I've once tried to run org.ANTLR.Tool on IKVM but didn't get far. So I know only what the homepage and the blog (featured on go-mono.com/monologue) says. In general, I'd advise against using the IKVM solution, as the native solution does work and the main targets are current with the Java one when doing a release.

FYI: Another approach to use the Java code as baseline is using the tool "sharpen" from the db4o team. It takes Java source code and transform it into C# code, which uses properties, etc. Cons are that you have to add annotations to the Java code and you may have to move untranslatable code into extra classes, for which you have to provide manual replacements.

Furthermore, you can't simply provide .NET-specific optimizations without doing a potentially harmful change to Java target or having to maintain code manually, if you can't teach sharpen about this special case. Another problem would be if other targets would want to go the same route. Then the Java code is going to be cluttered even more - which wouldn't be practicable or requiring some kind of annotations-standard for sharpen-like tools.

Johannes
> 
> Thanks,
> C. Mundi

-- 
Jetzt 1 Monat kostenlos! GMX FreeDSL - Telefonanschluss + DSL 
für nur 17,95 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a


More information about the antlr-interest mailing list