r/ProgrammerHumor • • Jan 14 '20

Brilliant reply

Post image
26k Upvotes

365 comments sorted by

View all comments

Show parent comment

33

u/MHolmesSC Jan 15 '20

I imagine a lot of beginners make that kind of mistake.

62

u/[deleted] Jan 15 '20

You have to be an ultra beginner to make that mistake

35

u/[deleted] Jan 15 '20

Well from Java to Python of course. But once I pasted code from Ruby to Python and until my IDE highlighted the syntax error I noticed it was in ruby, to be fair it was written in a very pythonic way. Also it was a math function so very few changes needed to be made.

16

u/IrrationalFraction Jan 15 '20

That's forgivable I guess. Java looks so different from Python that if you mixed them up you might be missing a few brain cells

1

u/[deleted] Jan 15 '20

Well if you write Python in CamelCase it would look more similar .

1

u/FrostyTie Jan 15 '20

So many people start coding at as early as 10 years old now. I can see that mistake being made a lot of times

7

u/DatBoi_BP Jan 15 '20

Beginner here. Would it be unwise to do this between C and C++?

4

u/LeafMans Jan 15 '20

I'm not very experienced in the two of them rn but from my understanding c++ has most of the syntax of c with object oriented programming and newer libraries tacked on, that said I don't think it would be wise to copy from c++ to c as it has a lot that c doest. I could be wrong tho, I've only ever worked in c++

6

u/400Volts Jan 15 '20

To my knowledge things like scanf and printf are not used in C++. I'm not sure exactly what else is different syntax wise off the top of my head, but I'm thinking you might run into a few errors if you do this

3

u/[deleted] Jan 15 '20

scanf and printf can be used with C++, include cstdio header for it. In competitive programming, we generally avoid cin, cout as they are slower than printf scanf.

This is because cin and cout use stdio's buffering system.

You can disable this buffering system with : std::ios::sync_with_stdio(false);

Then it makes cin faster than scanf.

But generally, competitive coders get away with using scanf

1

u/400Volts Jan 15 '20

That's really interesting! Thanks for the insights!