Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Lua Sucks!

  • Please log in to reply
6 replies to this topic
  • Members
  • 920 posts
  • Last active: Nov 02 2012 09:54 PM
  • Joined: 20 Dec 2004
Why does Lua suck?

[*:9zdd9mfh]Because it's a stict-ass MF, which makes it so you can't debug code easily...

I'm trying to edit youtube.lua (from VLC, which unfortunately uses Lua, ugh!). The code is failing, so I'm trying to find out why. I NEED to see the value of vars at different points in the script, to find out why it's failing, so I write this...

vlc.msg.info('youtube.lua debug - return 1 - path('..path..')')
...& I get an error msg...

attempt to concatenate global 'path' (a nil value)

...I'm only trying to concatenate "a nil value" cuz the earlier code is failing & setting path to nil, why can't it just tell me the value is nil...by using my debug code, instead of bombing out?

So then I write this UGLY ASS code to workaround Lua being a dumbass...

if path==nil then

		vlc.msg.info('youtube.lua debug - return 1 - path('..path_disp..')')
...I have to invent a new var, just so I can output 'nil', when it's nil.

Note: If you have an alternate solution to this problem, plz post it! -- How do I output ANY VAR, regardless of what its value might be? -- this means output nil if it's nil / don't complain that you can't output nil.[/list]

[*:9zdd9mfh]if then end (aka: not using braces for blocks) is retarded: you can't easily find the end of the block...but with braces, you can.

[*:9zdd9mfh]Not having != is retarded: I can easily do ==, but I forget every time what Lua changed != into!

[*:9zdd9mfh]Not having ++ & += is retarded: there's just NO REASON to not have them! (dumb Lua wants: var=var+1)

[*:9zdd9mfh]Using .. for concatenation is annoying: + (plus) works perfectly fine for concatenation AND adding (in JavaScript).

[*:9zdd9mfh]Using nil instead of null: I mean, just, WTF?, come on...why?[/list]
Basically, there is NOTHING about Lua that makes sense or is good.

Bottom line: If I could avoid writing in Lua, I would. As a language, it just sucks. But it's embedded in VLC, so I must use it. I just wish VLC would embed AutoHotkey or JavaScript...then I could use a REAL language! -- & get stuff done, instead of fighting with STUPID error msgs -- "errors" that are not even errors! -- they are only "errors" cuz the language wants to be strict & act like they are problems worth complaining about, when they are not.
Useful forum links: New content since: Last visitPast weekPast 2 weeks (links will show YOUR posts, not mine)

OMFG, the AutoHotkey forum is IP.board now (yuck!)...I may not be able to continue coming here (& I love AutoHotkey)...I liked phpBB, but not this...ugh...

I may not reply to any topics (specifically ones I was previously involved in), mostly cuz I can't find the ones I replied to, to continue helping, but also just cuz I can't stand the new forum...phpBB was soo perfect. This is 100% the opposite of "perfect".

I also semi-plan to start my own, phpBB-based AutoHotkey forum (or take over the old one, if he'll let me)
PM me if you're interested in a new phpBB-based forum (I need to know if anyone would use it)
How (or why) did they create the Neil Armstrong memorial site (neilarmstronginfo.com) BEFORE he died?

  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
Been a while since I looked at lua but I think you have to instantiate each variable with a value to avoid
Never lose.

  • Members
  • 237 posts
  • Last active: Apr 14 2015 01:57 AM
  • Joined: 19 Dec 2010
Why not use tostring?
And I don't know how someone could hate lua, I find it to be enjoyable.

  • Guests
  • Last active:
  • Joined: --
yo lua is an awszum prog lang and i luv it

  • Guests
  • Last active:
  • Joined: --
Design decisions are made for a reason. It seems like your needs are rather different from those of the Lua creators. For instance, ~= means "not equals" just as much as "!=" does. After all, ~ and ! both mean NOT in a lot of C-like languages.

Lua names things differently because it has different design goals in mind; nil is not a null pointer, as you imply, but rather an absence of a value. Keywords are used instead of block braces because they are also used for table literals, and this can confuse people new to programming (I know it did for me when I was first using it in AHK_L), as well as the fact that they read like English (a decent editor will allow you to fold code just like any other language). I mention these because they are conscious design decision to cater to a niche that probably does not include the author of the first post.

In conclusion, it might not be right for one person, but that doesn't mean it is without merit for another. Lua isn't the be-all end-all language - no language is.

  • Members
  • 411 posts
  • Last active: Aug 06 2013 05:00 AM
  • Joined: 05 Dec 2010
Lua is used in many programs because its cross compatable with different operating systems, its lightweight, and easy to embed/use.
Autohotkey is Windows only, is not embedable, definatly not lightweight, and is sometimes not easy to use.

[*:9zdd9mfh]if then end (aka: not using braces for blocks) is retarded: you can't easily find the end of the block...but with braces, you can.
This is what indentation is for, for example:

    blah blah blah
    if apple == "cheese" then
        blah blah blah
    blah blah blah

I do agree with the fact that lua doesn't have a ++/-- or +=/-=

  • Members
  • 1 posts
  • Last active: Oct 29 2013 08:10 PM
  • Joined: 25 Oct 2013

One of ways is to use tostring() function:

vlc.msg.info('youtube.lua debug - return 1 - path('..tostring(path)..')')

Another way, through i'm not sure it will work in VLC's Lua, is to attach global metatable to all Lua strings (already acquired and future) and reload concatination operator:

-- Somethere in Initialize() or main chunk
require("debug").setmetatable("", {
    __index = string;
    __concat = function(a, b)
        local mt = debug.getmetatable("")
        debug.setmetatable("", nil)
        local res = tostring(a) .. tostring(b)
        debug.setmetatable("", mt)
        return res

-- in middle of run-time
vlc.msg.info('youtube.lua debug - return 1 - path('..path..')')

-- In something like finilize()
debug.setmetatable("", { __index = string; })

The problem with this approach is that there can be other developers code which excepting to get error on concatination string with nil, for example, if they are using pcall/xpcall. But this approach shows a course of life of evolution of Lua: you can implement everything with a lot of different ways which suites you more and if this gets popular it will be included in core, perhaps in Lua 6.0 you will not have to use tostring() for concationation with nils.