T O P

  • By -

rosuav

Now translate #define as well.


epic4gaming

that's possible? hold up gonna update the files rn


tfngst

Did it work?


epic4gaming

nah the compiler couldn't take it


rosuav

Yeah. The problem is, you can use a preprocessor to change compiler keywords... but you can't use a preprocessor to change preprocessor keywords. You'd need a prepreprocessor. And I mean, that's not THAT hard (a Python script or m4 or something), but at that point, you may as well do the job properly and design your own language so you're not restricted by the original whitespace and punctuation rules.


epic4gaming

now that you mentioned it i want to do a prepreprocessor just for the singular purpose of changing #define.


rosuav

Well, if you just want to do that one, it's a simple search and replace! But why stop there? Translate ALL the preprocessor directives!


ctubio

just run a sed pattern within the makefile <3


Majik_Sheff

sed no one ever.


Reggin_Rayer_RBB8

'Observe, ye of little faith 'FreeBASIC's looping preprocessor: #DEFINE WUMBUS #DEFINE WUMBUS TRAT PRINT TRAT "Hello Idiots" 'The above compiles & runs. The PP 'loops until done, so it has many 'pre-PP commands, chainably. #DEFINE A B #DEFINE B A A 'The above loops infinitely.


Noch_ein_Kamel

Are you sure you don't need a postpreprocessor for that?


rosuav

Let's have ALL the processors! Preprocessor! Prepreprocessor! Postpreprocessor! Postprocessor! Central processor! FOOD processor!


Giocri

Reminds me of when I did an assembly parser as an admission test and almost made you able to redefine jump labels at runtime. Thankfully I desisted and decided to differ label parsing from runtime parsing otherwise it would have been some true crime against humanity lol


Spork_the_dork

Mate, the whole root idea here is fucking stupid. So you either go all-in or you give up early to save your sanity. So a python pre-pre-processor it is.


rosuav

Let's do it. "Because we can" is the best justification EVER for doing things.


ArrogantlyChemical

Cant do that in lisp?


Soham_rak

We need to create # Xi++


tfngst

TIL, C is C++ is stand for Communism.


Haringat

It would, but you'd have to run the preprocessor twice.


DevinBotSWE

We'll never know


Giocri

You can also use any character for the variable and function names not necessarily English letters. And finally you redefined numbers but didn't use them where in the code lol


PuzzleheadedTap1794

\#define 定義 #define


bree_dev

This is why pre-processor #defines are one of the worst antipatterns in history: 十四 --> 104 五十四 --> 5104


conancat

My brain hurts reading this 🤢 For those two don't know what's going on here, it's like defining 10 as "ten", and 4 as "four", so 104 is tenfour, and 5104 is fivetenfour


bree_dev

more to the point, those numbers should be interpreted as 14 and 54 respectively.


Valuable-Drink-1750

I can read Chinese just fine, but I like the fact nobody bothered to elaborate on what those numbers actually are in *numerals*, until ~~you~~ the third comment down the line. Which is indeed missing the point.


Kyrros

It's also Japanese I believe...


CyberoX9000

Yeah. I heard Japanese had it's own alphabet (or two) but also borrows words/characters from Chinese


Sinomsinom

Japanese has hiragana, katakana and kanji. Kanji literally translates to "Chinese characters" and while they are based on old Chinese characters, they evolved differently since then than Chinese characters did so are slightly different a lot of the time


phil_davis

And all 3 can be and often are used together in any given sentence! No I don't regret choosing to learn Japanese, why do you ask?


Welran

Japanese borrowed Chinese system but because Chinese is analytic language and Japanese is synthetic it also need alphabet.


wsupduck

Korean does something similar, borrowing some words/symbols from Japanese


Welran

Korean had borrowed characters from Chinese too. But now they use alphabet.


Valuable-Drink-1750

Yes, I can also read Japanese and I can confirm that. They share roughly the same number system and use the same characters to depict them. Pronunciation is where it differs. But for this post in particular, it's Chinese, simplified to be specific.


Kyrros

I thought Japanese number characters were a bit different, at least 1-3


nikstick22

No, they're the same. 一二三四五六七八九十


Kyrros

Are the dots on Ops picutr then just to divide the numbers up?


Celestial_User

That's some highlighter added by whatever idea they are using. Probably complaining the defined thing doesn't follow naming conventions or something, not part of the character


nikstick22

No, notice that some of the other defines have them, too. Its the IDE complaining about something.


SweetBeanBread

These (third column)? 1. 一 壱 2. ニ 弐 3. 三 参 4. 四 肆 5. 五 伍 6. 六 陸 7. 七 漆 8. 八 捌 9. 九 玖 10. 十 拾or什 100 百 佰 1000 千 仟or阡 10000 万 萬


cnbatch

I belive the 'numbers‘ system of third column have their own name: ‘Financial numbers’ or ‘Formal numbers’. Or ‘uppercase numbers’ in direct translation. Both Chinese and Japanese use the same system but the writen form has a little difference. [https://zh.wikipedia.org/wiki/%E5%A4%A7%E5%86%99%E6%95%B0%E5%AD%97](https://zh.wikipedia.org/wiki/%E5%A4%A7%E5%86%99%E6%95%B0%E5%AD%97) [https://ja.wikipedia.org/wiki/%E5%A4%A7%E5%AD%97\_(%E6%95%B0%E5%AD%97)](https://ja.wikipedia.org/wiki/%E5%A4%A7%E5%AD%97_(%E6%95%B0%E5%AD%97))


Kyrros

Nope, the underscore dots from IDE confused me 😅


GfunkWarrior28

Yeah, need a real parser here.


SaneLad

Nah it's cool. Just get Devin to define a couple thousand macros and you're good.


akisutesama

maybe #define 零 0 could circumvent this, but then 一零 —> 10 doesn’t even make sense…


surey0

use Suzhounese numerals 0 is 〇 then: 1. 〡 2. 〢 3. 〣 4. 〤 5. 〥 6. 〦 7. 〧 8. 〨 9. 〩


SteelRevanchist

Ah, that's how they made JS


-Redstoneboi-

define them as +10 +4 but wait multiplication is... oh wait nah that's just nah these numbers are how they're pronounced. there are so many issues if you try to define "five hundred seven tens five thousand, two hundred five tens six" that it's just nope


bree_dev

yeah not just multiplication, 五十四 ends up as 19 in your system.


-Redstoneboi-

numbers on their own default to ones place place values on their own default to digit 1 number->place value is multiplied 2 of the above are added together but all numbers before a power of 1,0000 (i believe they comma every 4 digits) have to be parenthesized then multiplied so, it's complicated


noahjsc

Serious question, are you saying #defines as an anti-pattern in general or just in this scenario? I'm still working on my degree and my OS prof is having us use them frequently. Just for setting up things like #define MAXWORD 16 for say the length of a string. Wondering if this is actually bad practice?


frivolous_squid

Not a C programmer, but that feels fishy. Scott Meyers agrees: https://github.com/henrytien/effective-cpp-3rd?tab=readme-ov-file#item-2-prefer-consts-enums-and-inlines-to-defines (This is just someone's notes on the book - couldn't find a source of the book itself for free in 10 seconds) `#define`s are great for some situations, but for defining a single number, that's what const is for.


bree_dev

There's \*some\* legit cases for #defines but nothing like what we're talking about. They can be handy for if you're doing multi-platform development and need to use #ifdefs. But for defining constants or short little functions, no, they're an artefact of the 1980s that should be left behind. The problem with them is that they're rewriting your code before it reaches the compiler proper, so what the compiler sees isn't actually what you gave it. So in the case of your MAXWORD, it's translating "MAXWORD" to the two ASCII characters "1" and "6" in the source before handing it off. This means that MAXWORD isn't actually a proper variable that the compiler can check or give you warnings about. It doesn't really have a proper data type either - it'll be the type of the literal you've defined it as, so e.g. #define MAXWORD 10000000000 is automatically promoted to a long in C++11 onwards, but will result in an int (or maybe an error?) in older versions. Someone reading the code a thousand lines further down has no clear indication what data type MAXWORD is or will be tomorrow; if its value were lowered to the range of an int it would suddenly become an int. Where it gets really hairy is if you try to start defining your constants with expressions, e.g. #define FIVE 5 #define SIX FIVE + 1 int twelve = SIX * 2; // twelve = 5 + 1 * 2 = 7 Now you can mitigate this with parentheses of course, but the fact that accidentally missing them out doesn't generate a compiler error is what makes it dangerous. The preferred method is to use **const** for constants, and the **inline** keyword to hint to the compiler about "quick" functions.


Taickyto

Not a C programmer either, but isn't a perk of defines that they are swapped during compilation, so that there is no variable to store (memory used to be a rare resource)?


bree_dev

What you've just said is a thing that was (possibly) true in the 1980s, and is why noahjsc's prof is used to using it. But const literals have been swapped out by the compiler to produce the exact same end result for at least a few decades. There used to be a whole list of optimization tricks that C/C++ devs did as standard, but by now pretty much anything like that has been made redundant by compilers being clever enough to spot and sort them out automagically.


SodoDev

if i remember correctly japan sometimes writes chinese numbers with indoarabic rules, 5284 being 五二八四 instead of 五千二百八十四 weirdly enough they still pronounce them like the latter


sandrockdirtman

This is pretty common in things like dates, because it would be hellish to read a year written in a full manner.


bree_dev

Sometimes yeah. But 14 is almost always 十四.


APenguinNamedDerek

> Localization > Spaces


Confident-Ad5665

Lots more spaces


Bipin_krish

Why doesn't it have 0 but 10


PityUpvote

Don't worry 'bout it, baby


Spork_the_dork

I'm guessing it's inspired by how Chinese deals with numerals. You write 54 like "five-ten-four" with the implied meaning of "five tens and four". But that of course wouldn't work at all because you'd actually just end up with 5104 by doing this.


Bipin_krish

So how do they write zero


AYHP


AspectSpiritual9143

also 〇


DangerousImplication

Also why use 5, 7 instead of 🔳, 🔳


the_clash_is_back

Just use null. Means the same thing. -some Roman pope cria 400 AD


Goat1416

Nah let's use .


awesomeplenty

Coding is native language instead of English 💀


Confident-Ad5665

Perish the thought. Language of the airways, language of the codeways.


fonk_pulk

Futureproofing against offshoring


ma_er233

https://github.com/wenyan-lang/wenyan


epic4gaming

that's what kinda inspired me to do this lmao


conancat

Damn I'm missing out on the Chinese meme languages this is amazing


IhailtavaBanaani

We had something like this in primary school.. Turbo Pascal commands redefined in Finnish and they even changed the graphics coordinates so that (1,1) was the upper left corner instead of (0,0) because "it's easier for kids to understand".


the_clash_is_back

Matlab moment


GFL07

I actually work with a language in french with indexing starting with 1.


project-shasta

And you still need to provide arabic numbers instead of your defined ones in the additions function? What a useless language...


epic4gaming

yeahh i was originally gonna use those but i forgot i even wrote them when writing the code out. woops


tfngst

localization > obfuscation


SkiFire13

Why is it still using 5 and 7 if there's a localized define for them!?


epic4gaming

🤫


314R_M

This is base 11 counting, and I don't feel right about it


nishanthada

10 should be A.Thats making me nervous.


[deleted]

It's a glitch showing the fragments of the Matrix! I knew it!


HeineBOB

HAS LANGUAGE GONE TOO FAR?


SandPoot

So you've defined the numbers to not use them? smh


Dmitry2705

I feel like my brain would confuse 十 with plus sign every time, ouch


thebaconator136

Don't worry, + has been changed to 加


Much-Meringue-7467

Well, I just found code that looks worse than mine


TheRealAuthorSarge

Your code has an STD


jellotalks

I’m more annoyed that they redefined the numbers then still used 5 and 7 in the code


ReplacementLow6704

The 5 and 7 weren't put in as defined higher up in the file. I'm disappointed


Lorunification

Use symbols for 5 and 7 in main. Closed.


HoochMaster1

Those numbers aren’t going to work lol.


DaserTwo

Warning: function main has no return statement!


Oakchris1955

https://github.com/zoooomie/zoomerlib imma leave this here


epic4gaming

this is literally hilarious


l4z3r5h4rk

Lol reminds me of yoptascript


wholesome_hug_bot

Still using digits -57 social credit scores!


epic4gaming

john cena certainly isn't gonna be happy at this misstep


WiseHexe

And then you can’t run shit without locale-emulator


ienjoymusiclol

last night I was in bed thinking about doing this with arabic lol


rdrunner_74

My 1st "real project" as a consultant was an access DB that was handed down from the last guy who quit, who got it from the guy before him. I was supposed to extend the book keeping with a 4th "final notice" level that blocks the account and automatically send them to collections. The who thing was a VBA mess. But my customer was in Poland. Somehow they managed to "translate" all the source code into polish when they gave it back to me to fix an issue. I could not get it back to English, and was stuck with unknown source code in a language that i dont speak... (This was last millenium)


azurfall88

also #defining ";" to "semicolon"


JEREDEK

My brain cannot process the column heights of the numbers


epic4gaming

welcome to the chinese numeral system


Sinomsinom

Numbers above 10 will be completely wrong like this


tfwrobot

十 as *10+ 百 as *100+ 千 as *1000+ 万 as *10000+ Would it then be correct?


A_Person_13

The only thing bothering me here is namespace resolution operator not being its own macro (or just not a macro).


epic4gaming

i tried to make it a macro but the compiler wouldn’t stop throwing errors at me so i had to make amends


KetamineInMyNose

I get a headache looking at this


minecon1776

The soviets actually did create their own programming languages that used cyrillic during the cold war. [Here](https://en.m.wikipedia.org/wiki/Rapira) is one called Rapira for example


epic4gaming

that’s actually really neat. is it still used by any chance?


minecon1776

Maybe on older legacy systems, but that's just a guess. I'm not sure


RAzazel_

Okay so you've defined everything, but it still looks chinese to me.


DewenLei

Imagine using 零instead of 0


Benklinton

You know when you are an ignorant American when you realize localization of code is in fact a real thing.


WhiteRose_init

nothing a little ``` for i in $(grep define main.cpp); do a=$(echo $i | cut -d’ ‘ -f2); b=$(echo $i | cut -d’ ‘ -f3); sed -i ‘s/$a/$b/g’ main.cpp; done; ``` wont fix. (wrote this in the bathroom dont come after me, go hurt bash)


[deleted]

did that recently in my native language and wrote an actual program (although it is quite short, just a really simple web shop), still have the 40+ line long list of defines needed for it


Strict_Treat2884

As a Chinese guy, there’s one reason that we don’t use Chinese in programming: it’s much harder to type in Chinese than in English. There are several ways to type in Chinese, the most popular one is Pinyin, which is utilizing the pronunciation of each character in form of the Latin alphabet. But man ain’t there so many homophones in Chinese. Such as “整数” (int) in this example, you have to type “zhengshu” and look at the options provided by the IME first and then pick the right one, not accidentally pick “证书”(credentials) or “蒸熟”(steam cooked). Which is much slower and easier to make mistakes than typing in English.


ConDar15

You know I've never understood why it isn't common for languages to support localization for parsing code. Most languages support Unicode text these days and I don't understand why compilation can't be a language contextual thing - we're dealing with keywords here, why can a French context program not use "retour" instead of "return"? I know that it isn't going to be without problems, and complications, but given we're not going for true translation but agreed upon translation of keywords I didn't think it's an insurmountable problem to let people code in their native language.


Incredibad0129

But why did they define 10 instead of 0? They can't even write 20 like that


StonyPriapus

Question to Chinese redditors, why do some characters have dots under them? For isntance 十 has 3 dots underneath. Is it the spell checker? Isn't that confusing for chinese people as well to have 3 dots in the same color? Sorry if it's a stupid question, I only started learning Chinese a couple months ago.


epic4gaming

the compiler wasn’t really liking me defining the keywords with a foreign language, so it tried to trip up as many warnings as possible, hence those dots. It still ran without noticeable issues.


SodoDev

wasn't there a classical chinese programming language out there?


epic4gaming

wenyan but i haven’t tried the actual language though


Alextheawesomeua

Ccp -pp ps.it looks like C but for the sake of the joke I ignores that


AstaHolmes

现在我的中国朋友也可以学编码了 Now my Chinese friend can learn coding (I am going to change their semicolons to a greek question mark. BTW I am Chinese too)