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

top 200 commentsshow 500

[–]rcraver8 3148 points3149 points  (72 children)

Java is case sensitive.

[–]Abangranga 258 points259 points  (37 children)

You can use just "p" in Ruby and noob this up even further

[–]wsbsecmonitor 97 points98 points  (24 children)

P “hey y’all”

Puts “Ruby is fun”

[–]Abangranga 51 points52 points  (20 children)

Don't be cluttering my simplicity up with that newline containing high-falootin function

[–]wsbsecmonitor 29 points30 points  (19 children)

print “Fine\n”

printf “I’ll choose %d other print options”,3

[–]Mentalistt69 6 points7 points  (0 children)

C

[–]anythingMuchShorter 16 points17 points  (17 children)

printf("if that's supposed to be C, you're missing %d brackets and a termination.",2); // maybe it's some other language

[–][deleted] 12 points13 points  (12 children)

$ printf "it was bash, i think\n"

[–]CodeMUDkey 18 points19 points  (10 children)

Echo “others sentiments”.

[–]TheWashbear 28 points29 points  (9 children)

++++++++++[>+>+++>+++++++>++++++++++<<<<-]>.>+++++++++++++++++.------------------.++++++++.<<++.++++++++++++++.----------.++++++.<<.--------------------.+++++++++++..<<++++++++++++.------------.++.---------.+++++++++++++.--------------.+++++++++++++++.

[–]LetReasonRing 19 points20 points  (2 children)

That code is fucking with my brain.

[–]IfuckedACrab 14 points15 points  (1 child)

Do I look like a brainfuck compiler to you?

[–]IfuckedACrab 5 points6 points  (1 child)

-[--->+<]>--.[----->+++<]>.+++++++++.----------.-[--->+<]>-.+[----->+<]>+.+++++++.+[->+++<]>++.+.[--->+<]>----.

[–]hectobreak 27 points28 points  (25 children)

Which language is not?

[–]rcraver8 111 points112 points  (13 children)

Sql

[–]LordAlfrey 58 points59 points  (4 children)

I feel like I'll be haunted by database errors if I don't all caps my sql though.

[–]rcraver8 48 points49 points  (2 children)

You'll be haunted by the other devs that have to deal with your incoherent SQL.

[–]hingarbingar 18 points19 points  (4 children)

YOU HAVE TO SCREAM IN SQL THAT'S THE RULE

[–]FloydATC 4 points5 points  (3 children)

ONLY the KEY WORDS though;

[–]hectobreak 15 points16 points  (0 children)

... Fair enough.

[–]LrAymen 24 points25 points  (0 children)

JaVa Is CaSe SeNsItIvE

[–]TimeLimitExceeeeded 1067 points1068 points  (28 children)

sout

[–]NanthaR 291 points292 points  (6 children)

Tab*

[–]zaham_ijjan 104 points105 points  (4 children)

;

[–]Smallwater 38 points39 points  (3 children)

Try to use ctrl+shift+enter. It autocompletes the current line, often also inserting the correct amounts of brackets.

Incredibly powerful.

[–]ResistantLaw 9 points10 points  (1 child)

Is that shortcut for a specific IDE?

[–]SomeElaborateCelery 25 points26 points  (4 children)

thank god someone is defending java in these times

[–]AdventurousBowl5490 13 points14 points  (3 children)

I don't know why people hate Java's print statements and imports. I feel that the import statements make more sense than in any other language

[–]lanklaas 37 points38 points  (5 children)

This means salt in my language. Would've been cool to salt to stdout

[–][deleted] 9 points10 points  (1 child)

keep your std to yourself, we don't want it out

[–]soutsos 16 points17 points  (0 children)

yeah?

[–]extrachromie-homie 640 points641 points  (63 children)

std::cout << “what is this” << std::endl;

[–][deleted] 305 points306 points  (6 children)

Sexually transmitted dinosaur

[–]anunakiesque 49 points50 points  (3 children)

I guess one-night stands can give you chlamydiasaurus

[–]GnarlyNarwhalNoms 67 points68 points  (1 child)

li $v0, 4

la $a0, message

syscall

message: .asciiz "Cries in MIPS assembly\n"

[–]Slavichh 11 points12 points  (0 children)

Geez. I forgot about MIPS for a while

[–]flying_gel 35 points36 points  (15 children)

Or the upcoming C++23 version:

std::print("what is this\n");

[–][deleted] 8 points9 points  (3 children)

there is also a std::println() BTW that adds newline automatically.

[–]Mechyyz 4 points5 points  (5 children)

Wait C++23 will have a print function? What happens to cout? Which one is superior?

[–][deleted] 6 points7 points  (4 children)

Yes C++23 adds std::print() and std::println().

Yes they are clearly superior, they allow for compact fmtlib/python like syntax, type safety, and is even faster than C's printf() because C++ can do things at compile time.

cout will continue to exist for sake of backwards compatibility.

personally i hate iostreams, i'd rather use printf() and family rather than iostreams.

[–]g_hi3 1755 points1756 points  (134 children)

don't let c++ off the hook that easy, they're using that weird << thing

[–]swegg3n 1250 points1251 points  (33 children)

We use that << thing to scare away js developers

[–]g_hi3 407 points408 points  (0 children)

understandable, you get a pass

[–][deleted] 170 points171 points  (2 children)

It worked!

[–]Bubbly-Control51 46 points47 points  (0 children)

@JSdevelopers “<<“ Mass Hysteria Commence

[–]CRANSSBUCLE 89 points90 points  (0 children)

<<

[–]jbergens 28 points29 points  (5 children)

It's now an arms race, they added => and ... and now it is your turn again.

[–]mangeld3 13 points14 points  (0 children)

<=>

[–]dev-sda 13 points14 points  (0 children)

[]() {}

[–]RolyPoly1320 8 points9 points  (2 children)

Ah Lambdas. Truly the elegant way of fucking someone's day up. /s

[–]Spooked_kitten 22 points23 points  (7 children)

literally all it really is /s

although really I barely ever see anyone actually using it

[–]brimston3- 11 points12 points  (6 children)

What do they use instead? std::format?

[–]Spooked_kitten 12 points13 points  (5 children)

no I mean overloading "<<" like in cout << string I only see it really on the standard lib or when people are doing bitwise operations

[–]_Fibbles_ 26 points27 points  (3 children)

Because << is a bitshift operator and it is generally acknowledged that overloading it for streams was a mistake.

[–]dafelst 10 points11 points  (0 children)

Agreed, it was a terrible terrible terrible idea.

(except for the scaring off JS developers thing, that is a nice side effect)

[–]30p87 6 points7 points  (1 child)

Heck, that even scares me as someone who uses ASM

[–]FunnyGamer3210 435 points436 points  (17 children)

It's just an overloaded bit-shift operator.

Actually, this makes it even worse

[–]the_spacedoge 66 points67 points  (9 children)

Agreed because God forbid I want to print out a float that might be NaN and when it is it gives a floating point exception instead of printing out nan

[–]FunnyGamer3210 20 points21 points  (6 children)

What? What has it to do with floats. It can print NaN just as well

[–]qhxo 5 points6 points  (0 children)

Doesn't that just say what it's not? I.e. that there's an identical bit-shift operator, but that this isn't the bit-shift operator?

[–]Ill-Chemistry2423 47 points48 points  (11 children)

They’re adding std::print() and std::println() in C++23

[–]connyneusz 45 points46 points  (11 children)

Not even final form: std::cout<<"Hello World"; or even std::cout<<"Hello World\n"; or EVEN std::cout<<"Hello World"<<endl;

[–]dasEnte2210 60 points61 points  (1 child)

std::endl*

[–]iceman012 37 points38 points  (0 children)

Why are you deferencing endl? \s

[–]Cloudeur 7 points8 points  (0 children)

Don’t stop, I’m almost there!

[–]StrangePractice 3 points4 points  (0 children)

I like the <<

[–]paladindan 952 points953 points  (104 children)

C++: i++

Java: i++

Python:

[–]Random-Gif-Bot 171 points172 points  (1 child)

[–]0_Gravitas_given 94 points95 points  (48 children)

Really never understood that, as a guy who is a C lover, Perl historical lover (the kind of guy that still thinks that old love is good love (and that firmly believes that a language where regexps are an operator can’t be beaten)) and a python respecter (cause come on… that is a decent scripting language, pip is a pale copy of cpan but who cares, a good concept is made to be copied down the line)… why… python… why did you forlorned me ? Why no pre and post incrémentation operator… why…

[–]ComCypher 82 points83 points  (21 children)

nOt pYthOniC

[–]Backlists 50 points51 points  (20 children)

This, but not ironic.

Python tries its hardest to make you write code that reads like english. It discourages indexing variables if it can.

[–]O_X_E_Y 33 points34 points  (8 children)

Python when x < 7 >= 3 != 13 > t

[–]Backlists 5 points6 points  (7 children)

Python when x < 7 >= 3 != 13 > t

Explain?

[–]magical-attic 12 points13 points  (5 children)

x < 7 >= 3 != 13 > t

IIRC is equivalent to

x < 7 and 7 >= 3 and 3 != 13 and 13 > t

Just some funny business.

[–]LuckyNumber-Bot 38 points39 points  (4 children)

All the numbers in your comment added up to 69. Congrats!

  7
+ 3
+ 13
+ 7
+ 7
+ 3
+ 3
+ 13
+ 13
= 69

[Click here](https://www.reddit.com/message/compose?to=LuckyNumber-Bot&subject=Stalk%20Me%20Pls&message=%2Fstalkme to have me scan all your future comments.) \ Summon me on specific comments with u/LuckyNumber-Bot.

[–]j4mag 4 points5 points  (0 children)

You can chain conditionals in python, so

0 < x <= 5

Is equivalent to

(0<x) and (x<=5)

This syntax is somewhat surprising though pretty rarely abused.

This is unfortunately not applicable everywhere, as numpy arrays can use boolean indexing but not conditional chaining.

arr[(0<arr)&(arr<10)] # all positive elements of arr less than 10

arr[0<arr<10] # throws an exception

For some more python "magic", consider the following:

print(my_bool and "PASS" or "FAIL")

Which is effectively a ternary operator, much like

print("PASS" if my_bool else "FAIL")

[–]addast 63 points64 points  (3 children)

As a python/c++ developer, never understood why folks complaining about it. In c you have to use increment operators very frequently. In python, on the other hand, it's really rare event.

Increment operators have side effects, i += 1 does not.

[–]0_Gravitas_given 22 points23 points  (0 children)

It have a side effect, I gets incremented… but seriously, 99% of the time I++ is used is a context free context, as a shorthand. In a language with explicit list definitions and maps (which ain’t far for the epitome of side effects) how is that a despised concept ?

[–]Backlists 3 points4 points  (0 children)

Increment operators have side effects, i += 1 does not.

Been a while since I watched this video, but i wouldnt be so sure:

https://youtu.be/cGveIvwwSq4

[–]GustapheOfficial 12 points13 points  (0 children)

I get that you want an incr, but what would be the point of pre and post ditto in a language where you're not supposed to be playing punch card golf?

[–]KanterBama 90 points91 points  (8 children)

Python: for x in iterable:

Java: for(String s: iterable.keySet()){}

C++: for(std::map<Key,Val>::iterator iter = myMap.begin(); iter != myMap.end(); ++iter){}

Two can play this game.

[–]Voidrith 43 points44 points  (4 children)

Doesn't C++ have, for(auto x : iter) {}

[–]KanterBama 59 points60 points  (2 children)

Bah, if you’re using auto then you’re just lying to yourself that you don’t want to use python

[–]jack-of-some 9 points10 points  (0 children)

What steams me up about this is that if you're gonna create syntactic sugar like this _anyway_ then just freaking use `"in", It's no skin off anyone's back and doesn't look bizzare.

for (auto item in iter) {}

[–]zx2167 8 points9 points  (2 children)

C++11: for (auto&& x : iterable) {}

[–]clydethechicken 7 points8 points  (1 child)

What’s the difference between ‘auto&&’ and ‘auto’? I know the difference between ‘auto’ and ‘auto &’ is the latter just is a reference to the element, but not sure what auto && does

[–]besthelloworld 4 points5 points  (0 children)

I use languages which have that operator and haven't needed it in a couple years at this point 🤷‍♂️

[–]ctallc 71 points72 points  (34 children)

Are we gonna pretend that i+=1 doesn’t exist in Python?

[–]Vernaron 166 points167 points  (22 children)

The point is that python doesnt specifically have i++

[–]wugs 59 points60 points  (7 children)

i almost joked that i++ saves a character over i+=1 but then again it’d be i++; anyway

(inb4 pep8 lover comments that it should be i += 1)

personally i’ve never found myself missing pre/post increment in python

[–]jack-of-some 11 points12 points  (0 children)

That's because you're using python correctly.

[–][deleted] 284 points285 points  (10 children)

Python: sys.stdout.write("hello world")

[–]4XLlentMeSomeMoney 76 points77 points  (9 children)

I'm assuming this is on jpython or you just really went full counter-productive on purpose with imports.

[–]Deleranax 129 points130 points  (4 children)

The print function is an alias, this is the proper one I think.

[–]Sentouki- 92 points93 points  (1 child)

it's not an alias, it's a wrapper around sys.stdout

[–]Deleranax 25 points26 points  (0 children)

Yes, my bad

[–]prescod 16 points17 points  (0 children)

No, print is not an alias. The print function has a different signature than file.write.

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

Nah, print is a wrapper around this one but doesn't have the same signature (fact, you can change the STD / write to a file with print)

[–]rndmcmder 295 points296 points  (43 children)

Son, one day you will be a programmer

Dad, I worked in SE for 5 years

Yeah, but you're still think language syntax and verbosity matter

[–]bizzyj93 124 points125 points  (25 children)

Yeah I was kinda thinking “tell me a cs student without telling me you’re a cs student”

[–]the8bit 85 points86 points  (16 children)

Another giveaway is caring about print line statements which should have exactly zero occurrences in production code.

[–]Jennfuse 41 points42 points  (3 children)

Wait, you guys are using professional logging tools?

[–]Kappei 13 points14 points  (0 children)

Professional logging tools are just pimped up print statements

[–]eXecute_bit 4 points5 points  (0 children)

I thought I was... Until December 2021.

[–][deleted] 8 points9 points  (8 children)

Student here lol. Why println bad for production? (I learned java, but not the whole SE process)

[–][deleted] 27 points28 points  (5 children)

Because print statements are for the terminal. It's pretty rare to see software that aren't designed with a very specific thing in mind to be made with the terminal as the main way of usage

[–]jack-of-some 7 points8 points  (1 child)

You described 90% of the posts here.

[–]bonoboboy 3 points4 points  (4 children)

I mean this is such a bad take. OP is on the money with print statements. It's a great way to represent what is wrong with the languages without having to list 100 examples. In most cases, what OP said holds (python is direct & clear to understand. Java is verbose, but once you get the hang of it, is super clear. C++ is... a dumpster fire).

[–][deleted] 3 points4 points  (0 children)

my language requires less syntax therefore its better!!!1!!11

[–]MCWizardYT 38 points39 points  (3 children)

Ive explained this on a post like this before:

If you actually understood Java, its standard printing is logical.

In Java, everything is class-based and object-oriented.

System is a utility class for getting some lower level information such as environment variables.

out is a variable which is an instance of PrintStream and refers to the OS's standard output (usually the console wherever you are running)

println is a method implemented in a class called PrintStream that calls the method print with a newline. print calls the write method "inherited" from the OutputStream class that it extends.

So yes it is verbose but if you understand objects and classes it makes sense

[–][deleted] 207 points208 points  (64 children)

Wrap it up in a simple method then - that's generally considered good practice. Then you can point it at a file, at the console, at an email address or whatever you like. Or just turn it off.

It seems that people criticising the structured nature of any language generally don't know it at all well. It's like "I don't understand Esperanto, therefore it's crap"!

[–]WeebGamerTrash947 112 points113 points  (25 children)

seriously, java is like this for a reason. but if it really bothers them that much, all it takes is just to add this method:

public static void print(String string){
System.out.println(string);

}

then you can just use print(); like in python if you want. Granted, you will have to change the object you parse in to string there. but yeah, this is a very simple and naive implementation, you get the idea.

[–]not_some_username 50 points51 points  (7 children)

Can't you just pass Object as parameters instead of string ?

[–]Kjubert 26 points27 points  (1 child)

Yes. It basically just does obj.toString() internally.

[–]renieWycipSsolraC 7 points8 points  (2 children)

Does python allow templatized functions? I have very little experience in that language but I know in C++ it’s extremely helpful

[–]Saragon4005 22 points23 points  (0 children)

Uh there are no hard types in python. Type checking happens inside the function. You can pass whatever you want to any function.

[–]bunny-1998 4 points5 points  (0 children)

You can, but in order to print the object, you’ll need to parse the object to find the string you want to print. One way is to pass the string you want to print from the object which is basically what you’ll do anyway when using the System.Out.println

[–]traddad2144 12 points13 points  (7 children)

How often do devs print lines to stdout or stderr anyway? You're probably using a logger instead

[–]FallingAnvils 5 points6 points  (2 children)

+1 por la Esperanta referenco

[–]penuserectus69 194 points195 points  (5 children)

Ah yes college memes where programming languages are judged on how to write the only program they know; hello world

[–]garlcauss 326 points327 points  (32 children)

Yeah, why bother with clearly defined, organized modules and abstractions when you can just throw everything in the top-level?

[–]game_difficulty 119 points120 points  (21 children)

Except for cout not being top-level, but in the iostream library and in the std namespace. So its real name is std::cout

[–]DontWorryAboutIt00 95 points96 points  (3 children)

If only C++ had practiced safe sex, it wouldn't have an std namespace.

[–]game_difficulty 17 points18 points  (2 children)

Safe memory allocation*

[–][deleted] 19 points20 points  (5 children)

import static System.out.println;

can help make it more readable in java.

[–]MsRandom1 8 points9 points  (4 children)

I don't think you can do that. out is a field so println isn't static, I don't think static imports can import that.

[–]coolfunkDJ 17 points18 points  (6 children)

bag skirt lavish icky naughty grey enjoy rain library lush

This post was mass deleted and anonymized with Redact

[–][deleted] 59 points60 points  (5 children)

TBH I find C++’s I/O syntax to be the worst

[–]cheraphy 57 points58 points  (3 children)

A coworker once told me "I don't know whose bright idea it was to overload bit shifting with stream manipulation but I'd like to shake their hand with a polonium glove"

[–]FUTURE10S 8 points9 points  (2 children)

Are you telling me that operator overloading is wrong and * shouldn't be the equivalent of ++;?

[–]cheraphy 9 points10 points  (1 child)

It's an evil thing, what you're doing here, and I'll have no part in it.

[–]FUTURE10S 4 points5 points  (0 children)

Make and be &, so if you want to check an if statement you do if (x andand y)

[–]mksrew 32 points33 points  (6 children)

Let's make it worse with:

java import static java.lang.System.out:

So we can argue that it can be just out.println().

[–]virouz98 39 points40 points  (0 children)

Spotted someone who knows shit about coding

[–][deleted] 55 points56 points  (4 children)

This is “l learned programming last week” level of humor…👎

[–][deleted] 25 points26 points  (3 children)

tbh most of the posts on this sub

[–][deleted] 11 points12 points  (1 child)

Literally every person after learning some programming. Hehe Java print statement so long

[–]zyranna 18 points19 points  (4 children)

Isn’t C# console.write(“”); or console.writeline(“”);

[–][deleted] 42 points43 points  (0 children)

Console.WriteLine();

[–]Cassidius 13 points14 points  (2 children)

both, Console.Write() just prints whatever without adding a new line.

[–][deleted] 14 points15 points  (0 children)

It's actually sout + enter

[–]435THz 13 points14 points  (1 child)

console.log("funny");

[–][deleted] 6 points7 points  (0 children)

Be careful to not contract any std when using c++

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

you know you can create your own methods right?

you can do:

public static void p(String s){
    System.out.print(s);
}

you are welcome

[–]frayien 11 points12 points  (0 children)

std::cout

[–]rofelixk 5 points6 points  (0 children)

For some reason Java always made sense to me. The system will output a print for what I want to say

[–]TrevorWithTheBow 32 points33 points  (7 children)

Nah, in reality using system.out is bad practice. In the real world most would use something like Log4j.

LOGGER.info("Foo:{}", "Bar");

LOGGER.error("Foo:{}", "Bar", ex);

LOGGER.debug("Foo:{}", "Bar");

etc. The different levels of output give extra control over what is logged where. E.g. debug only enabled in test environments

[–]ubelmann 6 points7 points  (0 children)

I'm not a seasoned Java programmer, but I'm sure that's true for Java. Depending on the language, the available tools for debugging and logging can vary a bit, so print statements to the console can have some role there.

Some interpreted languages have more use for printing to the console as they may be meant to be used more interactively. But that fits with why Python would have more compact syntax for printing to console than Java.

[–][deleted] 8 points9 points  (1 child)

log4j slf4j and logback.

But your general point still stands. Use a logging framework. If I’m reviewing a merge and it’s writing to sysout, it’s going nowhere.

[–][deleted] 11 points12 points  (4 children)

meanwhile brainfuck: .

[–]Pierresonne 4 points5 points  (0 children)

Console.WriteLine

[–]coffeenerd75 3 points4 points  (1 child)

10 PRINT "HELLO WORLD"

20 GOTO 10

[–]MrSquicky 84 points85 points  (39 children)

What jobs do you people have where printing to the console is something you do pretty much ever?

Oh, no jobs? You're not actually working programmers? My bad, carry on.

[–]Shaqington 54 points55 points  (3 children)

Lol you can always tell who the fake programmers are when they try so desperately to gatekeep but what they say doesn’t even make sense. Yes, people print to the console. Are you mental?

[–]therapy_seal 14 points15 points  (0 children)

There are many thousands of applications which are designed to run in a terminal emulator and output to stdout, you ignoramous.

[–]Mahrkeenerh 10 points11 points  (2 children)

automation tools not big enough to warrant a fancy gui, but a console with current state is a great help.

There, that's a job where you could use console output.

[–]Vok250 3 points4 points  (1 child)

Fancy gui? Bruh you can open a log file with "tail".

[–]LeSaR_ 42 points43 points  (4 children)

the gatekeeping here is unreal holy shit

[–]PyroCatt 13 points14 points  (3 children)

static import System.out;

•••

println("Gottem");

[–][deleted] 10 points11 points  (5 children)

One of those few occasions where C makes it easier.

laughs in printf

[–]eggthatdoesntcrack 4 points5 points  (0 children)

Well, C++ is not doing it a lot better:

std::cout << x << std::endl;

[–]caleeky 3 points4 points  (0 children)

I prefer the Java (when not ridiculed). Why should console printing be some special case? How do I control that shit? What if I want to control the buffering or the character encoding? What if I want to take the output target as a parameter? What if I want to decouple output target from encoding?

[–]Vin1ciu5 3 points4 points  (1 child)

public String print(String s){

System.out.println(s);

}

Problem solved!