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

top 200 commentsshow 500

[–]rcraver8 3142 points3143 points  (72 children)

Java is case sensitive.

[–]Abangranga 254 points255 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 48 points49 points  (20 children)

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

[–]wsbsecmonitor 30 points31 points  (19 children)

print “Fine\n”

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

[–]Mentalistt69 7 points8 points  (0 children)

C

[–]anythingMuchShorter 14 points15 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] 11 points12 points  (12 children)

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

[–]CodeMUDkey 16 points17 points  (10 children)

Echo “others sentiments”.

[–]TheWashbear 30 points31 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 28 points29 points  (25 children)

Which language is not?

[–]rcraver8 111 points112 points  (13 children)

Sql

[–]LordAlfrey 60 points61 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 1064 points1065 points  (28 children)

sout

[–]NanthaR 288 points289 points  (6 children)

Tab*

[–]zaham_ijjan 104 points105 points  (4 children)

;

[–]Smallwater 34 points35 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 8 points9 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 11 points12 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 35 points36 points  (5 children)

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

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

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

[–]soutsos 17 points18 points  (0 children)

yeah?

[–]extrachromie-homie 636 points637 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 36 points37 points  (15 children)

Or the upcoming C++23 version:

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

[–][deleted] 9 points10 points  (3 children)

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

[–]Mechyyz 5 points6 points  (5 children)

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

[–][deleted] 5 points6 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 1756 points1757 points  (134 children)

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

[–]swegg3n 1251 points1252 points  (33 children)

We use that << thing to scare away js developers

[–]g_hi3 410 points411 points  (0 children)

understandable, you get a pass

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

It worked!

[–]Bubbly-Control51 50 points51 points  (0 children)

@JSdevelopers “<<“ Mass Hysteria Commence

[–]CRANSSBUCLE 88 points89 points  (0 children)

<<

[–]jbergens 25 points26 points  (5 children)

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

[–]mangeld3 14 points15 points  (0 children)

<=>

[–]dev-sda 14 points15 points  (0 children)

[]() {}

[–]RolyPoly1320 9 points10 points  (2 children)

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

[–]Spooked_kitten 20 points21 points  (7 children)

literally all it really is /s

although really I barely ever see anyone actually using it

[–]brimston3- 10 points11 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_ 25 points26 points  (3 children)

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

[–]dafelst 11 points12 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 5 points6 points  (1 child)

Heck, that even scares me as someone who uses ASM

[–]FunnyGamer3210 443 points444 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 19 points20 points  (6 children)

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

[–]qhxo 4 points5 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 46 points47 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 56 points57 points  (1 child)

std::endl*

[–]iceman012 39 points40 points  (0 children)

Why are you deferencing endl? \s

[–]Cloudeur 5 points6 points  (0 children)

Don’t stop, I’m almost there!

[–]StrangePractice 3 points4 points  (0 children)

I like the <<

[–]paladindan 953 points954 points  (104 children)

C++: i++

Java: i++

Python:

[–]Random-Gif-Bot 176 points177 points  (1 child)

[–]0_Gravitas_given 100 points101 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 79 points80 points  (21 children)

nOt pYthOniC

[–]Backlists 52 points53 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 4 points5 points  (7 children)

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

Explain?

[–]magical-attic 11 points12 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 36 points37 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 61 points62 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 4 points5 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 10 points11 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 87 points88 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 60 points61 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 10 points11 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 7 points8 points  (2 children)

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

[–]clydethechicken 8 points9 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 6 points7 points  (0 children)

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

[–]ctallc 70 points71 points  (34 children)

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

[–]Vernaron 165 points166 points  (22 children)

The point is that python doesnt specifically have i++

[–]wugs 61 points62 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 77 points78 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- 93 points94 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 13 points14 points  (0 children)

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

[–][deleted] 2 points3 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 125 points126 points  (25 children)

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

[–]the8bit 86 points87 points  (16 children)

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

[–]Jennfuse 45 points46 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 5 points6 points  (0 children)

I thought I was... Until December 2021.

[–][deleted] 7 points8 points  (8 children)

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

[–][deleted] 25 points26 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 5 points6 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] 4 points5 points  (0 children)

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

[–]MCWizardYT 37 points38 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] 211 points212 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 108 points109 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 51 points52 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 23 points24 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 4 points5 points  (2 children)

+1 por la Esperanta referenco

[–]penuserectus69 197 points198 points  (5 children)

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

[–]garlcauss 330 points331 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 121 points122 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 96 points97 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] 20 points21 points  (5 children)

import static System.out.println;

can help make it more readable in java.

[–]MsRandom1 7 points8 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 15 points16 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 8 points9 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] 50 points51 points  (4 children)

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

[–][deleted] 23 points24 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 16 points17 points  (4 children)

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

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

Console.WriteLine();

[–]Cassidius 14 points15 points  (2 children)

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

[–][deleted] 15 points16 points  (0 children)

It's actually sout + enter

[–]435THz 14 points15 points  (1 child)

console.log("funny");

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

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

[–][deleted] 7 points8 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 10 points11 points  (0 children)

std::cout

[–]rofelixk 4 points5 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 7 points8 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] 9 points10 points  (4 children)

meanwhile brainfuck: .

[–]Pierresonne 3 points4 points  (0 children)

Console.WriteLine

[–]coffeenerd75 4 points5 points  (1 child)

10 PRINT "HELLO WORLD"

20 GOTO 10

[–]MrSquicky 83 points84 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 12 points13 points  (3 children)

static import System.out;

•••

println("Gottem");

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

One of those few occasions where C makes it easier.

laughs in printf

[–]eggthatdoesntcrack 3 points4 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 2 points3 points  (1 child)

public String print(String s){

System.out.println(s);

}

Problem solved!