5

Any opions/experience with Lua? Im using this language right now in my internship. Its suprisingly easy, but not as popular as javascript or c#.

Comments
  • 1
    If tables acted like arrays I probably wouldn't hate it as much.
    Mainly use it to write modules for tes3mp.
  • 3
    First of all Lua is not really comparable to C# or Javascript. It's more in the area of Python, Perl, Ruby, Groovy, etc.

    Lua is a nice language, with simple, but clean syntax. But I miss some basics, like built-in classes, the known workarounds with meta-tables are very messy.

    What I don't like about it, is adding new modules. I always fiddled around for hours until things work out. It would be nice if there was something like a standard library as in python so you could get started right away.

    I know that someone now will tell me that Lua can be very small, can be integrated to anything und only needs little ressources, therefore it should not have too much luggage to carry around. But for everyday use I just want to start programming and not build my own framework first.

    So I use Python for small scripts, although I would prefer the Lua syntax over that crappy indentation/missing-block-termination bullshit of Python.
  • 1
    @ddephor
    I love both Python and Lua, I don't really get what you find annoying about the indentation thing in Python... But okey dokey.

    I've never had many issues with packages, but that's just my experience and it all depends on what packages we're talking about.

    Python is a beautiful scripting language that, once you start to get fluent does it start to show its colours.

    Lua is great for embedded systems and games. Works great for projects too. If you want it to run fast, look into LuaJIT.

    But as @ddephor said, I do miss some basic functionality such as native classes.

    Lua has a simple base model, making it faster to learn.
  • 0
    @coolq The fact that a block is finished by reducing indentation instead of a real block-terminator is clearly bullshit.
    That means the indentation defines the implementation, if you change indentation, you get another implementation. Who came up with such idiocy?
    And if you mix up indentation you have to use external tools (editor, VCS, backup) to restore your program. The structure is not self-contained.

    And even if you don't mix it up, it's needlessly hard to read. Where does the 'else' block belong, to the first or the second 'if'? Is it right this way or did someone before accidently change indentation?

    And additionally even a good editor can't set the right indentation, because it can't anticipate your intention.

    All that would be better if there would be a block-terminator like any other language has. It does not have to be as long as 'end' in Lua, it does not have to be a C-like full block enclosement with brackets. A single character is enough and these problems are gone.
  • 0
    @ddephor
    Good IDEs such as PyCharm do an excellent job at correctly indenting your code.

    I fail to see your point, you should be indenting your code in the first place, when you use Python for long enough you get quick at identifying the indentation levels.

    And what is a "real" block terminator? Why can't it be what we already have, a dedent?

    If you do not correctly indent your code then it is likely you're writing spaghetti code 😛

    I find it very easy to read, in fact I find it much more readable than C precisely because there are no terminating characters. It feels cleaner.

    Python is shorter, cleaner and more readable. That is my opinion 👍

    How long have you used Python?
  • 1
    @coolq Don't get me wrong, indentation is important, without correct indentation every sourcecode will not be readable. But it should not be part of the syntax, and especially not a fundamentally important structural part that can change the behaviour of the code.

    I don't know Pycharm, but how can it set the correct indentation? It does not know when a block ends.
    If you have two nested 'if'-statements and then make an 'else'-block, how should an editor know to which 'if' that 'else' belongs?
    If a block just ends without a statement that explicitely ends the block (like a 'return' or 'break'), how should an editor know that the block is finished? It just can't.

    I use emacs and if set up for python it helps by toggling through the possible indentation levels every time I press 'tab'. But it cannot automatically set the indentation right like with any other language, where I don't have to check it, because with a single 'tab' my editor will do it 100% right for me.
  • 0
    @ddephor
    Why shouldn't it be it be part of the syntax?

    To increase indents you press tab, to decrease indents you press backspace. Quick and easy.

    "It just can't"
    Actually PyCharm can do that, just try it. It does it automatically.

    Don't use Emacs, use PyCharm. Don't use Nano, don't use notepad++ or IDLE. Not until you fully understand Python and are proficient at it.
  • 0
    I don't want to learn and use another editor for every language. So I use emacs, where the basic usage is the same for any language.

    But OK, I tried Pycharm and it can't do indentation right. It just lets the developer do it, it only handles one indentation level, that's all and no big deal. And I didn't find options for auto indenting.

    That's not what I expect from a dev environment.
    I want to set up my environment to the language used (at best automatically by file), then it should handle indentation so I don't have to use up my limited brain capacity for that. I want the right indentation when I press 'enter' to change to the next line or press a single key (usually 'tab') to have the right indentation immediately. I don't want to press 'tab' several times or even 'backspace' for correction.

    That works perfectly with emacs or Visual Studio. Fixing indentation manually is a very rare case there, except for Python, where the language specification prevents automatic indentation.
Add Comment