Rust wins again - D bites the Dust

Nicholas Cooper
Nicholas Cooper

Ownership and Borrowing in D
Nearly all non-trivial programs allocate and manage memory. Getting it right is becoming increasingly important, as programs get ever more complex and mistakes get ever more costly. The usual problems are:
memory leaks (failure to free memory when no longer in use)
double frees (freeing memory more than once)
use-after-free (continuing to refer to memory already freed)
The challenge is in keeping track of which pointers are responsible for freeing the memory (i.e. owning the memory), which pointers are merely referring to the memory, where they are, and which are active (in scope).
The common solutions are:
Garbage Collection – The GC owns the memory and periodically scans memory looking for any pointers to that memory. If none are found, the memory is released. This scheme is reliable and in common use in languages like Go and Java. It tends to use much more memory than strictly necessary, have pauses, and slow down code because of inserted write gates.
Reference Counting – The RC object owns the memory and keeps a count of how many pointers point to it. When that count goes to zero, the memory is released. This is also reliable and is commonly used in languages like C++ and ObjectiveC. RC is memory efficient, needing only a slot for the count. The downside of RC is the expense of maintaining the count, building an exception handler to ensure the decrement is done, and the locking for all this needed for objects shared between threads. To regain efficiency, sometimes the programmer will cheat and temporarily refer to the RC object without dealing with the count, engendering a risk that this is not done correctly.
Manual – Manual memory management is exemplified by C’s malloc and free. It is fast and memory efficient, but there’s no language help at all in using them correctly. It’s entirely up to the programmer’s skill and diligence in using it. I’ve been using malloc and free for 35 years, and through bitter and endless experience rarely make a mistake with them anymore. But that’s not the sort of thing a programming shop can rely on, and note I said “rarely” and not “never”.

Solutions 2 and 3 more or less rely on faith in the programmer to do it right. Faith-based systems do not scale well, and memory management issues have proven to be very difficult to audit (so difficult that some coding standards prohibit use of memory allocation).

But there is a fourth way – Ownership and Borrowing. It’s memory efficient, as performant as manual management, and mechanically auditable. It has been recently popularized by the Rust programming language. It has its downsides, too, in the form of a reputation for having to rethink how one composes algorithms and data structures.

The downsides are manageable, and the rest of this article is an outline of how the ownership/borrowing (OB) system works, and how we propose to fit it into D. I had originally thought this would be impossible, but after spending a lot of time thinking about it I’ve found a way to fit it in, much like we’ve fit functional programming
into D (with transitive immutability and function purity).

dlang.org/blog/2019/07/15/ownership-and-borrowing-in-d/

Attached: d6.png (5.03 KB, 200x200)

Other urls found in this thread:

prev.rust-lang.org/en-US/friends.html
github.com/rust-lang/rfcs/blob/master/text/2000-const-generics.md
github.com/rust-lang/rust/pull/62435
danluu.com/deconstruct-files/
code.dlang.org/packages/sumtype
doc.rust-lang.org/book/ch18-03-pattern-syntax.html#destructuring-to-break-apart-values

Henry Robinson
Henry Robinson

Solutions 2 and 3 more or less rely on faith in the programmer to do it right
you can't tell us to hire actually competent programmers instead of diverse pajeets and women!
Reminder that these languages are designed for retarded programmers and you're probably one of them if you advocate for these.

Angel Evans
Angel Evans

muh competent programmers
Reminder that everyone who says that is a LARPer.

Isaac Flores
Isaac Flores

It's an obvious choice, really. Overpay angsty white dudes who make rookie mistakes, or hire many competitively-paid professionals from the East who use quality languages.

Logan Gomez
Logan Gomez

Nim and D both steal Rust's killer feature
Rust is winning

Dominic Williams
Dominic Williams

Nim and D (stillborn meme languages) both imitate Rust's killer feature in order to stay relevant
Rust isn't winning

Ryder Evans
Ryder Evans

oh yeah, Rust isn't stillborn. I heard the babe's cry myself. It cried out "Judith Butler", "Karl Marx", "Emma Goldman".
So 'stillborn' is the wrong term.
You might call it a post-birth abortion.
Or an act of eugenics.

Joshua Roberts
Joshua Roberts

Rust is mentioned
anti Rust shills show up
anti Rust shills get BTFO
anti Rust shills claim that they weren't BTFO
everytime
prev.rust-lang.org/en-US/friends.html

Jose Myers
Jose Myers

I've shipped games made in a meme language

Attached: smug-office-loli.png (1012.43 KB, 2138x1449)

Kevin Watson
Kevin Watson

weeb
doing anything else than being degenerate
pick one

Robert Moore
Robert Moore

<weeb
<doing anything else than being degenerate
sitting on Zig Forums
expecting people not to be degenerates
he's not a degenerate himself
God needs you! You're so pure, go to the church.
/church/index.html

Jayden Ross
Jayden Ross

The weeb is immunized against all dangers: one may call him a degenerate, pedophile, weirdo, autist, it all runs off him like water off a raincoat. But call him a weeb and you will be astonished at how he recoils, how injured he is, how he suddenly shrinks back: "I’ve been found out."

Liam Hughes
Liam Hughes

Ha ha! It's funny because it's not even a little bit true.

Dominic Ortiz
Dominic Ortiz

sudo apt remove chrome* *google* fonts-noto*

sudo apt remove javascript-common

sudo apt remove rust* libstd-rust* cargo*

sudo apt remove snapd* libsnapd*

Brody Nelson
Brody Nelson

reddit spacing

Cameron Robinson
Cameron Robinson

no SystemD on the removal list.
Halfassing at its finest.

Jack Adams
Jack Adams

guix package -i brain
Ok, but really you're right about a few things:
Google is cancer, but sane distros use ungoogled chromium.
Snap packages are centralized crap, SaaSS owned by Canonical and their repo (the only one you can use actually) contains nonfree software.
javascript
It shouldn't be used for desktop stuff, but it is not malicious by design.
rust
I don't like the syntax or all the hype around it, but it doesn't seem malicious. It even fixes some problems C has and weenies think of as features.
apt
sudo apt purge apt
Install Guix, because APT is shit.

Bentley Morgan
Bentley Morgan

APT is shit
based

Adrian Smith
Adrian Smith

You sound jealous, goon.

Josiah Barnes
Josiah Barnes

You sound degenerate, weeb.

Lincoln White
Lincoln White

X wins again - Y bites the Dust
doesnt matter, replace whats in use by and large (like C++ or Python) by actually being more useful and powerful without being complicated piece of shit, thanks

Thomas Perry
Thomas Perry

Rust's syntax

Wait, you mean that shoehorning C++11's syntax into a language that forces a type driven design pattern while adding idiosyncratic changes that have no benefit and act as a footgun for people coming from a different language WASN'T a great idea?

8frens, on the reals, should I abandon Rust and learn D?

Liam Parker
Liam Parker

D's a lot of fun. The only complaints I saw on the forum were from being trying to use brand new features (like this one) and getting jerked around a bit as the language evolved.
The big downside to D from the perspective of someone looking at Rust is that D is garbage-collected and the no-GC option isn't a first-class alternative. If you start with -betterC from the beginning you can avoid GC, but this is a very different (though still very good--better than C, like it says on the tin) experience.

Mason Gomez
Mason Gomez

filter and global report all rust shill threads

Jaxson Sullivan
Jaxson Sullivan

this. and
what is Ada?

Who let /reddit/index.html in?

Samuel Carter
Samuel Carter

Wait, you mean that shoehorning C++11's syntax ...
Probably yes, they didn't invented everything themselves.
8frens, on the reals, should I abandon Rust and learn D?
The same question. D seems to be what C++ should be - it has so consistent syntax.

Logan Diaz
Logan Diaz

muh syntax
LARPer spotted

kys

being against pedophiles is reddit
weeb spotted

Austin Morales
Austin Morales

LARPer spotted
LARPer spotted. Syntax is one of the most important things in ANY language if you think differently, go and use brainfuck and show us syntax doesn't matter.

Eli Moore
Eli Moore

Syntax is one of the most important
LARPer spotted
muh brainfuck
But brainfucks syntax is fine.

Daniel Butler
Daniel Butler

LARPer spotted
Better, if you think syntax is not important at all, use plain binary code - it (AFAIK) doesn't have any syntax. Go ahead, syntax is for LARPers!
But brainfucks syntax is fine.
So write an OS in it or a browser or a reimplementation of grep, find, etc. In languages with normal syntax it is easier task. Can you code in LISP? Its syntax is great.

Grayson Diaz
Grayson Diaz

anime or loli
same as molesting children or CP
Why are you trying to normalize pedophilia? I wonder (((Who))) has entered this thread?

syntax doesn't matter
yes it does if it's especially bad like in Rust

Attached: JIDF-enters-the-thread.webm (4.76 MB, 854x480)

Adrian Barnes
Adrian Barnes

hurr durr try cutting a steak with a spoon
having trouble with it? well i guess spoons suck then
This is what you sound like.
Stop LARPing.

no u
Good argument, weeb.

Oliver Ward
Oliver Ward

hurr durr try cutting a steak with a spoon
having trouble with it? well i guess spoons suck then
Funny as fuck.
More like
<try programming with a language with a shitty syntax
<having trouble with it? well I guess languages with shitty syntax are not good for programming
fixed

Liam Brooks
Liam Brooks

try programming with a language with a shitty syntax
having trouble with it? well I guess languages with shitty syntax are not good for programming
Funny as fuck.
More like
<try programming with a language made to manipulate simple tape machines
<having trouble with it? well I guess languages made to manipulate simple tape machines are not good for programming complex virtual machines
fixed
also stop LARPing please

Owen Gray
Owen Gray

You are just constantly repeating same thing. Also, why are you ignoring points? You aren't a paid shill, are you?

Attached: paid-shill.webm (2.83 MB, 1280x720)

Sebastian Brown
Sebastian Brown

You are just constantly repeating same thing. Also, why are you ignoring points? You aren't an unpaid anti Rust shill, are you?

Dominic Ward
Dominic Ward

What a shame. You aren't very creative. Why don't you post something useful to prove you actually know something. Post some Rust code. But you are just an amateur shill, aren't you? Or is Rust so bad programming language that there simply aren't any programs written in it?

Attached: Fuhrer.png (19.57 KB, 174x162)

Jordan Stewart
Jordan Stewart

Post some Rust code
what's the best Rust tutorial that isn't written or related in any way to the commie?
Looking for tech writing, non-Rust inspiration.

Brayden Rodriguez
Brayden Rodriguez

what's the best Rust tutorial that isn't written or related in any way to the commie?
Doesn't exist. Prove me wrong.

Colton Rivera
Colton Rivera

Syntax matters
<No U

That's a major reason why S-expression based languages are still niche. It's a really awkward way to express thoughts in code, and the advantages it has for simple implementation and high-level abstraction doesn't make up for it.

If you wrote down how to solve a problem on paper, you'd end up with a C-like, and probably not S expressions or some Reverse Polish Notation coolguy stuff.

And Rust is definitely in some unhappy middle ground that just feels complicated

Rust by Example is fine. O'Reilly has a pretty decent book, I hear.

Joseph Sullivan
Joseph Sullivan

If you wrote down how to solve a problem on paper, you'd end up with a C-like,
fib(N) = R :-
(
N < 2 -> R = N;
R = fib(N - 1) + fib(N - 2)
).
>he doesn't know a logical language

Carter Wright
Carter Wright

Just a reminder that Borrow checking and Automatic Garbage Collection are crutches designed to aid brainlets in programming.

Attached: 1562179018427.gif (1.69 MB, 498x278)

Jose Russell
Jose Russell

You aren't on /g/, obvious board tourist. Lurk more or back to cuckchan.

Daniel Long
Daniel Long

desperately trying to change the topic
I don't have to prove anything to a LARPer.

reddit spacing
you'd end up with a C-like
nice brain damage

Leo Gonzalez
Leo Gonzalez

This is why D is shit. It has to have every feature and programming model under the sun, it's no wonder nobody fucking bothers to learn all that shit.

Attached: D.jpeg (85.24 KB, 540x535)

Brandon Martinez
Brandon Martinez

have you heard of a language called C++?

Oliver Walker
Oliver Walker

C++ only started doing that that after it already had decent adoption. If it didn't have adoption, nobody would bother with it.

Anthony Brooks
Anthony Brooks

Are you sure? I don't think there is anything quite as complicated as C++ except maybe APL.

So if you wrote down a note to yourself about how to do something, you would actually first define a bunch of categories and explicitly define their capabilities? Or write an abstract syntax tree? Or do whateverthefuck Forth does?

Or would it be more like:
Open a file,
Read each line and do this
But don't do it if you see this other thing
Close the file. Done.

C-like syntax dominates because it's close to how we write, and that's how most of us learn to encode information (which is a broader category that programming falls into). You didn't take class notes with a bunch of method-chaining or arrows everywhere.

Which is why I get tired of all this multi-paradigm shit. Your language shouldn't do and be everything for everyone. Imperative is fine. OO is fine. FP is also fine. Doing all three just seems to lead to code bases diverging into various dialects that appear unpredictably in code bases.

Go sucks in a lot of ways, but I've never had the problem of not understanding the source of a library I use. I rarely look at C, but it's usually not that confusing. Python, however takes too much from different styles. Python could look like Java or C or Scala (or all three) depending on who wrote it. Then I look at Rust code, and I'm wading through type definitions to find the logic I actually care about only to see some macro shit that I have to look up in another crate's docs.

Just glance over this shit.
HTTPS://docs.Rust-lang.org/STD/vec/struct.vec.html

There are about 100 explicit trait implementations. 66 of them are for partial equality for arrays size 0-32 borrowed and then owned (I guess you're out of luck if you have an array of length 33). In the source for this craziness is a macro with a comment that less important trait methods were left out to reduce "code bloat". Really.

Isaac Sanchez
Isaac Sanchez

Or do whateverthefuck Forth does?
Forth is a wordcode interperter that mostly does stack operations.

Andrew Wilson
Andrew Wilson

have no clue whatsoever about Forth
no, these nocoders probably don't know anything either

Christopher Bennett
Christopher Bennett

C syntax is the best and most natural
Spotted the braindead cnile.
extensive documentation is bad
Ok. You can stop LARPing now.
arrays size 0-32
This is being worked on.
github.com/rust-lang/rfcs/blob/master/text/2000-const-generics.md
github.com/rust-lang/rust/pull/62435
I guess you're out of luck if you have an array of length 33
No. You just have to manually coerce the array to a slice.

Jose Edwards
Jose Edwards

have a 32-element array
this is ok
add a single element
now get error
"oh you just have to do this thing to fix the error"
would much rather use a language that's reasonably designed, thanks.

Logan Campbell
Logan Campbell

add a single element
You can't add something to an array. An array in Rust is of fixed size. The length is part of the type signature.
You would have to create an array of length 33, copy the the old stuff over and then put the new element in.
reasonably designed
<why isn't Rust perfect from the beginning
Because not having certain trait implementations for arrays of length > 32 really isn't a big deal. You very rarely use arrays in Rust. You mostly use slices.

Hunter Morris
Hunter Morris

You can't add something to an array.
this person calls people 'cnile'.
YOU ADD SOMETHING TO AN ARRAY BY EDITING THE SOURCE CODE BECAUSE YOUR PROGRAM NOW NEED +1 ELEMENTS
CODE IS NOT SOMETHING YOU FRAME AND PUT ON A WALL
CODE GETS EDITED AND CHANGES OVER TIME

Chase Morris
Chase Morris

<why isn't Rust perfect from the beginning
yes, it takes a long time to build a stable house from incoherent foundations.
and the entire time that you're hacking on thing, moving weights around, scratching your head about why something worked before but doesn't work now, you can say "oh it's still maturing". Yeah, and Perl6 is a 100-year-language so it doesn't matter how long development takes.

Cameron Cox
Cameron Cox

C borrowed from Algol. It's not good because it's C, it's good because it reads like most people think, unlike Lisps, for example. Rust is also a C-like, Mr. Valedictorian from University of Mumbai. Rust just also allows you to write a hideous mish-mash of functional and imperative style with macros and Java decorators (Oops, I mean proc-macros) sprinkled everywhere.
manually coerce to slice
Now that's sophistication!
muh just wait until we get const generics
Always tomorrow, it seems.

Do other languages require explicit implementation of how to do an elementary operation like "are these the same?" The point is, there is an outrageous amount of really basic shit Rust forces you to explicitly define the behavior of. You can't even represent a struct without applying the Derive(debug) decorator. When do you NOT want that ability? Does duck-typing really cause that many mission critical errors? Because you're spending a lot of time telling the rust compiler, "yes, rust, you can show this in an error message" or "yes, rust, you can compare these things of the same type." Sensible, opinionated defaults are really refreshing sometime.

Larry Wall, in his infinite love for NEETkind, sent his only begotten daughter Camelia to die for our sins. Take not her name in vain. Accept her into your heart and be saved from your floating point arithmetic sins.

Josiah Scott
Josiah Scott

what does fixed size mean
Rust has a dynamically sized array. It is called Vec.

LARPing

Do other languages require explicit implementation of how to do an elementary operation like "are these the same?"
Yes
You can't even represent a struct without applying the Derive(debug) decorator.
?
When do you NOT want that ability?
When you don't want to accidentally expose stuff, like for example passwords.
Does duck-typing really cause that many mission critical errors?
Yes
Btw you're an actual fucking retard. Go to university or pick up a few books.

Liam Mitchell
Liam Mitchell

LARPing
You constantly complain about LARPing but you never post code or contribute anything of substance.

Jack Hall
Jack Hall

you never post code
Found the newfag. I posted a lot of code on Zig Forums.
Also what code should I post?
contribute anything of substance
Does anyone on Zig Forums contribute anything of substance? You sure as hell aren't.

Hunter Ross
Hunter Ross

you'll expose PASSWORDS!
Are you fucking serious? If you're developing the program, then you need to hide program internals from yourself? Better blindfold myself before I open up my editor! Why is your sensitive user input getting passed around in the clear in the first place? Do you not realize your structs are private by default? This contrivance is hysterical, irrational paranoia. Rust shills are so emotionally unstable they'll throw out the most nonsensical defenses. The accusations of C++'s unsafety floating around in Rust's fluff-pieces on Medium are grossly exaggerated and ignore every post C++11 feature. Never mind the fact that most modern languages are memory safe to begin with. But, yeah, let's kill any sane default behavior because what-if-I'm-retarded?

D, why couldn't you be the language big tech decided to shill?

Some of us do have jobs.

Leo Hughes
Leo Hughes

Are you fucking serious?
Yes
If you're developing the program, then you need to hide program internals from yourself?
Programmers fuck up something as simple as don't free the same pointer twice. Why wouldn't they fuck up accidentally outputting secrets?
Do you not realize your structs are private by default?
You're so fucking retarded. If you derive Debug your structs aren't private anymore because you can inspect the Debug output.
Never mind the fact that most modern languages are memory safe to begin with.
Which of those don't use a GC?
Some of us do have jobs.
What does that have to do with what I wrote though?

Daniel Howard
Daniel Howard

GC baaaaad. Rust goooood.
This is a Redditor meme. Most business problems are being solved with garbage collected languages. What is this board written in? If you can do HFT at Jane Street in OCaml, the GC is not your problem.

I also don't know why you think that hiding debugging info from yourself is a feature or even prevents the programming error you described, but I wish you luck in your comp sci 102 class this fall.

Gavin Rogers
Gavin Rogers

Most software is also complete fucking garbage, especially whatever heap of shit Zig Forums runs on.

Luke Cooper
Luke Cooper

GC baaaaad. Rust goooood.
Who are you quoting?
programmers always write correct code
that's why you shouldn't enact precautions
But that's the whole point of Rust.
Also no debugging info is hidden. gdb doesnt give a shit if your type implements Debug or not.
comp sci 102 class this fall
I never had this class. I didn't go to a burger university.

Evan Diaz
Evan Diaz

everything sucks!
With a nuanced opinion like that, you must be really smart. I bet you get paid a lot for your quality software.

University of Mumbai student detected

Carter James
Carter James

University of Mumbai student detected
More like one of the top German universities.
Protip: Everything does suck. Most software is a badly designed patchwork of braindamage. Just take a look at this: danluu.com/deconstruct-files/

Nicholas Wood
Nicholas Wood

People much smarter than both of us combined are saying that most modern software is complete shit.

Jaxson Thompson
Jaxson Thompson

programming languages are bloat

Ryder Reyes
Ryder Reyes

danluu.com/deconstruct-files/
If that's actually the case, we need to push back on this kernel brain damage
PostgreSQL developers are based and braindamagepilled.

Josiah Flores
Josiah Flores

that text makes everything storage related look really bad

Hunter Mitchell
Hunter Mitchell

Are you that idiot who made a thread to suck your own dick over some toy event loop you wrote in C++ as part of your "environmentally friendly" blockchain vaporware bullshit? How about you confine your bullshit to your ivory tower where you continue to solve no useful problems whatsoever.

Opinion discarded.

This is now a thread about dogs. See pic related.

Attached: 2iamidblhde21.png (977.42 KB, 720x960)

David Edwards
David Edwards

brainlet detected

Parker Martinez
Parker Martinez

No. I don't write C++. I'm the genius that posted the Rust code in that thread.

Adam Young
Adam Young

Gr8 b8 m8, 8/8

Hudson Brown
Hudson Brown

Rust's only selling point is being implemented much better by other languages
Rust becomes obsolete
thinks Rust is winning
Absolute state of Rustrannies.
P.S. - you will never be a real woman

Kayden Wright
Kayden Wright

the borrow checker Rust's only selling point
What about pattern matching? D doesn't have that.
you will never be a real woman
Obviously. I'm a man.
P.S. - you will never be not a LARPer

Parker Miller
Parker Miller

selling point

You're obsessed with calling others LARPers because you're LARPing as a programmer using Rust.

Wyatt Mitchell
Wyatt Mitchell

LARPing as a programmer using Rust
But I am a programmer using Rust.
unbased btw

Liam Green
Liam Green

D is powerful enough to implement sum types with pattern matching as a library.
code.dlang.org/packages/sumtype

Dominic Hughes
Dominic Hughes

Pretty cool. But the pattern matching is very limited.
doc.rust-lang.org/book/ch18-03-pattern-syntax.html#destructuring-to-break-apart-values

Ethan Gomez
Ethan Gomez

in uni
Imma real programmer, mom

Reddit isn't sending their best.

Nicholas Robinson
Nicholas Robinson

in uni
wrong