Open akefirad opened 2 months ago
While I have no authority here, I can state my opinion, which is that you should learn Lua. It is an easy to learn language with a lot of utility. With regards to this project, Vifari is made possible by Hammerspoon, which is a bridge between the OS and Lua. Once you learn Lua, you might find all sorts of other uses for Hammerspoon. Then when you join the cool kids in Neovim and WezTerm, you’ll be ready as well as they both use Lua for their configurations.
Sure, but if I use TS2Lua I should be able to enjoy all of the above you mentioned (theoretically). That's the whole point of TS2Lua. After around 20 years of coding, I learned that I'm not smart enough to work without a type system 😁
@akefirad thank you for your interest, but I guess not atm 😉
Basically the reasons are very similar to what @pkazmier have said:
Overall you need 2 core features - accessibility api (for keys) and fast canvas painting (for labels). If those are slow or problematically implemented, then everything just not works. And IMO hammerspoon is the most mature OSS automation framework for macs with practically no competition atm. At least I dunno any other solid alternatives w/o going to compile languages.
To do it properly in TS I guess it might be possible a) with external mac automation npm libs, which I guess there are none atm, but maybe I'm wrong b) with writing custom FFI binding code, which... may work, but a big long-term headache I guess.
Personally, can't say I'm a fan of lua - more a neutral attitude (just one next language again 🙄), but it is very-very simple and easy to read and fix if needed. Mostly you need to get used to lua tables (which are both arrays and hashes) and that's it. And it is the language of Neovim, Hammerspoon, WezTerm, so people use it anyway for scripting.
On the other side, looks like TS2Lua is a thing. But why need lua at all then? I mean lua is because of hammerspoon mostly. And the choosing cycle repeats.
So, I guess if you know a way to do Accessability and Canvas "natively" in TS it may be worth it for better tooling and larger community. If not, I guess it will be simpler to stay just as lua script.
P.S. There are couple of things really missing in lua that may make all better:
there is no real parallel execution - all is a single thread including Hammerspoon itself. This is a huge PITA as it requires soft passing of control, or app becomes unresponsive. Plus I can't browse accessibility tree really in parallel - only one by one. That's why it is a bit slow.
there are distribution problems - e.g. ideally it should be brew install vifari
, but even if you can attach hammerspoon as a dependency, you need a custom editing of hammerspoon config later on. Or you are stuck with git distribution like neovim is doing which is very not ideal either.
Those 2 problems IMO doesn't have any solution in foreseable future for lua.
Thus, I guess the answer is maybe if we can find interesting resolution to above problems.
This is great project. I'd like to contribute to this as much as I can. But I'm not quite comfortable with Lua. Any chance you might consider using TS (transpiled to Lua, e.g. TypeScriptToLua)?