My current project at work is all in React, and I agree that JSX is great ... for generating JavaScript applications.
I also agree with SDPhantom that that generated Lua code is massively cringe-worthy. It's bloated, convoluted, overly verbose, visually unappealing (those underscores everywhere!) and just generally hard to read and follow.
Compare:
lua Code:
local window = New("WindowWithTitle")
-- ^ Let's pretend here that "New" is your constructor function,
-- and returns a valid frame with all the appropriate parts.
window:SetMovable(true)
window:SetWidth(512)
window:SetHeight(512)
window:SetPoint("CENTER")
window.title:SetText("Broxxigar the red")
local text = window:CreateFontString()
text:SetPoint("TOPLEFT")
text:SetPoint("BOTTOMRIGHT", window, "RIGHT")
text:SetJustifyH("LEFT")
text:SetJustifyV("TOP")
text:SetText("Even for an orc, Broxigar the Red was obsessed with honor ...")
-- ^ Truncated for the sake of brevity in this example.
local button1 = New("SmallButton")
button1:SetParent(window)
button1:SetPoint("BOTTOMLEFT")
button1:SetText("OK")
button1:SetScript("OnClick", function(self, mouseButton)
print("You pressed ok")
end)
local button2 = New("SmallButton")
button2:SetParent(window)
button2:SetPoint("BOTTOMRIGHT")
button2:SetText("Cancel")
button2:SetScript("OnClick", function(self, mouseButton)
print("You pressed cancel")
end)
window:RegisterEvent("UNIT_AURA")
window:SetScript("OnEvent", function(self, event, ...)
if event == "UNIT_AURA" then
print("Someone gained aura!", ...)
end
end)
Now there's no mystery variables, you're not creating a billion unnecessary tables and functions, and it's very clear to anyone who looks at it what's going on at any place in the code.