Why is C++ so ugly?

Why is C++ so ugly?

Other urls found in this thread:

youtube.com/watch?v=zBkNBP00wJE
twitter.com/SFWRedditVideos

Why is your post so ugly?

That's not even valid C++

I always lol at how much less code python takes to do the same thing.

Yet at the same time marvel at how much more powerful C++ is.

Why is C not type safe?

Because types is a high-level concept and C is intended to merely be a portable assembly.

Post is beautiful user

But is it user. Just no endl

>iostream.h
>.h

>no return type for int

>cout is on default namespace instead of std

It's not valid C++

You may be right, but that doesn't invalidate my point that C++ output is ugly with its angle brackets.

>angle brackets
C also has "angle" brackets, user, it's the logical shift operator.

#include
int main()
{
printf("%x\n", 1

> a script language for children is simple

paint me surprised

This. C is a meme language beyond extreme low level. Go C# and WPF for anything high level and serious.

>python = less code
std::cerr > sys.stderr, "text"

simplicity and ease-of-use is why python is a great scripting language

You are a faggot for not running Visual Basic then.

>Visual Basic
>simplicity and ease-of-use
Pick one

i unironically think c++ is beautiful

I don't write much C++ but took a c++ class in college. That bitch never never showed us cstdio. Wrote so much
cout

Well, until the gazilleon different C++11 std::to_string, output streams and output stream buffers were objectively easier to deal with. But now, I just do

std::string text = "this is a number: ";
text += std::to_string(2);
printf("%s\n", text.c_str());

Nigga it's so painfully simple and easy that I literally stopped using it in favor of C# for that reason.

Granted, C# has more support in forums but still, it was so easy I couldn't bear it.

Granted, I have experience from C to assembler so I'm not new, but still.

I used to program Visual Basic. I honestly and sincerely think that C++ is easier than having to deal with all of the Microsoftianisms that come with that shit and that you can't opt out of. I guess .NET is somewhat similar in that aspect.

Swift is godly

Python requires aligning statements depending of loop types. It's a regression to the 60's when it was required by languages such as COBOL and FORTRAN.

The one thing i don't like about python is its use of white space. I'm to use to brackets.

Why do you shitpost if you can't write the most basic C++ code correctly?

> implying stdio.h is absent in c++ standard library

to get you to reply

There are a million ways to do things in C++.

That's part of why people are weary about the language.

Then what is K?

>implicitly typed main
>main declared with unspecified parameters
>random white spaces after printf
>not appending a newline at the end of printf

You're a shit c programmer


>declaring main without a type in C++, which is illegal
>returning 0 instead of EXIT_SUCCESS

You're also a shit C++ programmer. You can also use printf in C++.

Your example only shows what it is like to print a single string.

Say you want to print a string and a number, printf can do that.
But you have to specify if it is an int, unsigned int, or a double.
You cannot print objects, you cannot redirect the stream to something else, say a log or a file.

Stuff like that is very useful to most programmers.
You can effortlessly print stuff, turn stuff into a string and then print it.
Obviously you could solve this in a different way, but cout works really well.

You practically compared apples and oranges just then.

I recommend you read into the differences between C and Python before you continue to speak uninformed in future.

Your "ugly" C++ gonna hit at least 3 errors u stupid fuck

Why are you so ugly?

>You cannot print objects
you just have an object to string function like you would in C++, then pass that string to printf. It requires two or three extra lines, but it's not really a hassle and is potentially a lot faster since you can avoid allocating from the heap.

>you cannot redirect the stream to something else, say a log or a file
that's what fprintf is for. Printf probably just calls fprintf internally in every implementation.

>You can effortlessly print stuff
I usually just use printf anyway because you separate the format from the data, so that you don't end up with the formatting being a pain in the ass to read because it's now spread over several lines. e.g.
cout

Agreed, Python's indentation is cancer

>#include
>main()
>No line feed at the end of Hello World

>>returning 0 instead of EXIT_SUCCESS
They are defined to be the same, why include a library just to write 0?

It's not the brackets that are ugly, it's the "::". Fuck that shit desu senpai.

>include a library
you're not including a library, you're including a header.

EXIT_SUCCESS and EXIT_FAILURE are better style. They clearly demonstrate what you are trying to do instead of using magic numbers. You also differentiate between whether you're using non-portable application specific exit codes or just signalling failure/success, when you use the macros.

Also, returning 1 on VMS actually indicates successful exit. I'm not sure what EXIT_SUCCESS is mapped to on that system. That's not really a concern in modern programming though.

>for children
Anyone doing serious machine learning research is using python.

Autism.

>not wanting to use magic numbers is autism

>OP can't even write a proper C++ main function
top kek

C++ is very ugly but you're not really making the case for that.

>exit status 0
>"magic number"
Not the guy you're responding to, but you're utterly retarded. Exit status 0 being success is defined in the C standard. EXIT_SUCCESS is ALWAYS defined to be 0, even on systems where 0 generally indicate failure. On these systems, the compiler has to create extra stub code in order to handle the fact that return 0 or exit(0) must indicate success.

If you're using exit(0), you're probably using exit(1) somewhere else. hence why I specified EXIT_SUCCESS and EXIT_FAILURE.

Alternatively you could be using exit(0) and exit(EXIT_FAILURE) which is horrifying.

>Alternatively you could be using exit(0) and exit(EXIT_FAILURE) which is horrifying.
It's just inconsistent, but it doesn't matter. EXIT_SUCCESS is always 0, EXIT_FAILURE is always 1.

It's just a preprocessor macro. Sure, it's being inconsistent, but it doesn't fucking matter.

because operator overloading is magic

>it doesn't fucking matter
Yes it doesn't. That's why it's called style.

[include]#include [/include]

there you go

I always use 0 and 1, that's a consistent style. There's no real reason to use EXIT_SUCCESS or EXIT_FAILURE and they're only still part of C because of legacy reasons.

>EXIT_FAILURE is always 1
I don't think that's correct.

when C is ported to quantum computers and 1 will mean both failure and success then your code is fucked

Yes, you are right. Only EXIT_STATUS is always 0. EXIT_FAILURE can be anything other than 0.

>porting C to quantum computers
Quantum computers will only ever run Haskell.

>Only EXIT_STATUS is always 0

Any return value that is non-zero is EXIT_FAILURE. It allows for implementation-defined fail states.

>i don't care about portability

At least don't try to sell that garbage as an advantage.

no, see

masterrace reporting in
System.out.println("This is so beautiful");

>high level and serious

C can be as high level as you want. It has literal billions of lines of library code with many having docs dating back to the 70's that can get your into your problem domain while still maintaining the performance expected of a language that is effectively an ASM abstraction layer.

>masterrace

The only reason java can get people jobs is because it can be easily taught to pajeets and can be easily managed by PMs.

C++ is better
you get the high level shit with the low level control

and the high level security issues and bloat

>no space after #include
>not specifying return type
>no return statement
>no \n
>random, pointless blank line
>no

>high level security
need more info on that

what makes C more secure?

more specifically in C you can debug and find out the security issues where in C++ boost and similar libraries keep shitting CVE's and vulnerabilities weekly, this is not to say that all C libraries are secure, it's just they're more scrutinized and maintained, also the language itself has alot of unnecessary features that take unnecessary memory / cpu usage

but nobody uses EXIT_SUCCESS anywhere else in any program.
It has the sole purpose of letting you return 0 on most platforms.
For a small application, you save 31 chars.
On larger applications, you would only use it if it is in your snippet.

>angle brackets

POO

The answer is operator overloading. Also there's literally no reason not to use printf in c++ too.

A lot of the C++ feature complexity is syntactic sugar.
In the end it compiles down to the same operations as an equivalent and more complex C code.

I saw a talk about this in cppcon, i'll try to find it.

it's pretty common to call exit from 'holy shit everything is unrecoverably broken' handlers. That wouldn't just be in main.

Who the fuck cares about saving 31 chars? I'm also not sure how you'd save 31 chars from using 1 instead of EXIT_FAILURE.

Something wrong user?

You're a shit programmer.

Fun.

You're full of shit.

youtube.com/watch?v=zBkNBP00wJE
This one?

if you really care this much about security, you should be using Ada. Ada forces you to be secure, while C++ and C encourage you to do stupid shit.

Why is Object Pascal so beautiful?

I was surprised the first time I saw Swift, it's kind of like Python (print statements, import statements, etc)

Get on my level, faggots. Most aesthetic programming language incoming.

++++++++++[>+++++++>++++++++++>+++>+.

C# can run on basically any PC platform, and any non-trivial program you write for the PC won't run on a non-PC anyways.

>No \n
You have no right to hold any opinion on either of those languages while you don't even know them.

Wtf? format strings are infinitely better than that garbage.

printf("This is a number: %i\n", 2);

Glorious.

It was modeled after your mom.

I always lol at people with literal shit for brains trying to compare C++ and python.

There are millions of ways to do things in many languages, it doesn't mean is the "correct way", specially after C++11

You know you could've just googled alternative ways, right? Anyway, if your "experience" is a college class, your opinion about the language is irrelevant.

>main
>return value
so what about concurrency?

>he calls them angle brackets

Go write javascript Pajeet.

C# is a ripoff language

So what about not being a fucking retard?

Hideous.

What about it? Elaborate.

list.push(a);
list.push(b);

list

Anything C++ can C can do too
Game_t *Game_New(bool init)
{
Game_t *game = malloc(sizeof(*game));

if (!game)
{
return NULL;
}
else if (init)
{
Game_Init(game);
}

return game;
}

Anything C can do a trivial turing machine can do.

My sides. Just billed a customer for 50K USD worth of riotously fast C code with a custom high level networking protocol and centralized database API. No other language could do this and run this lean on the customer's low power nodes.