[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

cpp features that dont suck

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 145
Thread images: 19

File: IMG_5151351351.jpg (31KB, 480x640px) Image search: [Google]
IMG_5151351351.jpg
31KB, 480x640px
itt: features from cpp you think C could actually use

ill start, i think the '&' reference type is pretty nice to use instead of pointers sometimes

absolutely no bullying people and calling them a r*tard because they like one feature
>>
this is a good thread someone reply to it
>>
>>61238012
It's really not. Who's this thread even for?
>>
>>61237845
I'd like to marry this girl (male).
>>
>>61238054
everyone on /g/ also u can look at the girl in the picture
>>
const is great for optimization
>>
File: .webm (1MB, 1280x720px) Image search: [Google]
.webm
1MB, 1280x720px
>>61238063
she's mine!
>>
>>61238075
i thought c already had const
would you explain the difference
>>
Smart pointers.
>>
File: f285a229b298d78293755d083a42c38d.jpg (832KB, 960x1280px) Image search: [Google]
f285a229b298d78293755d083a42c38d.jpg
832KB, 960x1280px
>>61238076
Not anymore
>>
>>61237845
>cpp features that dont suck
//TO-DO
>>
>>61238213
Wonder what she smells like
>>
File: anzujaamu.jpg (695KB, 960x1280px) Image search: [Google]
anzujaamu.jpg
695KB, 960x1280px
>>61238237
Sex
>>
>>61237845
l/r-value references are great for code optimization
classes are good if you are not a Pajeet.
>>
Namespaces
>>
>>61238118
Fuck, no
>>
>>61238237
old cum and salt
>>
>>61238447
delet
>>
File: 1487028825775.jpg (166KB, 1024x1280px) Image search: [Google]
1487028825775.jpg
166KB, 1024x1280px
>>61238447
No
>>
>>61238438
>Fuck, yes
FTFY
>>
>>61238237
Donkey cum
>>
File: 05673b01f923e6c34ba85f0744ded7fd.jpg (362KB, 960x1280px) Image search: [Google]
05673b01f923e6c34ba85f0744ded7fd.jpg
362KB, 960x1280px
>>61238971
Wrong again
>>
>>61238352
literaly just think of better names lol
>>
no readable compile errors, it makes everything so much more fun
>>
The only decent sepples feature is that once you declare struct you can just use it as a type instead of having to write struct everywhere.
>>
>>61237845
Please tell me this girl is female?
>>
>>61242107
why would you want that?
>>
Moar Anzu please
>>
>>61242124
Cause I don't know how to fuck a dick.
>>
>>61242141
later
>>
File: 1498279674416.png (349KB, 386x581px) Image search: [Google]
1498279674416.png
349KB, 386x581px
>>61242159
When nigger?
>>
>>61238237
Bubble gum
>>
I was trying to figure out the point of references the other day, it just seems like a const pointer (not a pointer to a const). Not sure if it's really a good addition though.
>>
File: IMG_20170702_195933.jpg (294KB, 1350x1800px) Image search: [Google]
IMG_20170702_195933.jpg
294KB, 1350x1800px
>>61242300
It Should replace pointers
Maybe c shouldn't use the terminology 'function ' if it's going to let you pass by reference
What a shitty language
>>
Why did you censor the word retard?
>>
>>61242353
It's getting to the point where I can't trust my eyes anymore. That's either a doll or an image of a human but the skin has been edited. The hair, skin, and eyes don't look very real but it could just be edited, a wig, and contacts. What a world.
>>
>>61237845
namespaces. namespaces are fucking amazing.
>>
>>61242366
You're banned from my threads retard
Don't show your face again
>>
>>61237845
>>61238076
>>61238213
>>61238250
WHO IS SHE
>>
File: JaGnqW3.jpg (81KB, 895x1190px) Image search: [Google]
JaGnqW3.jpg
81KB, 895x1190px
>>61242159
When damnit
>>
>>61242382
How new are you? Why can't you read? Please read.
>>
>>61242385
when i get. Home
>>
>>61242385
Consider suicide you disgusting cock lover
>>
File: akqFHv1.jpg (170KB, 931x1239px) Image search: [Google]
akqFHv1.jpg
170KB, 931x1239px
>>61242391
Hurry
>>
>>61242381

Tell you what, I'll consider giving a shit about what you have to say when I see (USER WAS BANNED FOR THIS POST) in red on my posts. As it stands, you're not a mod, and I'm not breaking any rules.
>>
>>61242403
fuck you filtered
>>
>>61242397
>>61242385
Is it wig, makeup, contacts, or do you think it's just wig, contacts, and editing? Very cute either way.
>>
>>61242385
Liyu goes in the other thread
Check the archive
>>
>>61242424
>>61242397
I mean catalog
>>
File: 1486972572442.jpg (36KB, 480x719px) Image search: [Google]
1486972572442.jpg
36KB, 480x719px
>>61242395
Why do I like penis?>>61242413
All if them are wigs expect for her pics of her hair super short and yes contacts no ones eyes are red. I think editing on the eyes I don't know how her eyes can be that big
>>61242424
Hey I didn't start it
>>
>>61242406

Just so you know, I am capable of taking off my tripcode. I don't do it often, but sometimes it helps me be more of an ass.
>>
>>61237845
& and && references are dangerous as fuck, but without them you don't get copy and move semantics so I don't know what to do.

ctors/dtors for RAII semantics and templates are the best features
>>
>>61242103
makes things more complicated
>>61238259
>classes are good
no, no they are not
>>61238352
literally just fucking name your functions prefixed with the "namespace"
>>61238118
hahahahhahahahahahahhaha
>>61238075
already has it
>>61238085
there isn't one
>>61237845
references are stupid and make functions disingenious and require you to think harder for something that's already complicated by default (unless you don't give a shit about optimization)

the one thing that c could use is a secondary facility for functions (or maybe even 3), we could call them procedures to align with pascal or whatever
something that has alternative properties, like a format better than function pointers (although it would have to be more complicated) or being inlined by default (or both)
basically what i want is lambdas from c++ but not retarded.
really just to clean up having functions in structures, im sure the oop fags would rejoice over that anyways.
if i got to ask for more i'd say a backport of postfix types from go or better threading/concurrency constructs but neither are really necessary.
>>
>>61242545
*leaks memory*
>>
Classes, templates, STL, exceptions, lambdas, references, namespaces, move semantics, type inference, RAII.

C is shit and obsolete, unless you need other languages to interact with your code, but even then, it's possible with C++.
And no, when it comes to langauges, there is no such thing as bloat. I'd rather have multiple tools for every situation than one tool that is shit but kind of works.
Fuck C.
>>
This thread is the reason C++ got designed in the first place, and is the same reason it turned into the nightmarish feature creep language it currently exists as.

C is good because C is simple. It was never meant to be used with 10 trillion built-in features.
>>
>>61242103
you can use the typedef keyword in C so you don't have to declare "struct <structname>" every time you use it.
it's just not a widely enforced practice for clarity's sake
>>
>>61242587
C is shit dumb dumb
>>
File: 1495604032802.png (76KB, 500x501px) Image search: [Google]
1495604032802.png
76KB, 500x501px
>>61242606
>>
>>61242439
How about moving to Turkey?
>>
>>61242598
>clarity's sake
type declaration.
struct shit {};

Using the type.
shit *x = malloc(sizeof(*x));

That would make sense.
But no, dumb ctards have to declare the struct everytime they want to use. If you don't what the type does you shouldn't be using it in the first.
>>
>>61242582
>And no, when it comes to langauges, there is no such thing as bloat.
I feel like this is generally true, but it can harm readability when you have a dozen different ways to do the same thing.
On the one hand, if you have a minimalistic language, people start inventing their own ass-backwards idioms to do basic shit. The good side to that is that you can still generally figure out what's going on in unfamiliar code since it's built out of the same small set of primitives everybody is familiar with.

The big problem with C++ is that none of its features were designed with respect to each other, it just kind of snowballed and accumulated shit. So most of the features are halfhearted and halfbaked, and constrained by backwards compatibility concerns.
>>
>>61242626
typedef struct shit_struct { poo poo } shit;
shit *x = malloc(sizeof(*x));

Wow, so hard!
>>
File: 1442140626777.jpg (55KB, 512x755px) Image search: [Google]
1442140626777.jpg
55KB, 512x755px
>>61237845
new and delete
template
>>
>>61242646
Won't pass code review
>>
>>61242652
Says who?
You can use typedef on struct declaration so you don't have to put "struct" everywhere, EXACTLY what you want to be able to do.
>>
>>61242647

Never noticed she had man hands till now
>>
>>61242658
Dinosaurs hate typedef structs and consider them bad style because ???.
>>
Really the only reasons I choose C++ for big projects is because of the C++ standard library and boost.
>>
>>61242691
I already told you. Clarity.
If the old geezers on your team don't want you to use typedef on structs, then fucking don't. A consistent codebase is more important than you wanting to skip typing "struct" or writing a macro to do it for you. That's literally all there is to that.
C can do what you want it to. Somebody not wanting you to do that is a situational problem and not the fault of the language.
>>
>>61242680
why is that strange
>>
typedef was mistake.
>>
Generics, this is my biggest gripe with C, other than that it's good.
>>
>>61237845
A reliable fucking set of common collections in the stdlib. No, seriously, I don't want to write linked list/array removal+shift/hash table code over and over again.
>>
>>61237845
>ill start, i think the '&' reference type is pretty nice to use instead of pointers sometimes
No. C++ referenced are extremely retarded.
They literally perpetuate invisible state changes.
>>
>>61242952
>referenced
references*
>>
File: ThreeDimensional 175.webm (2MB, 1280x720px) Image search: [Google]
ThreeDimensional 175.webm
2MB, 1280x720px
>>61242891
what is a gneieric
>>
>>61242943
And namespaces. Those are great, too.
>>
>>61242891
C has an extremely important feature that basically no other language has, and many other languages actually rely on: its simple and stable ABI.
How to you propose "Generics" (whatever that actually means) be implemented without fucking that up?

>>61242969
My point is the same as above. Also, namespaces are fundamentally useless.
>>
>>61243006
>>61243019
That has literally nothing to do with what I said.
You don't even know what an ABI is, do you?
>>
>>61243024
im not buying your anime bytes invite just leave me alone
>>
>>61238075
You mean constexpr maybe?
>>
>>61243041
Why are you so rude? It's really off putting.
>>
>>61238065
i want to look like the girl in the picture :(
>>
File: ThreeDimensional 192.jpg (110KB, 640x640px) Image search: [Google]
ThreeDimensional 192.jpg
110KB, 640x640px
>>61243082
whatever i delted it
>>
>>61243093
A lot of your posts have the same spirit, I'm leaving.
>>
>>61237845
>absolutely no bullying people and calling them a r*tard because they like one feature
Alright, but the people who like zero features, or two or more features, are dead fuckin meat.
>>
>>61243109
sorry
>>
File: 1498093862047.png (3MB, 1920x1080px) Image search: [Google]
1498093862047.png
3MB, 1920x1080px
>>61243155
We all make mistakes, I forgive you. Luckily I was too distracted to close the tab. My images aren't sorted so you can have this one.
>>
>>61242989
You don't need to expose generics as part of your public ABI.

>>61242952
You mean like global and static variables?
>>
>>61243263
>You mean like global and static variables?
That's slightly different.
Here is an example. Please tell me what the last line of this C++ code will print:
int a = 10;
fn(a);
std::cout << a << std::endl;

The prototype and implementation of fn has deliberately been left out.
>>
>>61243288
>Declarations only count when I do it!
a = 10;
fn(a);
std::cout << a << std::endl;

It's just as impossible to know what this will print.
>>
Is Anzu a her?
>>
>>61243322
he's a she
>>
>>61243300
if it pritns anything other than 10 it's shit language.
>>
File: she.png (61KB, 325x971px) Image search: [Google]
she.png
61KB, 325x971px
>>61243322
Girl (male)
>>
>>61243430
C is shit, OK then.
>>
>>61243443
yes
>>
>>61243443
That's not C though. Dumb fuck.
>>
>>61243430

If fn takes a as a mutable reference, it could change the value of a to something else. This is an extremely useful language feature. Why might you want to mutate your function's arguments? Well one example would be a swap procedure. Where might this be useful? In sorting a list, of course!
>>
>>61243483
C already has a mechanism for that, it's called pointers.

I can understand the desire for purity and clarity that explicit pointer usage satisfies but the fact is that C already has plenty of impure mechanisms.
>>
File: ThreeDimensional 612.jpg (316KB, 1200x1200px) Image search: [Google]
ThreeDimensional 612.jpg
316KB, 1200x1200px
>>61243483
list.sort()
>>
>>61243472
replace the streams with printf and the point still stands, autismo
>>
>>61243514
int a = 10;
fn(a);

In C a will always be 10. Dumb fuck.
int a = 10;
fnp(&a);

value of a might change in the function call.
>>
>>61243514
>>61243443
C is incapable of changing the value outside of it's scope without a pointer, and no pointer is being taken there.
C will always print 10.
>>
>>61242567
*maintains readability*
*statically allocates*
>>
>>61243483
>This is an retarded useful language feature.
FTFY
>>
>>61243536
Fuck, I changed the wrong word. I should pay more attention to what I'm doing.
>>
>>61243525
>>61243527
Unless it's a global, which is the point I made earlier. Read a little before you make shitposts.
>>
>>61243528
>*maintains readability*
void *ptr = get_thing();

How do I know whether I should free ptr?
>>
>>61243545
>If I change your example to something completely different, that somehow invalidates it.
Fucking idiot.
>>
>>61243585
>You're only allowed to look at declarations if it suits my point
>>
>>61243494
And references are just syntactic sugar for pointers.

>>61243500
And this is just syntactic sugar for listtype::sort(&list)
>>
>>61237845
Ok, I'll go.

Methods
Constructors
Destructors
Polymorphism by virtual methods
Operator overloading
Function/method overloading
static_cast/dynamic_cast/reinterpret_cast
User-defined contextual conversions
Templates
Template metaprogramming
Type traits
constexpr
The STL
Modules (future)
Concepts (future)
Optional parameters
Lambda expressions
Scoped and strongly typed enums

Anything I missed?
>>
>>61243606
> syntactic sugar
Don't say that or the rest of the Cfags will start climbing out of the woodworks.
Just as soon as they're done handrolling their 50th boilerplate linked list.
>>
>>61243595
You fucking know the local variables that you're working with at the moment, and don't have to look far to see how they're defined. Projects have hundreds to thousands of functions, defined all over the fucking place.
My whole point is that the C++ code is misleading as fuck (as is most C++ code) and hides a lot of important information from you.
You'll say "just look at the prototype". Sure, but are you really going to go hunting around your codebase for fucking dozens of function prototypes so you can fucking reason about the state of a couple of variables?
>>
>>61243575
Generally in C you allocate the memory your self and call init function on it.
If you want to provide function that retuns allocated memory then you provide creation function and function to delete the object.
thing var;
thing_init(&var);
void *ptr = thing_new();
void thing_del(ptr);

Then again most people program in their own fucked up way and you can never be sure.
>>
>>61243643
Constructors/destructors are magnitudes better than this. And it's standard.
>>
>>61243701
Constructors and destructor are fundamentally pointless, and don't add extra power or anything of actual value.
>>
>>61243613
>Methods
>Constructors
>Destructors
All fantastic. RAII is by far the best idiom C++ has brought to the table. Memory management without a GC and without free/delete, what could be better?
>Polymorphism by virtual methods
Meh, I don't like how C++ has two major and conflicting polymorphism mechanisms.
>Operator overloading
Dangerous, people use it for retarded shit. Streams, for example. At the same time it's indispensable if you're working with any arithmetic types that aren't primitives. Needs to be used with discretion.
>Function/method overloading
Absolutely useful, but it comes with name mangling which is the main thing that fucks the C++ ABI. I'm not sure if this is entirely a good thing, but at least I can turn it off.
>static_cast/dynamic_cast/reinterpret_cast
>User-defined contextual conversions
Generally useful, although it sucks that casting is so much more complicated than C. Especially when you have complex logic in implicit casts.
>Templates
The other fantastic feature C++ brought to the table. Along with lambdas it's the reason std::sort is twice as fast and twice as readable as qsort. Syntax sucks a bit though and there are weird, sometimes esoteric limitations. Maybe D has it better.
>Template metaprogramming
garbage and unreadable, please just use constexpr
>Type traits
Not familiar with this.
>constexpr
A small but useful thing. Doesn't cause any damage but makes life a little easier. It's nice.
>The STL
It's pretty great in general, but some stl classes are really showing their age. Too often you'll find it lacking and try Boost, but then you're bogged down with dependencies.
>Modules (future)
Desperately needed and needed soon.
>Optional parameters
See function overloading.
>Lambda expressions
Great in theory but a little awkward to use unless you're templating a lot.
>Scoped and strongly typed enums
That's all right.

Anything I missed?
>>
>>61237845
You think anzu would fuck me for 1k?
>>
>>61243709
I too love memory leaks.
>>
>>61243749
That has literally nothing to do with that.
>>
>>61243723
Namemangling in sepples is well defined.
Virtual methods and how classes are stored / called is implementation defined and the biggest reason why sepples cannot be used easily from other languages.
>>
>>61243761
>Namemangling in sepples is well defined.
No it's not.
>>
>>61243752
>Namemangling in sepples is well defined.
Where's the standard definition?
>>
>>61243752
The exact purpose of a destructor is to release resources when the object that contains them goes out of scope.
>>
>>61243853
A destructor is just a function which frees resources or whatever.
What you're describing is something else.
>>
>>61243889
In C++, a destructor runs whenever an object goes out of scope, just as a constructor runs whenever it enters scope.
They're not the same as open/close functions.
>>
>>61237845
As you say, goth chinatsu chan
>>
>>61242957
Bbrrrrraaapppptt!!!
>>
>>61243322
Female (male (female))
>>
When did /g/ become so retarded they they can't into C/C++? Where
I literally program in C for my job and I even tutored an embedded C course when I was at university.
>>
>>61244258
>C/C++
You just triggered some anons with that.
>>
Posting one of my personal hobby project, not even close to be done you might want to take a look my generic list
https://github.com/purpasmart96/pmd_test
>>
>>61243322
girl(girlboy) (male she/male)
>>
File: 1476166550629.jpg (112KB, 1080x1080px) Image search: [Google]
1476166550629.jpg
112KB, 1080x1080px
>>61242382
Anzujaamu.
She is not NOT >>>NOT<<< a trap. That's a stupid meme from reddit. She's actually Turkish and a girl from birth, also she's anorexic and honestly it grosses me out but her face is pretty qt I guess and she has a nice fashion blog.
>>
>>61247850
Fucking gross. Pretty sure that's not even a human.
>>
>>61243739
Doubt it, her parents are loaded and she's making a lot of cash with all the shilling she does for makeup and other weeb cosplay products.
I'd only pay if i can cum inside her tbqh.
>>
>>61248030
She's slutty as fuck

- Turkish anon who goes to Bilkent
>>
>see anzu in op
>open thread expecting to see more anzu
>there's lots of anzu pics
every time
>>
>>61247919
It's not "she" is a roach.
>>
>>61237845
Being able to call methods on structs / unions seems like common sense, and there would be no loss in performance, The way rust does it is sort of how i would imagine it would go, just without traits and the other OOP stuff, since it's still C we're dealing with here
>>
>>61248065
delet
>>
>>61251125
t. Anzu's cuck of a bf
Thread posts: 145
Thread images: 19


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.