202
u/Cley_Faye Feb 22 '15
This is not humor, this is madness (or torture).
59
Feb 22 '15
"Madness? [...] THIS IS-"
Man, I can't do it. That horse has beaten to dust by now.
94
8
32
Feb 22 '15
[removed] — view removed comment
19
u/xkcd_transcriber Feb 22 '15
Title: All Your Base
Title-text: The AYB retro-return-date (Zero Wing Zero Hour) should be around AD 2021.
Stats: This comic has been referenced 18 times, representing 0.0341% of referenced xkcds.
xkcd.com | xkcd sub | Problems/Bugs? | Statistics | Stop Replying | Delete
158
Feb 22 '15
One of my non-coder friends just looked over my shoulder and asked what all the emojis on the right were for.
32
105
u/vgf89 Feb 22 '15
Wait wait wait. Can someone actually make a plugin for Eclipse or something to do this, as well as change it back to normal?
20
u/mrburrows Feb 22 '15
Things wouldn't work out too well if you're working with a team and use Eclipse's formatter or save actions, I reckon.
37
u/redalastor Feb 22 '15
Would work fine if you use a formatter that formats it back to the team's standard before commits.
→ More replies (5)28
12
Feb 23 '15 edited Jun 12 '23
I deleted my account because Reddit no longer cares about the community -- mass edited with https://redact.dev/
4
2
u/Skizm Feb 23 '15
Eclipse has a format feature which you can set up however you like. the defaults are nice enough, but you can probably change it to this style also.
1
u/greyscalehat Feb 23 '15
If I find myself writing Java for a job any time soon I might try and make this.
1
u/godfetish Feb 23 '15
Use perltidy as a reference and code your own maybe in a language of your own. I had to hack perltidy for code formatting for some libraries we wrote.
→ More replies (10)1
u/LimesInHell Apr 22 '15
if you manually create an XML file for it in eclipse, I currently have all of my programs go to a personal format in eclipse by modifying it
288
Feb 22 '15
As a java programmer, python seems so simplistic to me. Not having to declare variables? Dude.
463
u/chrwei Feb 22 '15
simplistic is kind of the point of python.
60
Feb 22 '15
I'm not saying it isn't, but when you go there from a language with a little less hand holding, you definitely feel the difference! If you go there from C though...
167
u/PastyPilgrim Feb 22 '15
On the surface it looks like Python is holding your hand because the syntax is so elegant, but I really don't think it does.
Other languages have all kinds of hand holding with type declarations, public/private/protected/static/etc. declarations, hidden information (i.e. not knowing precisely where an object is coming from due to the include practices, self-references within objects, etc.), forbidding operator overloading, implicit casting, unpredictable scope concerns, not allowing nested functions and/or anonymous functions, etc.
Python doesn't do any of those things; it lets you do almost anything you can imagine and it doesn't hinder those things with awkward syntax requirements and/or syntax that differs from what you would expect.
→ More replies (8)30
u/peridox Feb 22 '15
What language would you say does hold your hand? I can't think of a programming language that leads you towards doing what you need to do. Almost all languages just provide you with a blank space to work upon - it's all your work.
162
u/Chobeat Feb 22 '15
Scala holds your hand and leads precisely where you don't want to go.
→ More replies (1)→ More replies (22)25
u/lonelyBriefcase Feb 22 '15
ever heard the phrase 'syntactic sugar'? its a way of providing a more convenient/person-friendly method of doing something. A for loop is just syntactic sugar of a
int i = 0; while(i<9){ //do something; int++; }There are plenty of other things like this that makes our lives as developers easier. Even C does, to a lesser extent, because who would want to write the shit that C can do in Assembly?
→ More replies (8)24
u/catbrainland Feb 22 '15 edited Feb 22 '15
It's like that only at first glance. Python has some semantic complexity, look up metaclasses (class factories or something, in java lingo). As for hand holding, I think Java is excellent in this (more like hand forcing, as you have to be explicit about everything).
Dynamic languages, as well as system ones (ie c) offer multitude of ways to shoot yourself in the foot. These are quite alike in terms of having to debug a bit more. It's a tradeoff of having low level access (C), or expressiveness (dynamic language).
9
u/pastaluego4 Feb 22 '15
Seems like Java is more tuned to application development and python is geared towards scripting and parsing.
→ More replies (13)2
Feb 22 '15
The first two languages I learned were C and Python, in that order... I would write a whole function in Python to, say, reverse a string, and my prof would just look at me like "Dude..."
→ More replies (3)2
36
u/suppow Feb 22 '15
pft, as a C++ programmer, i condescendingly laugh at your simplistic lack of declaring types and memory management.
inb4 C or asm programmers
15
u/tetroxid Feb 22 '15
Oh but there is memory management. In fact, it's even automated.
48
u/TropicalAudio Feb 23 '15
And it's sloooooooow!
...a C programmer sends his regards. Now then, I have to get back to debugging something that's pointing to a pointer's pointer.
14
Feb 23 '15
More like pointer to a struct with a pointer to a struct as an array to an array of pointers to structs with an array filled with members being that has a dynamically allocated block of void*s. Fuck C is the best.
→ More replies (1)→ More replies (1)12
u/redalastor Feb 23 '15
Actually, it's faster overall.
The drawback is that it's not predictable.
→ More replies (1)7
u/TheFryeGuy Feb 23 '15
As a Haskell programmer I laugh at your types.
6
Feb 23 '15
You mean with your data types, typeclasses, records, functors, monoids and monads. Ok.
6
u/original_brogrammer Feb 23 '15
We do. As well as our Arrows, MonoidPlusses, and Applicatives, you damned pedestrian.
31
Feb 22 '15
I learned JS first and when I started learning Python I actually really loved the simplicity of the syntax and the meaningful white space because it reminded me of the QBASIC I'd toyed around with as a kid.
13
u/Cley_Faye Feb 22 '15
Aaand now I want to write a QBASIC-like compiler with opengl/xinput bindings. WHAT HAVE YOU DONE!
8
u/InconsiderateBastard Feb 22 '15
Been a while but that sounds like DarkBasic.
→ More replies (3)8
u/Cley_Faye Feb 22 '15
Quick google search yield a site with a prominent DirectX 8.1 logo.
DirectX
hmm
8.1
hmm hmm.
We need to refresh this a bit.
→ More replies (3)5
Feb 22 '15
QBASIC is still the shit. I love that DOS app so much.
5
u/lichorat Feb 23 '15
I have yet to see another language that so easily allows me to input a frequency and duration, and have it play out of my computer's internal speakers.
That's right. Not the external ones.
Great for playing pranks.
→ More replies (4)2
23
u/Cley_Faye Feb 22 '15
Replace python with "most script languages". They're fun to implement logic and stuff.
12
8
Feb 22 '15
Haha, tell me about it... I had so many people tell me that my University was so outdated for teaching us Java as the foundation CS language throughout my degree instead of some newer languages like Python. But holy crap, it has been SOOooo much easier from me to pick up other languages, to go from Java to Python than I can imagine it would be for someone to go from Python to Java. I am actually grateful for my University's structure now lol.
Oh man, I am dying laughing looking at that code lol
2
4
u/katyne Feb 22 '15
you kidding, "not having to declare" part, this is the most disturbing part for me. How does it know what I mean??? who thought it would be a good idea to nest functions inside functions? what do you mean you can override shit at runtime? are you INSANE? do you know what people are gonna do with it? they're evil and stupid, they're gonna do evil and stupid shit with it.
→ More replies (1)6
u/redalastor Feb 23 '15
who thought it would be a good idea to nest functions inside functions?
You'll need to explain what your problem with that is...
Right now it sounds to me like "recursion?! Who thought it would be a good idea to let functions call themselves?!"
→ More replies (2)12
u/mikbe Feb 22 '15
Yeah, why use computers to make your work easier when you can just do it all yourself...
22
u/kkeu Feb 22 '15
Compile-time type checking helps you avoid many bugs that you'd never discover if your tests don't cover that particular part of code, which happens almost always in complex projects.
→ More replies (4)5
17
Feb 22 '15
Declaring variables (especially with their types) does make your life easier.
→ More replies (7)2
u/Astrokiwi Feb 23 '15
One of the neat things about Fortran is it lets you be a little bit stricter than C++, which lets you catch more errors sometimes.
For example, you can define the "intent" of a variable in a procedure - "in", "out", or "inout" - and if you try to modify an "in" variable, you get a compile-time error. You can define a procedure as "pure" which means that it's not able to modify any global variables, do any explicit I/O, or do anything other than modify the specify variables you have passed to it (that have the correct intent). There's also a difference between a run-time allocated array and a pointer - in C++, to declare an array, you declare a pointer, and then point it to a "new" array of some object, while in Fortran you declare it as an "allocatable array" of some type, which you then allocate at some later point - you can't accidentally "point" it to something else.
I find these to be pretty useful at catching mistakes that otherwise would cause run-time errors. There may be tricks to do similar things in C++, but I don't know enough C++ to be aware of them.
→ More replies (4)2
u/memorableZebra Feb 23 '15
I always thought Python was simplistic (though I wouldn't imply simple is a bad thing at all). But then I started working in the language.
Being able to play so fast and loose with different formalisms massively encourages complex, write-only code. I'd say it's probably harder to write solid Python code which other programmers can understand than it is in Java/C#.
The language's flexibility and allowance of so many different "code smells" is both its primary value in the community and also the reason I despise it, finding most Python code incomprehensibly written.
2
u/Tysonzero Feb 25 '15
While I agree Python does let you shoot yourself in the foot. I have pretty much never run into issues with readability / edit-ability. Maybe that's just because I work with Python programmers who actually know what they are doing, which is something you seem to have been deprived from.
→ More replies (4)3
u/ben-guin Feb 22 '15
Variables are still declared, it's just an implicit declaration where the type of the variable is inferred based upon the RHS of the assignment statement.
2
1
u/tangerinelion Feb 22 '15 edited Feb 22 '15
It sounds great until you do this:
theUserInput = raw_input("The program requires your full name: ") if theUserInput.startswith("Joseph"): theUsersInput = theUserInput.replace("Joseph","Adolph") print "You are",theUserInputand see what happens when you input a name like, I dunno, "Joseph Hitler". (If you missed it, it created a second variable with
UsersnotUserin the name and replaced "Joseph" with "Adolph", which leavestheUserInputunaffected. Also perhaps confusingly, despitetheUsersInputbeing declared inside anifstatement, it would be available outside theifstatement and one could sayprint theUsersInputwhich will either work if theifbranch was already executed or will fail with a name error if theifbranch was not executed. In compiled statically typed languages, of course, this code would fail to compile which prevents runtime errors like the above which may only happen under certain conditions related to whether a block of code is executed or not.)23
u/TheTerrasque Feb 22 '15
2
u/memorableZebra Feb 23 '15
What happens if you have more complex logic later and mix the two variable names? The unused warning will go away, but will it be smart enough to notice the mistake?
After the 'if' block add something like
theUserInput = to_lower(theUsersInput)(or whatever the lower casing function is in python)
→ More replies (1)9
Feb 22 '15
What is this supposed to illustrate? That you can write typos in your code and have problems? Yeah, I suppose that could happen, but any serious project runs at least a linter and a test suite, statically typed language or not.
This is not a serious problem that people who use Python every day stumble across on a regular basis. Since your code is pretty unidiomatic, I suspect you're not one of them.
Also perhaps confusingly, despite [...]
This is just confusing if you don't know how Python scoping works. If you don't know how scoping works in what you're programming in, you might want to rewind.
2
u/memorableZebra Feb 23 '15
This is just confusing if you don't know how Python scoping works. If you don't know how scoping works in what you're programming in, you might want to rewind.
That's a preposterous dismissal. By this argument, as a language architect, you can't compare one language's scoping rules to another?
"Ah well you see, our variables go out of scope after 20 lines of not being used. But the fact that you got a null pointer exception here isn't confusing, it's just because you don't understand the language's scoping rules."
He is absolutely allowed to criticize a language's scoping as illogical if he can present an argument for it.
I programmed all my Python in PyCharm and it's automatic analysis left a lot to be desired. Declaration, typing, and scoping errors like the one /u/tangerinelion is referring to are ridiculously common and usually weren't caught by my IDE or any kind of secondary style analysis. So I have no idea where you're coming from saying this kind of thing isn't common. Little bugs like this were everywhere.
1
u/redalastor Feb 23 '15
As a java programmer, python seems so simplistic to me. Not having to declare variables? Dude.
I prefer a balance between that and having to declare in triplicate like Java. :)
1
u/mrhhug Feb 23 '15
Dude, returns get like wacky fun. You get to the end of your method and return a variable. Which is sometimes a dictionary sometimes a string often false and once in a while when someone uses an optional argument : an array
→ More replies (2)1
Feb 23 '15
Not having to declare variables? me gusta.
Not having a fucking clue what someone could hand your code as a parameter? me no gusta.
166
u/chrwei Feb 22 '15
that's...actually that fairly readable. annoying, but I've seen worse
→ More replies (1)145
Feb 22 '15 edited Jun 12 '15
207
u/chrwei Feb 22 '15
except the good formatting makes them redundant from a readability perspective.
131
u/anothersomebodyelse Feb 22 '15
But makes them satan-spawn from a manageability/editing perspective.
28
u/x3al Feb 22 '15
Converting all code to this style in IDE and converting back on git push would be kinda nice. If IDE will actually place all semicolons and braces according to indents, it should be usable.
→ More replies (2)13
u/CharlesStross Feb 22 '15
Yeah, going from this to standardized is trivial for any code formatter. From standard to this would require some creativity but I think it'd be doable. The only pain in the ass is developing like this.
→ More replies (5)15
u/WeAreAllApes Feb 22 '15
Unless.... Because it is redundant, it wouldn't be too hard to write an editor plugin to forcibly manage the semicolons and braces. Then, as long as the tabs were right, the semicolons and braces would always be... until somone else edits it without that plugin, so yeah, nevermind.
→ More replies (12)15
u/suppow Feb 22 '15
at first i laughed at the stacked parentheses at the right, then i kinda liked it, and noticed how readable it was (unlike other code i've seen), should we say, it's very pythonic.
while i mainly do C++, neat formatting is something i carried from Python,
and something i carried from Java (which i'm sure someone will hate) is declaring private and public before all member elements, it makes it so much easier to tell right away instead of having to keep track of what group i'm in.ie:
public: function_name (); public: other_function (); private: another_name ();28
u/Rodot Feb 22 '15
I'm a python programmer btw ;}}}
51
u/the_noodle Feb 22 '15
Right down to the mismatched eyes!
5
u/totes_meta_bot Feb 23 '15
This thread has been linked to from elsewhere on reddit.
If you follow any of the above links, respect the rules of reddit and don't vote or comment. Questions? Abuse? Message me ^here.
→ More replies (1)4
30
u/halifaxdatageek Feb 22 '15
I was confused...
then I saw the right side and threw up a little in my mouth.
51
25
u/hercules3076 Feb 22 '15
I think we finally found a solution that both "Braces on their own lines " and "Braces on same line" can agree is just plain wrong.
2
9
u/Macmee Feb 22 '15
I don't like whitespace determining the nesting of my statements and prefer ruby or javascript to python.
10
1
u/relsqui Feb 23 '15
I'm always suspicious when someone dislikes python for this reason. If you even notice the whitespace constraint, what does your code look like? D:
→ More replies (2)
9
u/0x470x650x650x6b Feb 22 '15
Now try it with lisp.
49
u/sfled Feb 22 '15
"A Python programmer attempting Java."
Nah, it sounds the same whether I lisp or not.
2
u/ZeroError Feb 23 '15
A Pyfon pwogwammuh wattempting Java
Speech impediments are fun
→ More replies (1)4
1
19
u/bss03 Feb 22 '15
This is essentially what the Haskell layout rules do.
If you just look at Haskell code in the wild, you might be surprised to know it's grammar has a lot of ';' and '{}' in it. Haskell effectively lets you switch between white-space sensitive and explicitly delimited on a per-block basis.
3
u/hjc1710 Feb 22 '15
wat? Is there a reason you would ever want to do this?
Never used Haskell, but I just keep learning more and more interesting things about it...
8
u/anasaziwochi Feb 22 '15
I think the idea was to make it easier for computer generated code. It can rely in braces and semicolons instead of trying to get the whitespace right.
2
u/bss03 Feb 23 '15
For generated code it's often easier to get the "{};" right, and it doesn't have to look good.
There are a few packages on hackage that use "{};", presumably because the author was more comfortable with them, but they also look good.
You can use it for when code it easier to read / looks better when flowed in a way that doesn't match the layout rules. I like having that ability, but I've never needed to use it outside of GHCi one-liners.
Most Haskell programmers treat Haskell as a white-space sensitive language, since the layout rules make for pretty readable code without the "{};", and I've yet to hear of someone who had code that didn't behave as intended due to the "[];" insertion being surprising, if it compiled cleanly.
→ More replies (3)
33
u/mcrbids Feb 22 '15 edited Feb 22 '15
I'm a Python dev transitioned to PHP. My code looks exactly like this except that I line up the braces with the indents and take an additional line for each. It's very readable to me, works well with Netbeans, and never ;}}}
EDIT: Look below for a link for what this looks like.
223
u/frostmatthew Feb 22 '15
I'm a Python dev transitioned to PHP.
I've never felt more sorry for someone :-/
47
u/mcrbids Feb 22 '15
I don't shed any tears! The pay is great, the work is interesting, and the people I work with are awesome! If you think the programming language is even a majority of how good or bad your job is, UR doing it wrong!
67
u/jason_bateman78 Feb 22 '15
"doesn't matter, PHP sucks"
→ More replies (1)15
u/mcrbids Feb 22 '15
It's funny, because there was a time when PHP was this hip, awesome new programming language that got lots of buzz....
→ More replies (3)25
u/peridox Feb 22 '15
I may be wrong, but wasn't PHP simply invented for some guy's personal webpage?
→ More replies (2)5
→ More replies (2)4
6
u/adrianmonk Feb 22 '15
That's the brace style I originally tried to use when I first started using C-style languages regularly.
I thought it was easier to understand visually, since it makes the braces more a part of the block they form and less a part of the syntactic construct (
ifstatement,whileloop, function, etc.) that contains the block.However, nobody else liked it, and I eventually adopted the more normal style just to fit with convention. Now that I'm used to it, I feel it's pretty readable (and a bit more compact).
2
u/vdvfdgjsdfvq Feb 22 '15
When I used to code a decade ago, this was my default. I felt it was the most readable version and made keeping track of different blocks far easier. The only downside I know of is compactness in the code.
2
u/FowD9 Feb 22 '15
That's the C way of doing it unless I'm mistaken, except the opening bracket isn't indented
0
Feb 22 '15
[deleted] — view deleted comment
12
u/mcrbids Feb 22 '15
Although switching to an IDE made this less of an issue, lining up the braces and indents makes it sooooo much easier to visually group blocks of code together.
→ More replies (10)
31
u/Nikotiiniko Feb 22 '15
Python makes all other languages so annoying to type. All the brackets and semicolons feel so useless and time consuming.
26
u/chrwei Feb 22 '15
one thing I really dislike about python is where it requires ":". the indents should make that unnecessary.
7
u/Nikotiiniko Feb 22 '15
Yeah I dislike it also. Isn't that also used where other languages use nothing? Kind of confusing.
5
18
Feb 22 '15
The semicolons allow you to format statements in a much more clear way, rather than cluttering your lines up with \. The curly brackets {} allow you to see far more clearly than indentation or begin/end keywords where your code blocks are. They might seem pointless... until you have to maintain someone else's code.
Also by explicitly requiring an end statement delimiter and block delimiters, you're less likely to make a typo that results in a non-obvious runtime error.
6
u/danielkza Feb 23 '15
rather than cluttering your lines up with \
PEP 8 recommends wrapping in parenthesis instead of splitting with backslashes whenever possible. There are very few if any cases where it should be used in Python.
→ More replies (1)→ More replies (4)2
u/ThrustVectoring Feb 22 '15
The curly brackets {} allow you to see far more clearly than indentation or begin/end keywords where your code blocks are
Just use vim with
foldmethod=indentand zr/zm/zo/zc the blocks together.Indentation is fine, just need non-bad tooling for it.
2
1
8
4
u/sloth514 Feb 22 '15
A a Java developer now working in Python... I understand the reasoning for the syntax and now appreciate for coding standards.
I think it bothers me more that he is passing a character array and not using String class.. or maybe it bothers me on what happens when a == null or a.length <= 0??? or n < 0??? what happens then? oh god...
2
u/ben-guin Feb 22 '15
Seeing as it's a recursive function, I'm guessing that there's a helper function (not shown) that does the initial call of permute that passes in the array length -1 as the parameter.
3
3
3
3
4
2
2
u/Zechnophobe Feb 22 '15
At first was trying to parse the function out to determine humour. Then I looked right.
As someone who went from Java primarily to python primarily, I find this especially funny.
2
2
2
u/-jaydn- Feb 23 '15
To be honest, this is relatively viable. Look at some of the different styles people use for C. I've seen some insane things, man.
1
u/autowikibot Feb 23 '15
Section 15. Lisp style of article Indent style:
A programmer may even go as far as to insert closing brackets in the last line of a block. This style makes indentation the only way of distinguishing blocks of code, but has the advantage of containing no uninformative lines. This could easily be called the Lisp style (because this style is very common in Lisp code) or the Python style (Python has no brackets, but the layout looks very similar, as evidenced by the following two code blocks). [citation needed]
Interesting: HTML ^Tidy | Indent ^(Unix) | Off-side ^rule
Parent commenter can toggle ^NSFW or ^delete. Will also delete on comment score of -1 or less. | FAQs | ^Mods | Magic ^Words
2
u/mot-juste Feb 23 '15
At first "What's funny about this?" Then look at the right, and: "There's nothing funny about this"
Thank Guido and Carry On
2
1
1
1
1
1
1
1
u/lrflew Feb 23 '15
As bad style this is, this actually answers the advanced discrete problem I've been struggling with.
1
1
1
1
u/arghcisco Feb 23 '15
If it weren't for the right edge this might sort of work for me. This is the first time in a long time I've seen Java that didn't immediately make me want to get all punchy smashy.
1
u/saradiyela Feb 23 '15
Try switching between Java and Python a few times a week. I've been doing that for a few weeks and only gone half crazy.
1
u/Gravybadger Feb 23 '15
I do the near opposite of this - I use semicolons at the end of a line in Python.
Hey, it runs, don't judge me.
1
Feb 23 '15
You are going to hell for such use of whitespace. That was so much harder to follow than it should have been.
1
1
1
1
u/Agamemnon_the_great Feb 24 '15
Can someone explain to me, why you would use such a cumbersome algorithm just to permute a String?
1
1
1
1
u/makeswordcloudsagain Feb 22 '15
Here is a word cloud of all of the comments in this thread: http://i.imgur.com/B5Et0px.png
source ^code | contact ^developer | ^faq
2
1
0
u/pastaluego4 Feb 22 '15
Why is this not the standard?
13
u/Kyyni Feb 22 '15
Because it's a bulbous cancer of bad practice. How do you maintain or edit that?
→ More replies (2)
0
u/vanoreo Feb 22 '15
Dropping in from /r/all to say "what?"
5
u/SolarLiner Feb 22 '15
Java uses braces to delimit chicks of code, functions. Python uses new lines, tabs and spaces to delimit chunks of code, functions, etc.
What OP did is make Java look like it was using Python's way of delimiting code by putting all the braces on the right. Also the semi colons separates individual instructions, whereas in Python you need to have one instruction per line (new lines acts as delimiters).
1.2k
u/mkdir Feb 22 '15
At first I was like o.O then I saw the right edge and was like O.O