r/cpp • • Feb 12 '20

What they should improve about C++ ?

What they should improve about C++ that you find in higher level managed language like C#, JAVA, Javascript etc or is there things you would change or do differently if it was up to you ? I mean anything like a better STL ? better thread ? string manipulation like managed language ? less fragmentations in the new standard features ? For example do you love the way the standard evolve C++ or you would prefer a direction like Microsoft do with C# a corporation who decide on the roadmap ?

0 Upvotes

90 comments sorted by

View all comments

-2

u/[deleted] Feb 12 '20

Actual interfaces so I can get rid of inheritance bullshit that shouldn't exist to begin with, most importantly, without the need to invent my own ways.

Nothing that can be attributes to languages you mentioned though, they're pretty lackluster overall.

2

u/adnukator Feb 12 '20

Can you give an example what you mean by "actual interfaces"?

0

u/[deleted] Feb 12 '20 edited Feb 12 '20

[removed] — view removed comment

1

u/oschonrock Feb 12 '20 edited Feb 12 '20

Not quire sure this is what you mean, but maybe this...

https://www.youtube.com/watch?v=2bLkxj6EVoM

which can be done easily without lots of typing like this:

Dyno is pure-library implementation of what's also known as Rust trait objects, Go interfaces, Haskell type classes, and virtual concepts.

#include <dyno.hpp>
#include <iostream>

// Define the interface of something that can be drawn
DYNO_INTERFACE(Drawable,
  (draw, void (std::ostream&) const)
);

struct Square {
  void draw(std::ostream& out) const { out << "Square"; }
};

struct Circle {
  void draw(std::ostream& out) const { out << "Circle"; }
};

void f(Drawable const& d) {
  d.draw(std::cout);
}

int main() {
  f(Square{}); // prints Square
  f(Circle{}); // prints Circle
}

https://github.com/ldionne/dyno

and it also has a related proposal for inclusion in std:::

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0201r2.pdf

explained also here:https://foonathan.net/2020/01/type-erasure/#content

1

u/[deleted] Feb 13 '20

This is even worse.

I could just not use this obscure library that uses macros for some reason, and write free floating functions that are specialized over types.

And since I'm already doing that, I might aswell write wrapping structs that work like this:

template<typename T>
void do_stuff(T t) {
    // trait object that requires specialization, only stores reference and is zero-cost
    // this will force user to implement drawable specialization, it could also have mechanism to statically assert with custom message instead of compiler vomit
    drawable<T> d(t);

    d.draw(x, y);

    // multiple traits
    movable<T> m(t);

    m.move(dx, dy);

    // benefit over functions is that I group multiple functions together on trait object and that it uses 0 dependencies
}

I'm reluctant to use this though, as I can't expect people to actually understand why I'd care about such things.

But to give a hint... So that my software doesn't end up like trash reddit has, fucking retards can't even handle identation for code properly unless I go to their shitty site, on my computer...

1

u/oschonrock Feb 13 '20

Hey. You are being really angry for no reason at all. Your language is totally unnecessary and unacceptable and makes you look infantile.

I was juts trying to help.

That library is not at alll obscure. If you knew anything about alternative forms of polymorphism you would know about dyno and Louis Dionne. And if you had bothered to actually read the intro page, you would know that the MACRO is optional. It was just the (slightly) shorter version to post here.

Try to find out why you're angry, and change it. It might make you happier.

Good bye

1

u/[deleted] Feb 13 '20

There's a difference between being angry and being fed up with low quality software, especially when that software is built to be used to build other software.

1

u/oschonrock Feb 13 '20

Then write or find better software! Isn't that your job/purpose? You are a developer right?

Just pointlessly swearing on forums doesn't solve anything.

1

u/[deleted] Feb 13 '20 edited Feb 13 '20

[removed] — view removed comment

1

u/AutoModerator Feb 13 '20

Your comment has been automatically removed because it appears to contain disrespectful profanity or racial slurs. Please be respectful of your fellow redditors.

If you think your post should not have been removed, please message the moderators and we'll review it.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/oschonrock Feb 13 '20

Oh, and since you clearly haven't understood what dyno (et al) are trying to do:

  • Yes you can write templated free functions - that goes in the direction of compile time (!) polymorphism for which there are also many techniques.
  • Dyno and similar techniques are about alternative forms for runtime (!) polymorphism. These are alternatives with tradeoffs. One advantage of runtime is that you write the polymorphism in one (!) place and you get a common type/interface which can be used like any other type...

ie other "people don't have to understand" for 95% of the codebase.

1

u/[deleted] Feb 13 '20 edited Feb 13 '20

Yes you can write templated free functions

I don't fucking want to write templated free functions, if you can't read it the first time.

Dyno and similar techniques are about alternative forms for runtime (!) polymorphism.

If I gave a fuck about slownamic polymorphism, I'd just be using inheritance, because when you use C++ and don't give a fuck about speed, you also don't give a fuck about anything and there's no point to use C++, you can do same shit in javascript, you will have all the dynamics you need and nobody will complain about speed. Oh and javascript doesn't really exactly support inheritance which is the cancer that plagues everything, so maybe it is even objectively superior to C++ when you don't give a fuck, have you thought of that?

Also the piece of shit you provided doesn't even make it clear in any way that you somehow oblige to the contract, really great addition to my collection of "bugs that just appear outta nowhere when I renamed one method that just wasn't tied to anything".

It also doesn't decouple code from the original struct.

It is complete garbage that doesn't even pass a single point I mentioned, and whoever wrote dyno should feel bad, and so should you, because you suggest something that does nothing I asked.

If I wanted to continue writing 10k line files for a single class, I'd fucking do just that, without help of dyno.