This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes IDEs, Version Control and other tools and the fly likes DSL vs standard programming language 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 "DSL vs standard programming language" Watch "DSL vs standard programming language" New topic
Author

DSL vs standard programming language

Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
I've heard several speakers at No Fluff Just Stuff conferences recommend creating a DSL to simplify developing applications, and it sounds interesting to me, but I wonder about the practical aspects of it. When does it make sense to create and use a DSL instead of straight java? When new people join the project, they'll probably need to know java as well as learn the DSL -- won't they?

Thanks for your insight into this matter,
Burk


SCJP, SCJD, SCEA 5 "Any sufficiently analyzed magic is indistinguishable from science!" Agatha Heterodyne (Girl Genius)
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
The most common way of using DSLs in software projects according to my experience is to write most of the code in a general-purpose language like Java and implement one or more little corners using one or more DSLs. In short, it's not an either-or. You typically use both and often more than just one DSL.

And, again, your configuration files can be considered DSLs in their own right...


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
Lasse Koskela wrote:The most common way of using DSLs in software projects according to my experience is to write most of the code in a general-purpose language like Java and implement one or more little corners using one or more DSLs. In short, it's not an either-or. You typically use both and often more than just one DSL.


Lasse,
My concern is that while a DSL should make it easier to write the code for that project, it means that in addition to learning their way around the project, new team members will also have to learn the DSL - which increases the time before they'll be affective. And if there's more than one DSL they don't already know then that time increases again. So it's a trade-off and I'm trying to get a feel for how to decide when it makes sense to build and use a DSL and when it doesn't.

Burk
Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

I always take what the speakers say with a pinch of salt. They always have something new to say! I agree with you Burk to some extent.

I have seen languages customized so much that they developers are so specialized they cannot get jobs further!


===Vyas Sanzgiri===
My Blog
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Hi Burk,

Burk Hufnagel wrote:My concern is that while a DSL should make it easier to write the code for that project, it means that in addition to learning their way around the project, new team members will also have to learn the DSL - which increases the time before they'll be affective. And if there's more than one DSL they don't already know then that time increases again. So it's a trade-off and I'm trying to get a feel for how to decide when it makes sense to build and use a DSL and when it doesn't.


Note that it's only the syntax that makes a difference - those new team members will need to learn the same logic by reading Java code any way - and the DSL (assuming it's a good fit/made well) should make grasping the logic easier. So yeah, it's a trade-off between learning the syntax/vocabulary of a DSL and the productivity boost provided by that DSL.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Vyas Sanzgiri wrote:I have seen languages customized so much that they developers are so specialized they cannot get jobs further!

Note that DSLs aren't even supposed to be reusable or standardized. At least not as a primary concern. DSLs are supposed to improve productivity.

By the way, if a developer sticks to working with one language for so long and in such a way that he can't get a job elsewhere, is that the language's fault or the developer's?
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
Lasse Koskela wrote:Hi Burk,
Note that it's only the syntax that makes a difference - those new team members will need to learn the same logic by reading Java code any way - and the DSL (assuming it's a good fit/made well) should make grasping the logic easier. So yeah, it's a trade-off between learning the syntax/vocabulary of a DSL and the productivity boost provided by that DSL.


I would hope a DSL offers more than just a syntactic difference, otherwise why bother with it at all. My understanding is that using a DSL lets you think in terms of the domain instead of trying to convert domain idioms into a general purpose language.

Burk
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
Lasse Koskela wrote:Note that DSLs aren't even supposed to be reusable or standardized. At least not as a primary concern. DSLs are supposed to improve productivity.


I agree with your sentiments, though you should be able to reuse the DSL for other projects in the same domain. And I think that if you understand the domain, the language should be comprehensible otherwise there's something wrong with its design.

Burk
Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

Lasse Koskela wrote:
Note that DSLs aren't even supposed to be reusable or standardized. At least not as a primary concern. DSLs are supposed to improve productivity.

By the way, if a developer sticks to working with one language for so long and in such a way that he can't get a job elsewhere, is that the language's fault or the developer's?


I agree to everything you are saying. But that is a big concern. Why would I invent something that will make me redundant?
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
Vyas Sanzgiri wrote:I agree to everything you are saying. But that is a big concern. Why would I invent something that will make me redundant?


So you can go do something else? <grin>

Seriously, I don't see creating DSLs as making you redundant - I see it as making you more efficient because you spend less time to get the same amount of work done. In this economy, that talent is valuable to an organization - which makes you more valuable to the organization.

Burk
Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

dhaval yoganandi
Ranch Hand

Joined: Jun 06, 2009
Posts: 35

I am agree with Vyas Sanzgiri. I am working on DSL since one and a half year. And now I forget some of my java concepts and even syntax and everything. Now I'm afraid of surviving in the market. But after all I can see its a developer's fault. He/she should not stick with DSL for long time. But, still to DSL its..


a.k.a stalker.
Burk Hufnagel
Ranch Hand

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

That's a trap we as developers can fall in to, but it's not fair to blame the DSL. I've worked for several companies that had their own proprietary language, and the trick I've found is to either be on projects that don't use it or to keep involved in a community (user group) that's focused on a general purpose language like C or Java.

Burk
dhaval yoganandi
Ranch Hand

Joined: Jun 06, 2009
Posts: 35

Burk Hufnagel wrote:Dhavai,

That's a trap we as developers can fall in to, but it's not fair to blame the DSL. I've worked for several companies that had their own proprietary language, and the trick I've found is to either be on projects that don't use it or to keep involved in a community (user group) that's focused on a general purpose language like C or Java.

Burk


Yes correct.. I am not blaming DSL as it is a good thing from company perspective. And yeah.. its good suggestions to involved in community of general purpose programming language. Thanks for the suggestion Burk..

-Dhaval.
Burk Hufnagel
Ranch Hand

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

Sorry about misspelling your name (I went back and edited the post to correct it) I guess I wasn't quite awake when I first replied.

I think DSLs and proprietary languages can be a good thing for a company, but at the same time they definitely have a cost. Other than previous employees, you won;t find people who already know the language you're using so you have to spend the time and money to train each new developer. In addition, some excellent developers won't be interested in the job because the knowledge and skill they gain with the proprietary language is mostly useless to other potential employers. Another concern is that after training your new hire, it may be that they aren't very good with the new language because the programming model just doesn't fit with how they think - though you can probably screen those folks out during the hiring process.

All in all I see it as another trade-off.

Burk
dhaval yoganandi
Ranch Hand

Joined: Jun 06, 2009
Posts: 35

Burk Hufnagel wrote:Dhaval,

Sorry about misspelling your name (I went back and edited the post to correct it) I guess I wasn't quite awake when I first replied.

I think DSLs and proprietary languages can be a good thing for a company, but at the same time they definitely have a cost. Other than previous employees, you won;t find people who already know the language you're using so you have to spend the time and money to train each new developer. In addition, some excellent developers won't be interested in the job because the knowledge and skill they gain with the proprietary language is mostly useless to other potential employers. Another concern is that after training your new hire, it may be that they aren't very good with the new language because the programming model just doesn't fit with how they think - though you can probably screen those folks out during the hiring process.

All in all I see it as another trade-off.

Burk


No problem about the misspelling of my name.

Absolutely right.. these all are the problems with DSL. And yeah.. if new hired employee leave the job after training, it will be very difficult to get another employee and train him/her. And its totally waste of time and money for company. Then the question is why they prefer DSL ?
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
dhaval yoganandi wrote:Then the question is why they prefer DSL ?


I think it's a language choice - the DSL lets you express what you're application is trying to do very clearly. As an example, some people don;t like Jave because you have to deal with checked exceptions, so instead of just writing the code to deal with a problem, you have to surround it with try/catch/finally blocks which clutter up the screen and can hide what the code is actually doing.

With a DSL your code can look more like high level instructions (validate credit card) instead of a series of instructions that implement the algorithm that validates the credit card. Does that make sense?

Burk
dhaval yoganandi
Ranch Hand

Joined: Jun 06, 2009
Posts: 35

Burk Hufnagel wrote:
dhaval yoganandi wrote:Then the question is why they prefer DSL ?


Does that make sense?

Burk


Yes it does. But, what about the new features and flexibilities we can get in GPLs? And I think it is very difficult to add new feature,flexibility and performance tuning in DSL architecture, unless and until it is well defined.

GPL = General Purpose Language

- Dhaval.
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
dhaval yoganandi wrote:But, what about the new features and flexibilities we can get in GPLs? And I think it is very difficult to add new feature,flexibility and performance tuning in DSL architecture, unless and until it is well defined.

GPL = General Purpose Language

- Dhaval.


New features in a GPL are great - if you have a use for them. I suspect that you don't need to update DSLs as much because the domain isn't changing that quickly. Remember, a DSL is specific to a particular domain and unless it undergoes an extreme change there probably isn't a need to change the DSL. You might change the underlying implementation to take advantage of some new feature in the GPL it's implemented in, but that shouldn't affect the DSL itself.

Burk
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DSL vs standard programming language
 
Similar Threads
Rude HCL HR
Java and DSL
Generic vs. DSL
Building an Internal DSL?
Need help in using apache camel routing