Is C++ obsolete? Is it nothing more than a buggier, unsafe Rust?

Is C++ obsolete? Is it nothing more than a buggier, unsafe Rust?

Other urls found in this thread:

nvd.nist.gov/
plv.mpi-sws.org/rustbelt/popl18/
github.com/fuchsia-mirror
doc.rust-lang.org/std/collections/struct.LinkedList.html
twitter.com/AnonBabble

Dubs confirm C++ will never die

its like a RUST but the community isn't made up of faggots

rust is the future.

In principle, basically.

In practice, there are lots of libraries written in C++ with no Rust analogue of similar maturity and completeness (although they suck to use and configure compared with Cargo crates). There are also far more C++ developers and far more tools for writing C++. If this situation (hopefully) changes, it will take time.

>buggier
just your code
>unsafe
it's as unsafe as you make it

Not OP btw.
>just your code
Nah. Just everyone's code who actually codes large applications:
nvd.nist.gov/
>it's as unsafe as you make it
There's no such thing as "sort of unsafe". With respect to any particular safety property, a language is either safe or isn't. Rust's safety properties prevent data races and vulnerabilities. C++ as a whole doesn't guarantee any safety properties; you can always introduce undefined behavior.

dubs confirm your thread sucks

is this the new rust shill thread?

C++ is sa-
#include

int
main(void)
{
std::unique_ptr x(nullptr);
*x = 0;
return EXIT_SUCCESS;
}
*switches to Rust*

>Rust
>Mozilla
>A sjw bullshit language

>using smartpointers
Just because you're too retarded to use raw pointers doesn't mean it's a bad language

Even if we had perfect Rust drivers and native graphics APIs (which we'll probably never have), kernel guys will literally never change. The next generation of graybeards might consider dropping C, the one after it might even attempt it

>Rust

>C is sa-
#include

int
main(void)
{
int *x = NULL;
*x = 0;
return EXIT_SUCCESS;
}
*switches to Rust*

if you need someone to hold your hand, c++ is not for you

Did you forget the Mozilla CEO hates faggots and actually was disowned by Silicon Valley faggots?

>thinking that image has any amount of humor or truth in it
so much 'tism

>buggier, unsafe Rust
I'm really sick of hearing about this meme language.

What can a NEET like you know about modern tech work environment?
t. silicon valley wageslave

Yeah now Mozilla is full poz

...

kek

>it's as unsafe as you make it

As unsafe as your coworkers make it. Projects get large enough that you just can't be on every code review, or you just don't have time to hunt for all the bad patterns and bugs on the codebase.

Disseminating good practices is nice but hard enough and people eventually slip up.

sepples was obsolete out of the box

Observe these two retards. They think that Rust McMagic sprinkle dust will solve all the problems.

We heard the EXACTLY same thing about Java! "Now retards can be your coworkers!" Look at how that turned out to be.

Rust is like the same Java episode except without the garbage collector. The language itself is still GARBAGE however.

>The next generation of graybeards might consider dropping C
for what? HolyC?

>We heard the EXACTLY same thing about Java! "Now retards can be your coworkers!" Look at how that turned out to be.
Beautifully said.

did i say anything about rust? sepples was obsoleted by c at its inception
bjarne is a murderer

The problem is that retards are already your coworkers. If the language makes them less likely to make a class of mistakes then that can be considered a valid argument for choosing that language.

Employees are subject to sturgeon's law as much as anything else.

And why should political opinions change the value of a programming language?

>"Rust can be thought of as a combination of two programming languages: Safe Rust and Unsafe Rust. Conveniently, these names mean exactly what they say: Safe Rust is Safe. Unsafe Rust is, well, not. In fact, Unsafe Rust lets us do some really unsafe things. Things the Rust authors will implore you not to do, but we'll do anyway."
What makes a language "safe" anyway?

C++ is a language where people who don't understand lifetime/concurrency safety will produce programs with occasional bugs that are hard to diagnose when they even get noticed.

Rust is a language where people who don't understand lifetime/concurrency safety will produce compiler complaints they can't really reason through and zero running programs.

ownership semantics

being unable to actually do anything of any substantial consequence, languages like scheme and befunge are safe because no one can do anything substantial with them

>The problem is that retards are already your coworkers
And they use Java which is "safe". Now you want them to switch to Rust and want me to hold their hands as well. Then you want me to code all the actual shit that gets work done in the "unsafe" subset of Rust.

Employ competent engineers. Go fuck yourself Rust fag.

Is there a quick way to find out if a programmer is competent at interview?

>I don't understand type systems, so Rust is Java without GC.

Being able to prove a progress and preservation theorem that shows every step of the execution does not cause an error unless an error condition is explicitly raised (and therefore explicitly handled).

You should look at PFPL by Robert Harper.

>I buy into hype so I think the concept underlying it is different
Oh Rustie

Why don't you raise a null reference exception or cause a data race in Rust of the kind you can easily produce in Java and prove me wrong?

ITT:
Seeplesfags:
>ad homs (rust is for sjw's etc)
>useful type-safe languages don't real because I've never used anything as sophisticated as ML
>even best practices for C++ like using smart pointers are dumb because everything I learned is more than ten years old
>real sepples people never create null refs or buffer overflows, even though people who actually program for a living do it all the time
>Rust is Java

Rust fags:
>WHY WON'T YOU WRITE IT IN RUST!!!!!
>Refuses to compile perfectly legal program
>MUH LINEAR TYPE SYSTEM!!!
>Can't even implement doubly linked lists
>Ends up using unsafe parts
>MUH SAFETY

Brendolf Reich, the faggot-hating ex-CEO of Mozilla, is also the creator of JavaScript. Is JavaScript /ourlang/?

>WHY WON'T YOU WRITE IT IN RUST!!!!!
This is unironically annoying and stupid, I agree.
>Refuses to compile perfectly legal program
Which? The compiler rejects unsafe programs, yes.
>MUH LINEAR TYPE SYSTEM!!!
Affine type system, but you're closer to being right than any other critics who have posted so far.
>Can't even implement doubly linked lists
>Ends up using unsafe parts
>MUH SAFETY
When was the last time you wrote a doubly linked list pointer implementation?

When (if) you did, you either tested the shit out of it, or formally verified it, or accepted that it may be buggy. Safe Rust obviates the need for this.

> buggier and less safe than rust
> rust has never been used in a real world application
How would you know

>Which? The compiler rejects unsafe programs, yes.
Perfectly legal AND safe programs.
>Affine type system
That's even worse for the record
>When was the last time you wrote a doubly linked list pointer implementation?
Every fucking time we reimplement our hardware.

> Type safety theorems don't real
plv.mpi-sws.org/rustbelt/popl18/

The main thing I miss in Rust is switch/goto. You don't need it much but when you do it sucks not to have it. Ad-hoc overloading is also nice to have.

Show them sleep sort and ask what the theoretical algorithmic complexity is, then ask what the real complexity is.

Then ask them how to break it.

Only person that passed that interview question in 2 years was an experienced c++ dev, and now I work at his old company building robots

>Perfectly legal AND safe programs.
Give one example. I've heard this repeatedly endlessly, and I've yet to see one example of it. I'm forced to conclude that people mean the shitty style of C++98 they're used to writing when translated directly into Rust doesn't compile because it doesn't typecheck, which is very much by design.
>That's even worse for the record
Wat. How?
>Every fucking time we reimplement our hardware.
You need to be more specific if this isn't just evasion. Hardware is usually designed in Verilog or VHDL. If you actually design hardware (or firmware) in C++, you can do so in Rust, unless you're working on such an unusual platform that LLVM can't target it. If it's unusual enough to lack this, then C++ is also a non-starter.

>>>/reddit/

...

Only 1yr programming experience here, learned C++ in college.

What’s wrong wth the pointers in C++?

What’s so unsafe about the pointer examples shown in this thread?

If the size of the itemset is bounded by n, isn't it O(n) given a magical no-overhead scheduler and O(n log n) given the CFS that Linux has?

The pathological case is just a huge largest element.

Am I missing something, or is the average dev actually that bad?

Yes. rust is amazing

Currently taking a C++ course in uni. It's pretty fun, I like it more than Java.

The average dev is actually that retarded. Your answer is perfectly right

>create a null pointer
>deference it
>QED C is bad
Sure convinced me

If you use pointers, Rust programmers throw an autist fit because they are too stupid to get them working.
>Give one example
I can't right now, maybe someone more familiar with your shit langauge can construct one, but the borrow checker only works because it allows a subset of programs, the moment you start getting circular dependencies (e.g. doubly linked lists) it shits the bed.
>Wat. How?
See Rust.
>Hardware is usually designed in Verilog or VHDL
People have to write drivers for them, Rustie. Quite often the "standard library" doesn't perform well on brand new architectures.

There are a few pathological cases depending on implementation, most being data type specific.

Another is size of the data set, or a pathological ordering of an extremely large set with an early sorted value near the end.

...

Woops, magic no overhead scheduler is O(max({n1..nn})) which is O(1)

>Is it nothing more than a buggier, unsafe Rust?

>suggesting that Rust is somehow better than any other language, let alone C++

the absolute state of Sup Forums

In the one with the smart pointer, a smart pointer is constructed out of nullptr and deferenced, which is the same as deferencing a null pointer (ie: undefined/crash). It's a simple example no actual dev would write in production code to show how easy null pointers are to introduce, even with modern practices.

There's nothing intrinsically wrong with null pointers, but when software mistakenly deferences them, it's misbehavior that can crash, which is why Tony Hoare called them his billion dollar mistake.

Rust's design makes it impossible to dereference null pointers outside of explicit unsafe blocks, which are only needed to do things like write work-stealing queues and doubly-linked lists with raw pointers, both of which are covered by existing libraries.

But pointers are just like pets, no? Our professor told us they’re like pets. I know that sounds dumb but- he said it’s like, if you train yourself to do your chores and always assign null at the end of a function, perhaps close them if its dynamic, etc. then nothing can go wrong.

What does unsafe even mean? That it’s possible to have memory leaks? Like if I don’t write proper code it’ll fuck up data/leak, or wont compile. Not big news...

Unsafe is a marketing term. It just means that the compiler doesn't allow you to use the full features of your computer.

Can't you just use constructors and destructors for this problem of null pointers in C++? That's what Microsoft told me on YouTube...

Common sense.

I just pulled out my old textbook, how is what the user even did possible? Will that compile? It covers smart pointers and it said you assign only once you have declared a variable of the type specified. Now that I think about it, that guy’s example is total garbage. How do you assign a value to a variable that doesn’t have a memory location? rhetorically speaking. Surely no one is dumb enough to do that.

I don't think this is right.

Call the largest number N (which may not be n). The longest-sleeping thread has to sleep for N seconds, so it's O(N).

If you have n numbers, each unique, then (n - 1) is the smallest you can make the biggest number, so it's at least O(n - 1) = O(n).

Traditionally, n in O(n) is the size of a given set. The sleepsort alg only executes as long as the largest single element of a given set, which is a fixed value, and therefore equivalent to O(1)

It does compile. It also runs (as undefined behavior).

You can assign any smart pointer a constant value. In this case, the constant value is std::nullptr.

So this example is the absolute state of C++. If you're lucky, your compiler does some constant folding and will warn you you're being retarded. Good thing Rust always does this.

How is it possible that C is perfect and flawless and C++ is obsolete?

I think you're still missing my argument. I'm claiming that if the elements are unique (which is needed for the sort to be stable), the biggest element must be at least n - 1 (pigeonhole principle), so the runtime must be O(n). The largest element is at least the size of the set minus one for a set of unique elements.

Unsafe is actually a PL term. It has a very precise meaning given by progress and preservation theorems.

Genuine question, less of a rust vs c++ thing here:

You can assign any pointer variable a constant value, iirc. Yea? And in general, the purpose of assigning it some value (a memory address) is to have direct access to the block of memory. So we just assigned the int pointer var x to some null place in memory.

Why in the world would you try to assign a value to the int in that space? You haven’t even specified a real usable memory address, the point of null is to not be a memory address.

Who the hell is dumb enough to do that?

But given the exact same set, except with the largest element duplicated once, your cost doesn't grow. So a larger set behaves exactly the same as a smaller set, and the cost comes down to a value of the set itself, which is always fixed.

What is made in Rust?

>Likes to build clocks

Ha

I don't care if a gay black jewish trans furry made the language, if it's the best, I'm going to use it.

A bunch of command line tools. Driver stuff made by Dropbox. Assorted compilers. Parts of Firefox. This post is unironic, accurate, and informative.

>People have to write drivers for them, Rustie. Quite often the "standard library" doesn't perform well on brand new architectures.
>Still missing the point
On platforms where the Rust standard library can't be used, neither can the C++ standard library. But both can be used without their standard libraries (Rust has a no_std pragma).

On platforms where you cannot target Rust b/c no LLVM, you can't target C++ either, so you have to use C or assembly.

This really isn't a compelling argument why C++ is stronger than Rust.

Okay. Sure. It depends on the set's elements.

Thanks

Yes. There are also small parts of Google's Fuchsia OS written in Rust, including the text editor Xi:
github.com/fuchsia-mirror

Most of it's written in C, C++ and a little Go though.

Yeah, I'm not saying free, just fixed. I guess a slightly better wording is amortized O(1).

Good question.

That example is deliberately horrible to demonstrate in three lines how things can be misused. No dev trying to write a data structure implementation would write that on purpose.

Null pointers are used in situations like this:
-To represent bounds (eg: the end of a doubly linked list) that require edge cases to handle them.
-To represent the absence of data (eg: the empty list).
-When you're modifying a data structure so it temporarily doesn't satisfy some integrity invariant (eg: deleting a node).

The thing is, null pointers are really best used within data structure implementations when you have to represent the data in terms of possible addresses (inb4 rust shilling; this is the take of the C++ standards committee). So unless you're implementing one, you should stick with smart pointers and references in C++ as a matter of good style and not use raw pointers outside the implementation (basically, treat all data structures as you would std containers).

You would like C# then.

In case it wasn't clear, I do actually believe Rust is a good alternative to C++, but I was trying to give more general advice that applies to either.

>>Every fucking time we reimplement our hardware.
>You need to be more specific if this isn't just evasion. Hardware is usually designed in Verilog or VHDL. If you actually design hardware (or firmware) in C++, you can do so in Rust

jesus christ you're a moron. doubly-linked lists are a super-common pattern for resource management in real-time systems, device drivers, and other kernel code, since it has bound complexities on allocate/free and you can write lockless operations for them halfway sanely.

don't worry about it, you're already qualified and ready to be a professional enterprise sepples programmer

because they're two different languages, one is based off of algol 68 and is designed by old hats who knew what they were doing, and the other is sepples

>jesus christ you're a moron. doubly-linked lists are a super-common pattern for resource management in real-time systems, device drivers, and other kernel code, since it has bound complexities on allocate/free and you can write lockless operations for them halfway sanely.
I get all of that. My point was Rust HAS a doubly linked list implementation, and like C++'s, this is what you'd use under almost all circumstances. It's right here (don't have a seizure when you see it):
doc.rust-lang.org/std/collections/struct.LinkedList.html

If you have to write your own, you can do this in unsafe Rust (and take advantage of Cargo), but then you're essentially writing the same code in C, C++ or Rust and it will need shittons of testing.

>you can do this in unsafe Rust
Which was the entire point of the person you were talking to and doubly linked lists are only one example where you need circular references. I've encountered literally thousands in every piece of REAL software.

Rust just doesn't work for real applications.
>You can use unsafe Rust
I'd rather just use C++
>Cargo-cult library
I'm not going to trust some code written by a pink haired tranny for production level shit.

>The pathological case is just a huge largest element.
>not calling sleep on the log of each element

> Not calling sleep on the inverse Knuth arrow function of each element in nanoseconds
> Not crafting inputs to stall the processor pipeline into outputting the elements in the inverse Knuth Arrow function of their order
> Not using rowhammer attacks to quantum tunnel into a parallel reality where the initial conditions of the universe cause its first star system to resemble the inputs in sorted order billions of years before the program is ever run
> Not smoking meth to make the sorting subjectively take even less time

Doesn't match cover the switch use case?

>RUST
>can't even print without using macros

and you call that a programming language? TOP kek.

But other people care.
Also claiming that Rust is the best is stupid.