>Jow Forums tells you rust is shit because of "le hipster community and only trannies use it" meanwhile, you can ask a question on stack overflow and that guy Shepmaster will answer it within 5 minutes. you also dont have all of the bullshit and bloat that comes with c++ while having a simple yet effective compile tool (cargo) without the need for bullshit makefiles.
in this day and age, if your building a new project, all you need are - >go >rust >javascript
Ok, Ill bite. I'm and Ada developer for highly reliable systems, why should I use rust instead?
William Barnes
There is a reason that C++ programmers try and shoot down all new languages, because there is nothing about C++ that translates to normal programming. You can never really learn C++ because a language built on templates can never be learned but is more akin to a plate spinning circus act. Common features in C++ like strings and vectors have to be implemented in templates because the core language has to maintain compatibility with C. C++ programmers will shy away from the word templates and try and get people to use the word generics to give the idea that C++ is a metaprogramming language. What they won't tell you is that the purpose of meta programming is to make DSL's. Even a language like Lisp which is specifically designed for metaprogramming requires a bottom up style of programming that starts from primitives and grows up into its use case. You never hear Lisp programmings brag about using packages or libraries because pulling in someone elses metaprogramming structures goes against bottom up programming. Lisp programmers will also tell you overuse of macros is a recipe for disaster. C++ programmers on the other hand brag at how much libraries they use, in fact they have to use a hermetically sealed ecosystem of libraries because introducing external libraries into C++ quickly turns into a plumbing nightmare. There are a lot of C++ programmers on Jow Forums, mostly over 40 who have wasted their entire career on C++ and are useless for anything else. They throw words around like 'expressiveness' to give the illusion that C++ somehow provides extra capability over other languages when its really more of a case of the emperors new clothes.
Aaron Powell
There is nothing wrong with Ada, this thread is specifically aimed at C++ programmers. Ada is still a relevant language that can stand equal to new languages like Rust, Go, Swift, D, etc.
Aaron Turner
Ok, now write a doubly linked list without using unsafe. Such a beginner's textbook data structure should be a breeze, shouldn't it?
Charles Gutierrez
It all compiles to machine code. Write your own langauge; who gives a fuck.
Chase Peterson
There is nothing 'unsafe' about declaring something unsafe. unsafe just means allowing the type system to ignore things like bit strings, its isolated and does not introduce anything 'unsafe' into the rest of the code.
Zachary Lewis
is this a copy pasta? because its fucking 100% correct t. 35 year old who spent entire career with c++
Henry Cooper
no, I just wrote it now
Andrew Parker
Certainly, but having to use it in the course of totally normal and regular programming does leave the question why the languages only half-heartedly attempts to be safe without really succeeding very well, when the only effect left from it are superfluous roadblocks in the process of writing so-called "safe" code.
Anthony Butler
You're quick OP. Jow Forums always bashes languages that are actually useful.. Java, Go, Rust, C# etc.. JavaScript is gay though.
Thomas Adams
i didnt read first time because wall of text... what you say sounds true tho
the difference between generics and macros is that the former can substitute types only. It's a spectrum. Any statically typed language is useless without generics. Modern C++ has only one major problem, and that's bad PR from stagnation that happened between C++98 and C++11. C++11 should have happened in 2004. C++98 is shit today but most people know nothing else. Places that restrict c++ to bare minimum for retarded 'safety' are the worst. Rust seems like new Java to me, a language designed for dumb coders that sacrifices expressiveness to prevent brainlets from hurting themselves, especially regarding mutable references. Go is a fad like ruby was a few years ago, it's horrifically slow and doesn't even do parallelism good. No reason to use it over something else.
Anything that needs performance (especially multithreaded): C++ Things that need to work in a browser: Javascript Expressiveness is more important than performance: Python (except for controlling gpu, then there's no performance impact), lisps You want a language that makes you feel smart just from writing in it: Haskell, Idris
how would you implement containers without templates is a statically typed language ?
Luis Campbell
Jow Forums hating on rust is an elaborate gatekeeping
Rust is actually the best modern language, shits all over go and c++. It's steadily picking up more steam, so if you get good at it now you are guaranteed to have a well paying job in 2-5 years in it.
Ian Rogers
this is a troll question, C++ is the ONLY language that relies on templates for core containers
Mason Diaz
I don't know much about programming. seriously wondering :^)
Jace Collins
>Any statically typed language is useless without generics. >C is useless
William Scott
How do you do multithreaded programs in Rust without unsafe?
>b) Multi-threaded Application that shares data, but does so via a message queue based system with copies of the data this can be safe. this is what lifetimes and .clone() are for. also you have mutex with .lock()
Gabriel Hernandez
It doesn't have the extensive static verification features of Ada like variable ranges but it does ensure memory-safety by tracking object ownership
Ada is used in scenarios such as avionics software in commercial airliners and military applications, essentially any scenario where failure due to programming errors would result in people getting killed
I have no idea how people can praise C macros let alone C++ templates with a straight face when Lisp macros still beat the shit out of them in terms of payoff for the amount of effort required
Bentley Scott
also when you create a new thread you have to "move" the value into the closure so it cant be accessed outside of the scope of the thread without passing it through a channel/stream
Henry Flores
How safe is lifetimes though? Is it just reference counting? Also cloning data will kill performance in the long run won't it?
Eli Cruz
Can you share a simple example to compare to C or C++ or Java?
Bentley Lewis
1) completely safe 2) no 3) depends on what you clone
Colton Wood
>not using an actor model like actix to do multi threading
Blake Lewis
You're confusing a requirement that arises due to C++'s limitations with something that's inherently necessary to make a container hold objects of any type
Java's generics and Haskell's type hierarchy are two examples of what you're looking for
Connor Moore
Cloning will always be safe and better than dealing with locks unless you're passing large data multiple of times, and at that point you should consider what you're doing because even locking should be used sparingly
Gavin Fisher
>putting Rust next to shitlangs Go and JS neck yourself OP Go takes C, removes the most useful things about it, adds a garbage collector and a package manager. Its only use case is for the horde of copy-paste-from-stackoverflow "software developers" who can't understand C. JS is a joke of a language that happened to be the only thing that could be used in a browser and on a server in 2008. Its community champions the exact brand of idiots that Go was created to compensate for. Rust is an impressive feat of modern computer science. It does everything C++ does, but without the bloat. Its memory management is fully automatic, yet it has no garbage collector. Its concurrency is elegant both in syntax and in implementation. Instead of compensating for problems in the software industry like Go, or prizing convenience over quality like JavaScript, Rust solves real problems, and it enables the programmer to do the same.
>the difference between generics and macros is that the former can substitute types only. It's a spectrum. That's not the only spectrum C++ is on >C is a useless language >C++ for concurrency when Rust exists >modern C++ is anything short of a bloated mess of overlapping, half-baked, and contradictory features >python is expressive, but rust isn't I guess you're on the spectrum too
Copying data instead of sharing it across threads means you don't need to coordinate access to that data with locks, it's still somewhat case-by-case but avoiding situations where you need to use locks can help with both performance and maintainability
Hudson Walker
>because it isn't >"doubly linked lists aren't safe" Is this what rustfags actually believe? If this is the sentiment behind the language and its users, that's just more reason to stay away.
Owen Carter
Rust has reference counters, Rc and Arc. Reference counting has runtime implications. Lifetimes are resolved at compile-time, and thus they have no runtime cost.
Ryan Brooks
holy shit please stop I like Rust but this is just retarded
Benjamin Moore
Safety in rust means memory safety, including multithreaded environments. A naive doubly linked list is not thread-safe. This is not a hard concept to grasp.
Chase Jones
sure. fn main() { let (insert, receive) = mpsc::channel(); //Creates a new channel to pass values let s = String::from("hello"); thread::spawn(|| { insert.send(s.clone()).unwrap(); //Send a clone of data into the channel }); // || {} is just an anonymous function
//Create a second thread thread::spawn(|| { let ns = receive.recv().unwrap(); println!(ns); //"hello" }); }
Cooper Martinez
>A naive doubly linked list is not thread-safe. Neither are hashtables, binary trees, heaps or managed vectors, so I guess Proper Rust Users should stay away from those too.
Andrew Green
oh i forgot you have to have "move" before the user function.
Jacob Rodriguez
>ask a question If you need to ask questions instead of consulting the language docs and standard (which should be comprehensible at-a-glance), it's a bloated, shit language. >bullshit makefiles Makefiles allow you to do whatever you want. You don't even need to use Make, it's something called choice and freedom instead of an ecosystem imposed on you. >go >javascript Python and C. You can trivially call any C code in Python, so that's that.
Caleb Perez
Can you show me a hashtable without unsafe?
Benjamin Gutierrez
A naive anything isn't necessarily memory safe. That's not the point of Rust. The point of Rust is that it forces proper, non-naive implementations of such data structures. The point isn't "theres no linked lists in Rust"
Michael Campbell
>Proper Rust Users Sorry, I meant Rustacaeans. My bad. Didn't mean to hurt your feelings.
>language parrots "safety" buzzword >standard library is written in unsafe code >every single popular rust library is written in unsafe code You literally can't do anything useful in Rust without bypassing its safety features. What a goddamn joke.
Eli Anderson
you can have thread safe heaps... thats what .clone() and .lock() is for. jfc have you even been reading the thread
Connor Ortiz
>Makefiles allow you to do whatever you want. You don't even need to use Make, it's something called choice and freedom instead of an ecosystem imposed on you. This so much. All the functionality subsumed by the compilter is one of the things I despise the most about all the nu-languages. A language that can't compile to standard object files isn't even worth considering.
Adam Robinson
It isn't thread-safe if two threads can step on each others' toes updating the heap.
Cooper Thomas
If you lock a doubly-linked list, then it's perfectly thread-safe. What are you talking about.
Hunter Lopez
Nobody is saying stay away from them, they're saying when implementing them there's more to worry about than just the bare naive implementation. There are perfectly usable implementations of data structures in the standard lib.
Dominic Robinson
>they're saying when implementing them there's more to worry about than just the bare naive implementation. So you're saying that you need unsafe to handle them? Then yes. See .
Dylan Miller
don't worry desu, other user is just retarded. Literally one of the first things I made in rust was a 100% safe binary tree.
Isaiah Morales
You can't lock the whole thing at once, you have to either lock each node piecemeal or control access to the list through a wrapper object that can be locked easily
Jordan Thompson
>control access to the list through a wrapper object that can be locked easily I dunno about you, but in C, I can just allocate a mutex separately to the root pointer of the list without having "wrapper objects".
Noah Miller
That's a cool job you have where all you do is implement data structures.
Christian Garcia
So your point is that it is only valid for programs to use pre-canned data structure implementation for vetted libraries? Fuck implementing a local variant of some common data structure to add some particular operation required for the task at hand, amirite?
Anthony Young
s/implemetation/implementations/ s/for/from/
Evan Carter
>cloning your data in and out of everything because it's unsafe otherwise
yikes, that is horrible for memory and cpu cache
Jacob Howard
it pretty much is, there's no reason to use C for anything. C++ is always better. C is forced to emulate templates with void* >Rust is an impressive feat of modern computer science. It does everything C++ does Rust doesn't even have static function overloading, case closed. >modern C++ is anything short of a bloated mess of overlapping, half-baked, and contradictory features >it's too complex for me and makes me confused thanks for confirming my Java impression about Rust.
Austin Allen
>ambiguous replace opinion dropped
Adrian Russell
No, my point is your claim about unsafe being a roadblock `in the course of totally normal and regular programming` is overblown.
Joshua Lee
>who cares, user, who has a computer with less than 32 gb ram anyway? >if my notepad program uses 4 gb in return for being provably safe, isn't that the very definition of progress is programming?
Caleb Perry
>C++ is always better. >doesn't even support pointers to compound literals
That's not what I meant. I meant the the borrow checker is an unnecessary roadblock in the course of totally normal and regular programming when you need to bypass it anyway every once in a while for totally normal needs.
Lucas Bailey
>C++ is always better lol, yes, if you consider ten times longer compile times a feature, C++ is the best thing ever.
the rust compiler makes guarantees about memory and thread safety for safe code, as static analysis is not perfect it gives you the option of using unsafe code for where you know you can implement something safely, or better yet, implement unsafe code *using a safe wrapper*, it is significantly easier to audit a rust program as a result because that >90-95% of your program written in safe rust isn't going to have undefined behaviour >without bypassing its safety features all unsafe rust lets you do is dereference a raw pointer, call unsafe functions, access or modify mutable static variables, or implement unsafe traits, unsafe rust is still subject to the borrow checker and other compile time checks for instance, you have to do a hell of a lot more than use unsafe blocks to disable safety features in rust
Xavier Nelson
If you're always keeping track of the root pointer when you access a doubly-linked list, then that root pointer is essentially your wrapper.
Kevin Lopez
Is spending twice the time writing totally normal code just to make the borrow-checker happy really worth spending an hour once a month on fixing a bug, though? I'm doubtful.
Adam Peterson
But your areas of potential unsafety are localized to a small region of your code, which is much easier to vet.
Whenever when using a linked list would you not be keeping track of a root pointer? Is there even a theoretical case for this?
Gabriel Powell
>doesn't even support pointers to compound literals That doesn't make any sense, a compound literal is syntactic sugar for structure initialization. Outside of lisp macros you can't get a pointer to syntactic sugar. It's also C99 only which makes it useless in practice, as almost every C project is ansi C. Compile times are irrelevant, nobody is recompiling everything with each change.
Xavier Roberts
>compile times
didn't know it was the 80s anymore
Noah Miller
See .
Robert Parker
>Compile times are irrelevant, nobody is recompiling everything with each change. Not in C, indeed, but since 50+% of a C++ program lives in header files, it sure the case there. My project taking 30 minutes instead of 3 to recompile sure does make a difference.
Adrian Long
most people complaining about the borrow checker barely even understand why it's there, lifetimes being valid for the scope isn't a difficult concept to understand, gramps refer to
Adrian Robinson
Are you programming on a raspberry pi?
Daniel Johnson
Yes? The whole point of a doubly-linked list is that you can efficiently traverse in any direction starting from any node. If you're always starting from the root node then what's the point of having a goddamn doubly-linked list?
Hudson Young
>most people complaining about the borrow checker barely even understand why it's there, lifetimes being valid for the scope isn't a difficult concept to understand, gramps Oh I totally understand why it's there and what it does. I'm just saying that, writing lots and lots of C code, I very seldom have the problems that it solves.
Isaiah Murphy
No, why? Have you never worked on a project larger than 1000 lines?
Jayden Allen
the borrow checker is easy to understand tho...
{ //a's lifetime starts let a = 4; //test_function(a) //lifetime ends here is uncommented } //lifetime ends at end of scope unless returned into another variable
Ryan Foster
More commonly, the point of a doubly-linked list is to be able to very easily insert and, particularly, remove elements, while keeping the ability to (more seldomly) iterate through all of them.
Ryder Gonzalez
It's not time spent bug-fixing that I'm worried about, what really troubles me are the bugs I don't know about.
Blake Fisher
>Not in C, indeed, but since 50+% of a C++ program lives in header files, it sure the case there. Let me guess, boost and msvc? You don't have to use boost, compile times without it (or similar heavy template library) are close to C. >My project taking 30 minutes instead of 3 to recompile sure does make a difference. Turn off link time optimization for development and make sure parallel compilation is enabled.