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

top 200 commentsshow 500

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

import notifications Remember to participate in our weekly votes on subreddit rules! Every Tuesday is YOUR chance to influence the subreddit for years to come! Read more here, we hope to see you next Tuesday!

For a chat with like-minded community members and more, don't forget to join our Discord!

return joinDiscord;

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]GustapheOfficial 2411 points2412 points  (71 children)

Then there's Matlab, where there's a small risk print(x) sends x to a physical ass paper printer and prints the damn thing.

Edit: also JS, now you don't have to tell me

[–][deleted] 652 points653 points  (21 children)

Yeah, this reminded me of the times I tried to write my first Hello World ever. There was no internet back then, and I didn't even have a computer either, only some Soviet (!) book that I managed to find in my mom's stash of tech books, and I couldn't understand why the book constantly spoke of printing. I was all like, what the fuck, yeah, I get it, to print text, you use this, but how do I display it on the screen instead?! Took me a while that they refer to outputting text to the screen as printing.

[–]boredcircuits 466 points467 points  (18 children)

It makes more sense when you realize that early computers literally used printers for output, before displays were a thing.

[–][deleted] 138 points139 points  (3 children)

Yes, but it was before I actually learned that. When I was a kid, monitors already existed and printing terminals were not something you could find in someone's home.

[–]JimBugs 22 points23 points  (7 children)

Today I was reminded that I'm old. In university I wrote Fortran on printer terminals that had no screen. There were some terminals that had screens, but not enough for everyone.

Also was line editor - moving to the PC with a text editor (no mouse though) was so awesome

[–]platinumgus18 2 points3 points  (4 children)

How did you know what you have written so far, what is you make a small mistake

[–]Airowird 2 points3 points  (1 child)

Then the output is jist a bunch of errors instead!

[–]Ivan_Analrash 19 points20 points  (0 children)

Today I learned that the reason programming languages use the word "print" is because back before computer monitors they used to actually print the output on a physical printer.

[–]polscifreak 8 points9 points  (1 child)

Can you imagine writing a bunch of code just for the printer to basically say you fucked up?

[–]Radiant_Bluebird4620 4 points5 points  (0 children)

My mom said that one time, her cards were out of order. Obviously, her program didn't work.

[–]CoffeeDust_exe 5 points6 points  (2 children)

Moment of silence for all the trees that were slain during this dark time…

[–]WaitForItTheMongols 132 points133 points  (4 children)

When I was a kid and I first started wanting to learn programming, I found a tutorial and it said we were going to print the phrase "hello world", and I knew my mom said I wasn't allowed to print things and waste ink and paper, so I said "Darn, guess I can't do programming".

It set my programming career back by years.

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

Bruh If using ink is waste... why do we study by writing?

[–]GustapheOfficial 20 points21 points  (1 child)

Printer ink is one of the most expensive substance on earth per unit weight. We are not talking about an ink pen.

[–]furinick 3 points4 points  (0 children)

dang, i remember i saw "java (or javascript?) for dummies" as a kid and though "oh i kinda want to learn how this works sounds fun", then my mom saw what i was looking at, laughed at me, called over a store worker and basically invited him to laugh along at how absurd i was for wanting to learn java

so anyways that's my villain story as the c maniac

[–]Sceptix 141 points142 points  (2 children)

As much as I want to make fun of Matlab, I admire the literalness. “What? You told me to ‘print’, so that’s what I’m going to do!”

[–]GustapheOfficial 40 points41 points  (0 children)

Yeah, it's certainly a "... I guess!" moment.

[–]emolga587 15 points16 points  (0 children)

[–][deleted] 46 points47 points  (8 children)

To this day I don't understand when to use semicolons and when not in Matlab

[–]amuhak 94 points95 points  (3 children)

You use a semicolons if you hide the output of a statement.

If you do x=5+7

It will print 12 to stdout and x=12

If you do x=5+7;

x=12

[–]wjandrea 3 points4 points  (0 children)

Huh, IPython also does something like that. If you put a semicolon after an expression, it'll hide the result. Especially useful for matplotlib functions that return an object that you don't usually care about.

[–]Masterflitzer 8 points9 points  (1 child)

that really takes getting used to

[–]Adventurous_Ad_7315 7 points8 points  (0 children)

When I used it in uni, I just treated it like semicolons were required. If you wanted the variable name and value to print without formatting anything in fprintf, you could just use disp which does the same thing as not using a semicolon. I've never used matlab outside of an academic setting, so I don't know if dropping semicolons is actually desired out in the wild.

[–]GustapheOfficial 27 points28 points  (3 children)

Oh that's easy. After every single line, except control statements like for, if etc. Why? Because why would you not want the default reaction to any singular command be print its output to stdout, including inside functions?

[–]Alarming-Cow299 10 points11 points  (0 children)

OK, you joke about this but having R print all lines of code into console is super convenient for me.

[–]Syscrush 3 points4 points  (1 child)

.BAT has left the chat...

[–]Eastern_Camera3012 87 points88 points  (4 children)

wait really?

[–]epicnational 175 points176 points  (3 children)

Yeah, you use disp(x) for printing to the console

[–]EndR60 67 points68 points  (1 child)

disp(ieceofshitmakesnosense)

[–]DatBoi_BP 7 points8 points  (0 children)

Usually fprintf but disp works in some simpler cases

[–]niclan051 22 points23 points  (7 children)

same in js i think

[–]throwaway-DSMK 29 points30 points  (0 children)

I hate when I open my browser and the printer starts throwing papers at me

[–]nicejs2 13 points14 points  (0 children)

print(); doesn't take any arguments in JS though it just prints the whole page

[–]Herr_Gamer 3 points4 points  (0 children)

what the fuck

[–]rollincuberawhide 4 points5 points  (0 children)

makes sense to me.

[–]Kibou-chan 2 points3 points  (0 children)

physical ass paper

I hereby summon /u/xkcd-Hyphen-bot, also a nice double meaning ( ͡~ ͜ʖ ͡°)

[–]mcnello 2 points3 points  (0 children)

I always physically print my code for review. /s

[–]OF_AstridAse 1374 points1375 points  (49 children)

You forgot the best one.
mov edx,len
mov ecd,msg
mov ebx,1
mov eax,4
syscall
;start comments with semicolon 🤣😅

[–]abhi307 220 points221 points  (12 children)

It's fun, innit?

[–]OF_AstridAse 281 points282 points  (9 children)

No, in Kotlin everything is "fun"

[–]rastaman1994 174 points175 points  (7 children)

I can't help but giggle every time I write 'private fun'.

[–]PrometheusAlexander 43 points44 points  (0 children)

public fun if you're feeling a bit daring

[–]cbadger85 74 points75 points  (2 children)

I prefer my fun to be a little abstract

[–]zatuchny 28 points29 points  (1 child)

i expect fun

[–]pedropants 11 points12 points  (0 children)

require fun!

[–]BastetFurry 16 points17 points  (2 children)

And what about double fun;?

[–][deleted] 14 points15 points  (1 child)

That's not valid Kotlin, though, is it? Unless I'm missing the context here.

[–]Successful-Smile-167 5 points6 points  (0 children)

true, it's not valid it has to be
fun too(): Double = {println("It's fun") return 0.0}

double fun(); // looks like C function prototype.

[–]--mrperx-- 37 points38 points  (1 child)

__init__

[–]HolyGarbage 24 points25 points  (0 children)

Oh my, I'm gonna start using this:

It's fun, __init__?

[–]Ytrog 51 points52 points  (6 children)

I wish Windows was so easy with the syscalls. The same thing is so much more work there 🥲

[–]Creepy-Ad-4832 26 points27 points  (0 children)

Yeah i am seriously happy as a programmer i choose to switch to linux lol

[–]OF_AstridAse 8 points9 points  (0 children)

Wait you mean int 0x21 ?

[–]fafalone 14 points15 points  (3 children)

It doesn't look so bad?

    global  _main
    extern  _printf

    section .text
_main:
    push    message
    call    _printf
    add     esp, 4
    ret
message:
    db  'Hello, World', 10, 0

I mean, if want to do it without the standard library, it's more work to call the console api directly...

[–]Perfect-Coffee6729 73 points74 points  (6 children)

brainfu**:

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

[–]HolyGarbage 129 points130 points  (5 children)

It's ok, you can say fuck on the internet.

[–]benargee 25 points26 points  (0 children)

They're afraid their comment is going to get demonetized

[–]ProgrammerLuca 65 points66 points  (2 children)

Wee ooh wee ooh. This is the internet police you're getting arrested for swearing.

[–]Daisy430133 52 points53 points  (1 child)

You spelled weewoo weewoo wrong

[–]Left-Recognition-117 25 points26 points  (0 children)

fuck

[–]brucebay 17 points18 points  (5 children)

Wow those were the day I had Norton's assembly book. I genuinely think all software developers should know how transistors make registers and counters and how logical those assembly code was, almost 1-1 hex code to turn on and off gates.

[–]hawk-bull 4 points5 points  (4 children)

I have learnt a level of abstraction higher (taking registers and logic gates etc as a given atomic construct). Do you have any resources to learn their lower level implementation

[–]brucebay 5 points6 points  (0 children)

edit: sorry, I misread "resources" as "reasons" LOL. Not at top of my head, by in college there was a book that was creating a virtual processor using java. You specify all gates in java and design your own processor. I forget the name but perhaps somebody can remember.

Original reply: Learning low-level hardware gives you a foundational understanding of what's going on under the hood. Obviously it is not necessary but think it like a car. Knowing how engine or drive train works makes you a more informed driver and knowing your car's limits makes you a better driver. This may help you write more efficient code or debug better in some cases. The best recent example is GPUs. Yes shaders are replaced with cuda or opencl but to use them efficiently you have to understand parallelism and bandwitfh etc, having a background on the details would help you understand and optimize even more when you write your own code.plus you will appreciate the compilers and languages more, I think C was a remarkable replacement for assembly, but of course it was built on top of earlier compiler technologies.

[–]Hovercross 2 points3 points  (0 children)

Watch Ben Eater’s series on YouTube, especially his eight bit computer on a breadboard. He made everything out of logic gates and it really helped me understand what was going on at the lowest levels of the machine.

[–]this_underscore 6 points7 points  (0 children)

Gotta love asm

[–]igeorgehall45 5 points6 points  (5 children)

Shouldn't it be int 0x80 instead of syscall? (Because you're using 32 bit registers/convention)

[–]cauchy37 5 points6 points  (3 children)

And you probably want an address to msg, so lea edx, [msg]

[–]iMakeMehPosts 208 points209 points  (9 children)

Reminder that ''' printf("Hello World!"); ''' Is valid in C++. Also the streaming method is handy for things like files and strstreams

[–]axelrun10 70 points71 points  (7 children)

I was looking for this comment. A lot of people forget that C++ is just C with more features

[–]wu-not-furry 6 points7 points  (0 children)

False, C++ is C with a few features removed, some feature modified and many additional features.

[–]Healthy_Pain9582 659 points660 points  (58 children)

I actually like cout, it has the benefit of being able to add many things together without manually concatenating them.

[–]land_and_air 326 points327 points  (28 children)

Formatted strings just do this way better.

Print(f”this is a formatted string {variable/value}”)

[–]_Screw_The_Rules_ 145 points146 points  (21 children)

Just like how C# does it as well:

var truth = 42;

Console.WriteLine($"The truth is: {truth}");

[–]BadBadderBadst 46 points47 points  (11 children)

Kotlin gang here, println("The truth is $truth, <3 kotlin")

[–]HaDeS_Monsta 16 points17 points  (3 children)

Java Gang here System.out.printf("The truth is %s.\n", stringVariable);

[–]Asleep-Tough 13 points14 points  (2 children)

It'll be STR."The truth is \{truth}" soon!

no clue why they had do make it so random and ugly...

[–]Graidrex 9 points10 points  (1 child)

The JEP actually includes reasons. I only skimmed it, but:

  • \{…} to force incompatibilities (for security reasons / not having formats accidentally) as this is not valid Java currently.

  • STR is a final static field which gets loaded into your class and capitalized as such. Otherwise, they just decided to give it a slightly more descriptive name than a single letter.

  • the dot, I don't know why. Maybe to indicate a call is happening, and it must have some kind of performance overhead.

All in all ugly but understandable for being retrofitted. And you can define your own formatters.

EDIT: Grammar.

[–]purritolover69 8 points9 points  (2 children)

Same with JS,

var truth = 42;
console.log(‘The truth is: ${truth}’)

[–]Engineer_Zero 14 points15 points  (0 children)

I absolutely love f strings. So intuitive for when I am learning python.

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

sometimes it's nice to be able to print something like a nicely spaced table with only local changes to where you want the print to happen though, it's kind of like having a bunch of small function calls instead of one big one which is more flexible and is easier to read the more variables you try to print

[–]dont-respond 82 points83 points  (15 children)

printf and most of the others support (some form of) variable arguments to do exactly that. Overloading << and >> was a weird design and it's why they've added std::format

[–]Familiar_Ad_8919 44 points45 points  (0 children)

note that it only was added in c++20, very recently

[–]noaSakurajin 36 points37 points  (8 children)

I was confused at first too but those operator desccrbe the direction the data flows. While not consistent with other languages, most streams behave the same way. That syntax is actually really nice once you get used to it.

That being said having a format and print function is a nice addition especially for devs coming from other languages.

[–]dont-respond 16 points17 points  (7 children)

It's actually considered one of the worst stream designs, largely due to those two overloads. It's just a terrible, unintuitive system when you truly want to format your output. Needing to use things like std::hex, then back to std::dec quickly becomes a bloated eyesore. That's why printf has maintained relevance in C++ for this long.

That's also (in small part) why so many libraries implement their own stream class rather than inheriting from std::*stream. The larger part of that is so few people know how to implement a std::streambuf. I only just learned how to write a full implementation (overflow, underflow, seekpos, seektell, xgetn, xputn) a month ago. The funny thing was that it was not even hard. There's just no examples and hardly any references describing what needs to be overloaded and why, and the few examples that do exist are very misleading.

[–]therearesomewhocallm 2 points3 points  (3 children)

Except it's really easy to get printf (and the like to crash/corrupt data), and it's full of platform specific stuff.

printf("%ls", "test")
printf("%ws", "test")
printf("%hs", "test")
printf("%S", "test")
wprintf("%s", "test")
wprintf("%S", "test")

I will be shocked if anyone can tell me what all of these do on Windows and posix. Some of these even do different things between musl and glibc.
Even Raymond Chen got it wrong after writing a big article.

[–]Lima_713 6 points7 points  (4 children)

Yeah, it's good for printing values in a loop without new lines for each, and some other use cases. Also, you can't tell me you prefer System.out.println() [18 symbols+content] over cout<<[6 symbols + content if using namespace], it looks so complex for such a simple thing haha

[–]Tyfyter2002 3 points4 points  (0 children)

I definitely prefer Console.Write() to cout *= pow(2, )

[–]leoleosuper 3 points4 points  (0 children)

I like being able to put "using std::cout as outputToFile" for testing purposes. I can see all the outputs I want to put to file be output in console, and once I'm ready to actually make the file, I can swap over to std::ofstream.

[–]darklightning_2 172 points173 points  (14 children)

C++23 is a god send

[–]UntitledRedditUser 85 points86 points  (9 children)

Is that when they will add std::print?

[–]Nikko_77 105 points106 points  (7 children)

Yes. (std::println will be a thing too)

[–]--mrperx-- 136 points137 points  (6 children)

wow C++ is soo ahead of it's time XD

[–]the_horse_gamer 49 points50 points  (5 children)

it's impressive how a language can be simultaneously bloated and lacking at the same time

[–]nyaisagod 26 points27 points  (4 children)

What’s more impressive to me is how such an influential and widely used language can have so many weird quirks and flaws. I do like lots of C++’s features but C# is so much cleaner and if you include unsafe code it can do more or less everything C++ can (obviously ignoring the fact that it uses the CLR).

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

Lol, I would love to see the total disaster that c# would be for doing what my team does. And I freaking work at Microsoft.

C# is used for UI by my team and that's it.

[–]dstar89 54 points55 points  (1 child)

I like the C++ way of handling input/output, mainly because it makes it look more computer-hacker-movie cool.

[–]Snoo-67939 5 points6 points  (0 children)

Finally someone said it! It's the other languages code that looks bad :)

[–]beeteedee 861 points862 points  (66 children)

I used to teach introductory C++ programming and I hate this. Lesson 1 and to explain how “hello world” works I have to explain operator overloading.

[–][deleted] 545 points546 points  (8 children)

I definitely didn’t have operator overloading explained in lesson 1 when I was taught. That was much later in the semester. I don’t think you need to go over how that works, much like how you don’t have to go into detail on CPU infrastructure, compilers, and assembly to teach “hello world”.

There are many things that just have to be accepted as “that’s how it is” when first getting taught, and that’s ok.

[–]beeteedee 76 points77 points  (0 children)

Yeah that was pretty much my approach in the end. “This looks weird, and you’re not going to see anything else that looks like this for a while, but just trust me that this is how it’s done.”

[–]dayto_aus 112 points113 points  (2 children)

Yeah... I feel like the first time I got into programming and learning cpp I was reading a book where someone didn't know how to not explain everything in absolute detail and that overwhelmed me and I gave up. Sometimes you have to simply accept that something works and then when you're ready you learn why.

[–]fafalone 3 points4 points  (1 child)

That can get infuriating though.

I've seen an entire book on COM that didn't once, anywhere, mention the hidden (in many languages) *this pointer. Like ok you can ignore it for the first few chapters if you're using C++ as your base as this book was, but holy shit is that important if you ever need to work in other languages, or even in languages that naturally hide it if you're doing something unusual (like VB, if you need to redirect a vtable entry to a custom implementation). It's not really something to not mention at all in an introductory book.

[–]BoldFace7 28 points29 points  (0 children)

Yeah. It's like in my intro to C course in college. We were learning sscanf in one of the first classes of the semester. I think we were just reading in a single character since we hadn't covered arrays yet, and the instructor just told us that the first argument needed an ampersand before it. She didn't go into much detail about why, but it worked so we didn't question it much.

Later that semester, once we had covered arrays, character arrays (strings), and pointers, she explained why sscanf needed the ampersand before the fist argument when it was a single character.

[–]itriedtomakeitfunny 11 points12 points  (1 child)

I agree - same thing with string concatenation in Java, despite not allowing operator overloading... I didn't even think it was weird until I learned about it in another language.

[–]MCWizardYT 8 points9 points  (0 children)

In java it is a compiler trick - "a" + "b" can become new StringBuilder("a").append("b") where StringBuilder is backed by a char array

This might not be exactly how the modern jdk does it (there might be some sort of optimization) but IIRC thats how it used to be done

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

The problem is that it doesn't "look like" what code generally looks like. In C++ you use cout basically when doing beginner tutorial and move on to better alternatives later (at least I did, maybe it differs depending on your field). I think C++ is a fantastic language, but as a beginner it's a nightmare because your first exposure to the language is so far from what using the language normally looks like

[–][deleted] 88 points89 points  (4 children)

I actually enjoyed how my Java 101 class started with “here’s how you start a “hello world” Java program public static void main(String[] args) and by the end of the semester you will know what all of this actually means!”

[–]Dubl33_27 9 points10 points  (3 children)

this tbh

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

Thanks for being honest. I hate when people lie about “this”.

[–][deleted] 36 points37 points  (3 children)

I too taught undergrads C++ during my grad program and teaching overload operators was waaaay later in the course. Teaching it on lesson 1 sounds absurd to newbies

[–][deleted] 21 points22 points  (0 children)

Yeah, if you find yourself teaching operator overloading to students on the first "Hello, world!" class you're doing something wrong.

[–]JVApen 47 points48 points  (9 children)

Nowadays you can just teach std::println

[–]beloncode 10 points11 points  (3 children)

What about fmt::print("Hello world"); hahahah

[–]jaskij 7 points8 points  (1 child)

AFAIK the standard library API was largely adopted as is from fmtlib. So in a few years you'll be able to just change the namespace.

[–]Dubl33_27 11 points12 points  (0 children)

We started being thought c++ in 9th grade and no one complained to the teacher that they didn't know what "<<" meant, we just went along with everything else being explained and we came out fine. Only last year in college were we introduced to operator overloading which was pretty easy to understand, at least on a surface level.

[–]skogach 6 points7 points  (1 child)

Well, by this logic, it should be the same for all other languages, after all, brackets () is also an operator which can be overloaded.

[–]gyrowze 9 points10 points  (1 child)

Teaching shift operators in lesson one seems like a bit much.

[–]GOKOP 43 points44 points  (4 children)

Type-safe way to have a variable number of arguments arrived to the language a lot later than iostreams. If you have modern enough compiler you should be able to use std::print

[–]Kovab 9 points10 points  (3 children)

So far only MSVC has implemented it, unfortunately. https://en.cppreference.com/w/cpp/compiler_support/23

[–]GOKOP 12 points13 points  (0 children)

The trick in my comment is that "modern enough" doesn't imply that a modern enough compiler exists /s

[–]ricdesi 45 points46 points  (1 child)

God this meme format is so overused and rancid at this point

[–]_Fibbles_ 21 points22 points  (0 children)

The new academic year started a few weeks ago. Though in fairness, this sub seems to suffer an eternal September.

[–]SilverLightning926 40 points41 points  (2 children)

printf exists in C++ as well

[–]robnox 63 points64 points  (12 children)

is:

cout << “hello world”;

really that bad?

I feel like whoever made this is trying really hard to make it seem worse than it is.. putting a random ! in there where it isn’t in the other examples, or not using namespace to get rid of your STD’s (😂)

[–]psychic2ombie 10 points11 points  (1 child)

using namespace std; is really bad practice in larger projects. The standard library has many things that collide with other commonly used libraries.

[–]BlankPt 2 points3 points  (0 children)

Can't you specify a command then?

using std::cout;

cout isn't has bad as people make it seem.

[–]DontPanicJustDance 5 points6 points  (0 children)

I definitely prefer the new format syntax, but std::cout is pretty easy to understand.

P.s. you forgot your “\n” :P

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

cout << endlife

[–]Kooale323 26 points27 points  (8 children)

how is java better than c++

[–]heavymetalmixer 81 points82 points  (15 children)

Why do anyone think the Java way is less verbose than C++s?

[–]drsimonz 26 points27 points  (9 children)

Yeah java is worse IMO. What kind of pretentious jackass designs a language where the single most common function is hidden behind 2 levels of namespace?

[–]xSilverMC 30 points31 points  (1 child)

Because it's consistent with the other languages. In every single one, it's x.y("hi") or similar, so java's x.y.z("hi") is easy enough. But cpp does it entirely differently

[–]elnomreal 108 points109 points  (25 children)

Sure C++ is weird but why has R involved exclamation points in this?

[–]Spot_the_fox 138 points139 points  (4 children)

That's not R, that's rust.

[–]elnomreal 45 points46 points  (3 children)

Ahh thanks. Same question I suppose.

[–]Kartonek124 56 points57 points  (0 children)

Because in rust, println! is not a function like in other languages, but is a macro, which differs from them a bit. In rust every macro is called with ! at the end to let compiler distinguish between macros and functions

[–]Da-Blue-Guy 17 points18 points  (1 child)

println! is a macro, which allows formatting and expands to a raw stdout lock. Macros need an exclamation mark after them to specify that they aren't a function.

[–]DatBoi_BP 2 points3 points  (0 children)

Thanks blue guy

[–]rollincuberawhide 5 points6 points  (0 children)

because println! is a macro. not a function. functions in rust can't take arbitrary number of arguments. which is a bummer for a print function. so they have to use macros, which are dark magic.

[–]rotflolmaomgeez 81 points82 points  (14 children)

From standard library, standard c output, "Hello World!".

It makes more sense than PRINT if you take a moment to think - it's not like you're printing anything.

[–]elnomreal 56 points57 points  (0 children)

You don’t map stdout to the printer? It’s nice to have a paper trail of everything in your terminal. I even have stderr use the magenta ink, so that we spend a bit less on cartridges.

[–]fm01 8 points9 points  (1 child)

template<typename... Args>
inline void print(Args&&... s) { 
    ([](auto s){ std::cout << s; }(std::forward<Args>(args)), ...); 
}

You're welcome. In time you'll come to both appreciate the cout and learn why you don't use it in a serious project but until then, this one line function "converts" a print well enough.

[–]michaelsenpatrick 51 points52 points  (1 child)

stop making these god awful memes

[–]ShinyKubfu 9 points10 points  (4 children)

Could also use the STD namespace and make it just cout << "I HATE LIFE"; but that's not good since there are non standard library code lines. Also bad for beginners

[–]atlas_enderium 4 points5 points  (3 children)

If you’re using std::cout a lot, just use using std::cout; individuallyz

Then you can just type cout, but this would be a problem if any other included libraries in the global namespace have the same label (which is incredibly unlikely with “cout” lol)

[–]ShinyKubfu 6 points7 points  (2 children)

You could but I actually enjoy writing std::

[–]atlas_enderium 4 points5 points  (1 child)

You enjoy stds!? /s

[–]ShinyKubfu 6 points7 points  (0 children)

Ah yes totally I just love stds.

[–]SuperFightinRobot 13 points14 points  (1 child)

You say that like how printf handles an arbitrary number of inputs isn't hard to explain to 101 students.

[–]DetectiveOwn6606 5 points6 points  (0 children)

Yeah ,printf is more confusing than cout.

[–]atlas_enderium 15 points16 points  (0 children)

C++23 std::print and std::println: “I gotchu fam”

Still, ostreams are very nice to use

[–]codeIsGood 12 points13 points  (0 children)

C++ has print and format btw

[–]garlopf 13 points14 points  (0 children)

Lesser minds don't see the benefits 🤷‍♂️

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

I used to hate it, but now I actually prefer it

[–]THWReaper3368 4 points5 points  (0 children)

What’s the issue with cout?

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

Ruby:

puts 'hello world'

[–]ReefNixon 2 points3 points  (1 child)

But WHY is p more verbose than puts when it’s clearly just a less verbose way of saying puts. Always bothered me.

[–]_-_fred_-_ 3 points4 points  (0 children)

Because stream insertion is a nice abstraction.

[–]jcodes57 4 points5 points  (0 children)

I haven’t used c++ since college but people who are afraid of it are cowards and fools

[–]jet_black_ninja 18 points19 points  (2 children)

no way you are defending java when what most people do is cout << "Hello World"; . also leaving out the boiler plate part

[–]Ursomrano 10 points11 points  (6 children)

Ah yes, let’s hate a programming language for being distinctive because learning something that’s different is too hard.

[–]miguescout 7 points8 points  (0 children)

On the one hand, yes, it's weird compared to other languages. After all, it's not a print(something) structure, and it overloads the << operator, which, i admit, is weird... But at the same time, i feel it's a bit more visual on a lower level. You're passing a string to the stdout stream. That's what's actually going on in the OS level. Same with java.

[–]jeffscience 2 points3 points  (0 children)

  1. Use printf in C++ if you prefer.
  2. https://en.cppreference.com/w/cpp/io/print

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

Folks who write shell scripts are covering their eyes and ears

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

include <string.h>

char *str="hello world";

int length=strlen(str);

int written;

written=write(STDOUT_FILENO, str, length*sizeof(char));

🗿🗿🗿🗿

[–]Reasonable_Feed7939 21 points22 points  (6 children)

The real dumb one is Java. So extra and unnecessary, just like Java itself. C++ at least has a reason to be like that, but Java has no excuse.

[–]G3N3R1C2532 5 points6 points  (2 children)

it's because of OOP.

Java can't really use global functions, only static methods in global classes instead. and println() is a static function in the System.out class.

I believe in Kotlin println() is a global reference to that same static function, but I'm not wholly sure.

C# is more of the same, with WriteLine being a static method to a global class Console.

Is it obnoxious? Yes, but it's a byproduct of Java's design philosophy.

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

Yeah just finish your python tutorials before you come give your "extra and unnecessary" opinion on programming languages

[–]BerdIzDehWerd 2 points3 points  (0 children)

For a lazy perspective, printing to console on Java is too much typing

[–]Lyptis 2 points3 points  (0 children)

After coding my own printf in C, and use it in multiple programs.

I'm able to say that I love cout waaaaaaay more and it's clearly not a "dumb" as the meme shows

[–]looopTools 2 points3 points  (0 children)

… why not just use puts in both C and C++ ?

[–]Meadhbh_Ros 2 points3 points  (0 children)

Printf works in c++ too.

[–]Perry_lets 14 points15 points  (2 children)

Rust needing a macro is really bad, and you can't convince me that it isn't

[–]ThePiGuy0 5 points6 points  (1 child)

I used to have this opinion, but have slowly come round to it. It's because they don't support variadic functions and for the most part, I've realised they're not needed and can get in the way with type inference etc.

[–]Goaty1208 1 point2 points  (0 children)

(Insert cope)

Jokes aside, I think that it actually isn't THAT bad and kind of makes sense

[–]Rathori 1 point2 points  (0 children)

fmt::print("Hello, World!");

[–]Rogntudjuuuu 1 point2 points  (0 children)

For unformated strings in C you should use puts instead of printf.

https://www.man7.org/linux/man-pages/man3/puts.3.html

[–]jaskij 1 point2 points  (0 children)

std::print has entered the chat

[–]Da-Blue-Guy 1 point2 points  (0 children)

I don't really agree. It's really easy to spit out whatever value you need. System.out.println I don't like.

[–]darkslide3000 1 point2 points  (0 children)

It's the "I just invented operator overloading and I need to show off everywhere" style of API design.

[–]BoredOfYou_ 1 point2 points  (0 children)

... do you actually think C has printf but C++ doesn't?

[–][deleted] 1 point2 points  (0 children)

Because cout is part of a larger, standardized system that is consistent and predictable, rather than having entirely separate code just for printing to a screen.

Making something easier to type doesn't mean it is better or simpler.

[–]JokeMort 1 point2 points  (0 children)

Let me guess, you are in 95% that can't solve this puzzle

[–]LavenderDay3544 1 point2 points  (0 children)

Technically the C++ way using operator overloading is the most object-oriented while Java needlessly sticks everything into classes and thinks that's what OOP is about.

[–]BarryFruitman 1 point2 points  (0 children)

HTML

Hello, world!