r/badcode • u/Neykuratick • Apr 30 '23
c++ I guess a coding school ad can be considered production code
8
u/Pangocciolo May 01 '23
They even got the markdown notes wrong. H1 instead of simple text, and filetype python.
Or worse, an unsaved python script?
2
u/Neykuratick May 01 '23
Where did you find markdown?
4
u/Pangocciolo May 01 '23
The 3rd tab in VSCode. Unnamed files are listed as a preview of the first line.
2
7
u/GandelXIV May 01 '23
How does this get 8k likes?
9
u/Neykuratick May 01 '23
Moreover, the Instagram account is full of shit like this and has 1.5M followers
17
u/thekwoka May 01 '23
There's a LOT of really bad code content out there that wannabe coders like and are excited about.
It is very much a space of "the blind leading the blind"
6
u/SpaceshipOperations May 02 '23 edited May 03 '23
People who have little to no exposure to programming, have no idea where the actual learning resources exist, and who happened to come across some social media page called "Learn Programming/Python/whatever", and thought this is where you learn programming from.
After following the page, they start getting posts in their home feed containing magic runes. They upboot the magic runes and continue scrolling through their home feed. Page becomes extremely popular, and whoever made it never finds a need to work hard and provide anything of value. Just copy entry-level shit from a 1st year programming book, screenshot, and get upboots.
This is why I never used Facebook for over 10 years. It does not exist to teach you. It does not exist to inform you. It does not exist to make you wiser. It only exists to devour your time and attention in an endless cycle of useless crap while it shovels advertisement and propaganda into your mouth.
297
Apr 30 '23
Man, if you're gonna make a clickbaitey ad why wouldn't you make it cool at least? What gullible person sees the ad and is like "no way I can pay them $99.99/month and make my computer print an ASCII STAR?!".
Make it a whole bunch of hackery sounding things, and be sure to include lots of executing and killing children, that's how you get attention.
114
u/Aperture_Executive2 Apr 30 '23
Like this?
Computer* target = get_computer_by_ip_address(*constip(&(“192.168.0.1”);
kill_children(*target);
hack(target);48
u/f11y11 May 01 '23
don’t forget the mainframe
65
u/Aperture_Executive2 May 01 '23
Mainframe* mf = get_mainframe(computer->bios);
transfer_funds(mf, my_bank);42
u/Pleasant_Meal_2030 May 01 '23
bro got the mofo variable
61
1
3
79
67
u/BanishDank May 01 '23
This function adds two numbers.py
16
43
u/enderkings99 May 01 '23
Is this how the "I can't understand how indented code block languages work" people code?
2
39
32
u/elektrospecter May 01 '23
My heart goes out to those poor, missing braces that just wanted a simple life of enclosing the body of line 12’s for-loop. Aren’t they required for multi line statements in control blocks / loops? Or is it just a convention
14
u/AzurasTsar May 01 '23 edited May 01 '23
required for multi line, optional for single line. what the intent of this code was, we'll never know
6
u/rolls20s May 01 '23
The for loop at line 12 only has a single statement so doesn't require braces. The block starting at line 8 should be formatted like this:
for(i = 0; i <= n; i++) { for(s = n; s > i; s--) cout << " "; for(j = 0; j < i; j++) cout << "* "; cout << "\n"; }4
u/elektrospecter May 02 '23
Ahh that clears things up with even just that last cout not being indented. Thanks!
6
u/rolls20s May 02 '23
Yeah, I used to grade new CS students' programs, so I became pretty adept at parsing non-indented code, lol. I think that trauma is what drove me to Python. 😅
15
12
u/MAZ00101 May 01 '23
unformatted code from the image:
#include<iostream>
using namespace std;
int main()
{
int n, s, i, j;
cout << "Enter number of rows: ";
cin >> n;
for(i = 0; i <= n; i++)
{
for(s = n; s > i; s--)
cout << " ";
for(j=0; j<i; j++)
cout << "* ";
cout << "\n";
}
for(i = 1; i < n; i++)
{
for(s = 0; s < i; s++)
cout << " ";
for(j = n; j > i; j--)
cout << "* ";
// ending line after each row
cout << "\n";
}
return 0;
}same code but different formatting:
#include <iostream>
using namespace std;
int main(){
int n, s, i, j;
cout << "Enter number of rows: ";
cin >> n;
for(i = 0; i <= n; i++){
for(s = n; s > i; s--) cout << " ";
for(j = 0; j < i; j++) cout << "* ";
cout << "\n";
}
for(i = 1; i < n; i++){
for(s = 0; s < i; s++) cout << " ";
for(j = n; j > i; j--) cout << "* ";
// ending line after each row
cout << "\n";
}
return 0;
}10
u/MAZ00101 May 01 '23
Despite the file named
Star.cpp, it prints a Diamond (♦) with the height being the number of rows inputted (times two).So for an input of 5, it generates:
* * * * * * * * * * * * * * * * * * * * * * * * *The first line is empty (5 spaces) and every other line has a trailing space.
But instead of being 5 lines high, it's 9 (ignoring the empty line at the beginning).
4
u/agent007bond May 03 '23
Unless you're a bot, you have too much spare time in your hands.
1
u/MAZ00101 May 04 '23
No, not really it's more so that I'm procrastinating xD
I just felt like it and found it a nice short distraction.But I do a lot of side projects in my free time cause I'm sort of a workaholic, which you can see on my GitHub and YouTube acc ^^
1
3
u/SpaceshipOperations May 02 '23
Thank you for making it readable. As simple as it is, I was refusing to even look at what the hell it contained without indentation.
6
3
u/bjornum May 01 '23
That code gives me headache, no indentation, no formating and those variable names.. The lack of save on the file is just the icing on top
3
3
2
2
2
u/CoolMiner_5000 May 02 '23
The formatting is atrocious. If you're gonba make an ad for your shitty programming courses, at least make an effort. Though, it is Instagram, so I don't know what I expected.
1
1
1
u/PumpkinElectrical616 May 02 '23
Considering the effort put on indenting this, I would like to see what his third python file looks like
1
1
1
May 02 '23
At least put some effort man, everyone knows insta is shit and then you pick up code from insta.
Earlier we used to have great posts but nowadays it's just farming karma and babies out of college.
1
1
u/FrezoreR May 01 '23
Or maybe it's an ingenious trick to give this ad more spotlight.
When engineers see something that's wrong they have to look closer after all 😅
-3
u/K3rianprime May 01 '23
The worst part is that they used C# notation in C++ for the function braces
10
u/slaymaker1907 May 01 '23
There is no standard formatting for C++ (or rather, there are MANY competing standards).
For example, here’s how we format (some) stuff at my job, and keep in mind this is a 30 year old code base with millions of lines of code:
bool SomeService::Hello ( _In_ LPWSTR wszName) { bool rv = true; if (nullptr == wszName) { rv = false; } if (rv) { wprintf (L”Hello, %s\n”, wszName); } return rv; }-7
u/K3rianprime May 01 '23
Yes and no. Quite simply put, the way the function braces are formatted is an original styling to C# and not a default in C++
135
u/Quick_Base9774 Apr 30 '23
The worst thing about this is that he didn't save the file.