-
Notifications
You must be signed in to change notification settings - Fork 111
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Thoughts / Concerns / Questions #697
Comments
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. |
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 |
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! |
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). |
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. :) |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
My PEGL library makes writing a recursive descent parser (with decent error messages I think!) much more concise and readable, while the library itself is very lean (300 LoC). I noticed that
tl.lua
spent about 3000 lines parsing, I think with PEGL it would be more like 300-400 (plus another 300 for the PEGL library itself if you wanted to stay in a single file) -- I currently parse Lua itself in a bit more than 200 lines (although it doesn't quite work yet).Looking at
tl.lua
I see no way to declare a TL type for lua to use. I'm looking for something likenewRecord
above. This is confusing to me, since one of the big benefits of including something like TL into your lua project would be the ability to stay with Lua for some things but get the benefits of expressing types (with autosetmetatable
and string formatting etc provided)In general I see very few library functions exported by TL. Is there a function for standard record formatting? For record equality? Does TL even use
setmetatable
?https://github.com/teal-language/tl/blob/master/docs/developing.md seems to indicate that TL is bootstrapping itself. Why? Isn't lua a "good enough" language for writing a compiler in? I have a hard time believing the win is worth the overhead mentioned in that doc.
The text was updated successfully, but these errors were encountered: