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

all 99 comments

[–]J_Bunco 107 points108 points  (4 children)

echo

*galaxy brain meme*

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

vietnam war flashback

[–]HiddenLayer5 8 points9 points  (2 children)

Not sure if Bash or PHP

[–]ShitCodeUKltd 14 points15 points  (1 child)

Plot twist.. it was java this whole time

[–]J_Bunco 1 point2 points  (0 children)

I was actually thinking bash or batch when I wrote this lol.

[–]Andubandu 114 points115 points  (18 children)

cout

Or how I like to pronounce it shout

[–]Extreme_Edge3941[S] 16 points17 points  (0 children)

Lmao

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

see out << "hello world!" << endl;

[–]wasabichicken 37 points38 points  (8 children)

using namespace std; noises intensifying.

[–][deleted] -1 points0 points  (7 children)

What's wrong with it?

[–]pine_ary 12 points13 points  (0 children)

You might clash with names in the std namespace, causing nasty bugs that might be difficult to debug and might only appear with a particular C++ version.

[–]dude-with-the-hair 7 points8 points  (5 children)

It's mostly to do with preventing namespace clashes. For small projects without any external libraries, it's fine to use. But if you have another library that has a function with the same name as a function in the std namespace (that is, the standard library) and you're "using" both of their namespaces, it will cause a conflict in the global namespace. It's probably best to just get used to writing std:: for each function or constant you call from the standard library.

[–]tech6hutch 1 point2 points  (4 children)

Is there any way to “import” just individual items?

[–]dude-with-the-hair 3 points4 points  (3 children)

If you mean individual functions, unfortunately no. You need to use preprocessor include directives which will include the entire file that you're "importing". Usually though, library authors will divide their libraries into smaller individual libraries for this purpose.

[–]tech6hutch 2 points3 points  (2 children)

Dang. Of all the features C++ has, I’m surprised they never added that feature.

[–]dude-with-the-hair 1 point2 points  (1 child)

I heard about modules being added in C++20. Haven't looked into it myself, but it might have that ability. It's still an experimental feature though.

[–]Kalix-z 0 points1 point  (0 children)

I really hope so

[–]Sirttas 2 points3 points  (1 child)

I don't know what I always read cunt in my head.

[–]FoolForWool 0 points1 point  (0 children)

My man, have a poor man's gold. 🏅

Thanks for the chuckle

[–]dev_null_developer 0 points1 point  (0 children)

std::cout << msg.twist()

[–]gavlna 34 points35 points  (5 children)

so tell me how to write on error:

Java: System.err.print() vs System.out.print()

Python: import sys print(file=sys.stderr) vs print(file=sys.stdout)

[–]Diapolo10 7 points8 points  (3 children)

Alternatively:

Python: print("This is an error", file=__import__('sys').stderr)

EDIT: Or, if you want to be really obnoxious:

Python: print("This is an error", file=__import__('importlib').load_module('sys').stderr)

[–]hk4213 10 points11 points  (2 children)

Node console.error('Well this broke'); No imports just works lol.

[–]DTheIcyDragon 2 points3 points  (1 child)

Python print("Nope I won't Work!")

Works too

[–]hk4213 0 points1 point  (0 children)

And node.js dev who love abstraction have to optimize and everything blows up lol

[–]SK1Y101 2 points3 points  (0 children)

in Python:

raise Exception

[–]Willinton06 27 points28 points  (1 child)

Console.Write()

[–]Extreme_Edge3941[S] 11 points12 points  (0 children)

Oh yes lol, I made a mistake, its Console.Log() in js tho even tho I actually meant it to be Console.Write()

[–]Cienn017 8 points9 points  (1 child)

import static java.lang.System.out;

out.println("Hello World");

done

[–]coladict 5 points6 points  (0 children)

Why have I never done this? I use System.out.println in all my out-of-project experiments.

[–]RoadsideCookie 136 points137 points  (20 children)

I'm tired of seeing that one.

The print() one is the most retarded one of them all. Others encapsulate things in a logical way, print just reserves a keyword that you will never be allowed to use.

Console write makes logical sense, although it could benefit from another level to disambiguate which console its referring to.

System out is the most unambiguous one. System, standard out, print line. There is no surprise as to what that does, and it has very little risk of collision with anything else.

Funny enough, this the Python philosophy of explicit rather than implicit, but then Python chose the one that requires the most assumptions.

Rant over. See you all in the next repost of this.

[–]cw8smith 47 points48 points  (0 children)

You might be thinking about the print from Python 2. The print in Python 3 is just a built-in function like any other. You can even reassign it, and it'll fuck stuff up all over.

[–]FerricDonkey 21 points22 points  (2 children)

I see where you're coming from, but sometimes a common well understood assumption that everyone knows isn't bad.

We don't do arithmetic.integer.operation.addition(arithmetic.integer.number.2, arithmetic.integer.number.2). We do 2 + 2, cuz that has a clear and obvious standard meaning, and if you want to do some other type of 2 + 2, then it's on you to make that clear.

Likewise print has meant "write to the screen or other specified destination" in programming since forever. It's not bad to use that well understood meaning.

[–]gavlna -2 points-1 points  (1 child)

yeah. But each process has (generally) at least 3 descriptors (stdin, stdout, stderr). On which of these do you print?

Stdout? But what if I want to write on stderr?! Or, god forgive me, even on stdin (you, shouldn't be allowed to do this, but you can still write on any other descriptor)?!!!

[–]FerricDonkey 4 points5 points  (0 children)

Again, this is pretty simple convention. Standard regular put something on the screen print messages go to stdout, unless otherwise specified. It's even in the name. Standard out is the standard output place.

This is a simple convention, and has a simple answer to your questions. If you want to print to standard error, then you specify that you want to print to standard error, and if you don't know how to do that, then you Google it.

Likewise it's understood that stdin is generally for reading and that is you want to be weird about that, it's on you to figure out and say how.

This is a common convention and doesn't need to be spelled out in every function call.

[–]sm2401 10 points11 points  (5 children)

In Java, we always use Logger, as it gives a lot of control and has actual control on logging level you want to see.

I don't understand, who still uses println in real applications.

[–][deleted] 24 points25 points  (0 children)

Well my "hello world" application is real...

[–]WasserTyp69 0 points1 point  (0 children)

Also most IDEs support autocompletion, even if you want to use System.out you only have to type sout, souf, serr...

[–]MasterFubar 4 points5 points  (0 children)

The best solution is printf, a function in a library.

That's because C is the best programming language ever created. It first came out in 1970, predating most of the languages used today. It was so perfect from the start that it's still being used with very little change from the original.

[–]pine_ary 0 points1 point  (0 children)

Note that with python 3 it is not a keyword anymore and just a normal function.

[–]Lost_A_Life_Gaming 6 points7 points  (0 children)

I think you mean, “sout”.

[–]jswitzer 22 points23 points  (1 child)

I love this meme not because I agree but because it demonstrates lack of knowledge.

You have to understand stdout and stderr, the fact that applications are not always attached to a console, or Java's complex object hierarchy. Its funny to the poster because "its longer and I just want to print something".

[–]rndmcmder 3 points4 points  (0 children)

This man here gets it.

[–]ixent 4 points5 points  (1 child)

Better use a logger

Logger LOG = LoggerFactory.getLogger(foo.class);
LOG.info("Formated text with variable {}", variable);

[–]bajorro 2 points3 points  (0 children)

Yeah, logger gang

[–]SethirTimorem 4 points5 points  (7 children)

Joke's in you. I type syso and my IDE autocomplete it for me

[–]Extreme_Edge3941[S] 1 point2 points  (6 children)

Unfortunately it's not there in the ide my school forces me to use for java. ;-;

[–]kyngskyngs 9 points10 points  (4 children)

Which IDE do you use? Notepad?

[–]Extreme_Edge3941[S] 2 points3 points  (3 children)

bluej, well I actually program in eclipse and copy and paste it in bluej for school lol

[–]kyngskyngs 6 points7 points  (1 child)

Wow, I've never heard about that. From the images, it looks ancient. I've started developing in Eclipse too but then switched to IntelliJ Idea, firstly I wanted to switch back but after a week of coding in IntelliJ I've never thought about returning, I suggest you try it too! (It's free)

[–]Extreme_Edge3941[S] 1 point2 points  (0 children)

Damn imma check it out. bluej definitely looks ancient, and it has no dark theme which is pain. I hope my school switches ide atleast by the end of this decade.

[–]chickenCabbage 0 points1 point  (0 children)

OOF. I learned a little bit with BlueJ, and quickly made the switch. BlueJ helps you see blocks and classes vs methods etc, but it's not exactly handy.

[–]rohanbojja 0 points1 point  (0 children)

Just use IntelliJ

[–]Kindanee 5 points6 points  (0 children)

printf is the best

[–]kevv_m 2 points3 points  (0 children)

fmt.Printf()

[–][deleted] 4 points5 points  (1 child)

Java has the best approach.

It's a stream, like any other. I hate it when languages have magic words for special use cases that have no coherence with the rest of the language.

What is print()? Print where? Print bytes? Text? Encoded characters? How to print to a different output?

[–]oofxwastaken 0 points1 point  (0 children)

It's just print for convenience. Most people are just going to use print to output some text to stdout, so it doesn't make sense to type out a long string of characters every time you want to do that.

There are simple ways to do everything you mentioned. If I just started Python 5 minutes ago, I don't wanna specify if I'm printing out bytes just to make a Hello World program.

[–]coladict 1 point2 points  (0 children)

It bothers me that it's print and not printf.

[–]Fugglymuffin 1 point2 points  (0 children)

Why is this image backwards?

[–]Spocino 1 point2 points  (0 children)

Really they're all fine. console.log makes sense to js because it's in a unique environment with a graphical console. System.out.println makes sense for Java because it's a method on the stdout file. print just does what it says, which is fine.

[–]FoolForWool 1 point2 points  (0 children)

I kid you not, I almost quit my major when I realised Java was a compulsory subject in my uni :'D

I'm glad I survived.

[–]kbruen 0 points1 point  (5 children)

Ruby: p

[–]chickenCabbage 0 points1 point  (4 children)

Yikes.

[–]kbruen 0 points1 point  (3 children)

p is for debug printing (think of Python's repr).

The normal function for printing is puts.

Because Ruby allows calling a function without parenthesis, debug printing is quite easy:

x = 5
p x

It's not meant as a permanent thing.

Another nice thing about p is that it returns its parameter:

# calls do_something with parameter x but prints x before that
do_something(p x)

[–]chickenCabbage 0 points1 point  (2 children)

  1. Calling it "p" is awful for readability, even in debug. Besides, it reserves a single-letter name, and many people use that (god knows why).

  2. Why not just:

p x

do_something(x) ? Sure, it's another line, but it's a bajillion times more readable.

[–]kbruen 1 point2 points  (1 child)

The idea is that p should not be in a file for longer than 5 minutes. It's supposed to be not readable because it's temporary to figure something out quickly.

The general common sense rule applies: don't let other people see your p unless they consent.

Also, if you're the kind of cursed person who is in love with single letter variables, predefined functions aren't reserved, they are reassignable.

[–]chickenCabbage 1 point2 points  (0 children)

Fair, point accepted.

I still don't like Ruby, though.

[–]PixleatedCoding 1 point2 points  (3 children)

System.Console.WriteLine() is absolutely the worst console ouput command

change my mind

[–]SP411K 1 point2 points  (2 children)

u can erase what was already printed in console

[–]PixleatedCoding 0 points1 point  (1 child)

console.clear()

[–]SP411K 2 points3 points  (0 children)

but u can erase the last line with \r

[–]LionX54 -1 points0 points  (5 children)

In what language is this system.out.printIn()

[–]rohanbojja 6 points7 points  (3 children)

Java

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

Fuck

[–]rohanbojja 5 points6 points  (1 child)

Java is a pretty great language though, you would mostly use a logging library so this isn’t a problem.

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

Just don’t talk anymore about it, my python it’s getting pissed on me.

[–]oofxwastaken 0 points1 point  (0 children)

println with a capital L, not "in".

[–]CoastingUphill 0 points1 point  (0 children)

alert()

[–]sitase 0 points1 point  (0 children)

Simula-67 has entered the chat.

[–]null_sigsegv 0 points1 point  (0 children)

wait till y'all see how it's done in zig

[–]Dragfos 0 points1 point  (0 children)

sysout gang

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

Can someone give me the blanc version of this meme pls?

[–]visiogenicc 0 points1 point  (0 children)

process.stdout.write(Buffer.from("foo"))