Hacker News new | past | comments | ask | show | jobs | submit login

I am curious. Was there any particular feature that your language had, which was lacking in C++, that helped in simplifying the test script?



Also not OP but: Having a limited language that looks more like data than code provides great opportunities to analyze it in ways that you can't analyze Turing-complete languages (halting problem and all).

An example: A friend works for a game translation studio and one of their games has a tool that read the game scripts and is able to detect missing/unused external resources, overlapping dialogue, unmatched mouth animation/voiceovers, etc... without even running the game.


Not OP, but looking at his example, conciseness.

DSLs are feared by many, but actually when you're doing the same thing over and over again and it's hugely verbose, they're great!


In essence as you gain expressive power you lose analytical/introspective/reasoning power. Being more powerful on a concrete level costs power on the meta-level. There is a great talk about this called “Constraints Liberate, Liberties Constrain” from Rúnar Bjarnason.


These are things you typically want to do run time, and not require a compile cycle to change.

There's also the risk of breaking changes to the scripts, if writing in C++ exposes too much of the project's object model.


Almost every DSL's capabilities are expressible in almost any language. The value is in the expression, not in what it expresses (usually).

I can describe (off-the-cuff example) a regular expression using any programming language's basic constructs:

  Regex r = new Character('a').then(new Repetition(new Character('b'));
Or I can write that as:

  ab*
Which is clearer? You can probably imagine a simpler example in most languages, but you still have to design and construct an API, and then train people to that API. The DSL offers (in theory, not all do) a more natural representation of the problem, which can then be converted to an internal structure or directly executed.

That more natural representation is what brings you most of the value. Another aspect of this, and this is where some have argued benefits in more algebraic-notation languages (the MLs) over others: You can often write DSLs that allow reasoning to be clearer.

Back to that regex example, you can view regular expressions as an algebra. You can manipulate them like algebraic expressions. You cannot manipulate that first example algebraically, so if you decide you want to change it in some way or conduct some analysis on it, those activities are much harder.

In the first API example, how would I alter it to indicate that a should be repeated 0 or more times? I have to insert a new new Repetition(...) element around the first Character element. It's tedious and error prone. For the regex, I add an asterisk after the a. It's clearer, more concise, more amenable to reflection (by the author and others), and more maintainable in the end.

Additionally, if I want, I can change the implementation of that DSL to reflect new capabilities or new backends. With the API version, that's harder to accomplish.

=========================================================

At work, we also have test DSLs. One of the biggest benefits besides the more natural expression of test cases, was that it was reimplemented and all the old tests continued to run without modification. From an old Fortran implementation to a more modern C# implementation. The ability to migrate 20+ years worth of test cases was a great boon. Every one of them could've been done in Fortran directly before, or C# now. But in 10-20 years we may have motivation to reimplement again. The one reimplementation was because: Original dev retired, poor documentation of code base, inability to port to modern operating systems due to graphics API used and code design, inability to extend to support newer systems being tested. I believe the C# implementation is better in all those ways, but limitations may be discovered in the future that require another rewrite (I do know it was successfully handed off to new developers, so it is more comprehensible and maintainable, if nothing else).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: