Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am the main author and designer of MELT, a domain specific language to extend GCC (the Gnu Compiler Collection). The implementation is available free software (GPLv3 licensed). If you want a detailed description, from the point of view of a Domain Specific Language, read my DSL2011 paper on MELT.

I have chosen a Lisp-like syntax for MELT, so as in Lisp or in Scheme, every operation is written with "Lots of Insipid Stupid Parenthesis" so the application of function f to arguments a and b is written (f a b) (like it is in Scheme or in Lisp). Of course, (f) -a function application without argument- is not the same as f -a simple thing denoted by a variable-.

MELT shares with many other Lisp-s and with Scheme the usual "control" operators like let if defun define cond lambda letrec list definstance etc... MELT does not use the common names for primitive operations (no car or + in MELT, which has pair_head list_first +i +iv with different meanings). And MELT deals with both first-class values (like in Scheme) and "stuff" (for raw GCC data like Gimple, details are in the DSL2011 paper)

The reasons I have chosen a Lisp-like syntax includes:

  • first, I am lame, and wanted to have a quick implementation. Parsing Lisp is trivial;
  • I was (and am) able to use e.g. Emacs lisp-mode for MELT without trouble.
  • A small MELT implementation was originally prototyped in Common Lisp
  • Current MELT translator is bootstrapped so is written in MELT
  • The implementation uses classical Lisp tricks: S-expressions are expanded by a macro mechanism (into a sort of internal abstract syntax tree), then normalized, and finally translated to C code.
  • GCC has several Lisp like formalisms inside (notably for the back-end, for "machine description" files).
  • the GNU projects have Emacs Lisp and Guile as Lisp-like dialects (I was not able to use them for technical reasons detailed in my DSL2011 paper).

My question is: should I offer an alternative, infix-like syntax (a bit Pythonic or Lua-esque)?

One one hand, I am afraid that some people (particularly young ones, who never met any Lisp-like programming languages; I had a course on Lisp in the 1980-s) are completely allergic to Lisp and won't even try MELT because of its look.

On the other hand, the only thing I could do is some simple parser producing the same AST as MELT has today, and the syntax will be ad-hoc (but infixed) and probably not pretty.

Also, working on an alternative syntax which I won't use will distract me (or take time) from other efforts (writing documentation & tutorial, making good examples of MELT, debugging and improving the implementation).

Some young persons (in particular Jeremie Salvucci and Pierre Vittet) have been able to learn and code MELT without prior exposure to MELT, to Lisp dialects (or Scheme) or even to compilation.

Would an alternative syntax attract people allergic to Lisp? A nice guy told me that syntax does not matter really for DSL-s. They can be adopted if they bring some value, even with a not very sexy syntax.

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

What makes sense to you? After all, it is your product and you can do with it as you please. The real question is this: will there be any reward for your work? You'll end up with two variants to support and if you introduce features they may not be compatible with each style (in a nice way).

If it was up to me, I'd stick with the lisp like syntax but that is because I enjoy that syntax. At the very least, I would ask the people that use your project what they think as they would be the ones who know and would be the ones most affected by your decision (if you are working on the alternative syntax, it is time away from feature enhancements etc).

share|improve this answer
    
The question is perhaps: would an infix syntax attract people so allergic to lisp that they won't even try MELT because of its lisp-like syntax? –  Basile Starynkevitch Dec 21 '11 at 22:12
    
@BasileStarynkevitch what about the reverse? If by switching to a more imperative style would you lose the people who use your product now? –  Jetti Dec 21 '11 at 22:13
    
I would still support my current lispy syntax, because I use it and I like it. (I was thinking of adding an additional infix parser to MELT, not replacing the current lispy one). –  Basile Starynkevitch Dec 21 '11 at 22:15
1  
@BasileStarynkevitch It would be more work for yourself. Twice the documentation to maintain. More code to maintain. Bottom line is you can't make everybody happy, so make yourself happy. You like lisp-like syntax, so stick with it –  Jetti Dec 21 '11 at 22:21
add comment

Learning a new syntax is not a big deal. However, by syntactic similarities, you associate yourself strongly with other languages in that field- even if your semantics are different, you will have a tough time showing people that they aren't that similar. C syntax is about the only syntax that doesn't have this problem, because when compare for example C to Java, they're radically different- anyone who's done more than a couple C syntax languages knows that it's a popular syntax with little semantic meaning.

However, with LISP, this is not a good thing. Not because LISP's syntax is terrible, but because programming in this decade involves flipping between data structures like pages in a book. When I see list_first, my reaction isn't "Great, you can do linked-lists and it's gonna be easy", it's "What if I need a deque, a queue, a stack, an array, a hash table, a binary search tree? What if I want the second element of my list? What if I need to invent my own data structure that needs a very specific implementation for reasonable performance? This language isn't going to support the expressiveness I need.". Compared to C++ or even C# or Java (to a lesser extent) or... where I can just change the name of the class I'm using and voila, new data structure, works with my old generic code.

As a young person who was never taught "LISP is slow" or anything like that, I'm definitely allergic to it, because it's fundamental building blocks are one of the slowest, least useful data structures, and there's no reason to even build a language on a data structure in the first place.

share|improve this answer
    
The reason I have list_first is that MELT's lists are not exactly like Scheme's lists: a list in MELT knows its head pair and its last pair... (so is not the same as a pair). And I have several other data structures (tuples, objects, hash-maps, ...). Actually, lists are not the most used data structure in MELT (objects, maps and tuples are more used than lists; and MELT raw stuff like Gimple are obviously widely used, and have boxed counterparts. In terms of dynamic value types, MELT is more like Lua or Python than like Lisp). –  Basile Starynkevitch Dec 21 '11 at 22:27
    
@Basile: If you want to attract users, then you need to show that. Lua's tables are obviously incredibly flexible, for example. However, quite simply, what I stated above holds- if you want to be all about the lists, then use LISP's syntax, and if you want to show that you're not just about lists, then you need something more generic. –  DeadMG Dec 21 '11 at 22:39
1  
@DeadMG Clojure seems to do just fine with its maps, vectors and sets. –  Jörg W Mittag Dec 22 '11 at 0:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.