r/shittyprogramming • u/BS_in_BS • Jan 02 '16
r/shittyprogramming • u/the_dinks • Oct 17 '15
New programming language on the scene: MemeArrow
i have a new programming language, it's called memearrow
instead of significant whitespace, brackets, or whatever, each statement is separated my levels of meme arrows
here's fizzbuzz
>for (int i = 1; i < 101; i++)
>>if (i == 3)
>>>if (i == 5)
>>>>print("FIZZBUZZ")
>>>else
>>>>print("FIZZ")
>>else if (i == 5)
>>>print("BUZZ")
>>else
>>>print(string(i))>inb4 someone takes my idea
edit: apparently people want me to flesh this out because we're all gross nerds. i'll share what we've done. also, i don't know what shit is called so bear with me.
i mixed up the different names but thanks for everyone for the ideas. let's do this.
>inb4 fizzbuz() :^)
>>implying i from 1 to 100 :^)
>>>mfw i % 3 == 0 :^)
>>>>mfw i % 5 == 0 :^)
>>>>>ayyy "FIZZBUZZ"
>>>>fambruh :^)
>>>>>ayyy "FIZZ"
>>>fambruh mfw i % 5 == 0 :^)
>>>ayyy "BUZZ"
>>fambruh :^)
>>>ayyy iinb4 declares a function
:^) ends control flow statements
implying is the for loops
mfw is the if statement
ayyy is the print statement (it ain't no function get yo shit outta here)
fambruh is the else statement (can be combined with mfw)
tfw returns a value
be assigns variables (duck typing)
# is the comment block, of course
r/shittyprogramming • u/[deleted] • Jul 21 '15
Just finished an interview with this guy...he didn't get the job. [JavaScript]
r/shittyprogramming • u/[deleted] • Jul 10 '24
Is this a good container image for my server?
r/shittyprogramming • u/romulusnr • Feb 04 '19
I swear I literally saw this algorithm in a recent code review.
for (int i=1; i<3; i++) {
if (i==2) {
assert testItemTwo==valueTwo;
}
if (i==3) {
assert testItemThree==valueThree;
}
if (i==1) {
assert testItemOne==valueOne;
}
}r/shittyprogramming • u/[deleted] • Nov 30 '14
I don't have access to sleep() on the system I'm programming, but still needed hold things up a bit.
r/shittyprogramming • u/redditthinks • Feb 29 '16
How to know if someone's a jerk (in 7 lines of code!)
import random
dude = 'Chad'
D = random.randint(8, 9)
if 8==D:
print("{}'s a dick".format(dude))
else:
print("{}'s cool".format(dude))r/shittyprogramming • u/MkemCZ • Feb 23 '23
FizzBuzz in a single Python expression, easily extendible
r/shittyprogramming • u/deathbutton1 • Apr 21 '17
A GUI is never user friendly. The only program that should ever be allowed to be less than 100% command line is doom.
r/shittyprogramming • u/greenpepperpasta • Jul 24 '25
Unix processes - Sexual vs asexual reproduction
Why are we limited to asexual reproduction when spawning child processes? Why can a process only have one parent?
We all know of the fork() system call, which is something akin to mitosis - it births a new child process which is a duplicate of the parent.
I propose a new system call, pid_t fuck(pid_t other);. This would be invoked with the PID of some other process to mate with. The resulting child process would be a duplicate of one of the parents, selected at random (kind of like breeding sheep in Minecraft).
I believe there would be numerous benefits to allowing sexual reproduction between processes. (Exactly what those benefits are is a topic for future study.)
r/shittyprogramming • u/robotmayo • May 18 '17
<wrong_sub>this</wrong_sup> All this does is check if a number is even. If you walk down the dependency tree it has 4 dependencies.
r/shittyprogramming • u/[deleted] • Jan 11 '17
My C compiler doesn't understand proper English, please help
I've been studying C recently, and I've noticed that C programmers really like to use "text speech" abbreviations, such as int or std. This is fine if that's what they prefer, but I prefer to use proper English, like so:
#include <standard library>
#include <standard input/output>
type definition structure {
character c;
integer x;
IEEE 754 double-precision floating point number y;
} Foo;
integer main(void)
{
Foo foo;
foo.x = 10;
print format("%d\n", foo.x);
return 0;
}But to my chagrin, I discovered that C compilers are so accustomed to C programmers' lazy text speech that they can't even understand proper language! I suspect it's today's younger, less mature compilers that are to blame. Would I have better luck with an older compiler?
r/shittyprogramming • u/[deleted] • Oct 22 '16
I used a JIT compiler to complete my class assignment, but when it finished I still had six hours until the assignment was due
Did I do something wrong, or did I accidentally use an AOT compiler?
r/shittyprogramming • u/Salixias • May 16 '14
You can never have too many pointers
r/shittyprogramming • u/nathodood • May 26 '19
Why is this pause symbol here with no specification as to how long the program is to be paused? Even the same line several characters to the right is confused! Why is that? Please help!!!
r/shittyprogramming • u/_JesseV • Nov 21 '14
I just wrote a super compact for loop for a knight on a chess board
r/shittyprogramming • u/avinassh • Jan 20 '18
Introducing GG Flip, a highly performant Javascript library to flip signs
TLDR: https://github.com/avinassh/gg-flip
If you want this as web service, then check GaS - GG Flip as a Service
Donald Knuth described in one of his TAOCP books that flipping the sign of a number is one of the hardest problems in Computer Science. But that was in the 60s. Thanks to years of research and after numerous publications, today have some interesting ways to do the same. Consider this:
x = 5
// get -5
x -= x*2;Above is one of the simplest and most efficient ways to flip the sign of a number. It uses the 'minimal' approach and there is now a popular npm library based on it. It actually works and is highly performant:
https://raw.githubusercontent.com/avinassh/gg-flip/master/perf.png
But as you can see, in today's webscale world flipping ~4000 signs per second wouldn't cut it. I started to look into the ways to improve it and started reading the code of V8 engine. My C is rusty, but I was able to read through most of the code and understand it. Turns out V8 highly optimises the switch blocks and they are way too fast compared to any other control statements. I decided to use make of this and implement a better sign flip. GG Flip is the result.
GG Flip is a Golang library which generates the Javascript sign flip library. I preferred Go because lack of generics seemed like a good design choice. This code has no external dependencies, you can run:
go get github.com/avinassh/gg-flip
go run main.goAbove code generates highly readable file lib.js, which is:
function signFlip(num) {
switch (num) {
case 0:
return -0;
case -0:
return 0;
case 1:
return -1;
case -1:
return 1;
case -9:
return 9;
// ...
case 9007199254740991:
return -9007199254740991;
case -9007199254740991:
return 9007199254740991;
default:
return num-num*2;
}
}Thanks to V8 and their clever switch block optimizations, the above code becomes highly performant. If the jumps in switch take a long time, then it fallbacks to the default, which flips the sign using minimal approach. It's a win-win! See the performance by yourself:
https://raw.githubusercontent.com/avinassh/gg-flip/master/perf2.png
Even in low memory environments (old computers, mobile devices, internet explorer), GG Flip performs almost twice as fast compared to the minimal approach and in the usual environments, it's almost 10x faster than the usual method and 4x faster than the minimal approach. Currently, GG Flip works only with the integers and for floats, it fallbacks to default switch case. In the next version, I will include all the float numbers, so that for floats also the performance remains same.
The final lib size is few GBs, so distribution may become a problem. But I am talking with popular CDN providers like Google, Cloudflare etc to ship this library directly. I am planning to send a PR to Javascript with this library so that GG Flip comes as a standard library as part of the glorious language.
I am also exploring Blockchain to see if this library can be distributed securely and quickly, to everyone. Bitcoin Cash which is a fork of Bitcoin, uses 4MB per blocks and hence might be a good candidate to distribute the GG Flip.
r/shittyprogramming • u/The-Gamble • Apr 22 '15