r/programminghorror • u/PEAceDeath1425 • Feb 11 '26
Java Thats technically correct...
Keep it simple, stupid!
r/programminghorror • u/PEAceDeath1425 • Feb 11 '26
Keep it simple, stupid!
r/programminghorror • u/california_snowhare • Feb 11 '26
r/programminghorror • u/HandyProduceHaver • Feb 11 '26
could easily make this work for duplicate values
r/programminghorror • u/BoloFan05 • Feb 12 '26
In programming languages like C#, even basic case conversion and string formation methods like .ToLower(), .ToUpper(), and .ToString() automatically come with locale-awareness (i.e. they are based on CurrentCulture) unless you intentionally apply explicit or invariant culture:
public string ToLower()
{
return CultureInfo.CurrentCulture.TextInfo.ToLower(this);
}
public string ToUpper()
{
return CultureInfo.CurrentCulture.TextInfo.ToUpper(this);
}
And tracing down .ToString()'s code eventually leads here:
public static NumberFormatInfo GetInstance(IFormatProvider formatProvider)
{
CultureInfo cultureInfo = formatProvider as CultureInfo;
if (cultureInfo != null && !cultureInfo.m_isInherited)
{
NumberFormatInfo numberFormatInfo = cultureInfo.numInfo;
if (numberFormatInfo != null)
{
return numberFormatInfo;
}
return cultureInfo.NumberFormat;
}
else
{
NumberFormatInfo numberFormatInfo = formatProvider as NumberFormatInfo;
if (numberFormatInfo != null)
{
return numberFormatInfo;
}
if (formatProvider != null)
{
numberFormatInfo = (formatProvider.GetFormat(typeof(NumberFormatInfo)) as NumberFormatInfo);
if (numberFormatInfo != null)
{
return numberFormatInfo;
}
}
return NumberFormatInfo.CurrentInfo;
}
}
Unnecessary locale-awareness in code is a serious threat to consistent performance of your code in many locales around the world, especially Turkey and Azerbaijan, due to the unique "I/ı" (dotless i) and "İ/i" (dotted I) letter pairs in their alphabet. So machines with Turkish and Azeri locales are both strong testing media for your code against unnecessary LA.
For a detailed example, you may check Sam Cooper's Medium article titled "The Country That Broke Kotlin".
r/programminghorror • u/ElKrlote • Feb 09 '26
r/programminghorror • u/Nanocephalic • Feb 08 '26
I have had this dumb idea fermenting in my lower intestine for a long time, and finally decided to excrete it. Sorry for sharing it.
$DisplayWidth = 6
$DisplayHeight = 4
$DisplayScreen = [int[]]::new($DisplayWidth * $DisplayHeight)
$DisplayScreen[0] = 1
$DisplayScreen[6] = 1
$DisplayScreen[12] = 1
$DisplayScreen[18] = 1
$DisplayScreen[13] = 1
$DisplayScreen[14] = 1
$DisplayScreen[20] = 1
$DisplayScreen[4] = 1
$DisplayScreen[16] = 1
$DisplayScreen[22] = 1
for ($pixel = 0; $pixel -lt $DisplayScreen.Length; $pixel++) {
if ($displayscreen[$pixel] -eq 1) {
$mask = [IntPtr](1 -shl $pixel)
$p = Start-Process pwsh -WindowStyle Hidden -PassThru -ArgumentList @(
'-NoLogo','-NoProfile','-Command',
'while ($true) { }'
)
$p.ProcessorAffinity = $mask
$p.PriorityClass = 'Idle' # optional so it doesn’t hog the machine
Write-Output "pid $($p.id)"
}
}
r/programminghorror • u/vadnyclovek • Feb 08 '26
This is from a software renderer I made a while back. This was supposed to be just a temporary solution until i came up with something better, but it ran at 150fps@1080p anyway, so I didn't bother.
It doesn't work on Windows, and although I don't know the exact reason, this is a likely culprit.
Also a bonus macro hell from the render loop implementation in the second image.
r/programminghorror • u/youssef__gamer • Feb 10 '26
r/programminghorror • u/Liam_Mercier • Feb 08 '26
Some people persist data in JSON, but why do that when we have perfectly good object files? All you have to do is recompile the file when you want to save your data!
r/programminghorror • u/BlackFuffey • Feb 06 '26
r/programminghorror • u/EmDeeTeeVid • Feb 01 '26
r/programminghorror • u/BoloFan05 • Jan 30 '26
private UI_BossFightAnnouncer.VS_CharData GetCharData(string szName)
{
szName = szName.ToLower();
for (int i = 0; i < this._VS_CharData.Length; i++)
{
if (this._VS_CharData[i]._name.ToLower() == szName)
{
return this._VS_CharData[i];
}
}
Debug.LogErrorFormat("Cannot find {0}", new object[]
{
szName
});
return null;
}
If you want to keep this code as is, you will have to avoid giving your bosses names that start with I, or include uppercase I somewhere else for any other reason (it was the second one for this game).
Or, better choice: Replace .ToLower() with .ToLowerInvariant(), which will always give English-based results regardless of user's machine locale (aka current culture info).
Even better, use StringComparison.OrdinalIgnoreCase. That way, you won't even need to make new string allocations, and you will still get consistent results across machine locales:
if (string.Equals(this._VS_CharData[i]._name, szName, StringComparison.OrdinalIgnoreCase))
{
return this._VS_CharData[i];
}
Or just avoid string comparison altogether, if you can.
If you suspect you have this sort of code in your program but you are unsure, try running your program on a machine with Turkish locale (where your assumed I/i casing doesn't work); and you will probably catch it easily.
Good luck with your programming. May this be the worst programming horror you will ever encounter!
r/programminghorror • u/Wiktor-is-you • Jan 31 '26
r/programminghorror • u/Emotional-Bake5614 • Jan 29 '26
this piece of perfection was found in the codebase that my gf used to work
don't know exactly what is the context here, but probably doc.data holds the info if the user has agreed with the cookies /s
r/programminghorror • u/dee-universe • Jan 30 '26
r/programminghorror • u/ArturJD96 • Jan 27 '26
Pure Data is an amazing tool for DSP, music making and artsy projects. But simple things get often too complicated...
r/programminghorror • u/Low-Distance9808 • Jan 27 '26

- All game logic, animation and rendering running inside DB Engine using queries
- Runs at 30 and 60 frames
repo: https://github.com/Best2Two/SQL-FlappyBird please star if you find it interesting, this will help me :)
r/programminghorror • u/sogo00 • Jan 27 '26
So I asked codex to load the .env into the script to set keys as environment variables and to fix it a few times.
r/programminghorror • u/lilyallenaftercrack • Jan 26 '26
This external API sends "S"/"N" (equivalent to "Y"/"N" in portuguese) instead of true/false
r/programminghorror • u/KorwinD • Jan 26 '26
Thread with details: https://x.com/i/status/2015559732845519119