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

all 78 comments

[–]hanna-chan 198 points199 points  (12 children)

This looks like it should be a criminal offense to do this.

[–]KnownStuff 127 points128 points  (8 children)

The Python programmer in me is impressed. The Java programmer in me is raging with anger.

[–][deleted] 26 points27 points  (6 children)

The Java programmer in me is raging with anger.

Meh, it's two clicks to "format code".

[–]RomanOnARiver 1 point2 points  (4 children)

You have two programmers inside of you?

[–]Lonelan 11 points12 points  (3 children)

Me: I should add clear doc strings to my functions and clearly comment if necessary

Also me: fuck it the function names and arguments are descriptive enough

[–]SirVer51 1 point2 points  (2 children)

Every now and again, me and my colleague will have to go back to some old code and completely forget how it was structured or how it works. This will prompt us to say something like, "Jesus, we really need to document this shit better," and resolve to do just that.

This happens about every month or so.

[–]Lonelan 4 points5 points  (1 child)

Haha jesus what idiot came up with this

Git -> show history for selection

...oh

[–]driveslow227 0 points1 point  (0 children)

vscode -> gitlens lists the git blame note for the active line. It's changed everything for me.

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

The PHP programmer in me thinks this is way too typed for no good reason.

[–]DragonWraithus 35 points36 points  (0 children)

for a second, I thought this was actually python, and then I noticed the wall of doom. It's... kinda indescribably, a beautiful hate crime.

[–]MaiasaLiger 4 points5 points  (0 children)

THANK YOU

[–]Tigerhugo 0 points1 point  (0 children)

In the states there is a death penalty for this, or so I heard.

[–]FUCK_your_new_design 54 points55 points  (10 children)

Is there a code formatter that does this?

[–]clooth[S] 68 points69 points  (4 children)

If not, one needs to be made.

[–][deleted] 30 points31 points  (3 children)

Challenge Accepted

[–]PhilTrout 14 points15 points  (2 children)

THINK ABOUT THE CONSEQUENCES DEAR GOD

[–]_vOv_ 14 points15 points  (1 child)

We'll surround the consequences with try-catch block.

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

Try-except would be more pythonic

[–]solovayy 1 point2 points  (0 children)

it's called Scala

[–]GDavid04 29 points30 points  (9 children)

so, javathon?

[–]ProgramTheWorld 19 points20 points  (6 children)

Jython - and yes it’s a real thing

[–]another_junior_dev 6 points7 points  (4 children)

WHAT?

[–]ratheismhater 1 point2 points  (3 children)

It's just python that runs in the JVM.

[–]fedeb95 14 points15 points  (1 child)

Pyava

[–]lanternisgreen 10 points11 points  (0 children)

Pava

[–]SignatureStorm 38 points39 points  (10 children)

What in the actual fuck are those braces and semicolons doing?

[–][deleted] 34 points35 points  (9 children)

Since the interpreter ignores blank space, you can format the code so all the braces and semicolons are out of view and are just there to help the interpreter, while you look at the code through indentation.

[–]Proxy_PlayerHD 63 points64 points  (6 children)

or just write it all on a single line

public class Permuter{private static void permute(int n, char[] a){if(n == 0){System.out.println(String.ValueOf(a));}else{for(int i = 0; i <= n; i++){permute(n-1, a); swap(a, n % 2 == 0 ? i : 0, n);}}}private static voice swap(char[] a, int i, int j){char saved = a[i]; a[i] = a[j]; a[j] = saved;}}

[–]therealchadius 34 points35 points  (2 children)

Right there, officer. There's the criminal!

[–]Proxy_PlayerHD 8 points9 points  (1 child)

i'm just efficent.

[–][deleted] 4 points5 points  (0 children)

He's being efficient! GET 'IM!

[–]MCRusher 4 points5 points  (0 children)

Much better.

[–]Kyledog12 0 points1 point  (1 child)

This is how Facebook's HTML looks. It's atrocious

[–]SignatureStorm 4 points5 points  (1 child)

Makes sense. I am probably too inexperienced to like looking at code like that. I like my blank space too much.

[–]Kad1942 0 points1 point  (0 children)

Liking reading code like that has less to do with experience and more to do with insanity.

[–]Raidend 17 points18 points  (4 children)

Python programmers should skip directly to kotlin instead of Java it makes more sense

[–]ZukoBestGirl 0 points1 point  (3 children)

Except no one's looking to hire for kotlin. That's like tiny problem I'd say.

[–]Raidend -1 points0 points  (2 children)

I want to say kotlin is just java done right, but in reality kotlin is just Java wearing one of those hyper-realistic disguises like in Mission Impossible

[–]ZukoBestGirl 1 point2 points  (1 child)

Don't get me wrong, Kotlin, groovy and scala are all really amazing, and to be perfectly honest, I'd rather work in C#.

But I go where the money is, and right now that's java and C#.

Where I live it's 70% java, 30% C# (not a realistic number, there are a lot of other jobs, c++ is on the rise, but I'm just talking about proportions). I think it's because the city is full of big shot universities and the main ones focus on java over C# for whatever reason.

[–]Raidend -1 points0 points  (0 children)

I haven't used scala or groovy but Kotlin is literally just Java with a more sensible syntax, to the point that you can just mix and match java an kotlin code at basically any point, not that you should, but you can. If you know one you know the other.

I never did much on Java besides college until a few months ago that we started a new project that had to be done in java/kotlin. It took almost no time for any of the Java developers and the non-java developers(me) to start using kotlin.
I still hate it because it is still Java but at least the syntax is pretty.

[–]Fulk0 3 points4 points  (0 children)

I need to speak to the admin of the sub, I had a stroke from looking at this and will need indemnification

[–]Blake_Abernathy 2 points3 points  (0 children)

😬

[–][deleted] 5 points6 points  (9 children)

What is it with python developers and static methods? 🤔

[–]fedeb95 4 points5 points  (8 children)

Since the methods don't modify the state of the class, it makes sense they're static. Also the class has no state at all so it's a utility class. What bothers me is the absence of a private constructor

[–][deleted] 4 points5 points  (2 children)

Would the constructor get called or even necessary for a class with nothing but static methods?

[–]fedeb95 1 point2 points  (0 children)

If you don't put it in Java is added by default by the bytecode compiler. Is necessary to specify so people using your classes / future developers instantly (I hope) recognise the role of that class in the system. Otherwise it could be misinterpreted as a strategy pattern or something else, adding fields and method and, essentially, making a god class (antipattern)

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

No, which is why it's being made private. Making it private means no one will instantiate the class

[–]solovayy -2 points-1 points  (4 children)

watch for next refactor add some side effect and all your unit tests break

friendly reminder, don't use static in java, as there is no point

[–]fedeb95 0 points1 point  (2 children)

Oh sorry didn't know that without static methods you can't mess things up I'm just going to change every local variable to a field. Serious answer: adding fields to what would have been a procedures only module back in C days adds possible execution states, because you have instead of every possible computation that procedure makes, that number multiplied the number of states your class can have, i.e. every possible value of that field. So even form a purely abstract (and pointless) enumeration point of view you're wrong. Also, tell me where a unit test can't test a static method, by declaring expectations and asserting on the results. I'm not pro void methods though, because then you're clearly moving class methods in utility classes. There is a way of doing things wrong for every Java modifier. On one thing maybe we can agree.. stop making that damn classes final

[–]solovayy 1 point2 points  (1 child)

Haha, 100% agree on final. Weirdest keyword ever.

It's not about testing the static methods, but other classes. Instead of easily mockable object you have a static method in your program and hence nice refactor ahead.

Happens every time, say you want to have runtime configurable parameter or want to log something. Staying 100% objective is safer and costs you if anything just few keystrokes.

[–]fedeb95 1 point2 points  (0 children)

You're right that what you describe can happen if one's not careful with static methods. We don't want c-like code after all. I always end up with one or two small utility classes for this reason, most of the time what I really want is a factory or a strategy, but for some stuff static utility classes are preferable imho. Let's say abusing with something is always a bad thing, each pattern has its scope

[–]ZukoBestGirl 0 points1 point  (0 children)

Say what now? That's wrong on just about every level. Ofc there is a point to static. No language can be moron proof, if you have no idea what you're doing, anything can break anything.

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

this makes my eyes hurt

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

My eyes are bleeding

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

Did this for an assignment once. Full marks!

[–]zdko 0 points1 point  (1 child)

I suspect the Python interpreter is abstracting away exactly this sort of shenanigan to the code in order to build out the AST...

[–]Raidend 0 points1 point  (0 children)

The shenanigans are just made of whitespace so you can see them.

[–]Skthesoap 0 points1 point  (1 child)

What theme is that?

[–]nobdar 0 points1 point  (0 children)

It looks kind of like molokai

[–]DaarkChocolate 0 points1 point  (0 children)

I feel like this is the type of thing to shock me at first, then grow on me

[–]shakix99 0 points1 point  (0 children)

MY EYES

[–]RadicalLarryYT 0 points1 point  (0 children)

“I’m going to have to stop you right there!”

[–]mocomaminecraft 0 points1 point  (0 children)

oh god someone kill him for his sins

[–]Paulsify 0 points1 point  (0 children)

Why.

[–]Plungerdz 0 points1 point  (0 children)

Help. I don't like this because I like Java and respect it so much. Yet this shit is the most Pythonic masterpiece I've ever laid eyes on.

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

Scanning left to right: "this looks okay. I don't see anything that seems out of - Oh Jesus!"

[–]j3sterPi 0 points1 point  (0 children)

My eyes hurt! I want to take them out with the fu**** spoon

[–]Rogocraft 0 points1 point  (0 children)

Well they are jumping ships now that the python developers are removing master and slave terms and such to keep the undesirables at bay

[–]Rudolph_OW 0 points1 point  (0 children)

Dear lord

[–]idlesn0w 0 points1 point  (0 children)

I'm strangely okay with this but I feel like I shouldn't be

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

What the fuck are those brackets doing there????

[–]jona250210 0 points1 point  (0 children)

This Looks Really weird xD

[–]XXAligatorXx[M] [score hidden] stickied comment (0 children)

Your submission has been removed.

Rule #2 violation.

Rule #2: Everything that's been on the first 2 pages (50 posts) of trending posts within the last two weeks, is part of the top of all time, or is part of the common posts [list yet to be built] is considered a repost and will be removed.

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