wood burning stoves 2.0*
The moose likes IDEs, Version Control and other tools and the fly likes Java and DSL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Java and DSL" Watch "Java and DSL" New topic
Author

Java and DSL

Stephane Clinckart
Ranch Hand

Joined: Oct 21, 2003
Posts: 89
Is Java well designed to support DSL ???
C# looks better designed for that.
Will the next version of Java reduce the gap?

Thanks a lot,

Stephane Clinckart
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
If you mean whether it's easy to create DSLs within your code base using the language syntax itself - i.e. to define an API - I suppose it's not that different between Java and C#. Did you have a particular language feature in mind that would give C# an advantage in this regard?


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Closures.

IMO Java is pretty internal-DSL-resistant due to relatively heavy syntax and lack of closures. Static imports help for cleanliness (think Mockito from a developer-centric DSL standpoint), blocks/closures would help quite a bit, IMO.
Stephane Clinckart
Ranch Hand

Joined: Oct 21, 2003
Posts: 89
Lasse Koskela wrote:If you mean whether it's easy to create DSLs within your code base using the language syntax itself - i.e. to define an API - I suppose it's not that different between Java and C#. Did you have a particular language feature in mind that would give C# an advantage in this regard?


I effectivly points some differences in the language itself:

- There is no lambda expression
- There is no Dynamic type like in C#4

I'm not a real expert with DSL...
--> but I think I know enough about to be sure it will be much more complex in Java to define DSL API than with C#4 due only to theses 2 differences.

The evolution of the Java language is much more slower than C# in the last 3/5 years.

I hope this gap will be reduce with Java 8... but Microsoft will not stop to evoluate also...

Another remarkable gap is Microsoft LINQ... The Java language is not yet enough evoluated to be ready to offer the sames functionnalities.
Of course... some frameworks will achieve to do almost the same... but with wich effort ???
May be Oracle will now accelerate the evolution of the Java language.

Wait & see...

Kind regards,

Stephane Clinckart

Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

Completely agree with you Stephane. But I doubt with the community behind it that Java will evolve any faster. Take a look at some lingering bugs and issues that haven't been fixed for ages !


===Vyas Sanzgiri===
My Blog
Stephane Clinckart
Ranch Hand

Joined: Oct 21, 2003
Posts: 89
Vyas Sanzgiri wrote:Completely agree with you Stephane. But I doubt with the community behind it that Java will evolve any faster. Take a look at some lingering bugs and issues that haven't been fixed for ages !


So... for a middle/long term Java is dead.

But I think the JVM will survive...

Now which new language will massivly be adopted by the communauty and be better than C#4 ???

Actually, I'm lost and can't predict it.

Do you agree ? Do you have some prediction?

Kind regards,

Stephane Clinckart
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
As I understand it Java 7 will have closures, and if you can't wait then I recommend taking a look at Groovy. It's basically Java syntax but it supports closures, and supports meta-programming so you get much of the dynamic goodness of Python or Ruby - and it compiles down to Java byte-code.

Burk


SCJP, SCJD, SCEA 5 "Any sufficiently analyzed magic is indistinguishable from science!" Agatha Heterodyne (Girl Genius)
Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

Java 7 will not have closures :http://tech.puredanger.com/java7/ I agree this is not an official source.
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
Vyas Sanzgiri wrote:Java 7 will not have closures :http://tech.puredanger.com/java7/ I agree this is not an official source.


I wasn't there, but evidently Mark Reinhold (a Principal Engineer at Sun) made the announcement that Java 7 would support closures at the Devoxx conference last November. and that sounds pretty official to me. DZone has a report on it here http://java.dzone.com/news/closures-coming-java-7 and the Java Posse mentioned the announcement in at least one of their podcasts late last year.

Burk
Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

Mark had said earlier in the year that closures would not be in Java 7. So they are not consistent. So my guess is wait and watch!

I am not convinced until I see Java 7 out in the open :-)
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
Vyas Sanzgiri wrote:Mark had said earlier in the year that closures would not be in Java 7. So they are not consistent. So my guess is wait and watch!

I am not convinced until I see Java 7 out in the open :-)


Well nothings for sure until it's delivered, but if Sun decided to announce something at one of the biggest Java conferences around (3200 attendees from 35 European countries and beyond) I expect they'd be pretty sure about it.
Burk
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

AFAICT closures will make it in in the new form; I sure hope so.
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
I think we kind of got off track on this. The original question was whether Java was "well designed" to support DSLs. I don;t believe it was specifically designed to support creating DSLs, but I believe that many of the same things that make it a great general purpose language contribute to making it easier to implement DSLs. So I say, "Yes."

Burk
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I say "no", because as a GPL it lacks many of the constructs necessary for clean DSL implementation, and has an impoverished model of abstraction.
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
David Newton wrote:I say "no", because as a GPL it lacks many of the constructs necessary for clean DSL implementation, and has an impoverished model of abstraction.

David,
Can you be more specific? What kind of constructs are you talking about? For the moment, in one of the other threads someone (I think Terrence) mentioned a DSL implemented in machine language (assembler) - if that's true then it seems reasonable that you can build whatever constructs you need in Java.

As for the "impoverished model of abstraction", that sounds pretty bad - but what do you mean by it?

Burk
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Closures are the biggest thing missing. The pomp and circumstance of Java also make things rather ugly when compared to other languages that allow a more natural internal DSL.

Java's shortcomings are well-documented; rather than continue this thread's spiral into forum-inappropriate chatter I'll just direct you to the web :)
nehaa arora
Greenhorn

Joined: Oct 27, 2009
Posts: 14
David Newton wrote:Closures are the biggest thing missing. The pomp and circumstance of Java also make things rather ugly when compared to other languages that allow a more natural internal DSL.

Java's shortcomings are well-documented; rather than continue this thread's spiral into forum-inappropriate chatter I'll just direct you to the web :)



Dunno if I am adding to the 'chatter' here..but i guess it would be real helpful to enlist imperative language features amenable to DSL development, as 'closures' were mentioned here. Does it then make more sense to pick a programming language suited for DSL work than build up sophisticated language frameworks in java .

thanks,
Neha
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
David Newton wrote:Closures are the biggest thing missing. The pomp and circumstance of Java also make things rather ugly when compared to other languages that allow a more natural internal DSL.

Java's shortcomings are well-documented; rather than continue this thread's spiral into forum-inappropriate chatter I'll just direct you to the web :)


At the risk of spiraling, the web;s a big place with lots of noise from people who don't know what they're talking about. Can you direct me to a place you think makes valid points?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Too many to try listing, but searching for "java +impoverished model of abstraction" returned this:

http://www.brainbell.com/tutorials/java/Basic_Java_Limitations.htm

There are an essentially unlimited number of others that go into similar detail. To be honest, I don't really think about it anymore--coming from a Lisp, Smalltalk, and Forth background, Java is like a prison with a really awesome wood/machine-shop: the tools might be awesome, but you're still in jail. If you were born in that jail, seeing how life might be different is difficult to explain--which is why I generally don't try to explain things like Lisp macros to people; until you've experienced what they bring to the table it can be a pretty tough sell.
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
David,

I came from a C/C++ background (with a little Delphi thrown in) so for me Java is a step up.

Burk
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java and DSL
 
Similar Threads
DSL vs standard programming language
Domains for DSL
How Fast is Your Broadband Connection?
Building an Internal DSL?
Need help in using apache camel routing