You can imagine my pain when back in school they made us use some shitty CASE software (Computer-aided software engineering) that uses its own language that lets you code either in french or english, or both at the same time if you want to. And they also have a chinese version.
We do code reviews as a service, and have so often encountered French, Dutch and German variable names, documentation/comments, method names, etc. The whole idea that maintenance of the code might some day be outsourced to someone non-native often does not occur
I've seen that happen, only with additional cost as "we'll need to test more to ensure the changes don't introduce regression, and we'll need to reverse engineer the working"
Because why would you ever? That seems like such a fucking headache writing a compiler, and syntex tree parser for a foreign langauge... if I was asked to program that, I'd probably leave the industry
...What? Why would you need to write a custom compiler? The picture clearly shows a program written in standard Python. They've just chosen to write the variable names in Japanese, which is perfectly allowed. Variable names are just text; the compiler doesn't have to learn to speak Japanese, any more than it knows how to speak English.
Someone on the Python Discord wrote something to mangle source code (basically translating characters using these) and it was horrible. The code still ran fine though.
There's less room for jank there than you might think. Python normalizes variable names, so as far as it's concerned 𝓷𝕦𝘮𝖇ℯ𝚛, 𝓃𝔲𝕞𝚋ⅇ𝓻, and number all refer to the same variable.
This is one of the things they did. It was one of the staff members or something on the Python Discord (I don't remember their name and I don't hang out there anymore). I remember that we were having a pretty hoity-toity conversation about unit testing and the Python AST among other things then we started talking nonsense like this.
English is native to the compiler... are you dumb? And what do you mean no? Show me on language that's not super obscure that isn't based in english...
Writing a language in a different language is just as easy/hard as writing an English based language. The problem is just that this language would not be very used or liked and that's for a good reason. English is the way to go in programming, always.
I’ll see people use other languages in malware to make it harder to read and work with. I was decoding a PHP webshell the other day and some took I wanted to use wouldn’t parse the characters in other languages.
Idk if people are joking around when they say there's not a lot wrong with it, but this is actually terrible code. Not for the use of Japanese, but from the code itself. Since this sub is about explaining why code is bad, I'll give it a shot. I probably will miss some stuff. If num1 or num2< 0 will almost always return true no matter the numbers. (if num1 is 0 and num2 is less than 0 that would be the only false. Negative num1 will return true). Setting the 正 to True and then just returning not True is unnecessary. That addition function will sometimes return a boolean instead of a number, which is unexpected behaviour for an addition function. The triple not is silly but w/e. For false, why use 雨 (rain)?If you're trying to replace true and false with characters, do it at the top of your code and perhaps use the translation consistently.
My guess about the 雨 is that it's one of those real life examples that teachers use teach boolean algebra (like "is raining" or "not weekend" = not party, or something like that)
I'm not sure if this is somehow makes sense in python, but the function 数を計算する(数1, 数2) seems either completely superfluous or should be somewhere else rather than in the middle of another function.
and it uses the concept of truthiness. If num1(Assuming it's storing an integer) is greater than zero, it'll return True regardless of the value of num2 XD Doing if num is the same as doing if num>0, other examples are if len(array) > 0 and if len(string) > 0.
I mentioned it in the comment, but "if num" isnt the same as "if number>0". It's equivalent to "if !!num". So only if num is 0, (or None or undefined) it will return false, all other values will return true.
This honestly looks like a fun way to learn two things at once. Probably someone learning their first bit of python and practicing their Japanese simultaneously.
People here say they could roughly figure out what's going on even without the text, so this could also be used the other way around: Learn a new language and coding through "code stories".
Kind of an ultra specific market by aiming at people who try to learn programming and a language at the same time, but honestly sounds like a format with potential.
Well the first not coerces it to Boolean, but then it's the wrong Boolean value, so the second not converts the Boolean back to the correct value, then obviously they need to check the opposite of that, so they slapped a not on that bad boy.
It's probably just to quickly knock together something funny. For that, it's alright code.
The only thing that gets on me nerves is the if not not not 雨, so is it not not not raining, or is it? (雨 means rain)
I am now itching to start using non-ASCII variables, but I fear it might anger my coworkers, because they are "special" characters and that "should not work". Or something. Maybe I'll give it a go, for funsies.
Aside from the fundamentally wrong part, actually we do something like this depending on problem domains and whom we are writing for. Non-Latin identifiers are indeed harder to type, but attempting to translate technical terms with no well-known English translations is likely to create more problems.
I would have just returned the sum in that first else statement to make match the if statement, why assign it to a variable then return that when you can just put a return on the line
I don't understand, this shouldn't work, right? I mean does python interpreter understands foreign language variables and function name? I don't think so, how come?
I kind of had to appreciate it once, though having a laugh, when working with Chinese devs and I saw the variable read了 to differentiate from the method read , since the present and past tense are the same in English. He didn't want to put readed
I mean they are the same in Chinese too (no tense) and we can argue linguistics about this variable, but it was something immediately everyone understood and it added clarity.
It was just an absolute pain to switch keyboards mid-word every time I used the variable and I ended up committing a change to lines or result or something like that
As recommended by the Unicode Identifier Annex, which Python more-or-less implements straight, 1) identifiers are still limited to letters and numbers, and 2) all identifiers are NFKC-normalized. This eliminates most if not all possible homoglyph issues. For example, Ⓓifferent will be normalized to Different internally.
I mean does python interpreter understands foreign language variables and function name?
Heck, the Python interpreter doesn't understand English language variables and function names. It doesn't care if you name a variable apples, apyls, ayhsjkui, or りんご. It's all just text.
To clarify, Python does not let you stick emojis or random garbage symbols in there, it still mostly restricts you to letters and numbers, but since 2007 it supports letters and numbers from other languages. Which is perfectly reasonable; I mean, programmers from other countries exist, and there's no reason to prevent people from writing in their native language if they want to.
In Poland government own software is often wrote with polish var names, I believe it is one of requirements in the contract, but it looks horrifying to see random polish jestPapiezMartwy when a broken English is a standard naming convention.
name = input("Please enter your name: ")
emoticon = "(°▽°)/ 🙇"
print("Hello {}! {}".format(name,emoticon))
def addNumbers(number1, number2):
true = True
if number1 or number2 < 0:
return not true
else:
sum = number 1 + number2
return sum
print("sum =", addNumbers(6, 9))
rain(?) = False
counter = 1
if not not not rain:
while counter < 11:
print(str(counter) + ". 😂😂")
counter = counter + 1
God trying to format that on mobile sucked, and I probably got some of that wrong anyways.
You can use double negation to convert from truthy-value to boolean, maybe the programmer wanted to do something like that. But you usually do double negation, not triple. Triple negation should have the same effect as single negation also on truthy values.
I think I’m Japanese but I don’t have any idea about the “not not not 雨”. And besides , 数を計算する is not wrong sentence but 足し算をする is better expression for the function which is just add up. So the code might be written by not a Japanese speaker or I’m ignorance.
not sure about Python, but in Ruby || and “or” have different precedence, so they are not equivalent. work went through a phase a few years ago where everyone thought it was hip to use the words “and” “or” instead of the logical operators not realizing that the words are flow control constructs borrowed from Perl, such as: “file.close or die”. or in Rails: “render and return”
we spend years correcting all the logic errors introduced by those changes.
They do completely different things, so there isn't really any style choice to be had there. In general the only reason to use binary OR is if you're doing bit manipulation. I.e., 0b00101 | 0b10110 == 0b10111.
595
u/delta-samurai Aug 27 '21
This is the first piece code I've ever seen in another language
101
u/WpGgs Aug 27 '21
not not not sugoi
58
u/uselessgd Aug 27 '21
print(str(????) + ". 😂😂")
35
u/valschermjager Aug 27 '21
needs no comments. naming of variables and functions are self-documenting. obviously.
58
u/ThatDudeBesideYou Aug 28 '21 edited Aug 28 '21
Idk if people are joking around when they say there's not a lot wrong with it, but this is actually terrible code. Not for the use of Japanese, but from the code itself. Since this sub is about explaining why code is bad, I'll give it a shot. I probably will miss some stuff.
If num1 or num2< 0 will almost always return true no matter the numbers. (if num1 is 0 and num2 is less than 0 that would be the only false. Negative num1 will return true).
Setting the 正 to True and then just returning not True is unnecessary.
That addition function will sometimes return a boolean instead of a number, which is unexpected behaviour for an addition function.
The triple not is silly but w/e.
For false, why use 雨 (rain)?If you're trying to replace true and false with characters, do it at the top of your code and perhaps use the translation consistently.
19
u/mpcs127 Aug 28 '21
if not not not 雨what the fuck21
u/metalovingien Aug 27 '21
Bad because I see too many English words !
18
u/awatt23 Aug 27 '21
This honestly looks like a fun way to learn two things at once. Probably someone learning their first bit of python and practicing their Japanese simultaneously.
8
u/RedEyesBigSmile Aug 28 '21
line 7 and 17 really want to make me commit seppuku.
But tbh I like the color scheme
8
u/ReporterNervous6822 Aug 27 '21
Need 2 more nots so it should be not not not not not
4
u/thatpaulschofield Aug 27 '21
Cho sugoi!
4
u/STUDBOO Aug 28 '21
やめてください!!
4
u/RobotC_Super_User Aug 27 '21
I think sb just allowed themselves a joke😅
4
u/[deleted] Aug 27 '21
Why so many not's?
2
u/mondie797 Aug 28 '21
I don't understand the language to judge.. I mean not python.
2
u/[deleted] Aug 28 '21
Font?
2
u/thanatica Sep 01 '21
It's probably just to quickly knock together something funny. For that, it's alright code.
The only thing that gets on me nerves is the
if not not not 雨, so is it not not not raining, or is it? (雨 means rain)I am now itching to start using non-ASCII variables, but I fear it might anger my coworkers, because they are "special" characters and that "should not work". Or something. Maybe I'll give it a go, for funsies.
2
u/propostor Aug 27 '21
Doesn't actually look that bad, all things considered.
I don't know Japanese but could still follow what the code was doing
2
u/wktr_t Aug 28 '21
You deserve both an award and a ban.
1
u/xSilverMC Aug 27 '21
Other than the weird boolean shenanigans i don't see anything really wrong with it, idk why the counter is in katakana though
1
u/sublunarwind Aug 27 '21
,VS,
1
u/chain_letter Aug 28 '21
1
u/chestera321 Aug 28 '21
I think this code is evil
1
u/ilikedankmemes3 Aug 28 '21
Prints “eleven (~) 😂😂”
1
u/Nonsensicallity Aug 28 '21
“not 正” is a lot less ambiguous than guessing whether or not the Boolean value is capitalized when you switch gears from one language to another.
1
u/yvt Aug 28 '21
Aside from the fundamentally wrong part, actually we do something like this depending on problem domains and whom we are writing for. Non-Latin identifiers are indeed harder to type, but attempting to translate technical terms with no well-known English translations is likely to create more problems.
1
u/Shadow_Gabriel Aug 28 '21
Nihongo jiouzu!
1
u/[deleted] Aug 28 '21
anime programming
bottom text
1
u/incoralium Aug 28 '21
It is bad.
Not Not Not
No += increment ...
Other language or ok if not a shared dev (look at the path it's literally a playground)
1
u/strindhaug Aug 28 '21
So this code will ask your name, greet you with that name, say Sum=False and then print 10 repeats of a dot and an emoji?
1
u/foxer_arnt_trees Aug 28 '21
If not not not
1
u/zeGermanGuy1 Aug 28 '21
The last line reads counter = counter + 1. Not so sugoi
1
u/Dmon1Unlimited Aug 28 '21
How does coding with different languages work?
If you want to reference a library with an English name that may not have a name in your language?
1
u/joujoubox Aug 28 '21
This is [Python]! Speak English!
1
u/WisconsinBadger414 Aug 28 '21
I would have just returned the sum in that first else statement to make match the if statement, why assign it to a variable then return that when you can just put a return on the line
1
u/Biggest_Man_George Aug 28 '21
IN THE NAME OF MIGHTY CHRIST, WHAT AM I LOOKING AT.
1
u/BarryFruitman Sep 02 '21
notnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnotnot1
u/Eye-Itchy Sep 15 '21
not not not
1
u/pyker404 Aug 27 '21
Well regardless it is in japaneseit is still bad coded
1
u/fugogugo Aug 28 '21
who put emoji in their code?
WHO.PUT.EMOJI.IN.THEIR.CODE
0
u/iYashodhan Aug 27 '21 edited Aug 27 '21
I don't understand, this shouldn't work, right? I mean does python interpreter understands foreign language variables and function name? I don't think so, how come?
Edit: I found one stack overflow question: https://stackoverflow.com/questions/53224425/how-can-i-use-japanese-language-characters-in-variable-naming
-1
u/SexyMuon Aug 28 '21
It's Chinese
-1
u/[deleted] Aug 28 '21
sugoin my cock
-1
u/5UP3RBG4M1NG Aug 28 '21
おはよう
-2
u/Gantzz25 Aug 28 '21
The input should’ve been:
-3
u/RedditAcc-92975 Aug 27 '21
I always knew python supporting unicode was a bad idea!
-3
u/theoldpenguim Aug 28 '21
bad because i refuse to say sugoi
0
u/[deleted] Aug 27 '21
[deleted] — view deleted comment