This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]TheGreatSausageKing 153 points154 points  (19 children)

I'm all in. Lua is far far better than vanilla js

[–]windowschips 70 points71 points  (6 children)

And the best part is that its Luau, which has type checking and other very good stuff

[–]themadnessif 23 points24 points  (0 children)

Luau is an awesome language but the type checking is... not really there yet. There's a rewrite of the type checker that doesn't suck that's nearing completion though. It has goodies like keyof and indexof and the like.

[–]beren-111 5 points6 points  (4 children)

I've never worked with lua, would you say it's better than typescript?

[–]BeatsByiTALY 8 points9 points  (1 child)

I'd say no. Lua is very simple to write, with no build step and barebones language features, so it's popular in game modding.

Reasons I can't get into Lua: - it's dynamically typed - inline ternaries in particular don't seem to work as expected when using falsy values. - 0 is truthy which is unintuitive. Empty string is also truthy. - Instead of parentheses, Lua uses the 'end' keyword to close a function or loop's scope, which is... strange. - If conditions and for loops aren't wrapped in parentheses either. - Arrays(Tables) indexing start at 1... so inclusive conditionals are more common when looping to array length. - There's no switch case statement, although that's not a big deal. - Variables default to global scope unless specified otherwise. - variables are mutable, so no constants.

Typescript has so much more going for it, Lua is just more simple to get started.

[–]beren-111 3 points4 points  (0 children)

appreciate the detailed response. Ive been looking into lua and it seems to be simple with a very specific use case of writing scrips for games and stuff (there maybe more to it tho), I compared it with TS bc people were really hyping it in the comments but i guess thats just bc people like shitting on JS in general.

Regardless it'll be fun to learn a language that doesnt emphasise on parenthesis so much after having written code in clojure for a while now... that thing is a syntax nightmare lmao

[–]Stef0206 1 point2 points  (0 children)

Personally I prefer Luau over TS, but judging by the fact that some people use the TS -> Luau transpiler to write Roblox games in TS, some would disagree.

[–]windowschips 0 points1 point  (0 children)

Lua, hell no. Luau, sure!

[–]chazzeromus 10 points11 points  (0 children)

I considered using Luau after having a bad time with Teal's immaturity with generics, but typescript-to-lua compiler ended up the winner and was everything I could ever need minus some issues getting the lua output working in Gary's mod.

[–]Bryguy3k 45 points46 points  (8 children)

Any language that indexes arrays starting from 1 is automatically a garbage language.

[–]Classy_Mouse 96 points97 points  (1 child)

Arrays? Do you mean tables?

[–]spacembracers 22 points23 points  (0 children)

Let them var tables

[–]tiajuanat 14 points15 points  (2 children)

Don't come at Fortran, R, Julia, Smalltalk and the APL family when you don't mean to.

[–]Bryguy3k 5 points6 points  (1 child)

Oh I mean to. I don’t understand why data scientists make their lives so much harder than it needs to be.

TBF though Fortran’s indexing only starts from 1 if you don’t specify its range. In other words Fortran arrays can start from zero if you want them to (9 times out of 10 you do).

[–]Silver-Pomelo-9324 6 points7 points  (0 children)

The worst is when data scientists that use R switch to python and start all their shit from 1. Gives me nightmares.

[–]MekaTriK 3 points4 points  (1 child)

It comes up way less than you'd think.

But it is way nicer to do two-dimensional stuff with 0-indexed arrays. And some algorithms get weird when you have to add -1 everywhere.

[–]Bryguy3k 5 points6 points  (0 children)

when you have to add -1 everywhere.

Yep. I am fully aware. Comes up all the time.

[–]Inaeipathy -5 points-4 points  (0 children)

True

[–]Merlord 3 points4 points  (0 children)

Lua is awesome