Allow "not equal to" operator "~=" in Luau to be written as "!="

I’m not most people, I don’t restrict my creative process just because one of the Lua creators couldn’t understand the difference between “Aproximate” and “Not Equal To”.

Roblox already recognises “!=” as “~=” and suggests you change it, there’s no reason this can’t be changed to be interpreted as “~=”.

I will not surrender to a new font when even the default studio font has this issue.

1 Like

In mathematical terms, you would be correct. However, Luau is a programming language where they decided ~= represents a relational operator. There is no “wrong sign” here because mathematics and computer science are two different fields that conform to their own rules.

4 Likes

This just seems pretty pointless, and at best a great way to make luau more confusing for beginners. As if this were implemented there’d be 2 symbols that mean the exact same thing, plus ~ is already being used in the type solver for negation types.

Luau nor roblox decided this, this is a decision made by the Lua devs back in the 90s

What about this is more confusing than 95% of languages using != instead of ~=. Many people attempting to learn lua will most likely know Python which uses the common !=.

If you wanna talk about confusing, look at the roblox documentation, I’ve never seen anything worse.

I guess Lua is just 5% of languages.

Many people attempting to learn lua will most likely know Python which uses the common !=.

Really? I would assume that a lot of the beginner developers just learning Lua will learn it from Roblox. And given Roblox’s younger audience, I would think that Lua might be their first language. Having an interest in development a while ago (when I first started Roblox), Lua was my first language from which I later branched into Python and more.

Python and Java are usually taught in schools in the US, so I guess != may be more commonly seen for those who have studied a bit of programming in academics.

I do think that consistency should be maintained. It would be weird to see both != and ~= in the same script (heck, same conditional), though I think any programmer who has seen both of those operators once will not be faltered. I don’t think that it’s something significantly confusing to the average developer. So, I believe that the != vs. ~= argument is trivial since whichever representation is used does not, in my opinion, significantly slow down a developer. I mean, if you are using negations everywhere, there’s probably a more readable way to rewrite that.

With respect to those newer to programming in general, those still grasping Luau and propositional logic might have an uncomfortable time reading code containing both != and ~=.

In agreement because if you learn multiple languages, they all have quirks in how they write syntax, but basically “mentally” the same. Sure, != makes more sense to me than ~= because most of the languages I’ve learned over the century have used this. At the same time, it’s easy to “flip” my brain into Luau mode.

I don’t think a lot here realize that some languages use == for “sorta equal to” and === for “exactly equal to” or even more fun with != and !== or just one = to compare equal something, you have to learn to recognize all the uses and differences. :thinking:

2 Likes

Someone’s discovered the wonders of JavaScript I see.
A language so buggy and broken they had to add a “super equals” just to make sure you aren’t comparing the number 5 to a string “5”.

4 Likes

Who actually made the decision is irrelevant in this case, my primary point is that Lua/Luau is a programming language that conforms to the rules of its field (computer science) and not the rules of the mathematics field he wants it to so badly conform to.

1 Like

i think you alone on this :broken_heart: not worth fighting fo

many people learning luau are first time game devs (children), also lua is widely used in game dev spaces and i havent seen a game that prominently uses python

Well, it is a minor annoyance and I can guarantee you that it is not a problem worth talking in the DevForum. Sure it is quite an idiotic that the math logic and the Roblox studio logic don’t align, but posting it in the DevForum is a little to far.

So you’re saying not X == Y isn’t confusing to new developers?

I don’t understand how it would break legacy code if you couldn’t use != from the start since Roblox literally yells you to change it to ~=.

I also use Jetbrains Mono that changes >= to ≥. Using ~= doesn’t change it to ≠ and it looks really unappealing.

Sorry for bumping this one month later

This is wrong, you even get a warning for writing this because of it’s ambiguity.

image

Sounds like something that can be fixed from within your IDE, maybe as a setting

2 Likes

I think you didn’t understand me, I said not X == Y is confusing for new developers.
It’s not even correct because not 5 will return false, basically you gonna compare false == 4 which will return false unless the 4 becomes a false boolean.

About the IDE one I’m not so sure, I’m using Roblox Studio so I doubt there’s personalization for it.

It would be nice if we got negation using !. Using if !Player.Character then return end makes it look nicer than typing not.

2 Likes

Yes I just wanted to notify you that the syntax was wrong :upside_down_face:

I thought you said you were using Jetbrains Mono?

Luau would never receive this feature under the current guidelines:

Whenever new syntax is introduced, we need to ask:

  • Is it backwards compatible?
  • Is it easy for machines and humans to parse?
  • Does it create grammar ambiguities for current and future syntax?
  • Is it stylistically coherent with the rest of the language?
  • Does it present challenges with editor integration like autocomplete?

[…]

In addition to these questions, we also need to consider that every addition carries a cost, and too many features will result in a language that is harder to learn, harder to implement and ensure consistent implementation quality throughout, slower, etc. In addition, any language is greater than the sum of its parts and features often have non-intuitive interactions with each other.

From: GitHub - luau-lang/rfcs: RFCs for Luau evolution

The ! is not stylistically consistent with the rest of Luau’s syntax, and serves no functional purpose other than being a synonym.

Languages are different. Over the past few years I have written less and less Luau code compared to code in languages which have similar features like you describe (single-character negation, !=), but I am not angry at Luau for not having these features when I write Luau code every once in a while. You grow use to them, and you understand that it really means nothing in actual programming. It doesn’t matter. The ~ is literally right next to the ! key anyway. Learning multiple languages and becoming use to their differences will simply make you better at programming, which is language-independent, and will make it easier to learn new languages as well.

1 Like

It’s a font

1 Like

This post was solved two years ago, its not being added because it would be inconsistent with vanilla Lua and other dialects of it. (unless you’re glua and that ended well).

God damn it :sob: I’ve been finessed

1 Like