0

How is it possible that written a programming language like CoffeeScript in itself like CoffeeScript? Firstly CoffeeScript doesn't exist that read CoffeeScript scripts and interpret them?

Kilian Foth
  • 107,706
  • 45
  • 295
  • 310

2 Answers2

1
  • First you design a language A on paper and white board.
  • Then you write an implementation of a language A (compiler, vm, interpreter, runtime depending on a scope of language) in language B.
  • Once you have stable environment for language A, you can start writing version of environment for language A in language A.

I would say, that unless language is slow or not turing complete, it's tools should always be implemented in it. That makes it's much easier for developers to work with it.

David Sergey
  • 513
  • 3
  • 11
  • 2
    I have to disagree with your last statement, or specifically with its absoluteness ("always"). Some languages are good for writing compilers in, some aren't. You have to weigh the benefits of writing a compiler in the language it compiles and thus increasing the amount of people able to work with it (because they only need to understand one language, not two) against the increase in complexity caused by using a language that might not be up to the task. I personally would much rather maintain a SQL compiler written in Scala than one written in SQL. – Jörg W Mittag Jun 19 '13 at 08:53
  • 2
    Wrong. Language traits that are required for writing compilers (pattern matching, ADTs, compile-time metaprogramming, etc.) are not necessarily the traits you want in your target language. And, by the way, you don't need a Turing-complete language to write a compiler. – SK-logic Jun 19 '13 at 09:39
  • @JörgWMittag I'm sorry, I meant turing complete languages, I've edited my post. – David Sergey Jun 19 '13 at 09:49
  • @SK-logic last paragraph is my opinion. And I didn't say that you need turing complete languages to write compiler, you don't need languages with fast environments to write compiler either. That is my preference and my opinion. In the end, if I'm a full time _LanguageA_ programmer, I will understand _LanguageA_ better than other languages, even if we suppose that there is _LanguageB_ that's the best language to write compilers. – David Sergey Jun 19 '13 at 09:52
0

Think of a subset of language to build another language. Don't watch it as building A with A but instead building A with B where B is a small language.

Think of it in this way: You build a simple interpreter with JavaScript and name it CoffeeScript, later on as your project goes bigger and bigger you start writing parts of your code with your new functions/construcs or in short - your own language like CoffeeScript.

lukas.pukenis
  • 372
  • 3
  • 10