Is C++ just C but with more stuff? Or is the syntax different? Even slightly?

Is C++ just C but with more stuff? Or is the syntax different? Even slightly?

Attached: cplusplus.png (918x1032, 47K)

Other urls found in this thread:

youtube.com/watch?v=PNRju6_yn3o
stackoverflow.com/a/3106752/2158002
stackoverflow.com/questions/22676/how-do-i-download-a-file-over-http-using-python
en.cppreference.com/w/cpp/language/aggregate_initialization
twitter.com/SFWRedditVideos

Oh hello Dopinder.

Some things are different behind the scenes.
A good example is the type system is more strict in C++.
That is why the memory allocation is different.

There's cool shit like virtual functions with dynamic dispatch. People like to shit on C++ but it's a pretty slick lang.

C++ claims backwards compatibility with C but it's not true, there are many syntactical changes that break C code.
For instance:
int foo[] =
{
[10] = 123,
};

will only work in C, not C++.

Attached: bought_together.jpg (499x249, 16K)

And that is a good thing.
-Werror is the only way to live.

>is Qt just C++, but with more stuff?

forever {
installGentoo();
}

Attached: 1546512176995.jpg (637x504, 69K)

C++17 is comfy

The original language started as C with more stuff, but they totally reworked everything behind the scene. In C, compiler does it. In C++, everything is implemented as an object and goes through bunch of templatic meta-programming before compiler takes over it. There is a lot more especially in type system.

>cool shit like virtual functions with dynamic dispatch

That the most absolutely basic essential thing to Object Orientation.

It's completely valid syntax and defined behavior in C, not even VLA (which I personally ban).

things like this just make me want to quit C++ entirely
youtube.com/watch?v=PNRju6_yn3o

Move semantics are weird. The language has too much stuff in general.

This was more about constructors and resolving overloaded functions between referenced and copied versions. And in this case also difference between std::string and string literals.
But yeah C++ is not ready for move semantics, e.g. moved-out objects still run destructors.

The difference is the "++". Can't you read?

C

C++

the second one has ++ DUH

C++ is obsolete now there's CSharp which is C with two rows of ++

>CSharp which is C with two rows of ++

Am I allowed to feel stupid for only now realizing this?

oh wow, I never knew

Is using a language like Python to prototype programs in a compiled language a myth or a common practice for you?

I want to try C++ to benefit from the static typing and the maturity of the C++ "ecosystem" as a whole. I'd rather have to deal with type errors before the program run, I'm curisous to see how people cope with building large program with Python without getting insane.

Doesnt csharp only work on winblows?

Attached: 1549723283583.png (900x961, 494K)

This would be solved by just using public member data. The retard even makes a sarcastic "haha but that would be too easy and straightforward" comment about it.

>using python
Python is not actually easy, at all. They sold you this myth on the fact that you could do this:
print "fag";

(obsolete with python3+)
In reality, could just use Qt with C++, and this will actually be easier to learn and prototype with.

Attached: 1550349121430.jpg (1280x853, 154K)

I learned Python through Django, when I studied in a field totally unrelated to programming, and stuck with it because it was convenient. I think it's still a good choice for beginner to learn programming, but getting in depth and understand how it works "under the hood" (everything is an object, the type system, etc.) must be a real pain for someone without some prior programming knowledge.

"I use Python for protyping" is something I read all the time, but I can't help thinking it as a waste of time since how idiomatic both languages are

cute grill + recaptcha is creepy

>must be a real pain for someone without some prior programming knowledge.
No. It will be even less painful than learning python with no prior knowledge. The idea of Dynamic Typing confuses more than alleviates people trying to understand functional programming. Not to mention, you have to "pip" your libraries in, and you have no metric to ascertain whether they and their authors are quality or trash.
And to that, beyond being a difficult language to read, you are going to have to interact with legions of kiddy python programmers, who chose the language strictly due to the fact that they are functionally retarded.
>Leave them; they are blind guides. If the blind lead the blind, both will fall into a pit."

>"I use Python for protyping" is something I read all the time, but I can't help thinking it as a waste of time since how idiomatic both languages are
It is completely pants on head retarded to prototype in python.
The best way to prototype, is the approach to programming in general.
In Qt, you are encouraged to take the mindset:
>Program everything as an API.

Thus in your headers, you would do most of your prototyping where for every member variable, you would define it as such
class QSpurdo : public QObject
{
Q_OBJECT // Meant to signal slot
public:
friend class Apu; // Apu can access benis
explicit QSpurdo(QObject *parent=nullptr);
QString benis(); // Must use condom
void setBenis(const QString &benis); // benis must already exist before setting it. IE no null benis allowed

signals:
void benisChanged(); // Emit signal every time benis is changed with setBenis

private:
const QString m_Benis; // Private benis.

protected:
QString getBenis(int micro); // internal benis function. People outside class need not worry
};

Attached: 1510112999955.jpg (957x621, 55K)

Maybe my sentence about beginner was poorly worded, I meant Python as a first programming language, not C++

Attached: like.jpg (335x478, 20K)

C/C++ is too old.
get on the rust bandwagon, and stay away from C's autistic little child

Attached: rmm19vt8vp911.png (2512x1018, 421K)

Yep, and it's even clearer with public members:
c.first = "joe";
c.last = "schmoe";
c.id = 42;

No need to guess if the constructor takes first,last or last,first.

For the most part. However there are certain things that are possible in C and not in C++. There are small syntactical differences and missing features like compound initializers, designated initializers and more implicit conversions.

C idioms are completely different to C++ idioms though. You shouldn't write them the same way even if you can.

it's even easier to code on linux desu

Thats just it though.
Its not a good first programming language. People just think it is, because you can do things like:
a = 1
b = a
c = b+a
a = "foo"

Very flexible!
Of course things start to fall apart when he gets the idea to add this line:
d = b+a

And you have a crash. What is initially perceived as flexibility is in reality just practiced obfuscation.

This is implicitly discovered when the learner inevitably wonders how to do a pointer. This is where he gets told:
>Impossible, but it's not a bug, it's a feature :-)
stackoverflow.com/a/3106752/2158002
And if you need that type of functionality, you have to do some complicated and retarded work-around, which reinforced the idea that it is fine to try and remove screws with a plyers instead of a proper tool.

C++ with Qt on the other hand, requires you to be explicit, and all the kiddy stuff you would learn in Python, can be done basically with QStrings and integers. As soon as you want to expand, you can jump into guis, pointers, networking, APIs: All of this without having you to start googling,
>WHAT IS THE BEST PYTHON LIBRARY FOR DOWNLOADING A WEB PAGE
>20 answers
stackoverflow.com/questions/22676/how-do-i-download-a-file-over-http-using-python
Have fun trying to figure out what is not obsolete or insecure or popular for the wrong reasons. What a shitty way for a newbie to have to learn a language.

Attached: 1552826291075.jpg (654x655, 21K)

You mean dotnet core? So all that's needed is install the dotnet sdk?

Examples on simple classes serve to scale to larger ones. Here you don't really need constructor, but that does not scale and for private members you need one.
Speaker's problem is that he want's to accept arbitrary combibation of owned and referenced arguments. Since the object assumes to own the strings, the referenced arguments need to be copied to new allocation.
The conventional way to do it in C++ is to always pass reference and always do new alloc. This has potentially one allocation+copy overhead.
Rust would do it here by always moving and let the potential realloc to caller.
C++-commitee way is to overcomplicate everything by finding a meta-prpgramming way that noone understands that allows everything.

const __m256i const1 = _m256_set1_epi16(0x0101);
template
int GetInt(){
int batchCount = (T_Size / 32);
int overBatchCount = batchCount / 128;
int sum = 0;
for (int j = 0; j < overBatchCount; ++j){
__m256i var = _m256_set1_epi32(0);
for (int i = 0; i < 128; ++i){
var = _mm256_add_epi32(var,const1);
}
for (int i = 0; i < 32; ++i)
sum += _mm256_extract_epi8 (var, i);
}
__m256i var = _m256_set1_epi32(0);
for (int i = 0; i < (batchCount & (128-1)); ++i){
var = _mm256_add_epi32(var,const1);
}
for (int i = 0; i < 32; ++i)
sum += _mm256_extract_epi8 (var, i);
return sum + (T_Size & (32-1) );
}

C++ is what you get when you take C and make Rust redundant

Interesting, I think the example you illustrated for the way Python handes what is generally understood as assignment will be of some use for me pretty quickly. I'll keep the C++and Qt combo in mind, thanks you

Attached: spurdrok.png (435x269, 5K)

It's a little different. For example Structs in C++ are just classes without default private fields. So they don't work like C style Structs.

Lol, I always use C style structs in low-level C++ code. Classes are just for really abstract high-level stuff.

Yes.

>tfw forced to write in C++
>use C style for everything

Attached: 1553412256764.png (164x174, 7K)

In the strict mathematical definition of "subset", C is not a subset of C++: there are valid C programs that don't compile with a C++ compiler, even using the latest standards for both. That said, C++ provides pretty much everything you'd normally use in C and more.
That said, good modern C++ looks nothing like good C. Anyone saying that the best way to use C++ in 2019 is "using it almost like C with classes/templates" clearly doesn't know the language well. Modern C++ calls for a much different style and different conventions, don't write it as if it were C.

How do you use c style structs in c++?

Just make a struct with no member functions and where all members are public, it's not that hard.
Make sure it is an aggreate: en.cppreference.com/w/cpp/language/aggregate_initialization