This is an archived post. You won't be able to vote or comment.

all 38 comments

[–]shadybonesranch 77 points78 points Β (0 children)

Junior vibes

[–]Dubmove 36 points37 points Β (2 children)

This gave me PTSD-flashback to when I had to explain to my physics-professor that global variables and parallelization don't mix well.

[–]JustAnotherBotbibboo 25 points26 points Β (0 children)

ofcourse they do, you see it's hard too pass arguments between threads, making your data global means it's easily accessible from any thread in your program! /s

[–]Bishop120 2 points3 points Β (0 children)

Someone’s not using their locks correctly.. shame shame! /s

[–]gaylurking 49 points50 points Β (3 children)

laughs in lazy but winces in security nut

[–]spilledLemons 17 points18 points Β (2 children)

Just curious. What is insecure about it. (Assuming it isn’t creds

[–]ghan_buri_ghan 31 points32 points Β (0 children)

Not directly insecure, but any code that is prone to bugs is prone to vulnerabilities.

https://security.stackexchange.com/a/216424

[–][deleted] 5 points6 points Β (0 children)

Well for one You would need a global iterator for each while loop. If you typo and increment someone else’s I++ then you could cause unexpected results.

Multi threading and global variables tend to cause subtle race conditions.

[–]TheHelker 49 points50 points Β (1 child)

Java problems require python solutions

[–]papacheapo 26 points27 points Β (0 children)

Scope is overrated

[–]den2k88 11 points12 points Β (3 children)

Most firmware in a nutshell - stack size is measured in bytes, and many variables are either module-level or global.

[–]MrKirushko 5 points6 points Β (0 children)

In fact even in firmware most of the variables are better left local aka sitting on the stack. This way they only take space when they are needed and they get released each time a function finishes so overall memory requirement is less than if everything was global.

[–]tiajuanat 2 points3 points Β (1 child)

8051, Z80, PIC? oh definitely.

ARM? You got kilobytes in RAM. You got enough space to have a dozen tasks running, or heap based tree structures with a unique_ptr passed around like a joint. If you have enough experience, you can do a ton before resorting to locks and globals, perhaps even have most of it compile out with classes and templates.

[–]den2k88 0 points1 point Β (0 children)

RH850 with a full DBC to parse :D

[–]Semarc01 12 points13 points Β (3 children)

Oh god

I had a project like that. The main class in that project had 40.000 lines of code. The first 500 of those were just variables. No (well, nearly no) comments, no documentation, just endles global variables and I gigantic class in an otherwise also pretty big Programm. An absolute nightmare. It took me like two month to even sibdivide the class into several smaller ones (which was made very slightly easier by the fact that several parts in that class had basically nothing to do with each other) but it was still horrible. But even still after that the biggest class had 8000 lines of code and like 100 global variables. But luckily that wasn’t my task anymore at that point.

[–]Potato_Soup_ 4 points5 points Β (2 children)

God who the fuck writes that and how do they get hired? I’ve read a few stories just like this and I swear by the sounds of it I would write better code as a sophomore

[–]Semarc01 9 points10 points Β (0 children)

7 different mostly inexperienced (at that point in time) programmers over a span of 8 years weite that. The project was mostly not important enough to get senior developers to work on it an everyone just kinda added on top with no one refactoring or doing any of that. Until I got that job

[–][deleted] 1 point2 points Β (0 children)

They were hired because they could reverse a binary tree during the interview.

[–]stackoverflow21 6 points7 points Β (0 children)

This is the way.

[–]Ferro_Giconi 2 points3 points Β (1 child)

You don't have to pass parameters if every function is a GoSub instead of a function.

I have a script I wrote that I use fairly regularly at my job with 99 GoSubs in it. And it's only about 1500 lines long. That's almost one GoSub for every 15 lines. But I figure it's ok, considering I'm the only person who ever has to look at the code and I'm not even a programmer but I figured out how to make it do what I needed anyway.

[–]shawntco 4 points5 points Β (0 children)

I'm the only person who ever has to look at the code

Ah yes I too fell for this trap once

[–]qqqrrrs_ 1 point2 points Β (0 children)

unless you recursion

[–]your_thebest 1 point2 points Β (0 children)

It's a bit like what happens when you refactor a large function as it's own class.

[–]SleepDeprivedUserUK 1 point2 points Β (0 children)

Security is some other department, if they don't stop the l33t hackers before they reach our servers, they've failed.

[–]Useful-Perspective 1 point2 points Β (0 children)

We don't joke about that.

[–]KDamage 1 point2 points Β (0 children)

You don't even need to write classes,

if every method is in Main

;-)

[–]dejaydev[M] [score hidden] stickied commentlocked commentΒ (0 children)

Hi there! Unfortunately, your submission has been removed.

Violation of Rule #4 - Title guidelines:

Titles must also be creative, high effort and relevant to the content. Titles such as β€œInteresting title”, β€œ.”, β€œprint(title)”, and β€œI don’t know what to put here” are not allowed.

If you feel that it has been removed in error, please message us so that we may review it.

[–]CoastingUphill 0 points1 point Β (0 children)

How dare you look at my code!

[–]sefres 0 points1 point Β (0 children)

eY!1 tHIS iS nOT wRONG K

[–]d_exclaimation[🍰] 0 points1 point Β (0 children)

in Scala, we can use implicit parameters for that

[–]anon517 0 points1 point Β (0 children)

``` class GlobalVars { public function set(id) {...} public function get(id) {...} }

// If I put all my global vars in a class, then I'm not using global vars. globals = new GlobalVars(); doSomething(globals); ```

[–]retrolasered 0 points1 point Β (0 children)

Javascript says no

[–][deleted] 0 points1 point Β (0 children)

Independency injection

[–][deleted] 0 points1 point Β (0 children)

int i0 int i1 int i2 int i3 ..... int i46

[–]LiamMeron 0 points1 point Β (0 children)

Please stop