Skip to content
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

Suggest and use a file extension other than .lua #97

Closed
Dekkonot opened this issue Nov 3, 2021 · 13 comments
Closed

Suggest and use a file extension other than .lua #97

Dekkonot opened this issue Nov 3, 2021 · 13 comments
Labels
enhancement New feature or request

Comments

@Dekkonot
Copy link
Contributor

Dekkonot commented Nov 3, 2021

As Luau grows as a language, it's gotten less and less compatible with normal Lua 5.1. It seems prudent to start using an extension that isn't .lua to allow tooling to make a distinction between the two languages.

This has some implications for Roblox as it allows .lua files to be loaded both with Run Script and local pluins at the moment, so it cannot be community driven. I'm not sure of the work that goes into this on your end but it would have to be on Roblox to support it.

My suggestion is .luau but anything works as long as it isn't .lua

@Dekkonot Dekkonot added the enhancement New feature or request label Nov 3, 2021
@gsckoco
Copy link

gsckoco commented Nov 3, 2021

From my understanding, Luau is fully compatible with normal lua scripts, is it not?

@regginator
Copy link

I thought that (like luac), Roblox could implement a .luau format for lua bytecode. The lua file extension is much easier to get around for source code, as none the less luau aims to be almost 100% backwards compatible with lua 5.1.

@Qix-
Copy link

Qix- commented Nov 3, 2021

"Fully" is pushing it, judging from the docs. Syntactically compatible with Lua 5.1, but the libraries are much different. I agree here, the extension should be changed. You cannot expect to run the same scripts in both environments, as the semantics have changed.

I think the spirit was to ease the pain of porting existing Lua scripts over (which IMO Luau facilities quite nicely, not having actually used it and just reading the docs).

@Dekkonot
Copy link
Contributor Author

Dekkonot commented Nov 3, 2021

From my understanding, Luau is fully compatible with normal lua scripts, is it not?

All Lua 5.1 should be for the most part compatible with Luau but not all Luau will be compatible with Lua 5.1 (e.g.: local foo: bar would be a syntax error in Lua 5.1).

I write code for both. I don't want a Lua extension to necessarily activate for a Luau file because it will start spewing errors when there's nothing wrong. A separate file extension fixes this issue, but it would be nice to have that extension supported by Roblox in an official capacity so Studio can load such files.

@zeux
Copy link
Collaborator

zeux commented Nov 3, 2021

The small downside to using .luau is that various parts of the ecosystem don't recognize it as an extension. This affects GitHub syntax highlighting and syntax highlighting / language modes in various editors. We've also historically used .lua everywhere at Roblox of course.

@zeux
Copy link
Collaborator

zeux commented Nov 3, 2021

I agree we should aim towards changing it though. Maybe a good first step would be to change "Getting Started" documentation to suggest .luau...

@Baileyeatspizza
Copy link
Contributor

Baileyeatspizza commented Nov 3, 2021

Editor extensions (I'm talking about vsc the name depends on the editor) can change to work for luau for example Roblox LSP supports .luau file types

it may actually be beneficial to change to change the file type to .luau as most editors will prompt you to install stuff that will highlight and do other language related things making them support the Luau environment more then just Lua

right now the hardest thing in my eyes would be extensions trying to differentiate between:

lua 5.1
luau
luau in Roblox (luau being used in the Roblox environment with all the Roblox api)

would require a lot of work for the extensions to try and guess but if the filename was .luau it would default to luau and thus no checking is necessary and its assumed that the file should be checked based on luau syntax and highlighted as such

as for GitHub when the .luau becomes more popular you can request for it to be highlighted and such here
https://github.com/github/linguist/blob/master/CONTRIBUTING.md
as long as it meets all the other requirements as well

@Dekkonot
Copy link
Contributor Author

Dekkonot commented Nov 3, 2021

The small downside to using .luau is that various parts of the ecosystem don't recognize it as an extension. This affects GitHub syntax highlighting and syntax highlighting / language modes in various editors. We've also historically used .lua everywhere at Roblox of course.

This is a potential concern but most of that tooling won't be able to read any Luau syntax as-is so I don't think it's all that worrying. Tooling that's actively maintained and supportive of Luau will adapt to recognize .luau and those that aren't will be out of date quickly either way. As an example, the recent release of if-then expressions mean any not maintained tools can't read files that use that syntax, so whether they read .luau is a mostly academic problem.

As for syntax highlighting, I agree that's a concern but most modern editors (read: not Notepad++) have ways around this problem and GitHub has a language repository (like @Baileyeatspizza mentioned), though there are some requirements before Luau could be added. That requirement becomes less obtainable the more projects are published using .lua for Luau though!

I agree that suggesting .luau would be a good first place to start though. 🙂

@zeux
Copy link
Collaborator

zeux commented Nov 3, 2021

@Dekkonot Yeah I think it's the right idea to gently push towards a separate extension. I think to start with we can make sure we mention this in the getting started guide, fix require() imlementation in Repl and Analyze to look for .luau extension first and, if absent, .lua extension as fallback, and support the extension in Roblox Studio. I think the reality is that there's going to be a lot of Luau source that still uses .lua extension but as long as Luau tooling supports .luau as an option this should be good.

@regginator
Copy link

regginator commented Nov 3, 2021

The small downside to using .luau is that various parts of the ecosystem don't recognize it as an extension. This affects GitHub syntax highlighting and syntax highlighting / language modes in various editors. We've also historically used .lua everywhere at Roblox of course.

This is partly what I meant; a lot of support has gone into the .lua format in the past on multiple different things such as IDEs like VSCode. I think it would be SO COOL to see debugging and custom plugins for things like vsc in the future with Luau now being mostly open sourced.
In my personal preference, I will keep using .lua for source code, and .luac for bytecode in vanilla lua, as that just seems like the way to go for me. It does make sense to possibly adapt to an extension like .luau for source code, but I feel like there should possibly be an extension for bytecode files like ".luaubc" or something similar.

@LoganDark
Copy link
Contributor

I have been looking into encouraging .luau but since the support is simply not there it is a hard sell to make. Definitely +1 for geting the ecosystem onto .luau instead of .lua.

@Bristlefrost1
Copy link
Contributor

I'm currently working on a PR to make .luau the default extension with .lua as a fallback option.

I'd also like to send PRs to both linguist and VS Code, but the problem is that Luau isn't really a thing outside Roblox and hence isn't likely going to be accepted as a PR. It simply wouldn't be worth GitHub's and Microsoft's time to support a language used by only one game, at least in their opinion.

zeux pushed a commit that referenced this issue Nov 6, 2021
As discussed in the issue, Luau has evolved from Lua to the point
where a new default extension `.luau` would be needed.

This change makes the REPL and Analyze look for `.luau`
extension first and if not found, fall back to `.lua`.
zeux added a commit that referenced this issue Nov 8, 2021
Update file extension from .lua to .luau

Contributes to #97
@zeux
Copy link
Collaborator

zeux commented Nov 8, 2021

I've updated "getting started" guide to suggest .luau extension instead of .lua. Since the command line tools now support .luau as well, I think this can probably be closed. I've filed an internal ticket for supporting .luau in Roblox Studio, but realistically that's not the most important thing here as it barely has any functionality to work with .lua files -- the more significant changes would need to happen throughout the ecosystem. So I think this can be closed now; feel free to link issues for other tools that are extension-sensitive to this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

8 participants