Can Jow Forums solve the rockstar c++ programmer problems

medium.com/@vardanator/why-cs-students-must-learn-c-as-their-main-programming-language-6d3b4f8720bd

Also is this true or huge cope?

Attached: cppjesus.jpg (643x683, 73K)

Other urls found in this thread:

stackoverflow.com/questions/24901/is-there-a-performance-difference-between-i-and-i-in-c
twitter.com/SFWRedditImages

>huge cope
cope for what. The points given make sense, even if you end up not using the language because others make it a lot easier to develop certain things, the language will still force you to learn all that shit mentioned which could prove useful

It's important to know C++, but sadly, even if students do learn it, they learn C++03, so while they get the knowledge that learning C++ gives you, they have absolutely no idea how to use C++.

>they learn C++03
Donuts and their "education". My c++ lecturer insults pre-11 c++ at machinegun rate.

To learn C++ properly, you have to learn the obsolete things first, though. It's hard for me to imagine someone learning C++ and completely skipping over things like new and delete.

Mostly everything is mentioned and explained, but it's stressed to never ever use naked new and delete unless you're rolling your own stuff. Same for all the obsolete stuff. We even went into concepts and modules last week, which aren't in yet, but we're required to know how the compiler implements those.
Our uni uses C as a primary language to teach undergrads, so it's not like they have to explain everything, just the differences from C and then new features. The course is more concerned about how the language is specified and implemented than how to use it because that's covered by the core guidelines.

Couldn't get past the first paragraph, this dude writes like a retard. C++ is a shit language and has been shit from it's very conception. It was a language born not by any actual problem to be solved like C, but by a language geek for the sake of creating "c with classes". A C++ programmer believes that the way to solve problems is to add more features to the language, a c programmer just writes more code. Of course C++ advocates are devoted to their indoctrination, they'll make claims such as "you're not a true c++ programmer unless you utilize such and such C++ features". Meanwhile those that just treat it as C but with extra niceties enjoy quick compile times and simple programs while the autistic C++ acolyte is fucking around with some template shit that has never been shown to actually make programs more robust but gives him a sense of accomplishment for solving an incidentally hard problem imposed on him by the insane language designers.

>Yep, Bob uses i++ instead of ++i everywhere. Meh, what’s the difference.
beside the in C/C++ when used as an expression, do some languages have a different behavior on those?

True is that you should know the things he listed, and more.
It's a very basic knowledge of how computers and operating systems work and how user-space programs interact with them. The problematic has nothing to do with C++ as such.
If you learn how computers work, how operating systems work, how compilers work, about language design and implementation, you will have a superset knowledge to reason about those things.
Focusing on language is mostly silly, C++ does many things badly and is not a good tool for way too many reason of low-level programming. It's arguably very popular and does many things well as all things with such traits are wort to analyze and learn something from.

C++ does since you can overload both to do different things. I can't see any sane reason to do it but you can.

the compiler will just use ++i all the time anyways

Friendly reminder you can overload a comma in C++, which is an operator for some fucking reason.

and in case someone cares for answers:

1) return (T *) malloc(sizeof(T)); or static_cast
2) 555 - side effects on i++ and ++j and begin post-increment on k
3) 6 - the problematic part is probably pointer arithmetic and 1[p]
4) 6, dunno what's the addressed problem here, maybe ++*pi, I always have to check if it shifts pointer or increments value
5) struct padding, every field is aligned to it's size (and whole struct is aligned to largest member), thus here char c1; int x takes 2 * sizeof(int) memory
this will take 8 * sizeof(int) space
the rule of thumb of sorting fields is from largest to smallest
6) hahaha yeah polymorphism and inheritance in C++ is usually the most hated feature. Program doesn't compile because when inheriting as private, you can't access it's public fields, thus A::sayHi() from B is not valid.
7) C preprocessor fuckups, it's just glorified string expansion. a) is clear, b) causes the post increment to run twice, c) expands to a + (b * a) + b
there are ways to fix those and it's a common practice of writing C macros
- dummy variables typeof(x) _x = x; to eliminate the side effect when used multiple times
- parenthesizing every input variable SQUARE(x) ((x) * (x))
8) dunno what Argument-Dependant Lookup means, probably some fix of name collisions because of function overloading or implicit namespaces
9)10)11)12) empty base optimization has something to do with empty structs/classes not taking at least 1 byte.
13) to customize the behavior in derived class. why is this a question?

Notice that none of those questions ask for how to design programs or how to utilize provided abstractions and features.

Each time I read a blog about how sepples is for the code guru, it's from someone who find trivial things. Linus is right when he said that sepples attract low tier programmers.

True. The sweet spot is C with RAII, simple templates, lambdas and minimal OOP, where apt. Most however just go full abstractions or full barebones.

The sweet spot is Go with pointer arithmetic and no garbage collector.

And generics and const types.

C, C++, C#, Objective-C, Java, JavaScript, Dart and other languages have different meanings for prefix and postfix increment operators, since they're all directly or indirectly based on C.

Some languages make a point of not including them. E.g. Swift had them, but then got rid of them, and Go only has the postfix versions.

They do have different meanings in general though, you know that right?

The compiler will change i++ to ++i if it knows it doesn't matter, e.g. on its own line within a for loop.

Oh, I wasn't aware those langs copied their use as expressions.
e.g. in Go it's statement and not an expression.

Anyway what I was meant to ask: if used as statement on separate line with nothing else, is these some difference? Operator overloading is so far the only answer I got.

on how much it differs in C++
Although the benchmarks in thread are probably not with optimizations and inlining. C++ is not sanely runnable without inlining anyway.

stackoverflow.com/questions/24901/is-there-a-performance-difference-between-i-and-i-in-c

>So, why is it a MUST for students to learn C++ as their first programming language (and learn it really well). Because, by learning C++, students have to:

>worry about memory management;
Only really useful in low level applications, which most software engineering is not.

>know the difference between compiler, linker and loader;
Rarely necessary, and doesn't even apply to many higher level languages.

>find out that compilers make some optimizations (compilers code better than you);
The whole point of this is that you don't need to learn it, so I'm not sure why he's making this point.

>learn meta-programming;
This is a higher level concept which could be useful, but isn't strictly necessary to know.

>distinguish compile time from run-time;
Eh, this is probably a good thing.

>really understand low-level implementation of polymorphism (such as virtual tables and virtual table pointers, or dynamic type identification);
Eh, maybe this could help you at some point down the line, but mostly too low level to care about.

>pointer arithmetics, which could be a good base for understanding node-based data structures (f.i., linked lists, trees or graphs);
Pointers are good to know, but you don't need to know pointer arithmetic for that. IMO node-based data structures are best learned in Lisp; unironically go read SICP.

>find out that compiler generates platform-specific code, and discover that there are many other platforms, instead of Windows on x86;
Well, now you know this, and you didn't even have to learn C++.

>find out that there are ELFs and PEs and other executable file formats, each of which has a bunch of sections you should at least partially be familiar with;
I have no idea how ELF executables work (and it hasn't come up so far), and I don't think mastering C++ would necessarily help with that.

(cont.)

>if used as statement on separate line with nothing else
Yep, identical, unless there's overloading.

Traps are gay.

Whenever I hear about someone wanting to hire a "rockstar developer" I think of motley crue building iPhone apps backstage before a show.

Attached: motley crue.jpg (800x600, 145K)

The true galaxy brain move is to use the highest level language you can get away with for the type of software you are building.

>find out that the size of data types is something you have to worry about (sometimes);
Again, this is usually too low level to care about, and he knows it.

>implement some function pointers to understand the under the hoods of callbacks;
Function pointers are gross, and you can understand callbacks without them.

>dive deeper into generic programming;
This is useful in languages with generics, but I don't think it really extends as a general computer science concept.

>use and understand iterators, implement containers supporting various categories of iterators;
Plenty of languages have iterators, learning C++ doesn't give you any better of an understanding of them then most other languages.

This guy has put all his time into learning C++, and now he's decided that everyone who doesn't understand the various intricacies of the languages as well as he does isn't a real programmer.

lmao, this guys github is nothing but barely started projects

Attached: Capture.png (1012x897, 203K)

>motley crue


When I get high I go high-level
Javascript, C#'s a drug for me
My app, my app
Kick start my app
Always got Rust CoC Coming after me
Custom built IDE doing 12Fizz
My app, my app
Kick start my app
Oh, are you ready backers?
Oh, are you ready now?
Ooh, app
Kick start my app Give it a grand
Ooh, yeah, baby Ooh, yeah
Kick start my app Hope it leaves alpha
Ooh, yeah, baby
Rewrite it in Go because C++'s a pain
Or it's because I don't get namespaces
My app, my app
Kick start my app
Say I got trouble, Trouble in my licence
I'm just looking for Another good Framework
My app, my app
Kick app my app
Yeah, are you ready backers?
Yeah, are you ready now?
Oh, yeah
Kick start my app Give it a start
Oh, yeah, baby Ooh, yeah
Kick start…
When we started this start-up
All we needed, needed was a Californian office
Years gone by, I'd say we've hired tranny ass
When I'm committing Or merging the branches
Compiler warning rushing Through my veins
And I'd say we're still suckin' ass
Oh, ah, it kick start my app
I hope it leaves alpha
And to think, we did all of this, to rock
Oh, yeah
Kick start my app Give it a start
Oh, yeah, baby, Oh, yeah
Kick start my app Hope it never stops
Oh, yeah, baby
Oh, yeah
Kick start my app Give it a start
Oh, yeah, baby Oh, yeah
Kick start my app Hope it never stops
Oh, yeah
Kick start my app

Attached: 51206-full.png (1282x716, 1.26M)

okay, this is epic.

Attached: apu.jpg (1000x800, 61K)

>In Java/C# you have automatic memory management, e.g. “don’t think about the memory at all”
The first k is this? Just because it's garbage collected doesn't mean you don't think about it, if you do anything high performance then you need to know exactly what's happening with memory, not use new, use pools, make sure shits in the stack and not the heap, otherwise garbage collection will thrash your shit up.

What do you call 1[p]? I have never seen this before. Does it exist in C?

[] is an indexing operator
A[B] espands to (*(A + B))

I've never seen it either, but after some testing it seems to be equivalent to *(1 + p) which is equivalent to p[1].

although in C++ is can be overloaded

if you are software engineering grad, you are supposed to be learned all these. What's the deal with "you don't need to know for high-level"?

My c++ is rusty but isn't the answer to the first question simply

return malloc(sizeof(T));

The question is stupid. You still need to call the constructor of T. But sometimes it require arguments.

Not as main language. I think learning the basics (including data structure) are valid exercises to understand how data flows.

I've learned it but never really made any efforts to keep it up. So i forgot most of the specifics for the language but kept the whole high level concept on how to write efficient code.

>a[5]
*(a + 5)
>5[a]
*(5 + a)

That's fair, the low level stuff is a solid part of a CS or SWE curriculum.

I guess I was more responding to his overly broad classification of "not a programmer".

I should have focused more on C++ not being the end-all be-all necessary language for learning these concepts.

So why do I need to return a type for question #1? Shouldn't it just be a void function since I am allocating memory? Also thanks op helped to test my knowledge.

you're returning a pointer to whatever you allocated memory for.
kinda like how malloc returns void*, you need to know where the memory is at some point.

Then again the whole question is retarded, using malloc/free in C++ is bad practice if T is a non-trivial type.
the real answer is "Fuck you, use vector"

what's the point of allocating memory if you're just going to throw away the pointer to it?

A monstrosity meant to make your coworkers hate you.

This guy is either esl or illiterate. Also most of this is basic 100 and 200 level stuff.

>kickstart my heart
KEK

Those aren't that difficult. The thing with C++ is that it's taught too early and it's difficult to digest all those concept from the start. Maybe it's good because it hardens programmers, maybe it's bad. idk.

universities should stop teaching high level programming languages. force people to stop treating them as trade schools. make students write in lambda calculus and assembly