-
Hey, I really love the language. I particularly like how it preserves Lua's design and "feel" while addressing the most common issues. I'm working on some of my own languages (http://civboot.org) and Lua libraries, including a recursive-descent parser library (https://github.com/civboot/pegl) which in a 370 line library file makes expressing Lua's syntax a breeze -- Lua's syntax is expressed in a bit more than 200 lines of code (not quite complete but I think I'm close). I'm also writing my own "base library" that includes a type system (https://github.com/civboot/civlib/blob/main/lua/civ.lua but don't read the code, I was learning Lua while I wrote it), the basics of which is something like:
I have a few thoughts/suggestions
|
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 3 replies
-
Keep in mind that teal has to parse teal code, not lua code (Or maybe it needs to do both? Forgot) so that would add some of the extra lines. In addition, you would be surprised how many extra lines some of the finer details can bring. So depending on where your parser exactly is I don't find it that big of a surpise that the teal one is so much bigger than yours.
I am not entirely sure I understand what you exactly want... Maybe
The API exposed by teal is for the time being very limited on purpose as it would be way too unstable. Also, formatting teal code isn't something that teal should be doing anyway (I think?)
Most languages bootstrap themselves. It is a good way to test the compiler. It also helped the maintainer already by finding type errors. IIRC they mentioned how rewriting from lua to teal fixed many bugs in the compiler due to the better typesafety and how only nil related problems are left when it comes to stuff that can be checked at compile time. |
Beta Was this translation helpful? Give feedback.
-
Sorry, I meant formatting teal records (like I'll respond to the other points when I get an example of what I want published to luarocks :D |
Beta Was this translation helpful? Give feedback.
-
This is what I want: https://github.com/civboot/metaty Lua already has a powerful (runtime) type system, it's just annoying to express types in it. IMO it would be good to build on the system that exists and have a language+syntax (like teal) that compiles to a Lua-native type library. If teal included something like metaty then it could just compile records directly to metaty calls. Of course, it would still do it's normal type checking/etc statically, but at runtime its types would just be metaty values.
FYI metaty has cleaner formatting of Lua values (not just records but also raw tables), a huge pain point of Lua for me personally.
I think in a lot of languages it makes sense, however when the language is just a transpiler and the language it's trans-piling to is such a powerful and expressive language I think it makes less sense. What if instead of teal being built in teal it was built in lua with type libraries (like metaty)? It's y'alls project so it's your decision, I just wanted to push back on that point. Feel free to close if you like and thanks for the discussion so far! |
Beta Was this translation helpful? Give feedback.
-
I moved the project to https://github.com/civboot/civlua/blob/main/metaty/README.md I've added function types as well (only runtime checking right now). |
Beta Was this translation helpful? Give feedback.
-
Hi! Thanks for the feedback. @lenscas's original reply already covered a lot of ground, so I'll just go through your original message and add some finer points from the author's perspective.
Not only parsing but also building the AST. It also keeps the project self-contained with no dependencies (otherwise I'd be using LPeg or something). I took a look at your library; it looks cool, but since it's a grammar interpreter, I don't think performance would be on par with the handwritten recursive descent parser, and our current performance isn't ideal. I probably could make the parser shorter with a metaprogramming-based generator, but then code would be dynamic and I wouldn't have the Teal type-checker to help me write it, and I find the current parser code easy to maintain.
Teal doesn't provide a, let's call it, "metatable-use-pattern" model of its own (to not call it an object model). Everyone has different opinions on how one of those should look like; for discussions with links to further issues, start here: #97.
Well, you like having static types when coding, why can't I have them too? 😁 On a more serious note, Lua is a scripting language; I have written entire applications in it, and it is on the back of that experience that I decided to create Teal — to make a Lua-like application-development language, first and foremost, for my own use! Plus everything @lenscas said. :) |
Beta Was this translation helpful? Give feedback.
-
I went on a bit of a code safari and have a conclusion: runtime type checking should only be for concrete types: it should not support generics or function types. See my write up here: civboot/civlua#2 If teal were to export runtime types I would recommend the constraints only support specific values (either native I tried to implement such a system and it's complexity and runtime cost outweighs it's utility. On the other hand, records have very little complexity (especially considering the gains of debugging) and absolutely zero runtime cost since you can selectively enable runtime checks and runtime checks were only happening in the constructor/__index/__newindex methods which can easily be swapped depending on whether checking is enabled or not. Just some thoughts if you do decide to go that route. Thanks for the great discussion! |
Beta Was this translation helpful? Give feedback.
Hi! Thanks for the feedback. @lenscas's original reply already covered a lot of ground, so I'll just go through your original message and add some finer points from the author's perspective.
Not only parsing but also building the AST. It also keeps the project self-contained with no dependencies (otherwise I'd be using LPeg or something). I took a look at your library; it looks cool, but since it's a grammar interpreter, I don't think performance would be on par with the handwritten recursive descent parser, and our current performance isn't ideal. I probably could make the parser shorter with a metaprogramming-based generator, but th…