- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Re: Scala as a DSL
Mon, 2010-02-08, 18:20
As well as Specs etc., and the SWT DSL on github.com/rodant IIRC.
-------------------------------------
Stefan Langer wrote:
I would say for comprehension, combinatory parsers, actor creation and
execution are good examples of DSLs written in Scala
2010/2/8 Razvan Cojocaru
>
> Anyone knows a good collection of examples of how Scala is good as a DSL?
> i.e. what are the kinds of things you can tweak into it? Is there a good
> pattern for scala-based DSL? I'm looking for declarative type of DSLs and
> chapter 18 from the scala bible is not quite satisfactory...
>
> Some are obvious with the currying thing and case classes with named
> arguments, what else?
>
> So:
> - currying: add statement at end of construct
> - case classes w/ named parameters: natural object creation/specification
> - operators: sometimes are natural, like +/-/+=...
> - lambdas: pass stuff around, andThen etc
>
>
>
>
> -----
> Razvan Cojocaru,
> Work: http://www.sigma-systems.com
> Me: http://feeds.razie.com/RazvanTech
> Playground: http://wiki.homecloud.ca
>
> --
> View this message in context:
> http://old.nabble.com/Scala-as-a-DSL-tp27501271p27501271.html
> Sent from the Scala - User mailing list archive at Nabble.com.
>
>
Mon, 2010-02-08, 21:07
#2
Re: Scala as a DSL
thanks - lots to go through :) i'll come back and ask about specifics later,
if there's something i'm having trouble with.
-----
Razvan Cojocaru,
Work: http://www.sigma-systems.com
Me, as a : http://feeds.razie.com/RazvanTech RSS Feed ,
http://twitter.com/razie Twitter .
Playground: http://wiki.homecloud.ca
Mon, 2010-02-08, 23:57
#3
Re: Scala as a DSL
Meaning usage of it?
-------------------------------------
Razvan Cojocaru wrote:
Do you have a nice sample of "combinatory parser" ?
Stefan Langer-4 wrote:
>
> I would say for comprehension, combinatory parsers, actor creation and
> execution are good examples of DSLs written in Scala
>
>
-----
Razvan Cojocaru,
Work: http://www.sigma-systems.com
Playground: http://wiki.homecloud.ca
Follow me: http://feeds.razie.com/RazvanTech RSS Feed ,
http://twitter.com/razie Twitter .
Tue, 2010-02-09, 00:07
#4
Re: Scala as a DSL
yes - sorry. I'm not sure exactly what this is... I skipped the course on
compilers and never had to write anything beyond simple BNF-driven yaccs...
Naftoli Gugenheim wrote:
>
> Meaning usage of it?
>
> -------------------------------------
> Razvan Cojocaru wrote:
>
>
> Do you have a nice sample of "combinatory parser" ?
>
>
> Stefan Langer-4 wrote:
>>
>> I would say for comprehension, combinatory parsers, actor creation and
>> execution are good examples of DSLs written in Scala
>>
>>
>
>
> -----
> Razvan Cojocaru,
> Work: http://www.sigma-systems.com
> Playground: http://wiki.homecloud.ca
> Follow me: http://feeds.razie.com/RazvanTech RSS Feed ,
> http://twitter.com/razie Twitter .
>
Tue, 2010-02-09, 00:17
#5
Re: Scala as a DSL
It's basically a syntax that lets you write something comparable to a BNF plus functions that handle various elements. I think the scala distribution contains some samples. Do you have any of the published Scala books? Also take a look at http://appbuilder.dev.java.net -- it uses parsers to parse expressions with a C/Java/Scala type of syntax (although there's work that needs to be done).
-------------------------------------
Razvan Cojocaru wrote:
yes - sorry. I'm not sure exactly what this is... I skipped the course on
compilers and never had to write anything beyond simple BNF-driven yaccs...
Naftoli Gugenheim wrote:
>
> Meaning usage of it?
>
> -------------------------------------
> Razvan Cojocaru wrote:
>
>
> Do you have a nice sample of "combinatory parser" ?
>
>
> Stefan Langer-4 wrote:
>>
>> I would say for comprehension, combinatory parsers, actor creation and
>> execution are good examples of DSLs written in Scala
>>
>>
>
>
> -----
> Razvan Cojocaru,
> Work: http://www.sigma-systems.com
> Playground: http://wiki.homecloud.ca
> Follow me: http://feeds.razie.com/RazvanTech RSS Feed ,
> http://twitter.com/razie Twitter .
>
Tue, 2010-02-09, 00:27
#6
Re: Scala as a DSL
OH YA...now I notice chapter 31...that's exactly why I skipped the compilers
course...
I just went through a mind-bending exercise to understand monads through
higher-order types and functions, got my arms twisted in the scalaz... if I
read this now, I will definitely require Prozac for a few months...or
whatever they prescribe these days...
thanks :))
Naftoli Gugenheim wrote:
>
> It's basically a syntax that lets you write something comparable to a BNF
> plus functions that handle various elements. I think the scala
> distribution contains some samples. Do you have any of the published Scala
> books? Also take a look at http://appbuilder.dev.java.net -- it uses
> parsers to parse expressions with a C/Java/Scala type of syntax (although
> there's work that needs to be done).
>
>
> -------------------------------------
> Razvan Cojocaru wrote:
>
>
> yes - sorry. I'm not sure exactly what this is... I skipped the course on
> compilers and never had to write anything beyond simple BNF-driven
> yaccs...
>
>
-----
Razvan Cojocaru,
Work: http://www.sigma-systems.com
Playground: http://wiki.homecloud.ca
Follow me: http://feeds.razie.com/RazvanTech RSS Feed ,
http://twitter.com/razie Twitter .
Tue, 2010-02-09, 10:17
#7
Re: Scala as a DSL
Actually I think combinatory parser library in scala (it's in the base library) is a lot easier to grasp then Monads, Functors and Applicatives and scalaz is definetly not something for a newb in Scala. It is a great piece of software and demonstrates extremely well what the type system is capable of but it is not something someone just starting out should look through.
Another good resource for something like setting up a DSL is to take a look at the way Arrays are done in Scala 2.8. You see all the type kungfu and it is part of the base library and once you understood it you are amazed how easy it is to use considering the complexity that is hidden inside the implementation.
- Stefan
2010/2/9 Razvan Cojocaru <razie@razie.com>
Another good resource for something like setting up a DSL is to take a look at the way Arrays are done in Scala 2.8. You see all the type kungfu and it is part of the base library and once you understood it you are amazed how easy it is to use considering the complexity that is hidden inside the implementation.
- Stefan
2010/2/9 Razvan Cojocaru <razie@razie.com>
OH YA...now I notice chapter 31...that's exactly why I skipped the compilers
course...
I just went through a mind-bending exercise to understand monads through
higher-order types and functions, got my arms twisted in the scalaz... if I
read this now, I will definitely require Prozac for a few months...or
whatever they prescribe these days...
thanks :))
Naftoli Gugenheim wrote:
>
> It's basically a syntax that lets you write something comparable to a BNF
> plus functions that handle various elements. I think the scala
> distribution contains some samples. Do you have any of the published Scala
> books? Also take a look at http://appbuilder.dev.java.net -- it uses
> parsers to parse expressions with a C/Java/Scala type of syntax (although
> there's work that needs to be done).
>
>
> -------------------------------------
> Razvan Cojocaru<razie@razie.com> wrote:
>
>
> yes - sorry. I'm not sure exactly what this is... I skipped the course on
> compilers and never had to write anything beyond simple BNF-driven
> yaccs...
>
>
-----
Razvan Cojocaru,
Work: http://www.sigma-systems.com
Playground: http://wiki.homecloud.ca
Follow me: http://feeds.razie.com/RazvanTech RSS Feed ,
http://twitter.com/razie Twitter .
--
View this message in context: http://old.nabble.com/Scala-as-a-DSL-tp27501271p27507916.html
Sent from the Scala - User mailing list archive at Nabble.com.
Tue, 2010-02-09, 10:37
#8
Re: Scala as a DSL
Razie,
this is a simple copy/paste of some code that
can easily be found by googing something like
"json parser scala"
to start with you can forget about what is behind the ^^
(it's functionality to transform the default abstract syntax
to one using standard collection)
the DSL almost literally follows the grammar
it contains grammar stuff like
"c" : parsing a character
~> : 'and' composition (forgetting about the lhs)
<~ : 'and' composition (forgetting about the lhs)
| : 'or' composition
...
and regular expression-like stuff like
repsep: repetition with a separator
...
On Tue, Feb 9, 2010 at 10:02 AM, Stefan Langer <mailtolanger@googlemail.com> wrote:
--
__~O
-\ <,
(*)/ (*)
reality goes far beyond imagination
class JSON extends JavaTokenParsers { def obj: Parser[Map[String, Any]] = "{"~> repsep(member, ",") <~"}" ^^ (Map() ++ _) def arr: Parser[List[Any]] = "["~> repsep(value, ",") <~"]" def member: Parser[(String, Any)] = stringLiteral~":"~value ^^ { case name~":"~value => (name, value) } def value: Parser[Any] = ( obj | arr | stringLiteral | floatingPointNumber ^^ (_.toInt) | "null" ^^ (x => null) | "true" ^^ (x => true) | "false" ^^ (x => false) ) }
On Tue, Feb 9, 2010 at 10:02 AM, Stefan Langer <mailtolanger@googlemail.com> wrote:
Actually I think combinatory parser library in scala (it's in the base library) is a lot easier to grasp then Monads, Functors and Applicatives and scalaz is definetly not something for a newb in Scala. It is a great piece of software and demonstrates extremely well what the type system is capable of but it is not something someone just starting out should look through.
Another good resource for something like setting up a DSL is to take a look at the way Arrays are done in Scala 2.8. You see all the type kungfu and it is part of the base library and once you understood it you are amazed how easy it is to use considering the complexity that is hidden inside the implementation.
- Stefan
2010/2/9 Razvan Cojocaru <razie@razie.com>
OH YA...now I notice chapter 31...that's exactly why I skipped the compilers
course...
I just went through a mind-bending exercise to understand monads through
higher-order types and functions, got my arms twisted in the scalaz... if I
read this now, I will definitely require Prozac for a few months...or
whatever they prescribe these days...
thanks :))
Naftoli Gugenheim wrote:
>
> It's basically a syntax that lets you write something comparable to a BNF
> plus functions that handle various elements. I think the scala
> distribution contains some samples. Do you have any of the published Scala
> books? Also take a look at http://appbuilder.dev.java.net -- it uses
> parsers to parse expressions with a C/Java/Scala type of syntax (although
> there's work that needs to be done).
>
>
> -------------------------------------
> Razvan Cojocaru<razie@razie.com> wrote:
>
>
> yes - sorry. I'm not sure exactly what this is... I skipped the course on
> compilers and never had to write anything beyond simple BNF-driven
> yaccs...
>
>
-----
Razvan Cojocaru,
Work: http://www.sigma-systems.com
Playground: http://wiki.homecloud.ca
Follow me: http://feeds.razie.com/RazvanTech RSS Feed ,
http://twitter.com/razie Twitter .
--
View this message in context: http://old.nabble.com/Scala-as-a-DSL-tp27501271p27507916.html
Sent from the Scala - User mailing list archive at Nabble.com.
--
__~O
-\ <,
(*)/ (*)
reality goes far beyond imagination
Tue, 2010-02-09, 10:37
#9
Re: Scala as a DSL
Another nice sort of DSL is scala.swing. If you are familiar with swing then take a look at this library especially Reaction, Reactions, Publisher, Subsrciber to see how scala wraps Swing to make it easier to use (= less boilerplate code).
-Stefan
-Stefan
Tue, 2010-02-09, 12:47
#10
RE: Scala as a DSL
I
second this. I've been using Scala Swing for a few weeks now, and it is a
really lovely piece of work. Examples are hard-ish to find on the net, but there
are good examples in the test code, including I think some Java Tutorial
examples written in Scala Swing.
It also allows you to easily delve into the real Swing classes to access
less common features. I think this is a good approach - directly support the
common 80% usage, make it possible (easy in this case) to do the other
20%.
I think my Swing code must be a good 2-3
times smaller (just an off-the-top-of-my-head figure) using this DSL than using
Swing directly from Scala, which I have also done.
The only thing I am really missing is an official GroupPanel
(GroupLayout). It's the only standard Swing layout I would use for things like
forms.
Kieron
From: Stefan Langer <mailtolanger@googlemail.com> [mailto:Stefan Langer <mailtolanger@googlemail.com>]
Sent: 09 February 2010 09:35
To: Luc Duponcheel <luc.duponcheel@gmail.com>
Cc: Razvan Cojocaru <razie@razie.com>; scala-user@listes.epfl.ch
Subject: Re: [scala-user] Scala as a DSL
Another nice sort of DSL is scala.swing. If you are familiar with swing then take a look at this library especially Reaction, Reactions, Publisher, Subsrciber to see how scala wraps Swing to make it easier to use (= less boilerplate code).
-Stefan
This message may contain confidential and privileged information and is intended solely for the use of the named addressee. Access, copying or re-use of the e-mail or any information contained therein by any other person is not authorised. If you are not the intended recipient please notify us immediately by returning the e-mail to the originator and then immediately delete this message. Although we attempt to sweep e-mail and attachments for viruses, we do not guarantee that either are virus-free and accept no liability for any damage sustained as a result of viruses.
Please refer to http://www.bnymellon.com/disclaimer/piml.html for certain disclosures.
From: Stefan Langer <mailtolanger@googlemail.com> [mailto:Stefan Langer <mailtolanger@googlemail.com>]
Sent: 09 February 2010 09:35
To: Luc Duponcheel <luc.duponcheel@gmail.com>
Cc: Razvan Cojocaru <razie@razie.com>; scala-user@listes.epfl.ch
Subject: Re: [scala-user] Scala as a DSL
Another nice sort of DSL is scala.swing. If you are familiar with swing then take a look at this library especially Reaction, Reactions, Publisher, Subsrciber to see how scala wraps Swing to make it easier to use (= less boilerplate code).
-Stefan
This message may contain confidential and privileged information and is intended solely for the use of the named addressee. Access, copying or re-use of the e-mail or any information contained therein by any other person is not authorised. If you are not the intended recipient please notify us immediately by returning the e-mail to the originator and then immediately delete this message. Although we attempt to sweep e-mail and attachments for viruses, we do not guarantee that either are virus-free and accept no liability for any damage sustained as a result of viruses.
Please refer to http://www.bnymellon.com/disclaimer/piml.html for certain disclosures.
Tue, 2010-02-09, 13:07
#11
Re: Scala as a DSL
Oh yes, scala swing really rocks!
I can understand that a few people are discouraged by the fact that it's, well, swing - and there's definitely a bit of negative reputation that it could stand to get rid of - but I've had nothing but fun working with the libraries and certainly not hit any nasty performance problems.
I think the only real pain point is with javax.swing.text, which has yet to be mapped to scala.swing. I've done some of this already, but it's a big undertaking as the package can't really be migrated piecemeal.
Who knows, maybe by the time I'm finished we'll have a wrapper for the JavaFX/Scenegraph stuff and it'll all become redundant :)
On 9 February 2010 11:31, <Kieron.Wilkinson@paretopartners.com> wrote:
--
Kevin Wright
mail/google talk: kev.lee.wright@googlemail.com
wave: kev.lee.wright@googlewave.com
skype: kev.lee.wright
twitter: @thecoda
I can understand that a few people are discouraged by the fact that it's, well, swing - and there's definitely a bit of negative reputation that it could stand to get rid of - but I've had nothing but fun working with the libraries and certainly not hit any nasty performance problems.
I think the only real pain point is with javax.swing.text, which has yet to be mapped to scala.swing. I've done some of this already, but it's a big undertaking as the package can't really be migrated piecemeal.
Who knows, maybe by the time I'm finished we'll have a wrapper for the JavaFX/Scenegraph stuff and it'll all become redundant :)
On 9 February 2010 11:31, <Kieron.Wilkinson@paretopartners.com> wrote:
I second this. I've been using Scala Swing for a few weeks now, and it is a really lovely piece of work. Examples are hard-ish to find on the net, but there are good examples in the test code, including I think some Java Tutorial examples written in Scala Swing. It also allows you to easily delve into the real Swing classes to access less common features. I think this is a good approach - directly support the common 80% usage, make it possible (easy in this case) to do the other 20%. I think my Swing code must be a good 2-3 times smaller (just an off-the-top-of-my-head figure) using this DSL than using Swing directly from Scala, which I have also done. The only thing I am really missing is an official GroupPanel (GroupLayout). It's the only standard Swing layout I would use for things like forms. Kieron
From: Stefan Langer <mailtolanger@googlemail.com> [mailto:Stefan Langer <mailtolanger@googlemail.com>]
Sent: 09 February 2010 09:35
To: Luc Duponcheel <luc.duponcheel@gmail.com>
Cc: Razvan Cojocaru <razie@razie.com>; scala-user@listes.epfl.ch
Subject: Re: [scala-user] Scala as a DSL
Another nice sort of DSL is scala.swing. If you are familiar with swing then take a look at this library especially Reaction, Reactions, Publisher, Subsrciber to see how scala wraps Swing to make it easier to use (= less boilerplate code).
-Stefan
This message may contain confidential and privileged information and is intended solely for the use of the named addressee. Access, copying or re-use of the e-mail or any information contained therein by any other person is not authorised. If you are not the intended recipient please notify us immediately by returning the e-mail to the originator and then immediately delete this message. Although we attempt to sweep e-mail and attachments for viruses, we do not guarantee that either are virus-free and accept no liability for any damage sustained as a result of viruses.
Please refer to http://www.bnymellon.com/disclaimer/piml.html for certain disclosures.
--
Kevin Wright
mail/google talk: kev.lee.wright@googlemail.com
wave: kev.lee.wright@googlewave.com
skype: kev.lee.wright
twitter: @thecoda
Tue, 2010-02-09, 15:17
#12
Re: Scala as a DSL
Interesting -- I wouldn't have classified it as a DSL though.
-------------------------------------
Stefan Langer wrote:
Another nice sort of DSL is scala.swing. If you are familiar with swing then
take a look at this library especially Reaction, Reactions, Publisher,
Subsrciber to see how scala wraps Swing to make it easier to use (= less
boilerplate code).
-Stefan
Tue, 2010-02-09, 15:27
#13
RE: Scala as a DSL
2.8 doesn't have a GroupPanel? I wrote one and submitted it.
-------------------------------------
Kieron.Wilkinson wrote:
I second this. I've been using Scala Swing for a few weeks now, and it
is a really lovely piece of work. Examples are hard-ish to find on the
net, but there are good examples in the test code, including I think
some Java Tutorial examples written in Scala Swing.
It also allows you to easily delve into the real Swing classes to access
less common features. I think this is a good approach - directly support
the common 80% usage, make it possible (easy in this case) to do the
other 20%.
I think my Swing code must be a good 2-3 times smaller (just an
off-the-top-of-my-head figure) using this DSL than using Swing directly
from Scala, which I have also done.
The only thing I am really missing is an official GroupPanel
(GroupLayout). It's the only standard Swing layout I would use for
things like forms.
Kieron
________________________________
From: Stefan Langer [mailto:Stefan Langer
]
Sent: 09 February 2010 09:35
To: Luc Duponcheel
Cc: Razvan Cojocaru ; scala-user@listes.epfl.ch
Subject: Re: [scala-user] Scala as a DSL
Another nice sort of DSL is scala.swing. If you are familiar with swing
then take a look at this library especially Reaction, Reactions,
Publisher, Subsrciber to see how scala wraps Swing to make it easier to
use (= less boilerplate code).
-Stefan
This message may contain confidential and privileged information and is intended solely for the use of the named addressee. Access, copying or re-use of the e-mail or any information contained therein by any other person is not authorised. If you are not the intended recipient please notify us immediately by returning the e-mail to the originator and then immediately delete this message. Although we attempt to sweep e-mail and attachments for viruses, we do not guarantee that either are virus-free and accept no liability for any damage sustained as a result of viruses.
Please refer to http://www.bnymellon.com/disclaimer/piml.html for certain disclosures.
Tue, 2010-02-09, 15:37
#14
Re: Scala as a DSL
If you manage to merge and hide all these platforms, swing, FX, SWT, GWT,
Canvas, whatnot - I think that would be cause enough for the start of a new
religion we might call something like "Finally makes sense, eh?"
Although I'm not a gui guy, I'd certainly offer to help somehow :)
Kevin Wright-4 wrote:
>
> Oh yes, scala swing really rocks!
>
> I can understand that a few people are discouraged by the fact that it's,
> well, swing - and there's definitely a bit of negative reputation that it
> could stand to get rid of - but I've had nothing but fun working with the
> libraries and certainly not hit any nasty performance problems.
>
> I think the only real pain point is with javax.swing.text, which has yet
> to
> be mapped to scala.swing. I've done some of this already, but it's a big
> undertaking as the package can't really be migrated piecemeal.
>
> Who knows, maybe by the time I'm finished we'll have a wrapper for the
> JavaFX/Scenegraph stuff and it'll all become redundant :)
>
>
> On 9 February 2010 11:31, wrote:
>
>> I second this. I've been using Scala Swing for a few weeks now, and it
>> is
>> a really lovely piece of work. Examples are hard-ish to find on the net,
>> but
>> there are good examples in the test code, including I think some Java
>> Tutorial examples written in Scala Swing.
>>
>> It also allows you to easily delve into the real Swing classes to access
>> less common features. I think this is a good approach - directly support
>> the
>> common 80% usage, make it possible (easy in this case) to do the other
>> 20%.
>>
>> I think my Swing code must be a good 2-3 times smaller (just an
>> off-the-top-of-my-head figure) using this DSL than using Swing directly
>> from
>> Scala, which I have also done.
>>
>> The only thing I am really missing is an official GroupPanel
>> (GroupLayout).
>> It's the only standard Swing layout I would use for things like forms.
>>
>> Kieron
>>
>> ------------------------------
>> *From:* Stefan Langer [mailto:Stefan Langer
>> ]
>> *Sent:* 09 February 2010 09:35
>> *To:* Luc Duponcheel
>> *Cc:* Razvan Cojocaru ; scala-user@listes.epfl.ch
>> *Subject:* Re: [scala-user] Scala as a DSL
>>
>> Another nice sort of DSL is scala.swing. If you are familiar with swing
>> then take a look at this library especially Reaction, Reactions,
>> Publisher,
>> Subsrciber to see how scala wraps Swing to make it easier to use (= less
>> boilerplate code).
>>
>> -Stefan
>>
>> This message may contain confidential and privileged information and is
>> intended solely for the use of the named addressee. Access, copying or
>> re-use of the e-mail or any information contained therein by any other
>> person is not authorised. If you are not the intended recipient please
>> notify us immediately by returning the e-mail to the originator and then
>> immediately delete this message. Although we attempt to sweep e-mail and
>> attachments for viruses, we do not guarantee that either are virus-free
>> and
>> accept no liability for any damage sustained as a result of viruses.
>>
>> Please refer to http://www.bnymellon.com/disclaimer/piml.html for certain
>> disclosures.
>>
>
>
>
Tue, 2010-02-09, 16:07
#15
Re: Scala as a DSL
On Tuesday February 9 2010, Luc Duponcheel wrote:
> Razie,
>
> this is a simple copy/paste of some code that
> can easily be found by googing something like
> "json parser scala"
>
> to start with you can forget about what is behind the ^^
> (it's functionality to transform the default abstract syntax
> to one using standard collection)
The code in the RHS of the ^^ operator would be analogized to
the "action code" of a parser generator such as JavaCC or ANTLR.
> the DSL almost literally follows the grammar
> it contains grammar stuff like
>
> "c" : parsing a character
> ~> : 'and' composition (forgetting about the lhs)
> <~ : 'and' composition (forgetting about the lhs)
> | : 'or' composition
The last of these appears to exhibit a copy-and-modify error. These are
more accurately described as:
"keyword" : match a literal string (*)
"RE-pat".r : match a regular expression
~ : juxtaposition
~> : juxtaposition (discarding the lhs)
<~ : juxtaposition (discarding the rhs)
| : alternatives (backtracking on failed
alternatives until one succeeds)
(*) Literals don't impose a word boundary. To get one, use the "\b" RE
operator.
> ...
Randall Schulz
Tue, 2010-02-09, 16:47
#16
Re: Scala as a DSL
If you want to help, you can start by writing up a detailed "feature comparison matrix" -- what A implements and if/how B implements it. :)
Then it's just a matter of a generalized API--that's all! :)
-------------------------------------
Razvan Cojocaru wrote:
If you manage to merge and hide all these platforms, swing, FX, SWT, GWT,
Canvas, whatnot - I think that would be cause enough for the start of a new
religion we might call something like "Finally makes sense, eh?"
Although I'm not a gui guy, I'd certainly offer to help somehow :)
Kevin Wright-4 wrote:
>
> Oh yes, scala swing really rocks!
>
> I can understand that a few people are discouraged by the fact that it's,
> well, swing - and there's definitely a bit of negative reputation that it
> could stand to get rid of - but I've had nothing but fun working with the
> libraries and certainly not hit any nasty performance problems.
>
> I think the only real pain point is with javax.swing.text, which has yet
> to
> be mapped to scala.swing. I've done some of this already, but it's a big
> undertaking as the package can't really be migrated piecemeal.
>
> Who knows, maybe by the time I'm finished we'll have a wrapper for the
> JavaFX/Scenegraph stuff and it'll all become redundant :)
>
>
> On 9 February 2010 11:31, wrote:
>
>> I second this. I've been using Scala Swing for a few weeks now, and it
>> is
>> a really lovely piece of work. Examples are hard-ish to find on the net,
>> but
>> there are good examples in the test code, including I think some Java
>> Tutorial examples written in Scala Swing.
>>
>> It also allows you to easily delve into the real Swing classes to access
>> less common features. I think this is a good approach - directly support
>> the
>> common 80% usage, make it possible (easy in this case) to do the other
>> 20%.
>>
>> I think my Swing code must be a good 2-3 times smaller (just an
>> off-the-top-of-my-head figure) using this DSL than using Swing directly
>> from
>> Scala, which I have also done.
>>
>> The only thing I am really missing is an official GroupPanel
>> (GroupLayout).
>> It's the only standard Swing layout I would use for things like forms.
>>
>> Kieron
>>
>> ------------------------------
>> *From:* Stefan Langer [mailto:Stefan Langer
>> ]
>> *Sent:* 09 February 2010 09:35
>> *To:* Luc Duponcheel
>> *Cc:* Razvan Cojocaru ; scala-user@listes.epfl.ch
>> *Subject:* Re: [scala-user] Scala as a DSL
>>
>> Another nice sort of DSL is scala.swing. If you are familiar with swing
>> then take a look at this library especially Reaction, Reactions,
>> Publisher,
>> Subsrciber to see how scala wraps Swing to make it easier to use (= less
>> boilerplate code).
>>
>> -Stefan
>>
>> This message may contain confidential and privileged information and is
>> intended solely for the use of the named addressee. Access, copying or
>> re-use of the e-mail or any information contained therein by any other
>> person is not authorised. If you are not the intended recipient please
>> notify us immediately by returning the e-mail to the originator and then
>> immediately delete this message. Although we attempt to sweep e-mail and
>> attachments for viruses, we do not guarantee that either are virus-free
>> and
>> accept no liability for any damage sustained as a result of viruses.
>>
>> Please refer to http://www.bnymellon.com/disclaimer/piml.html for certain
>> disclosures.
>>
>
>
>
Tue, 2010-02-09, 17:07
#17
Re: Scala as a DSL
This has been tried multiple times and up to now nobody has really come up with something that is usable across all types of applications.
Just take a look at SWT and SWING. The simple fact that both have a totally different mindset makes it hard to generalize across both in a consistent way without resorting to rebuilding major parts of the underlying structure.
So better not waste time on this but rather provide a consistent but distinct interface to both.
-Stefan
2010/2/9 Naftoli Gugenheim <naftoligug@gmail.com>
Just take a look at SWT and SWING. The simple fact that both have a totally different mindset makes it hard to generalize across both in a consistent way without resorting to rebuilding major parts of the underlying structure.
So better not waste time on this but rather provide a consistent but distinct interface to both.
-Stefan
2010/2/9 Naftoli Gugenheim <naftoligug@gmail.com>
If you want to help, you can start by writing up a detailed "feature comparison matrix" -- what A implements and if/how B implements it. :)
Then it's just a matter of a generalized API--that's all! :)
-------------------------------------
Razvan Cojocaru<razie@razie.com> wrote:
If you manage to merge and hide all these platforms, swing, FX, SWT, GWT,
Canvas, whatnot - I think that would be cause enough for the start of a new
religion we might call something like "Finally makes sense, eh?"
Although I'm not a gui guy, I'd certainly offer to help somehow :)
Kevin Wright-4 wrote:
>
> Oh yes, scala swing really rocks!
>
> I can understand that a few people are discouraged by the fact that it's,
> well, swing - and there's definitely a bit of negative reputation that it
> could stand to get rid of - but I've had nothing but fun working with the
> libraries and certainly not hit any nasty performance problems.
>
> I think the only real pain point is with javax.swing.text, which has yet
> to
> be mapped to scala.swing. I've done some of this already, but it's a big
> undertaking as the package can't really be migrated piecemeal.
>
> Who knows, maybe by the time I'm finished we'll have a wrapper for the
> JavaFX/Scenegraph stuff and it'll all become redundant :)
>
>
> On 9 February 2010 11:31, <Kieron.Wilkinson@paretopartners.com> wrote:
>
>> I second this. I've been using Scala Swing for a few weeks now, and it
>> is
>> a really lovely piece of work. Examples are hard-ish to find on the net,
>> but
>> there are good examples in the test code, including I think some Java
>> Tutorial examples written in Scala Swing.
>>
>> It also allows you to easily delve into the real Swing classes to access
>> less common features. I think this is a good approach - directly support
>> the
>> common 80% usage, make it possible (easy in this case) to do the other
>> 20%.
>>
>> I think my Swing code must be a good 2-3 times smaller (just an
>> off-the-top-of-my-head figure) using this DSL than using Swing directly
>> from
>> Scala, which I have also done.
>>
>> The only thing I am really missing is an official GroupPanel
>> (GroupLayout).
>> It's the only standard Swing layout I would use for things like forms.
>>
>> Kieron
>>
>> ------------------------------
>> *From:* Stefan Langer <mailtolanger@googlemail.com> [mailto:Stefan Langer
>> <mailtolanger@googlemail.com>]
>> *Sent:* 09 February 2010 09:35
>> *To:* Luc Duponcheel <luc.duponcheel@gmail.com>
>> *Cc:* Razvan Cojocaru <razie@razie.com>; scala-user@listes.epfl.ch
>> *Subject:* Re: [scala-user] Scala as a DSL
>>
>> Another nice sort of DSL is scala.swing. If you are familiar with swing
>> then take a look at this library especially Reaction, Reactions,
>> Publisher,
>> Subsrciber to see how scala wraps Swing to make it easier to use (= less
>> boilerplate code).
>>
>> -Stefan
>>
>> This message may contain confidential and privileged information and is
>> intended solely for the use of the named addressee. Access, copying or
>> re-use of the e-mail or any information contained therein by any other
>> person is not authorised. If you are not the intended recipient please
>> notify us immediately by returning the e-mail to the originator and then
>> immediately delete this message. Although we attempt to sweep e-mail and
>> attachments for viruses, we do not guarantee that either are virus-free
>> and
>> accept no liability for any damage sustained as a result of viruses.
>>
>> Please refer to http://www.bnymellon.com/disclaimer/piml.html for certain
>> disclosures.
>>
>
>
>
> --
> Kevin Wright
>
> mail/google talk: kev.lee.wright@googlemail.com
> wave: kev.lee.wright@googlewave.com
> skype: kev.lee.wright
> twitter: @thecoda
>
>
-----
Razvan Cojocaru,
Work: http://www.sigma-systems.com
Playground: http://wiki.homecloud.ca
Follow me: http://feeds.razie.com/RazvanTech RSS Feed ,
http://twitter.com/razie Twitter .
--
View this message in context: http://old.nabble.com/Scala-as-a-DSL-tp27501271p27515831.html
Sent from the Scala - User mailing list archive at Nabble.com.
Tue, 2010-02-09, 17:27
#18
Re: Scala as a DSL
Don't worry, I wasn't being too serious, nor was Razvan.
-------------------------------------
Stefan Langer wrote:
This has been tried multiple times and up to now nobody has really come up
with something that is usable across all types of applications.
Just take a look at SWT and SWING. The simple fact that both have a totally
different mindset makes it hard to generalize across both in a consistent
way without resorting to rebuilding major parts of the underlying structure.
So better not waste time on this but rather provide a consistent but
distinct interface to both.
-Stefan
2010/2/9 Naftoli Gugenheim
> If you want to help, you can start by writing up a detailed "feature
> comparison matrix" -- what A implements and if/how B implements it. :)
> Then it's just a matter of a generalized API--that's all! :)
>
>
> -------------------------------------
> Razvan Cojocaru wrote:
>
>
> If you manage to merge and hide all these platforms, swing, FX, SWT, GWT,
> Canvas, whatnot - I think that would be cause enough for the start of a new
> religion we might call something like "Finally makes sense, eh?"
>
> Although I'm not a gui guy, I'd certainly offer to help somehow :)
>
>
> Kevin Wright-4 wrote:
> >
> > Oh yes, scala swing really rocks!
> >
> > I can understand that a few people are discouraged by the fact that it's,
> > well, swing - and there's definitely a bit of negative reputation that it
> > could stand to get rid of - but I've had nothing but fun working with the
> > libraries and certainly not hit any nasty performance problems.
> >
> > I think the only real pain point is with javax.swing.text, which has yet
> > to
> > be mapped to scala.swing. I've done some of this already, but it's a big
> > undertaking as the package can't really be migrated piecemeal.
> >
> > Who knows, maybe by the time I'm finished we'll have a wrapper for the
> > JavaFX/Scenegraph stuff and it'll all become redundant :)
> >
> >
> > On 9 February 2010 11:31, wrote:
> >
> >> I second this. I've been using Scala Swing for a few weeks now, and it
> >> is
> >> a really lovely piece of work. Examples are hard-ish to find on the net,
> >> but
> >> there are good examples in the test code, including I think some Java
> >> Tutorial examples written in Scala Swing.
> >>
> >> It also allows you to easily delve into the real Swing classes to
> access
> >> less common features. I think this is a good approach - directly support
> >> the
> >> common 80% usage, make it possible (easy in this case) to do the other
> >> 20%.
> >>
> >> I think my Swing code must be a good 2-3 times smaller (just an
> >> off-the-top-of-my-head figure) using this DSL than using Swing directly
> >> from
> >> Scala, which I have also done.
> >>
> >> The only thing I am really missing is an official GroupPanel
> >> (GroupLayout).
> >> It's the only standard Swing layout I would use for things like forms.
> >>
> >> Kieron
> >>
> >> ------------------------------
> >> *From:* Stefan Langer [mailto:StefanLanger
> >> ]
> >> *Sent:* 09 February 2010 09:35
> >> *To:* Luc Duponcheel
> >> *Cc:* Razvan Cojocaru ; scala-user@listes.epfl.ch
> >> *Subject:* Re: [scala-user] Scala as a DSL
> >>
> >> Another nice sort of DSL is scala.swing. If you are familiar with swing
> >> then take a look at this library especially Reaction, Reactions,
> >> Publisher,
> >> Subsrciber to see how scala wraps Swing to make it easier to use (= less
> >> boilerplate code).
> >>
> >> -Stefan
> >>
> >> This message may contain confidential and privileged information and is
> >> intended solely for the use of the named addressee. Access, copying or
> >> re-use of the e-mail or any information contained therein by any other
> >> person is not authorised. If you are not the intended recipient please
> >> notify us immediately by returning the e-mail to the originator and then
> >> immediately delete this message. Although we attempt to sweep e-mail and
> >> attachments for viruses, we do not guarantee that either are virus-free
> >> and
> >> accept no liability for any damage sustained as a result of viruses.
> >>
> >> Please refer to http://www.bnymellon.com/disclaimer/piml.html for
> certain
> >> disclosures.
> >>
> >
> >
> >
> > --
> > Kevin Wright
> >
> > mail/google talk: kev.lee.wright@googlemail.com
> > wave: kev.lee.wright@googlewave.com
> > skype: kev.lee.wright
> > twitter: @thecoda
> >
> >
>
>
> -----
> Razvan Cojocaru,
> Work: http://www.sigma-systems.com
> Playground: http://wiki.homecloud.ca
> Follow me: http://feeds.razie.com/RazvanTech RSS Feed ,
> http://twitter.com/razie Twitter .
>
> --
> View this message in context:
> http://old.nabble.com/Scala-as-a-DSL-tp27501271p27515831.html
> Sent from the Scala - User mailing list archive at Nabble.com.
>
>
Tue, 2010-02-09, 18:17
#19
Re: Scala as a DSL
I think the ideal solution would be to decide on one, and wrap that; the problem is that - arguably - the best solution is scenegraph (upon which JavaFX is based) but this isn't yet complete.
Just search online for JavaFX and JTextPane to see what I mean
On 9 February 2010 16:07, Naftoli Gugenheim <naftoligug@gmail.com> wrote:
--
Kevin Wright
mail/google talk: kev.lee.wright@googlemail.com
wave: kev.lee.wright@googlewave.com
skype: kev.lee.wright
twitter: @thecoda
Just search online for JavaFX and JTextPane to see what I mean
On 9 February 2010 16:07, Naftoli Gugenheim <naftoligug@gmail.com> wrote:
Don't worry, I wasn't being too serious, nor was Razvan.
-------------------------------------
Stefan Langer<mailtolanger@googlemail.com> wrote:
This has been tried multiple times and up to now nobody has really come up
with something that is usable across all types of applications.
Just take a look at SWT and SWING. The simple fact that both have a totally
different mindset makes it hard to generalize across both in a consistent
way without resorting to rebuilding major parts of the underlying structure.
So better not waste time on this but rather provide a consistent but
distinct interface to both.
-Stefan
2010/2/9 Naftoli Gugenheim <naftoligug@gmail.com>
> If you want to help, you can start by writing up a detailed "feature
> comparison matrix" -- what A implements and if/how B implements it. :)
> Then it's just a matter of a generalized API--that's all! :)
>
>
> -------------------------------------
> Razvan Cojocaru<razie@razie.com> wrote:
>
>
> If you manage to merge and hide all these platforms, swing, FX, SWT, GWT,
> Canvas, whatnot - I think that would be cause enough for the start of a new
> religion we might call something like "Finally makes sense, eh?"
>
> Although I'm not a gui guy, I'd certainly offer to help somehow :)
>
>
> Kevin Wright-4 wrote:
> >
> > Oh yes, scala swing really rocks!
> >
> > I can understand that a few people are discouraged by the fact that it's,
> > well, swing - and there's definitely a bit of negative reputation that it
> > could stand to get rid of - but I've had nothing but fun working with the
> > libraries and certainly not hit any nasty performance problems.
> >
> > I think the only real pain point is with javax.swing.text, which has yet
> > to
> > be mapped to scala.swing. I've done some of this already, but it's a big
> > undertaking as the package can't really be migrated piecemeal.
> >
> > Who knows, maybe by the time I'm finished we'll have a wrapper for the
> > JavaFX/Scenegraph stuff and it'll all become redundant :)
> >
> >
> > On 9 February 2010 11:31, <Kieron.Wilkinson@paretopartners.com> wrote:
> >
> >> I second this. I've been using Scala Swing for a few weeks now, and it
> >> is
> >> a really lovely piece of work. Examples are hard-ish to find on the net,
> >> but
> >> there are good examples in the test code, including I think some Java
> >> Tutorial examples written in Scala Swing.
> >>
> >> It also allows you to easily delve into the real Swing classes to
> access
> >> less common features. I think this is a good approach - directly support
> >> the
> >> common 80% usage, make it possible (easy in this case) to do the other
> >> 20%.
> >>
> >> I think my Swing code must be a good 2-3 times smaller (just an
> >> off-the-top-of-my-head figure) using this DSL than using Swing directly
> >> from
> >> Scala, which I have also done.
> >>
> >> The only thing I am really missing is an official GroupPanel
> >> (GroupLayout).
> >> It's the only standard Swing layout I would use for things like forms.
> >>
> >> Kieron
> >>
> >> ------------------------------
> >> *From:* Stefan Langer <mailtolanger@googlemail.com> [mailto:StefanLanger
> >> <mailtolanger@googlemail.com>]
> >> *Sent:* 09 February 2010 09:35
> >> *To:* Luc Duponcheel <luc.duponcheel@gmail.com>
> >> *Cc:* Razvan Cojocaru <razie@razie.com>; scala-user@listes.epfl.ch
> >> *Subject:* Re: [scala-user] Scala as a DSL
> >>
> >> Another nice sort of DSL is scala.swing. If you are familiar with swing
> >> then take a look at this library especially Reaction, Reactions,
> >> Publisher,
> >> Subsrciber to see how scala wraps Swing to make it easier to use (= less
> >> boilerplate code).
> >>
> >> -Stefan
> >>
> >> This message may contain confidential and privileged information and is
> >> intended solely for the use of the named addressee. Access, copying or
> >> re-use of the e-mail or any information contained therein by any other
> >> person is not authorised. If you are not the intended recipient please
> >> notify us immediately by returning the e-mail to the originator and then
> >> immediately delete this message. Although we attempt to sweep e-mail and
> >> attachments for viruses, we do not guarantee that either are virus-free
> >> and
> >> accept no liability for any damage sustained as a result of viruses.
> >>
> >> Please refer to http://www.bnymellon.com/disclaimer/piml.html for
> certain
> >> disclosures.
> >>
> >
> >
> >
> > --
> > Kevin Wright
> >
> > mail/google talk: kev.lee.wright@googlemail.com
> > wave: kev.lee.wright@googlewave.com
> > skype: kev.lee.wright
> > twitter: @thecoda
> >
> >
>
>
> -----
> Razvan Cojocaru,
> Work: http://www.sigma-systems.com
> Playground: http://wiki.homecloud.ca
> Follow me: http://feeds.razie.com/RazvanTech RSS Feed ,
> http://twitter.com/razie Twitter .
>
> --
> View this message in context:
> http://old.nabble.com/Scala-as-a-DSL-tp27501271p27515831.html
> Sent from the Scala - User mailing list archive at Nabble.com.
>
>
--
Kevin Wright
mail/google talk: kev.lee.wright@googlemail.com
wave: kev.lee.wright@googlewave.com
skype: kev.lee.wright
twitter: @thecoda
Tue, 2010-02-09, 20:17
#20
Re: Scala as a DSL
I was more hopeful than serious :)
However, I think that people overreact and tend to think too big. 90% of all
applications out there don't use more than say 10-20 widgets - at least
could make do with that. We don't write an Eclipse every day but we pay
dearly because library developers think we should!
Think about Java itself - we put up with this language only because of the
support (libraries/api) and portability. Same here...i would be VERY glad to
have just 20 widgets that worked everywhere.
I was playing with the idea sometime ago and it worked well so far, but
never had time to expand on it on different technologies, although it should
work just as well:
http://code.google.com/p/razpub/source/browse/trunk/razpub/src/com/razie...
You just gave me an idea - I'll start a project called 20widgets and get to
work...if I find the time :)
Naftoli Gugenheim wrote:
>
> Don't worry, I wasn't being too serious, nor was Razvan.
>
>
-----
Razvan Cojocaru,
Work: http://www.sigma-systems.com
Playground: http://wiki.homecloud.ca
Follow me: http://feeds.razie.com/RazvanTech RSS Feed ,
http://twitter.com/razie Twitter .
Wed, 2010-02-10, 21:37
#21
Re: Scala as a DSL
...took a few hours, half spent fighting... let's call it environment issues:
http://code.google.com/p/20widgets/
looks like crap :) but it's a start:
http://farm5.static.flickr.com/4036/4346282427_38e42ff429_o.jpg
Razvan Cojocaru wrote:
>
>
> You just gave me an idea - I'll start a project called 20widgets and get
> to work...if I find the time :)
>
>
-----
Razvan Cojocaru,
Work: http://www.sigma-systems.com
Playground: http://wiki.homecloud.ca
Follow me: http://feeds.razie.com/RazvanTech RSS Feed ,
http://twitter.com/razie Twitter .
Fri, 2010-02-12, 15:17
#22
RE: Scala as a DSL
It doesn't appear to be, no. I haven't tried yours, I am actually playing
with Andreas Flierl's GroupPanel at the moment, but I would really like to see
an offical one under the normal Scala license.
What can we do to
move this along? Can it still be added for 2.8, or is it too
late?
From: Naftoli Gugenheim <naftoligug@gmail.com> [mailto:Naftoli Gugenheim <naftoligug@gmail.com>]
Sent: 09 February 2010 14:09
To: Kieron.Wilkinson@paretopartners.com; mailtolanger@googlemail.com; luc.duponcheel@gmail.com
Cc: razie@razie.com; scala-user@listes.epfl.ch
Subject: RE: [scala-user] Scala as a DSL
2.8 doesn't have a GroupPanel? I wrote one and submitted it.
-------------------------------------
Kieron.Wilkinson wrote:
I second this. I've been using Scala Swing for a few weeks now, and it
is a really lovely piece of work. Examples are hard-ish to find on the
net, but there are good examples in the test code, including I think
some Java Tutorial examples written in Scala Swing.
It also allows you to easily delve into the real Swing classes to access
less common features. I think this is a good approach - directly support
the common 80% usage, make it possible (easy in this case) to do the
other 20%.
I think my Swing code must be a good 2-3 times smaller (just an
off-the-top-of-my-head figure) using this DSL than using Swing directly
from Scala, which I have also done.
The only thing I am really missing is an official GroupPanel
(GroupLayout). It's the only standard Swing layout I would use for
things like forms.
Kieron
________________________________
From: Stefan Langer [mailto:Stefan Langer
]
Sent: 09 February 2010 09:35
To: Luc Duponcheel
Cc: Razvan Cojocaru ; scala-user@listes.epfl.ch
Subject: Re: [scala-user] Scala as a DSL
Another nice sort of DSL is scala.swing. If you are familiar with swing
then take a look at this library especially Reaction, Reactions,
Publisher, Subsrciber to see how scala wraps Swing to make it easier to
use (= less boilerplate code).
-Stefan
This message may contain confidential and privileged information and is intended solely for the use of the named addressee. Access, copying or re-use of the e-mail or any information contained therein by any other person is not authorised. If you are not the intended recipient please notify us immediately by returning the e-mail to the originator and then immediately delete this message. Although we attempt to sweep e-mail and attachments for viruses, we do not guarantee that either are virus-free and accept no liability for any damage sustained as a result of viruses.
Please refer to http://www.bnymellon.com/disclaimer/piml.html for certain disclosures.
From: Naftoli Gugenheim <naftoligug@gmail.com> [mailto:Naftoli Gugenheim <naftoligug@gmail.com>]
Sent: 09 February 2010 14:09
To: Kieron.Wilkinson@paretopartners.com; mailtolanger@googlemail.com; luc.duponcheel@gmail.com
Cc: razie@razie.com; scala-user@listes.epfl.ch
Subject: RE: [scala-user] Scala as a DSL
2.8 doesn't have a GroupPanel? I wrote one and submitted it.
-------------------------------------
Kieron.Wilkinson wrote:
I second this. I've been using Scala Swing for a few weeks now, and it
is a really lovely piece of work. Examples are hard-ish to find on the
net, but there are good examples in the test code, including I think
some Java Tutorial examples written in Scala Swing.
It also allows you to easily delve into the real Swing classes to access
less common features. I think this is a good approach - directly support
the common 80% usage, make it possible (easy in this case) to do the
other 20%.
I think my Swing code must be a good 2-3 times smaller (just an
off-the-top-of-my-head figure) using this DSL than using Swing directly
from Scala, which I have also done.
The only thing I am really missing is an official GroupPanel
(GroupLayout). It's the only standard Swing layout I would use for
things like forms.
Kieron
________________________________
From: Stefan Langer [mailto:Stefan Langer
]
Sent: 09 February 2010 09:35
To: Luc Duponcheel
Cc: Razvan Cojocaru ; scala-user@listes.epfl.ch
Subject: Re: [scala-user] Scala as a DSL
Another nice sort of DSL is scala.swing. If you are familiar with swing
then take a look at this library especially Reaction, Reactions,
Publisher, Subsrciber to see how scala wraps Swing to make it easier to
use (= less boilerplate code).
-Stefan
This message may contain confidential and privileged information and is intended solely for the use of the named addressee. Access, copying or re-use of the e-mail or any information contained therein by any other person is not authorised. If you are not the intended recipient please notify us immediately by returning the e-mail to the originator and then immediately delete this message. Although we attempt to sweep e-mail and attachments for viruses, we do not guarantee that either are virus-free and accept no liability for any damage sustained as a result of viruses.
Please refer to http://www.bnymellon.com/disclaimer/piml.html for certain disclosures.
And don't forget databinder dispatch!
-------------------------------------
Blair Zajac wrote:
On Feb 8, 2010, at 7:08 AM, Razvan Cojocaru wrote:
>
> Anyone knows a good collection of examples of how Scala is good as a DSL?
You can also check out Scala Migrations:
http://code.google.com/p/scala-migrations/
Regards,
Blair