06/Feb/2021

Updated on 20/May/2021

-- I really like, or want to like, Lua for many reason, either because it's
-- so simple and concise, so lightweight and lean for a scripting language,
-- or for it being made in Brazil (come to Brazil).
-- But it has some small details that individually make me annoyed, and
-- together make me always not like use it after some time.

-- I will mark them with
-- :| for minor stuff
-- :( for kinda annoying stuff
-- And them give an example on how I'd want them (not 100% accurate)
-- None of these are major, they are only nitpicks

-- Comment notation :|
-- the "--" are fine
-- it's the multi line ones ( --[ --] ) that are ugly,
-- specially the levels thing
-- Fix:
--/
    Random stuff --/ can be nested /-- here
/--

-- Contrary to most people, indexes starting at 1 is fine
-- 0 index is nicer but 1 is not that bad

-- writing 'function' can be long :|
-- function -> fun (can be just an alias)

fun something()

end

-- No switch statement :(

switch thing
    case 3 do
    -- ...
    end
    case 7,8 do
        -- multiple case values
    end
    default do
        -- if everything else fails, do this    
    end
end

-- no 'continue' for loops :(
-- without it you need to use 'goto' (WHY?)

while true do
    if (x%3) == 0 then continue end
    -- ...
end

-- meh way to write 'for' loops :(

for j=2, j<=10, j += 1 do    -- also the "+=" and "-=" operators, their lack is :(
    if j != 0 then           -- "~=" to "!=" operator, the default is :|
        -- ...
    end
end

-- 'elseif', a very stylistic choice thing :|

-- variables global by default :|
-- having to write 'local' for 90% of vars, 
--     specially if you want to initialize without assigning :(

-- have variables be local by default
-- have a keyword to initialize default vars

my a
my b = 2
our c -- global

-- yes, I like myself some Perl

-- can't index strings :(

my stringo = "egg"
if stringo[1] == "e" then
    -- ...
end

-- Or at least a simple way to turn a string into a table

if stringo.chars()[2] == "g" then
    --...
end

-- no way to set fixed var/param types :|
-- of course these would be optional,
-- it's simply a bit more of useful detail

my number someone = 2
my string sometwo = false -- give error

fun sus(number somegg) gives number -- also give the return type
    --...
end

-- in the same vain, no true constants :|

my PI is 3.14
our PIE is "apple and cinnamon"

-- 'is' for const, '=' for vars

-- no structs/classes :(
-- built in structs, preferred to classes if you at least
-- want to keep it simple
my Vehicle is struct {
    model,
    number speed,
    horn = "honk",
}

my lil_one = Vehicle{"500", 120}
my lil_two = Vehicle{speed=200, horn="beep", model="NSX"}

-- string.char(v) will halt the program if v isn't an ASCII val :|

-- no function overloading :|
-- it's not necessary, but can be useful for having nice code
-- though, I agree that the C++ way of doing it (having two functions
-- with same name but different parameters) is kinda dumb

fun area_square(heigh, length)
    -- ...
end
fun area_circle(radi)
    -- ...
end
my area(...) = fun {area_square(height, length), area_circle(radi)}

-- or something else, it's an example, not exactly how I want it.

-- Metatables feeling weird to use and limited :|
-- This is more of a personal thing, as I generally feel most
-- metaprograming in languages is weird do use. So I don't even have
-- a 'fix' for this one, it's simply meh for me, maybe a Rust-like trait system?

-- These were all my nitpicks/wishes that I had in my mind right now,
-- feel free to tell me how I'm wrong :)

Comments
HTML Comment Box is loading comments...