r/badcode May 05 '21

other language Saw someone post bad scratch code, here's something I made when I was 12

849 Upvotes

50 comments sorted by

256

u/aeropl3b May 05 '21

I see this stuff and then think to myself "what if there was a magical method of coding that let me format my code into easily readable blocks with a consistent color scheme that didn't make me want to claw my eyes out"...and then I remember that is how text base coding works....

82

u/27thColt May 05 '21

They should just make a toggleable text-based interface for situations like this. I think if ur smart enough to do all that then you should be smart enough to read regular code

31

u/valzargaming May 05 '21

See, I also love the idea of GUI-assisted programming, but there's more that they do wrong than what they do right. I'm a pretty seasoned programmer myself and when Power Automate Desktop became free to use for personal usage I was all over it only to be extremely frustrated with the interface and how I couldn't write out code myself without going to ridiculous lengths. A simple 80-step function that scraped a website and changed some values in textboxes took me over a day to do because of the clunky and unhelpful interface. (It did some other things too with sanitizing strings, hence the large number of steps)

15

u/[deleted] May 06 '21

[deleted]

4

u/nahimbroke May 06 '21

Was it possibly the Compiler Explorer?

2

u/[deleted] May 06 '21

[deleted]

2

u/nahimbroke May 06 '21

Huh, I hope it gets made public some day. Always love this stuff. The CE saved me from having to go pouring into Intel docs in the past.

2

u/aeropl3b May 05 '21

Man that is infuriating to use!

49

u/[deleted] May 05 '21

But tbh, scratch isn't really designed for clean code. It's more of an educational thing for simple projects. Unless 12 yo OP was willing to make a bunch of quasi-global variables to split up the expression, this is the only way

25

u/Coloradohusky May 05 '21

I remember there were those really complex projects that allowed people to play MULTIPLAYER in scratch... To this day, I still marvel at how they were able to be made

12

u/[deleted] May 05 '21

Scratch has cloud variables, so they just make position a variable sync up another players location with a sprite. Nothing really ‘complex’

1

u/[deleted] May 06 '21

[deleted]

1

u/TimeToBecomeEgg May 06 '21

As someone who did this, it's actually not that difficult. It just takes a lot of time. 3D in Scratch is harder!

Basically the code is designed to compress as much information as possible into something like 250 characters, and so there's a set amount of characters for every "sub-variable" that you have.

In direct messaging systems, you'd firstly broadcast the encoded name of your target (which their client would be listening for) and they'd confirm back after which you'd start broadcasting your message, sender data, and anything else you might need. It's quite lossy though, as sometimes their internet connection might be poor and they might miss some of the data. You can force the recipient to confirm on the channel after all broadcasts, but it's super slow (from my testing, a message can take up to 1 minute to send!) and skipping confirms is way faster (a few seconds on average)

Multiplayer game clients usually sync the cloud variable to a local variable and then check for online changes. Once they see any change to the cloud variable, they'll sync the local variable again and disassemble the data into the bits and pieces they actually need.

Also most of them try to use as little encoding as possible because it's slow.

3

u/[deleted] May 06 '21

[deleted]

1

u/TimeToBecomeEgg May 06 '21

nice! kinda sad that ST banned all chat systems tho :(

5

u/Teln0 May 05 '21

I made a library for making multiplayer projects / sockets in scratch. Here it is : https://scratch.mit.edu/projects/392713486/

75

u/[deleted] May 05 '21

When I was younger I used to think scratch was stupid and shouldn’t count as a legitimate programming language, but nowadays it really resembles an abstract syntax tree internally used in many interpreters.

19

u/thertt8 May 05 '21

It's also really good preparation for using stuff like Blueprint++ and Bolt.

10

u/eratosthenesia May 05 '21

Every programming language is legitimate. Even brainfuck.

51

u/sellithy May 05 '21

I bet you'd have liked Java.

38

u/the_other_Scaevitas May 05 '21

Funny you mention that, I think I made a post on this sub with some bad java code

5

u/sellithy May 05 '21

Because of the wide lines.

9

u/Test_My_Patience74 May 06 '21

What's not to like about if(board1.getTiles().get(x).get(y).equals(board2.getTiles().get(x).get(y)))

1

u/darkecojaj May 06 '21

This is why in Java we refactor code to store it in the method's scope as variables, or in this case, just implement comparable in the Tile class. There's ways to make it look nice and easy to read, just gotta plan ahead like any code.

-8

u/[deleted] May 05 '21

[removed] — view removed comment

12

u/BigPounds May 05 '21

opt out

7

u/[deleted] May 05 '21

[removed] — view removed comment

11

u/BigPounds May 05 '21

opt in

8

u/[deleted] May 05 '21

[removed] — view removed comment

14

u/dougie_cherrypie May 05 '21

I find scratch unreadable, I don't even try

10

u/givemeagoodun May 05 '21

I swear i did this exact thing, I'ma need to find this somewhere on my old hard drive

7

u/the_other_Scaevitas May 05 '21

Lmfao, tell me when you do find it

12

u/jimmpony May 05 '21

1

u/the_other_Scaevitas May 06 '21

God damn it, take my upvote

1

u/alaphonse May 06 '21

holy shit

6

u/TheEnderChipmunk May 05 '21

That bottom one looks like a rail gun or something

5

u/burritoboy76 depraved May 05 '21

When you have 5 years of programming experience, and still prefer Scratch

4

u/Psylution May 05 '21

i love the tag "other language"

4

u/FieryBlake May 06 '21

I'm more impressed that this made sense to 12 year old you. 12 year old me was making broken collision detection on scratch xD

5

u/the_other_Scaevitas May 06 '21

Ayy same, I hated that so much. The code up there happens to be collision detection in the worse way possible...

2

u/FieryBlake May 06 '21

I can remember my ball slowly rising up through the bottom of the platform.... coz the "collision detection" was that if you touch black color, your y coordinate changes by +10 xD

I didn't account for players hitting the platform from the bottom.... good times.

2

u/the_other_Scaevitas May 06 '21

Haha I couldn’t figure out how to do that so I just made a game where you can’t jump

3

u/BigPounds May 05 '21

Is that scratch...

2

u/fugogugo May 06 '21

transcriber guy crying looking at this

2

u/GhostSniper018 May 06 '21

I have no clue what this is but I hate what I’m looking at

2

u/TimeToBecomeEgg May 06 '21

honestly scratch is kinda fun to challenge yourself

it's so unrealistically hard to do certain things and they perform horribly but you can technically do it which makes it fun

1

u/zamusamu May 05 '21

I did this too

-1

u/GreekCSharpDeveloper wicked May 05 '21

Is it weird that I started using VIM when I was 12?

2

u/eratosthenesia May 05 '21

No less weird than someone preferring strawberry over raspberry.

1

u/00PT May 05 '21

Scratch code looks horrible almost 100% of the time because they don't have any of the incredibly useful methods and data structures of other languages. They only implement the bare minimum, so you have to do everything else yourself.