titan-lang / titan

The Titan programming language
http://titan-lang.org
MIT License
406 stars 13 forks source link

Is titan intended to be a superset of lua? #251

Closed fcrick closed 6 years ago

fcrick commented 6 years ago

Will I be able to treat existing lua code as if it was titan code without modification?

TypeScript does this with javascript and while I'm sure this constraint makes language development frustrating at times, it has all sorts of benefits for workflow. When I write lua code, I'm always thinking of how nice it would be to have optional static type checking.

hishamhm commented 6 years ago

Will I be able to treat existing lua code as if it was titan code without modification?

No, because Titan is not only a fully statically-typed language, it is also statically-compiled. For this reason, there are dynamic constructs in Lua which aren't (and won't) be available from Titan, which makes Titan not a superset of Lua. The good news is that Lua is available from Titan programs, so the dynamic parts of the program (e.g. scripting) can use Lua, while the core application can be written in Titan, well-typed and compiled.

snarlynarwhal commented 6 years ago

Just to make sure I understand, when you say:

Lua is available from Titan programs

You mean that we can import and call Lua code from a Titan script, right?

I want to use Nakama Server which uses Lua for server side scripts. With Titan I can access the server Lua functions?

hishamhm commented 6 years ago

Yes, you will be able to require and interact with Lua scripts from Titan modules, and that includes using Lua functions provided by the Lua environment where the Titan module is loaded. The Lua functions, of course, will not have the same typing information as Titan functions so runtime type checks will be necessary. This part of the two-way interaction is still work in progress, but that is the goal.

snarlynarwhal commented 6 years ago

Okay awesome, thanks!

flamendless commented 6 years ago

Hi, just want to clarify this:

here are dynamic constructs in Lua which aren't (and won't) be available from Titan

Do you mean lua tables?

hugomg commented 6 years ago

Titan can use Lua tables, but in a restricted manner. For example, Titan can use a table if it is acting as an array or as a "struct".

The sort of dynamic features we were talking about are things like metatables. For example, in some circumstances may raise a runtime error if it encounters a table that has a metatable.

adam-cyclones commented 5 years ago

I hope Titan mirrors Typescript in terms of design as I suspect it does. Recently I have been falling in love with Lua, but I come from Typescript land, I miss types! So far this project looks very enticing to me. If it matures I'd happily contribute some tooling extensions such as vscode language support.

One thing I'd like to see you implement from Ts is the import export syntax.