alexschneider / teascript

5 stars 2 forks source link

INTLITS and FLOATLITS vs Number #84

Closed juansc closed 9 years ago

juansc commented 9 years ago

As I was working on the exponents in teascript, I was wondering why we make the distinction of integer and floating point numbers in teascript, since we will generate the code in JavaScript, which uses the number type.

rtoal commented 9 years ago

The choice of target language should have nothing to do with the design of your source language. Zero. Nada. None. You should be able to translate teascript to LLVM, assembly, machine language, C, C--, JVM, asm.js (which DOES have separate floats and ints despite being a subset of JS - go figure!) or whatever.

Whether you choose to have separate ints and floats (like Java, C, and Python) or mix them into a single number type (like JavaScript and Lua) is a choice you make for your language completely independent of the target. So is whether your language is static or dynamic.

The thing that is really cool about writing translators is that you CAN make radically different sources and targets.

I could also make the point this way (no offense intended): "I was wondering why C++ has types and classes and structured loops, since we are translating to assembly language which has none of these things."

Still, the question you have is interesting because you describe teascript in your README as something that translates to JavaScript, so one might think it would be like CoffeeScript. The thing about CoffeeScript, though, is that CoffeeScript IS JavaScript, just with a new surface syntax which is awesome.

I believe teascript is its own language. That is why.

juansc commented 9 years ago

Ok that makes sense.