[ / / / / / / / / / / / / / ] [ dir / agatha / cutebois / fascist / fast / komica / leftpol / vichan ][Options][ watchlist ]

/tech/ - Technology

You can now write text to your AI-generated image at https://aiproto.com It is currently free to use for Proto members.
Email
Comment *
File
Select/drop/paste files here
Password (Randomized for file and post deletion; you may also set your own.)
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Expand all images

New Volunteer

File (hide): 1c911e6894fbde3⋯.gif (619.72 KB, 150x113, 150:113, 91a628eb17d897d1defc688251….gif) (h) (u)

[–]

 No.937842>>937902 >>937909 >>937910 >>937924 >>939548 >>939564 >>939581 >>939628 >>940606 >>940616 >>940617 [Watch Thread][Show All Posts]

C++ is among the worst programming experiences I've ever had, the touted advantages of using it are exactly what is making it difficult to use because they are implemented so horrendously.

Why is inheritance so messed up just so you can have multiple inheritance (i.e: where's my super)? Why is the documentation unclear on basic stuff (I just want to replace an item in a list dammit)? Why does the compiler randomly decide it doesn't want to upcast? Why is it that the only way I can solve this cyclical dependency is by putting the actual method lines away from the original class, making my code difficult to read?

This language is actual trash and you should be shot if you use it.

 No.937844>>937870 >>939607

Oh and a few other ones:

Method pointers make absolutely no sense, why can't I cast them to method pointers for other classes (seriously, you might as well resort to static methods with your own this pointer)? Why is the syntax for using them so retarded?


 No.937847

<The more complex we make it, the smarter we'll be for knowing how it works


 No.937870>>937979 >>937980 >>939481

Inheritance is perfectly fine, the documentation is not a C++ problem in itself, the compiler decides nothing randomly. I take your complaint about cyclical dependencies as valid, though. That's the C burden, fortunately we might see modules, and thus the end of #include insanity in C++20.

>>937844

>why can't I cast them to method pointers for other classes (seriously, you might as well resort to static methods with your own this pointer)?

You can always reinterpret_cast, but why would you do that? What's so retarded about std::bind?


 No.937877

OP, you are just bad.


 No.937898>>938050

C++ had to be somewhat backwards compatible to C. It was this requirement that caused many kinds of sophisticated semantics and syntax for C++ language design.


 No.937902>>937975

>>937842 (OP)

Do you absolutely have to use C++? If not, an alternative you might be interested in Ada2012. It isn't a simple language, but it's a lot saner to work with than C++.


 No.937909>>937978

>>937842 (OP)

Perhaps you're just not smart enough? Consider using Java or Python as languages that'll be easier for you to grasp.


 No.937910

>>937842 (OP)

Just use C or Java.


 No.937924>>938050

>>937842 (OP)

It's been known for a long time C++ is shit. Here's the famous FQA shitting on old C++98:

http://yosefk.com/c++fqa/

The C++ story goes like this: once upon a time there was C and C was king, because it was pretty good for practical reasons (though it had some warts like pointers and array decay and null terminated strings that don't know their own size etc.) Then came the OOP (object oriented programming) craze which is still going strong today: the thought that if you divide your code into blobs of interdependent data and code (classes, basically a bunch of functions with a shared hidden state) which may have inheritance relationships between them THEN for magic reasons your code will be better, easier to maintain, easier to understand etc. Then some narcissistic faggot called Bjarne Stroustrup decided he's gonna make an OO language to make him popular. Of course he'd have to piggyback on the popular language of the time, which was C. So: popular C + popular OOP = popular C++. Bjarne didn't care about the fact that OOP actually requires the language underneath to be high level i.e. garbage collected (among other things, like arrays being first class citizens) all he cared about was making a popular language that weenies would quickly adopt as a replacement for C.

C++ is shit because it's basically still low-level C but with a bunch of hacks added to it (for example, adding virtual functions to a class changes its size even if you don't add new member data, that's a hack; you can overload functions but that's made possible with name mangling INCOMPATIBLE between different compilers, that's a hack) to make it seem high-level and object oriented (and OOP does more obfuscation than it does anything else) while at the same time for the sake of drawing from C's popularity a facade of backward compatibility is maintained (basically by not deprecating old leftover stuff from C that shouldn't ever be used in C++ code anymore, such as string.h, malloc+free, stdio.h etc).

My suggestion to OP: if you need to stick to C++ do yourself a favor and use C++11 at least, preferably the latest (C++17), and for God's sake avoid using the C parts that they refuse to deprecate. Look up "modern C++", it's code talk for doing things in as a non-C way as possible. Otherwise just use another language.


 No.937975

>>937902

No, I was trying to reimplement the runtime for my programming language in C++ so I could make the transpiled code more readable and keep all the code in one area, I'm just gonna go back to doing it C, it just werks.


 No.937978>>939548

>>937909

The issue is that the language isn't hard because the difficulty provides some advantage (e.g: more control or speed), it's hard because it's designed by retards.


 No.937979

>>937870

The fact that the standard doesn't guarantee member function pointers can be reinterpretted like that. I'm not going to start littering my code with undefined behaviour lest it break with a GCC update or on a different architecture.


 No.937980

>>937870

>The compiler decides nothing randomly.

I've literally used new and had the compiler tell me it's not a pointer, C++ compilers are buggy as hell because the language spec is overcomplicated.


 No.938050>>938056 >>938062

>>937898

>sophisticated

That's not the word I would use.

>>937924

>once upon a time there was C and C was king, because it was pretty good for practical reasons

C and UNIX became popular in the 80s with RISC workstations because they could get the code for cheap. They didn't have to write an OS.

>Then some narcissistic faggot called Bjarne Stroustrup decided he's gonna make an OO language to make him popular. Of course he'd have to piggyback on the popular language of the time, which was C. So: popular C + popular OOP = popular C++.

C++ is based on C because Stroustrup worked at AT&T and was stuck using C, but wanted to fix some of the parts that sucked, like strings and error handling. He couldn't really fix them because C sucks too much, but that was his intent with C++. If there were any "narcissistic faggots", they were the creators of C and UNIX who spread their code everywhere even though they knew it was bad. That is a good theory that they did it because they wanted to be popular because they certainly didn't do it because they thought it would be good for the users.

>Bjarne didn't care about the fact that OOP actually requires the language underneath to be high level i.e. garbage collected (among other things, like arrays being first class citizens)

This is true, but neither did anyone else at AT&T. They could have told him not to waste so much company time on that bullshit, like they could have done with C and UNIX, but for some reason, he was allowed to turn C++ into an AT&T product and they marketed it.

>all he cared about was making a popular language that weenies would quickly adopt as a replacement for C.

It wasn't until later that C became popular and then the UNIX weenies invented some bullshit excuse for why they're stuck with C and C++. C was the language replacing other languages, like Pascal, Fortran, and Lisp.

    I've always thought that if Lisp were a ball of mud,
and APL a diamond, that C++ was a roll of razor wire.

That comparison of Lisp and APL is due to Alan Perlis - he
actually described APL as a crystal. (For those who haven't
seen the reasoning, it was Alan's comment on why everyone
seemed to be able to add to Lisp, while APL seemed
remarkably stable: Adding to a crystal is very hard, because
you have to be consistent with all its symmetry and
structure. In general, if you add to a crystal, you get a
mess. On the other hand, if you add more mud to a ball of
mud, it's STILL a ball of mud.)

To me, C is like a ball. Looked at from afar, it's nice and
smooth. If you come closer, though, you'll see little
cracks and crazes all through it.

C++, on the other hand, is the C ball pumped full of too
much (hot) air. The diameter has doubled, tripled, and
more. All those little cracks and crazes have now grown
into gaping canyons. You wonder why the thing hasn't just
exploded and blown away.

BTW, Alan Perlis was at various times heard to say that
(C|Unix) had set back the state of computer science by
(10|15) years.


 No.938056

File (hide): 2e893b1392c406a⋯.mp4 (611.29 KB, 1280x720, 16:9, shut-up-richard.mp4) (h) (u) [play once] [loop]


 No.938062

>>938050

Lispbro, can you drop ugh.pdf for me? I wiped my phone and lost it.


 No.938066

C++11 is good. If you wrote a lot of C you'd understand its value. The main issue with C++ is only experts have any chance of not turning a large project into a pile of shit (and if you don't agree you're not an expert), but webdev sucked up all the shitters so it's not the problem that it used to be. The average C++ guy is now highly experienced.


 No.939012>>939022

Git gud and have some respect, OP.

Operating systems are written in C++. The code that actuates the flight surfaces on aircraft is written in C++. The software that runs robots is written in C++. It’s not because some whiny channer phaggot has issues that the language is shit.

Git gud.


 No.939022>>939188

>>939012

>The code that actuates the flight surfaces on aircraft is written in C++

That's usually Ada.


 No.939188>>939247 >>939250 >>940622

File (hide): 2f89cf3b73bff18⋯.png (60.54 KB, 454x339, 454:339, SKJV4.png) (h) (u)

File (hide): da07e667e616ed0⋯.jpg (1.42 MB, 2185x1457, 2185:1457, Ada getting BTFO.JPG) (h) (u)

>>939022

C++ now rules the skies.


 No.939247

File (hide): 8403b7e75743e17⋯.jpg (28.83 KB, 182x216, 91:108, wasting time.jpg) (h) (u)

>>939188

> spend 10x more money

> still end up with tons of broken bits

Hurr durr, we sure showed those Ada guys.


 No.939250>>939483

>>939188

Remind me to never board an F-35


 No.939481>>939531

>>937870

Tell me more about c++20 senpai


 No.939483

>>939250

Don't worry, your fat nigger ass will never.


 No.939531>>939536 >>939570 >>939596

>>939481

https://en.wikipedia.org/wiki/C%2B%2B20

https://en.cppreference.com/w/cpp/compiler_support

Oh God I see they're gonna add concepts in C++20. Yeah, write meta code that you'll have to maintain as if it was real code, just for better compiler error messages, that's a sane idea ain't it! /s

https://en.cppreference.com/w/cpp/experimental/constraints

Then again why am I bitching, it's established tradition in C++ that the language user plays an important role in making the language high level, by manually writing the relevant code such as assignment operators and copy constructors. So this is just more of the same old "want high level functionality? code it yourself" bullshit that makes C++ the scam that it is.


 No.939536>>939544

>>939531

It's pretty easy to get megabytes of incomprehensible error spam from incredibly minor template misuse. The language needs a way to limit that in the more complex template libraries. Don't let me stop you being mad about change, though.


 No.939544>>939547 >>939570

>>939536

Change can be good or bad, and I see you're very optimistic. Have fun screwing up your concept definitions and instantly breaking all the code using them when you correct them.


 No.939547

>>939544

I'm a good C++ programmer, it'll be fine.


 No.939548>>939629 >>939726

>>937842 (OP)

>you can have multiple inheritance

>language does not stop me from doing dumb shit so it sucks

>I just want to replace an item in a list dammit

Because it's a fucking list, not a vector?

>>937978

No, it is exactly because it provides both control and speed. And lack of clarity is cost for it.


 No.939564>>939568

>>937842 (OP)

>This language is actual trash and you should be shot if you use it.

You don't need to, the language will do it for you.


 No.939568>>939569

>>939564

>webdevs react to systems languages


 No.939569

>>939568

I'm actually an old C hand and this was a shitpost.


 No.939570

>>939531

>>939544

It's not that bad, it is extremely rare to have to change a concept from my experience. They're write-once-and-forget boilerplate.


 No.939581>>939604

>>937842 (OP)

> (i.e: where's my super)

SuperclassName::currentFunctionName(args) works for all superclasses.


 No.939596

>>939531

Well that's not the good story I was looking for


 No.939604>>939620 >>939729

>>939581

Why do cucklang devotees call it 'super' and not 'parent'? It's inheritance, you inherit from parents. Is it the thought of having children that scares them, or because they didn't have a father and MI is a painful reminder?


 No.939607

>where's my super

Pajeet my son, Java is what true shitcoders strive for.

>I just want to replace an item in a list dammit

std::replace(mylist.begin(), mylist.end(), oldvalue, newvalue);

If this isn't what you meant, then maybe you should learn to clarify your own thoughts.

>Why does the compiler randomly decide it doesn't want to upcast?

<I don't understand it; it must be random!

>putting the actual method lines away from the original class

Because for now, the compiler reads files from top to bottom and expects to find all symbols it needs in the same compilation unit.

>>937844

>why can't I cast them to method pointers for other classes

<why can't I cast function pointers to function pointers with a different signature

What the fuck are you trying to do


 No.939613>>939614

One thing that's legitimately shit about method pointers is that they can't be passed to C with a void * set to this as is the standard way of doing C callbacks and invoke the C++ method without it being undefined behavior. Getting around this requires a glue layer between C libraries and C++ that costs a few extra instructions per call. Like, how did they even fuck this up?


 No.939614>>939617

>>939613

>Like, how did they even fuck this up

A method is just a function that takes an object as an implicit parameter. Obviously it would not make any sense to pass it to c without some crazy closure system.


 No.939617>>939621

>>939614

>A method is just a function that takes an object as an implicit parameter

Except it isn't. That's the problem. It should have been, and that's how it's implemented in all compilers I'm aware of, but it's not defined that way, so it's undefined behavior if you do it.

>it would not make any sense to pass it to c without some crazy closure system

But it does. The way it works today in portable code is goofy - pass a dummy function and void *this to the C callback, then have the dummy function do the this->real(). It's this shitty little stub function that exists only because the standard got autistic about not tying the hands of compiler authors.


 No.939620>>939631

>>939604

'super' -> 'superset'

thinking of classes in terms of sets of classes, collections of classes with a common property is the best way to design systems when dealing with oop.

all classes which implement XXX interface are better understood as "the collection (superset) of classes which implement XXX interface".

if you're thinking in terms of parent class and child class then youre using inheritance badly. you sound like you're in middle school, flipped through "Head First Inheritance and How to Suck Mediocre Dick", and only ever inherit from 1 class.


 No.939621>>939627

>>939617

>Except it isn't. That's the problem.

except it is. this is a basic feature of c++.

>pass a dummy function and void

that dummy function would have to be done as code generation at runtime. There is no way to get a static address to a function for a particular instance of an object without something retarded like a single threaded global variable.


 No.939627>>939755

>>939621

>except it is. this is a basic feature of c++.

Looks like you're going to learn something today, anon. It's explicitly forbidden in C++.

Because you're a faggot and need to stop being one, I've written you an example. It will "work" with gcc with a warning, but fail to compile with clang.


#include <stdio.h>

struct c_data {
int n;
};

extern "C" void c_caller(void (*callback)(void *), void *data) {
callback(data);
}

extern "C" void c_callee(void *data) {
struct c_data *c_data = (struct c_data *) data;
printf("c_callee: %i\n", c_data->n);
}

class Cpp {
public:
int n;
void cpp_callee() {
printf("cpp_callee: %i\n", n);
}
};

int main() {

struct c_data c_data = {123};
c_caller(c_callee, &c_data);

Cpp cpp;
cpp.n = 321;
// UB
c_caller((void (*)(void *)) &Cpp::cpp_callee, &cpp);
}

Result on gcc:


c_callee: 123
cpp_callee: 321

Because the standard forbids this, making the C++ part portable requires a dummy function as a go-between. With some template magic they can be generated automatically but the cost will still be there at runtime.


 No.939628

>>937842 (OP)

How are you so stupid?

Oh nm, you're probably a pajeet.


 No.939629

>>939548

>Because it's a fucking list, not a vector?

Do people still get confused over this?


 No.939631>>939786

>>939620

>superset

>when pure virtual exists and the "super" might not be a "superset".

Clearly people who call parent classes superclasses are retarded.


 No.939726

>>939548

>language does not stop me from doing dumb shit so it sucks

Learn to read retard, my problem isn't the existence of multiple inheritance, my problem is the fact that I can't have super because of it.


 No.939729

File (hide): ef40be555c8ba3a⋯.jpg (58.86 KB, 640x606, 320:303, 2dm3x1mkqc811.jpg) (h) (u)

>>939604

>Why do cucklang devotees call it 'parent' and not 'base classes'? It's inheritance, you inherit from base classes. Is it the thought of having derived classes that scares them, or because they didn't have a father and MI is a painful reminder?


 No.939755

File (hide): b6a6a4a016f8cd7⋯.jpg (48.18 KB, 720x837, 80:93, DUePfMyVMAE6OcK.jpg) (h) (u)

>>939627

> It will "work" with gcc with a warning, but fail to compile with clang.

lol whatever man works on clang for me. stop spreading anti cpp fud.


 No.939786>>939793

>>939631

Yes, the super class you derive from will still be a superset of all classes deriving from it, pure virtual does not change this. Try again.


 No.939793>>940155 >>940607

>>939786

>is explicitly missing the subclass's function

>but it's a superset

Low int roll.


 No.940155>>940599

>>939793

>completely lacks an understanding of the basics of polymorphism and inheritance

yeah ok confirmed for 12 yo streetshitter


 No.940531>>940533

Bjarne Shitstreet is a retard. C++ is an insult to programming.


 No.940533

>>940531

smarter than u tho


 No.940599>>940607

>>940155

>can't say why the example is incorrect

>resorts to name calling

Tee hee


 No.940606

>>937842 (OP)

if you don't use lisp+python to do everything, you are basically a brainlet


 No.940607>>940612 >>940772

>>939793

>>940599

Pure virtual


 No.940612>>940772

>>940607

What, where's the rest of my goddamn post. Anyway, what I wrote was:

Pure virtual is an implementation specification rather than representation of logic, meant to aid the programmer. Think of it as declaring a variable that shouldn't ever change as const, technically you don't have to do that, if the rest of the implementation is sound, everything will work fine, however as people aren't perfect we restrict ourselves so that we can have analysis tools detect errors we cound possibly make.

Additionally, pure virtual doesn't mean a class doesn't contain such a method, it means that the whole class is in itself abstract, we just do it on per-method basis since it allows for partial definition of said class, again - to aid the programmer. There exists a concept of a "thing", there exist many objects that are "things", but there is no object that is purely a "thing" and nothing else.


 No.940616

>>937842 (OP)

Java is among the worst programming experiences I've ever had, the touted advantages of using it are exactly what is making it difficult to use because they are implemented so horrendously.

Why is inheritance so messed up just so you can have multiple inheritance (i.e: where's my super)? Why is the documentation unclear on basic stuff (I just want to replace an item in a list dammit)? Why does the compiler randomly decide it doesn't want to upcast? Why is it that the only way I can solve this cyclical dependency is by putting the actual method lines away from the original class, making my code difficult to read?

This language is actual trash and you should be shot if you u it.


 No.940617

>>937842 (OP)

Lol, sorry about your melanin, OP.

Maybe in your next life you will be white.


 No.940622>>940623 >>940634

>>939188

>115K lines assembly

But why?


 No.940623

>>940622

Because tons of small chips are going to require that.


 No.940634

File (hide): f65abefd768dcb0⋯.jpg (147.46 KB, 1920x1080, 16:9, TtoFTUh.jpg) (h) (u)

>>940622

Microcontrollers, son.


 No.940772

>>940607

>>940612

you STILL have yet to understand how wrong you are.


 No.941919

Wow OP if you weren't so busy guzzling cock maybe you'd read the book.




[Return][Go to top][Catalog][Screencap][Nerve Center][Cancer][Update] ( Scroll to new posts) ( Auto) 5
65 replies | 6 images | Page ?
[Post a Reply]
[ / / / / / / / / / / / / / ] [ dir / agatha / cutebois / fascist / fast / komica / leftpol / vichan ][ watchlist ]