DCL (Domain Dpecific Language) in golang

392 views
Skip to first unread message

gerald...@gmail.com

unread,
Jul 31, 2014, 8:19:35 AM7/31/14
to golan...@googlegroups.com
Hello,

Im currently doing a compiler course and would like to to know if golang is suitable for creating a very simple domain specific language?

Please share your experience...

At the end of the course there is final project, we have to create a simple programming language. 

Would you recommend golang or should I use a functional language like O'Caml or Scala?

Thanks,
Gerald

Jan Mercl

unread,
Jul 31, 2014, 9:12:10 AM7/31/14
to gerald...@gmail.com, golang-nuts
I'd recommend Go as it is possible to write a Go compiler in Go and Go
is not only a simple DSL.

-j

gerald...@gmail.com

unread,
Jul 31, 2014, 9:14:24 AM7/31/14
to golan...@googlegroups.com, gerald...@gmail.com
yeah, but the question is the the effort, since golang does not provide operator overloading and other usefule features like templates?

is the go compiler opensource? i could thake a look into...

Jan Mercl

unread,
Jul 31, 2014, 9:22:59 AM7/31/14
to gerald.stanje, golang-nuts
On Thu, Jul 31, 2014 at 3:14 PM, <gerald...@gmail.com> wrote:
> yeah, but the question is the the effort, since golang does not provide
> operator overloading and other usefule features like templates?

AFAICT, the lack of some features, including those you've mentioned,
is the main reason why coding in Go requires _less_ effort.

> is the go compiler opensource? i could thake a look into...

Yes it is: https://code.google.com/p/go/
(https://code.google.com/p/go/source/browse#hg%2Fsrc%2Fcmd%2Fgc)

-j

Kevin Malachowski

unread,
Jul 31, 2014, 9:48:02 AM7/31/14
to golan...@googlegroups.com
I've written one simple language in Go (it had simple shell-like syntax that was used to pass output from functions into other functions to create sound; ie a synthesizer) and another slightly more complicated one that had syntax based off Go itself (using the official Go libraries to do tokenizing, hand writing my own parser). I found it very suitable, but then again Go has been my favorite language for a while now.

What sorts of problems do you think you'll run into? The lack of templates and operator overloading are more reasons that the source code will look different than C++ than reasons you shouldn't use Go. As Jan said, since its a Turing complete language you can do anything in it that you could do in, for example, C/C++.

Kevin Malachowski

unread,
Jul 31, 2014, 9:51:33 AM7/31/14
to golan...@googlegroups.com
Rereading your post, it looks like you were suggesting Scala or OCaml, not C/C++ as I assumed. If you're looking to learn Go and have good programming experience already, this project could probably get you a little more used to Go. If you don't have too much experience already you might want to stick to a language you already know for this since its not a definitely easy problem.

Gerald Stan

unread,
Jul 31, 2014, 9:57:11 AM7/31/14
to Kevin Malachowski, golan...@googlegroups.com
Hi, 

I found a nice tutorial about creating a programming language. The compiler was written in go:

Please let me know if know some nice articles, github repos like this...


2014-07-31 15:51 GMT+02:00 Kevin Malachowski <nifta...@gmail.com>:
Rereading your post, it looks like you were suggesting Scala or OCaml, not C/C++ as I assumed. If you're looking to learn Go and have good programming experience already, this project could probably get you a little more used to Go. If you don't have too much experience already you might want to stick to a language you already know for this since its not a definitely easy problem.

--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/bHzk04SoD1o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gerald Stan

unread,
Jul 31, 2014, 9:58:33 AM7/31/14
to Kevin Malachowski, golan...@googlegroups.com
@Kevin: "I've written one simple language in Go". is it opensource and on github? i would like to take a look at it...

Harmen B

unread,
Jul 31, 2014, 10:00:16 AM7/31/14
to gerald...@gmail.com, golang-nuts
For compiler related task I would personally use Ocaml or Haskell. Their (Hindley-Milner) type system is so much more advanced than Go that it'll probably help you there. Go's strengths (parallelism, simplicity) are rather awesome in the context of server things, but won't help you much with compiler things. The ML based languages are just too good at this.
(And all examples are probably in Haskell anyway :)


On Thu, Jul 31, 2014 at 2:19 PM, <gerald...@gmail.com> wrote:

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.

Ibrahim M. Ghazal

unread,
Jul 31, 2014, 10:00:38 AM7/31/14
to gerald...@gmail.com, golang-nuts
On Thu, Jul 31, 2014 at 4:14 PM, <gerald...@gmail.com> wrote:
> yeah, but the question is the the effort, since golang does not provide
> operator overloading and other usefule features like templates?
>

There are two kinds of "DSL":
1- Languages parsed by another program.
2- Languages that bend another language to look like something else.

Go is great for the first kind. A good start is:
http://www.youtube.com/watch?v=HxaD_trXwRE

As for the second kind, I've seen it used mostly in C++ (example:
http://boost-spirit.com/ ) and Ruby (See
https://gist.github.com/geeksam/24ef10be8c773a2c1bd4 ). Thankfully,
Go's syntax doesn't allow such tricks, so you'll have to stick to the
first kind.

egon

unread,
Jul 31, 2014, 10:04:19 AM7/31/14
to golan...@googlegroups.com, gerald...@gmail.com
On Thursday, 31 July 2014 15:19:35 UTC+3, gerald...@gmail.com wrote:
Hello,

Im currently doing a compiler course and would like to to know if golang is suitable for creating a very simple domain specific language?


 
+ egon
Reply all
Reply to author
Forward
0 new messages