DSLs for CSS?
At EclipseCon 09, Bernd Kolb, Tom Schindle and I briefly chatted that it might be cool to build a DSL for CSS. Of course we’d use Xtext
This isn’t a unique idea, here’s two DSL’s for CSS:
Both are pretty similar. The main advantages seem to be:
- Simplication of the syntax through the removal of characters (e.g. “{”. “}” ) and reliance on indentation to denote scoping.
- Constants and calculations for reusing and computing values.
The first I find ‘pleasant’ in that it does aid readibility, but given you’d need to forgo your existing CSS tooling I’m not sure of the trade off for purely syntactic nicety. Mind you if your CSS editor is a text editor, it might make more sense.
The constants and calculations do however seem pretty valuable for commercial deployment, and their lack in CSS has made me question how people manage consistency in large web deployments with complex style sheets. I guess it’s write-once/don’t-touch.
If one were to build a DSL for CSS in Eclipse, what would you want to see as language features?
Posted May 26th, 2009 by Kevin McGuire in category: e4
You can skip to the end and leave a response. Pinging is currently not allowed.
2 Responses to “DSLs for CSS?”
Leave a Reply
You must be logged in using your Eclipse Bugzilla account to post a comment.


Rafael Chaves Says:
May 26th, 2009 at 11:08 pm
1) isn’t CSS a DSL for styling already?
2) what calculations do you think would be interesting to do? I see stylesheets as things that are really static, the variability in the application UI coming from the actual elements being styled.
3) I am not sure I get why you guys are pursuing CSS as the styling technology. Is CSS general enough to support other kinds of non-HTML based presentation technologies? I like something more along the lines of PMF: http://www.eclipse.org/pmf/
Yes, I am a model head.
Kevin McGuire Says:
May 27th, 2009 at 10:55 am
1) Yes, although a highly restrictive one. At a theory level I think it’s valid to look at alternative syntax’s and the ability to achieve more readable, more easily expressed results. But at the practical level I’m more interested in things like the ability to use constants. Let’s say you want consistent margins around all your elements, it’d be nicer to have that in a constant you can change in one place. Very basic good comp.sci. practice.
2) They are declarative but don’t need to be static. The ability to have live ‘variables’ whose values you change from say JavaScript could be interesting for expressing more dynamic layouts. For example, how do you express the min/max behaviour we have in Eclipse? It’s not at all clear. I don’t know the area that well, but I think one issue facing the web world is that HTML and CSS came from a world of static, document centric pages. An IDE is the opposite, highly configurable and maleable.
3) I like CSS because it’s an established standard with proof through massive usage that you can style interesting UIs with it. If I were to pick something else it’d be XAML (e.g. XWT). I don’t know PMF that well but I think it’s solving a different problem. For example, they say,
“PMF focuses in fact on high level presentation modeling concepts on GUI by ignoring the displaying technology artifacts such as appearence, layouts and data binding support. It allows each technology to make its specific connection with this framework.”