Tag Info

Hot answers tagged

21

Let me just quote Paul Vick, ex chief developer of the VB compiler and now working on Project Oslo and the M language: It’s mind-bendingly, stupendously difficult to build a new language, even one that’s largely based on an existing one. Yet many programmers think, “hey, I use languages, how hard can this be?” and go at it. … probably over 98% of them ...


16

Read On Lisp and then decide for yourself. My summary is that Ruby is better at providing convenient syntax. But Lisp wins, hands down, at the ability to create new abstractions, and then to layer abstraction on abstraction. But you need to see Lisp in practice to understand that point. Hence the book recommend.


13

Ruby's facilities for DSL authoring don't change the nature of the language. Ruby's metaprogramming facilities are inherently tied to Ruby syntax and semantics, and whatever you write has to be shunted into Ruby's object model. Contrast that with Lisp (and Scheme, whose macro facilities differ), where macros operate on the abstract program itself. Because a ...


10

To answer the question of whether CSS is a domain specific language, according to Martin Fowler, it is. In fact he lists it among examples of DSLs. You do have to understand that talk about DSLs has been going on for a while now, and Wikipedia's more narrow definition has come along much later in the discussion. Understand that Wikipedia is edited by ...


9

You can try ANTLR (or ANother Tool for Language Recognition) a parser generator that is among others available for dotnet. In the community you can find definitions for sql, c# and many other languages. According to google there is also ide support: ANTLRWorks: The ANTLR GUI Development Environment Eclipse plugin


9

What you seem to be describing is Lazy Evaluation. Computations to be performed when the result is needed, rather than when it appears in the source code. In Haskell, this is done by hiding these computations behind monadic abstractions. In C++, the abstractions are similar, but more explicit, and partially hidden behind overloaded operators and expression ...


8

You might want to read parts of Martin Fowler's upcoming DSL book, if you're thinking of writing you own language. I can't really think of a business case to create a language from scratch other than it being a tremendous learning experience. Edit: for DSL's there are plenty of business cases, but the key here is not to get carried away and Keep It ...


8

You are overlooking the obvious fact that not all database platforms accept the same SQL syntax, so embedding SQL statements throughout your application just won't work for every database platform. If you ever need to support multiple database platforms, you will have to rethink most (if not all) of these SQL statements.


7

The most fundamental problem of common SQL use is, that SQL queries are strings, that are somehow composed from another language. This is where SQL injections and other vulnerabilities and WTFs come from (your example is quite poorly chosen, because your query doesn't actually have any parameters). The next problem is actually a corollary: if you just have ...


7

The easiest way to go is a fluent interface. This requires no tools at all, and gives you great IntelliSense support, but you still have to write things in a .NET-kinda way, such as Mix.Paint(Color.Green).With.Paint(Color.Red); Alternatively, you can write beautiful DSLs in Boo. There is an entire book on that subject.


7

A few thousand lines for a parser + interpreter that actually does something interesting is not unusual in the least. I looked at the SVN repo and especially your main grammar and noticed various things: You have various utility classes that would make more sense in a general algorithms library. A quicksort implementation, really? IIRC, the C++ standard ...


6

I would recommend creating your DSL on top of an existing language (internal DSL). I've done this a few times with Python, creating systems where the consumer of the DSL writes a python file that is used as a configuration file for the system. The configuration file uses constructs (classes, functions) that I have defined. These constructs form the DSL. ...


6

It's a language. It's specific to a domain. If you're going to have a "DSL" list on your resume, I don't see why CSS wouldn't count as one.


6

This is called Lazy Evaluation. It is a quite common pattern. In fact, every time you use the && or || operator in a C-like language, the second operand will only be evaluated if it needs to. Likewise, in an if/then/else, only one of the branches is evaluated. Lazy Evaluation has some interesting properties: In the absence of side-effects, making ...


5

Seems like the main reason you'd want a new language is that you start discovering patterns in your code that existing languages don't handle well. But there are a bunch of problems with creating your own language. You'll be missing out on all the libraries and frameworks that are built up for existing languages. You'll spend a lot of time designing and ...


5

One reason could be to create it as an experiment to learn about language design and compiler building. Another reason could be to build a scripting language into an application when you don't have the option to add a third-party API.


5

I have not read it, but I'd recommend the book by Martin Fowler on the subject "Domain Specific Languages". Many of his other books have proven to be very insightful and helpful in my thinking about software development. And I expect the DSL book to be as much so (it is on my to read list). http://martinfowler.com/books.html


5

Your thinking is still too low-level. You're looking for a better way to say things like "What's the value of O2 detected by O2 Sensor #2?" But why do you need to know that value? What are you going to do on the basis of the value? If you just want a wrapper that's a bit less cumbersome, sure, write that. But if you want a genuine domain-specific ...


5

This depends on the complexity of the domain. If it mainly consists of structured data, a visual editor may be more intuitive to use, but if the domain contains significant amounts of logic, experience has shown time and time again that visual editors are a poor tool for that. Additionally, there are some very common, very useful tasks that are trivial with ...


5

The distinction is hard to make, and depend of the language used. It is also subjective. In clojure, you can define APIs which look like a DSL. For exemple, hiccup allows you to generate html: (html [:span {:class "foo"} "bar"]) This can be considered as a DSL with a lisp syntax. The fact that html could be a macro gives it the same amout of power as if ...


4

It is always "feasible", to use the word in your (original) question, but it is not very often useful and very rarely optimal given the abundance of well-supported and mature languages and frameworks that exist. It is an interesting intellectual challenge, however.


4

I don't think you can program without creating a new language, so it's good to realize that's what you're doing and understand the issues. What is a language?Vocabulary, syntax, and semantics. An off-the-shelf language like VB, Java, C#, etc. is just a base language. As soon as you add classes, methods, etc. to it, you have added vocabulary and ...


4

In designing language syntax, you have such a wide range of choices that it's really a matter of taste, not engineering. If you want a tried, tested, and familiar syntax, rip off a language or three of your choice. If you want to explore and invent something new, the range of potential pitfalls is also so wide that existing examples may not help. There's ...


4

This is an indirect answer to your question. In 1982 I wrote the first commercial C source-level debugger, CDB (also possibly the first remote debugger, kernel debugger, and multi-process/multi-thread debugger). I initially wrote it because I needed it (the only other option was sdb on a VAX, except I didn't have a VAX, and sdb sucked planetoids). This ...


3

Except for self-educational purposes, I would like to claim that there is today no need whatsoever to create your own language. In any circumstance. Ever. Regardless of what you want to do, there are boatloads of existing languages you can take/adapt to your needs.



Only top voted, non community-wiki answers of a minimum length are eligible