7 ms·
> Alternatively, just write software in a Lisp variant (with good macros, clojure is quite meh here) or Ocaml or Haskell. These languages put you at the level o
by flavio81 9y ago
> Alternatively, just write software in a Lisp variant (with good macros, clojure is quite meh here) or Ocaml or Haskell. These languages put you at the level of writing a language for each problem domain immediately and with a comprehensive and useful toolkit.
Great comment. And if a domain-specific-language (DSL) of really custom syntax is needed, an alternative is to use Racket (a Lisp-family language), which allows for creating DSLs of all kind. Racket is already used for designing your own programming language and trying it, so I'm surprised that the author did not mention suggest Racket as a test-bed for the new language.
> This article is sort of fundamentally wrong that it's difficult to write small, purpose built languages. It's not, and even outside the functional and homoiconic meta-syntactic world we have seen code generators deployed regularly.
Correct. For example, most of the common systems used today do use a 'code generator' internally: Every software that uses an ORM library (i.e. Hibernate), is already using a sort of domain-specific-language (i.e. HQL) that, via a code generator, translates to another language (i.e. SQL). So most major platforms (Java, .NET, etc) already have one or many popular libraries that do implement some sort of (limited) DSL and code generator.
I think the aim of the article was to create a new compiler from the ground-up.
I think the correct choice for syntax is something that can't be boiled down to three pieces of advice or one article. It is a topic that would require very deep discussion.
- mrkgnao 9y agoDoes Racket support non-Lisp-like syntax for DSLs written in it? I've been hearing really great things about how it has the best macro system on earth, but Haskell has spoiled me to the extent that I'm a bit lazy (no pun intended at all) to look at things outside of that broad area (so Idris, PureScript, etc.) nowadays, but Racket seems to be interesting enough that (to continue the pun) I can afford a bit of IO for it. Most of my interest stems from this excellent project in Racket that's shaping up to be quite something: https://github.com/lexi-lambda/hackett https://github.com/lexi-lambda/hackett It uses the "type systems as macros" paper's approach to create a Haskell-like language in Racket. (btw, I think you meant e.g., not i.e.)
- iitalics 9y ago>Does Racket support non-Lisp-like syntax for DSLs written in it? Yes! You can override the reader so that it parses anything, and there are modules for writing grammers[1][2]. Still, it is usually much easier to just use the built in s-expression parser, and if you're writing a lot of lisp, you probably don't mind s-expressions anyways :) Hackett has interested me too, I hope that progress can continue to be made, it would be a nice alternative to Typed Racket (which is great, but very complex). I'm working with the author of the "Type Systems as Macros" paper right now, we're working on implementing a linear language (along the lines of Rust) using Racket's macro facilities and the turnstile[3] package. Being able to embed arbitrary type systems in Racket really shows the insane power of the macro system. [1] http://docs.racket-lang.org/parser-tools/LALR_1__Parsers.html http://docs.racket-lang.org/parser-tools/LALR_1__Parsers.htm... [2] http://docs.racket-lang.org/ragg/ http://docs.racket-lang.org/ragg/ [3] https://github.com/stchang/macrotypes https://github.com/stchang/macrotypes