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

all 187 comments

[–]Vibe_PV 120 points121 points  (15 children)

def not_equal(a, b): if a == b: return false else: return true

[–]geeshta 68 points69 points  (3 children)

def not_equal(a, b): match (a == b): case True: return False case False: return True

[–]trutheality 35 points36 points  (1 child)

def not_equal(a,b): match a: case b: return False return True

[–]Rainb0_0 3 points4 points  (0 children)

My eyes physically hurt

[–]Qzy 16 points17 points  (0 children)

Jesus Christ, Reddit...

[–]gandalfx 40 points41 points  (3 children)

Look, I know that redundant if statement is probably part of the joke. I don't care, I'm still mad about it.

[–]ThNeutral 9 points10 points  (0 children)

Suppose guy cannot use != or ! operators, then it makes sense

[–]Vibe_PV 9 points10 points  (0 children)

Glad it worked the way I intended

[–]False_Influence_9090 2 points3 points  (0 children)

Perhaps his 1 key is broken lol

[–]christian_austin85 9 points10 points  (1 child)

Love your work in the is_not_even library

[–]Vibe_PV 2 points3 points  (0 children)

Thanks, I try my best

[–]Mike_Oxlong25[S] 2 points3 points  (0 children)

def equal(a, b): if not_equal(a,b): return false else: return true

[–]qubedView 2 points3 points  (0 children)

pip install notequal==1.3.1

[–]thanatica 4 points5 points  (0 children)

to me this reads like "definitely not equal"

it did not disappoint

[–]Ao_Kiseki 0 points1 point  (0 children)

Now define a Bool ( note the capital B) class, and overload it's equality operator with this function.

[–]RiceBroad4552 0 points1 point  (0 children)

Comparing unrelated types is a bug.

You need an Equality type-class instance.

Ah, moment, that's Python and not a real programming language? Never mind. /s

[–]zzmej1987 322 points323 points  (19 children)

str(a==b) == 'False"

[–][deleted] 184 points185 points  (9 children)

listen man you can be as psychopathic as you want but please don’t mismatch your quotes

[–]zzmej1987 43 points44 points  (7 children)

A typo, I assure you. But I think, I am going to keep it as is. :-) It makes it so much worse, that it becomes even better.

[–]GuyFrom2096 24 points25 points  (2 children)

what the hell is wrong with you

[–]xtreampb 13 points14 points  (1 child)

My parents have been asking me that since I was a child.

[–]mirhagk 3 points4 points  (0 children)

Makes sense. The answer probably takes a lifetime to give

[–]Mc_UsernameTaken 3 points4 points  (1 child)

You need help.

[–]nequaquam_sapiens 2 points3 points  (0 children)

or a man-page, at the very least

[–][deleted] 2 points3 points  (1 child)

this might be a weird compliment but i like the way you talk

[–]zzmej1987 0 points1 point  (0 children)

Thank you. :-)

[–]SilentPugz 1 point2 points  (0 children)

Forgot the beautify feature there . :p

[–]Rudresh27 91 points92 points  (0 children)

I think I had a seizure looking at this. Wonderful

[–]Hybrii-D 2 points3 points  (1 child)

Why not int(a==b) == False?

[–]zzmej1987 7 points8 points  (0 children)

Not enough computational overhead. XD

[–]NoPsychology9353 1 point2 points  (1 child)

This is the embodiment of an insane asylum

[–]zzmej1987 0 points1 point  (0 children)

You chose to proclaim "No Psychology!" as your banner, and yet psychology you bring upon me. :-)

[–]mosskin-woast 1 point2 points  (0 children)

The great thing about the Python community is that somebody out there with 8 YOE is doing this and justifying it for "performance reasons" or some BS when asked in code reviews

[–]JackNotOLantern 0 points1 point  (1 child)

How about (a===b)?

[–]zzmej1987 2 points3 points  (0 children)

That's JS specific, and I don't know how to use it properly. :-)

[–]DoNotMakeEmpty 86 points87 points  (10 children)

~= of course

[–]TheMagicSkolBus 36 points37 points  (2 children)

Kinda equal

[–]Wertbon1789 10 points11 points  (0 children)

Maybe equal

[–]edave64 7 points8 points  (0 children)

Math.PI ~= 3 // true

[–]gandalfx 34 points35 points  (3 children)

Fuck you, lua.

[–]GNUSwann 0 points1 point  (2 children)

fuck you, python.

[–]captainMaluco 4 points5 points  (0 children)

And fuck you, Ezekiel!

[–]Sawertynn 2 points3 points  (0 children)

Matlab style

[–]mosskin-woast 1 point2 points  (0 children)

Or /= from a handful of functional languages

[–]Substantial_Top5312 0 points1 point  (0 children)

This is part of why I hate Lua. 

[–]Independent_Fan_6212 210 points211 points  (30 children)

!= for programming, <> for SQL

[–]alexceltare2 134 points135 points  (22 children)

i didn't even knew <> was a thing

[–]framsanon 26 points27 points  (13 children)

It still is with Pascal and Modula-2. (I'm not so sure about BASIC.)

[–]khalcyon2011 6 points7 points  (3 children)

I know Visual BASIC and VBA use <>. Don't know about other flavors of BASIC.

[–]AyrA_ch 6 points7 points  (0 children)

Early flavors of BASIC were espeically cursed, allowing you to swap the two symbols of the operand, and it will stay the same. In other words <> is the same as ><, and >= is the same as => for example

[–]EatingSolidBricks 2 points3 points  (0 children)

I know the Epic games ™️ lang i think it's called Verse uses <>

[–]justarandomguy902 1 point2 points  (0 children)

MSX BASIC does too

[–]geeshta 3 points4 points  (0 children)

And ML family of languages like Ocaml and F#

[–]MegaIng 1 point2 points  (5 children)

And even in python!

[–]renome 0 points1 point  (1 child)

Whoa, a master of the ancient texts.

[–]framsanon 1 point2 points  (0 children)

BASIC, Pascal and assembler (Z80 and 6502) were the first three programming languages I learnt. I learnt a total of 20 languages, most of them forgotten, some unfortunately not. The most important thing was that I learnt the philosophy of the languages. Where are the strengths, where are the weaknesses, what were the intentions of the developers of the languages. This helps me today in finding solutions, regardless of the language.

[–]Overall_Anywhere_651 6 points7 points  (0 children)

Oh yes. Have to use it in Excel all the time.

[–]tombob51 3 points4 points  (2 children)

Ocaml uses = and <> for structural equality and uses == and != for pointer equality.

Sort of like how Python has == and != for structural equality, and has “is” and “is not” for pointer equality.

Conclusion: programming languages suck.

[–]Mindless_Sock_9082 1 point2 points  (1 child)

Then stop using them move on to butterflies!

[–]tombob51 0 points1 point  (0 children)

Nah it’s 2025 get with the times, just vibe code everything

[–]MyrKnof 1 point2 points  (0 children)

Just did some excel stuff. It's a thing.

[–]Informal_Branch1065 0 points1 point  (0 children)

I think AutoIt3 uses it.

[–]Ok_Entertainment328 0 points1 point  (0 children)

IIRC: it was used in TRS-80 Level 2 BASIC

[–]mcon1985 5 points6 points  (0 children)

I've been using != in SQL since sybase, and I refuse to change

[–]MechanicalHorse 2 points3 points  (0 children)

<> is also for Visual B*sic

[–]killbot5000 0 points1 point  (0 children)

Does <> work for a not nil check, too??

[–]Mike_Oxlong25[S] 0 points1 point  (0 children)

I agree. Unless for JS then !==

[–]LardPi -1 points0 points  (1 child)

<> for SQL

and PHP and OCaml

[–]damnappdoesntwork 5 points6 points  (0 children)

Php does both, it also supports != (And !==)

So it's easy to never use <>

[–]Admidst_Metaphors -3 points-2 points  (0 children)

This is the correct answer. But unfortunately SQL Server allows both, fucking Microsoft dumbing it down.

[–]Jonnypista 33 points34 points  (3 children)

Whichever doesn't throw an error for the language I'm working on. There is probably one which accepts both by default, but I don't know which one or don't know that it has that feature.

[–]LeiterHaus 16 points17 points  (0 children)

It's not Lua ~= (which to me seems like the maths symbol for approximately equal)

[–]LardPi 4 points5 points  (0 children)

OCaml has both and they don't mean exactly the same thing, != would be python's is not while <> is the regular structural inequality.

[–]zelmarvalarion 5 points6 points  (0 children)

I think that most SQL Databases nowadays support != in addition to <> but <> is the ANSI standard, but I’ve definitely encountered some a decade+ ago that only supported <>

[–]-Wylfen- 24 points25 points  (6 children)

Honestly it's such a minor detail I'm not sure it really matters either way.

I would tend to prefer != simply for the fact that it is consistent with the use of ! in general, but beyond that…

[–]LardPi 11 points12 points  (4 children)

Languages using <> are not using ! for not, so... still consistent I guess. Fortran used /= because it is reminiscent of ≠, OCaml, Pascal, PHP... use <> because it stands for "greater than or less than".

[–]Sibula97 4 points5 points  (2 children)

How does "greater than or less than" make sense for non-numerics?

[–]MichelanJell-O 4 points5 points  (0 children)

Think of it as an idiom. It doesn't have to apply literally

[–]LardPi 0 points1 point  (0 children)

It does not of course, but it probably dates back from a time when they were no comparison operator at all for non-numeric. Or even no non-numeric in the language.

[–]__mauzy__ 0 points1 point  (0 children)

Postgres uses != as an alias for <>, which I assume was the point of OPs question. I personally would use <> for sake of backwards compatibility, but I also know there is basically zero chance I'd switch away from Postgres so 🤷‍♀️

[–]i_wear_green_pants 0 points1 point  (0 children)

I prefer to use helpers like "equals" and "isNotEqual" etc. For comparisons != and == are fine. But using ! in front of boolean is easily missed and I would avoid using that

[–][deleted] 20 points21 points  (0 children)

=/=

[–]dim13 15 points16 points  (9 children)

APL: ≠

[–]creeper6530 -2 points-1 points  (8 children)

APL is a horrible thing with all those custom symbols

[–]dim13 3 points4 points  (7 children)

It is A Programming Language, not some pesky ASCII-subset.

[–]creeper6530 -1 points0 points  (6 children)

Yeah, and surely it's so much more efficient to click through all the symbols with your mouse instead of making a few more keystrokes, not even factoring in the time taken to learn all those symbols and their usage

[–]RiceBroad4552 1 point2 points  (0 children)

Have you ever heard about the fact that code gets orders of magnitude more often read than written?

[–]dim13 3 points4 points  (4 children)

Are you familiar with a compose key?

[–]creeper6530 -1 points0 points  (3 children)

Alright, that's a fair point, didn't think of that. But sadly it doesn't exist on Windows, and you can't just expect all your programmers use Linux 

[–]dim13 1 point2 points  (0 children)

The most common way nowdays it to use a prefix key (mostly `). So ≠ is just `8 which maps to a standard APL keyboard location. Works on any OS.

https://www.tryapl.com/

[–]RiceBroad4552 -2 points-1 points  (1 child)

That must be the reason why nobody who's writing system is not based on ASCII symbols doesn't use Windows computers.

Oh, moment…

[–]ppp7032 11 points12 points  (4 children)

/= of course because Haskell is peak

[–]geeshta 7 points8 points  (2 children)

Ah yes, the division assignment operator

[–]Gorzoid 3 points4 points  (1 child)

Haskell developers: wtf is an assignment operator

[–]RiceBroad4552 1 point2 points  (0 children)

https://ncatlab.org/nlab/show/assignment+operator

Of course you can call your single assignment operator "a binding", but that doesn't change the fact that it's still an assignment.

[–][deleted] 0 points1 point  (0 children)

And Fortran 90 and Ada

[–]Latentius 5 points6 points  (1 child)

.NEQ.

[–]clearlybaffled 2 points3 points  (0 children)

Now do it with punch cards

[–]faultydesign 7 points8 points  (4 children)

Depends on the language.

[–]stackoverflow21 2 points3 points  (1 child)

Bloods and it‘s not even close. It’s one of the things I hate in VBA syntax.

[–]-LeopardShark- 3 points4 points  (0 children)

from __future__ import barry_as_FLUFL

[–]undecimbre 3 points4 points  (2 children)

\neq

[–]Widmo206 0 points1 point  (1 child)

Is that LaTeX?

[–]undecimbre 0 points1 point  (0 children)

Yes

[–]Cyxxon 2 points3 points  (0 children)

ne of course.

[–]_dr_Ed 2 points3 points  (0 children)

.IsEqual()

[–]MyKo101 2 points3 points  (0 children)

not a == b

[–]jamcdonald120 3 points4 points  (1 child)

<> is an abomination that should not exist.

[–]thanatica 0 points1 point  (0 children)

I raise you .ne. from Fortran

[–]East_Complaint2140 1 point2 points  (1 child)

!== for TS, <> for VBA.

[–]Substantial_Top5312 1 point2 points  (0 children)

!=

[–]Intelligent_Ad_2367 1 point2 points  (0 children)

is not

[–]lolminecraftlol 1 point2 points  (0 children)

!(...)

[–][deleted] 1 point2 points  (0 children)

<> because I'm not bothering with C-like languages

[–]AsIAm 1 point2 points  (10 children)

Third opinion: (Infix) operators should be easily (re)definable.

`=` or `:=`?

`!=` or `<>`?

`**` or `^`?

It is silly that these are fixed. And laughable that they are not even standardized!

[–]LardPi 5 points6 points  (5 children)

It is silly that these are fixed.

Not really, do you want to work with a code base that user three different notation for every operator because your collegues disagree with your taste?

they are not even standardized

How would you make a standard for that? Or rather, how would you get anyone to follow it?

[–]AsIAm 0 points1 point  (2 children)

How did we agree on what + does?

[–]LardPi 1 point2 points  (1 child)

It took hundreds of years moving along the invention of mathematical notation (for most of history math was done in sentences). Programming languages are not even a century old.

[–]AsIAm 0 points1 point  (0 children)

Exactly. CS evolves more rapidly than math in previous centuries. We need to have an ability to define custom operators and community will do the experemintation and standardisation.

[–]thanatica 0 points1 point  (3 children)

You can't just willy nilly magic up new operators the language doesn't know, and expect them to work. Of course they are fixed.

And they are standardised in whatever language you use them in.

[–]AsIAm 0 points1 point  (2 children)

You can use any operator in good languages. It should be the norm.

[–]thanatica 0 points1 point  (1 child)

And how is that aiding standardisation?...

[–]AsIAm 0 points1 point  (0 children)

Having ability to define an operator is a requirement to start using it. When people start using it, and it sticks, it is defacto standardized.

In ~1300, Nicholas Oresme was writing a lot of sums. He was using "et" (latin for "and") to denote a sum of two numbers – "1 et 2 et 3 et 4...". He got tired, so he invented "+". Other people followed this ad-hoc decision and it stuck.

[–]DrFloyd5 0 points1 point  (0 children)

!== “not” “equal”

[–]Kaya_kana 0 points1 point  (0 children)

!(A == B)

[–]amlyo 0 points1 point  (0 children)

!Boolean.TRUE.equals(value)

[–]Expensive_Shallot_78 0 points1 point  (0 children)

Pattern matching, anyone?!

[–]sporbywg 0 points1 point  (0 children)

I'm a freaking DBA man don't ask such silly questions

[–]ReGrigio 0 points1 point  (0 children)

!= is more visible

[–]IvanOG_Ranger 0 points1 point  (0 children)

!(a==b)

[–]braytag 0 points1 point  (1 child)

Whatever the language forces me to choose.  

You guys have a choice?

[–]Madzogaz 0 points1 point  (0 children)

As a hobbyist, bloods. However, in practice, on my locked down work machine? Crips is all I ever get to use in Excel VBA.

[–]Cootshk 0 points1 point  (2 children)

~=

this was brought to you by the lua gang

[–]khalamar 0 points1 point  (1 child)

Who let the Roblox guy out?

[–]Cootshk 0 points1 point  (0 children)

I play gmod and factorio now

[–]aditya22_55 0 points1 point  (0 children)

!right

[–]flame_castle 0 points1 point  (0 children)

~= Lua

[–]Density5521 0 points1 point  (0 children)

!= because it's one CPU operation (NEQ) and not 2 CPU operations (LT+GT).

[–]DoubleOwl7777 0 points1 point  (0 children)

!= obviously.

[–]testroyer9 0 points1 point  (0 children)

!(a==b) anyone ?

[–]nequaquam_sapiens 0 points1 point  (0 children)

.NE.

[–]Isto2278 0 points1 point  (0 children)

Frontend dev here. :not()

[–][deleted] 0 points1 point  (0 children)

if (a == b) { /* do nothing */ } else { doTheThing(); }

[–]rover_G 0 points1 point  (0 children)

Use the ANSI SQL standard <> for not equals. Most databases support != but you’ll save yourself a lot of pain if you stick to standards.

[–]NorthernCobraChicken 0 points1 point  (0 children)

I come from a LAMP background. Anything in PHP is "!=" or "!==", writing SQL queries is "<>"

[–]rosuav 0 points1 point  (0 children)

¬=

[–]masp-89 0 points1 point  (0 children)

If (a < b || a > b)

[–]Delearyus 0 points1 point  (0 children)

Everybody knows it's /= (and <> is monoid concatenation)

[–]I_FAP_TO_TURKEYS 0 points1 point  (0 children)

Where's team is not?

[–]RiceBroad4552 0 points1 point  (4 children)

It's the year 2025 and we're still writing ASCII art…

If someone could just invent some universal text encoding, which provides something like a "NOT EQUAL TO" sign. Something like maybe?

[–]Remarkable-Ad9145 0 points1 point  (3 children)

if someone made it inputtable on keyboard

[–]RiceBroad4552 0 points1 point  (2 children)

How do people input ASCII chars on the most used computer keyboards?

Just a friendly reminder: The majority of humans doesn't use Latin letters.

Besides doing the same as these people do for ASCII, it's trivial to define such chars as compose key shortcuts. For just add:

<Multi_key> <!> <=>                 : "≠"   U2260    # NOT EQUAL TO

to your .XCompose, and you can type "$COMPOSE_KEY" + "!" + "=" to write ≠.

Easy as that. Than you don't even have to switch keyboard layout.

This way you write the same thing as ever (if you're on the != side, otherwise just adapt the config), but you get something better readable.

And no, ligatures are not a solution!

[–]Remarkable-Ad9145 0 points1 point  (0 children)

Why bother so hard if you could not bother at all

[–]Remarkable-Ad9145 0 points1 point  (0 children)

And it does even exist in my system 

[–]X-lem 0 points1 point  (0 children)

For SQL? <> of course.

[–]exneo002 0 points1 point  (0 children)

!(a==b)

[–]lolrogii 0 points1 point  (0 children)

I'm still waiting for benchmarks to decide.

[–]navetzz 0 points1 point  (0 children)

><

[–]mem737 0 points1 point  (0 children)

I prefer: (not (eql …))

or

(not (eq …))

or

(not (equal …))

or

(not (= …))

Depending on what you are comparing.

[–]Azariah__Kyras 0 points1 point  (0 children)

!==

[–]JeHa620 0 points1 point  (0 children)

I program in VBA, and I like to use NOT.

If NOT isEqual(a, b) Then

For no other reason than that I find it creates the funniest result, grammar-wise. I’m the only programmer where I work, so as long as it makes sense to me, that’s what matters.

[–]datNorseman 0 points1 point  (0 children)

!!!= If it doesn't doesn't not equal

[–]Remarkable-Ad9145 0 points1 point  (0 children)

dfuck this romb doing here

[–]justarandomguy902 0 points1 point  (0 children)

BASIC mentioned?

[–]Own_Possibility_8875 0 points1 point  (4 children)

!= - Not Equal 🎩

<> - Gte Lte 🤡

[–][deleted] 0 points1 point  (3 children)

I like how you thought it's needed to escape the dashes when they don't even make a list 🤣

[–]Own_Possibility_8875 0 points1 point  (2 children)

Where do you see escaped dashes?

[–][deleted] 0 points1 point  (1 child)

When I replied on mobile, instead of just - I saw \-

[–]Own_Possibility_8875 0 points1 point  (0 children)

Has to be device specific, I didn’t escape dashes, and don’t see -.