/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous Thread:

Other urls found in this thread:

gist.github.com/anonymous/76b49b64175bdc8a65ae4b3749b73167
screenshots.firefox.com/BmOrAYbvyd2zq3T5/null
github.com/godotengine/godot/issues/16020
pastebin.com/vuhCdDFc
github.com/redox-os/redox/issues/1136
en.coursera.org/learn/data-structures/lecture/Q9CVI/path-compression
cs.princeton.edu/courses/archive/spring13/cos423/lectures/UnionFind.pdf
cs.princeton.edu/courses/archive/spr09/cos423/Lectures/path-compression.pdf
cs.cmu.edu/afs/cs.cmu.edu/academic/class/15859-f09/www/handouts/seidel-unionfind.pdf
algs4.cs.princeton.edu/15uf/QuickUnionPathCompressionUF.java.html
twitter.com/NSFWRedditImage

Threadly reminder that leaking memory and crashing is a valid side-effect because it's not a result. Rust DOES NOT compile programs that produce unintended output and other invalid results, unlike C++.

Treadly reminder to use #![feature(nll)].

Wait, this is not >>>r/Rust ????

>mfw the memes are real

disgusting

>the face of mozilla

>ancom
>antifa
>antiim
this guy's like a collect'em'all of cults
>MLM
that's a new one, can't be multi level marketing (tbf it kinda is tho)
>Marxism–Leninism–Maoism
oh wow, let a thousand flowers bloom

Does NLL make the BC not treat me like some kind of drooling retard who has no idea what I'm doing?

I rather use chrome than Firefox now, thanks

No, NLL can't make BC not to treat you the way you ought to be treated.

But the BC treats EVERYONE like that.

>white male
>face of mozilla
Stop oppressing me.
t. Elisabeth Henry

Not me tho.

>upper-middle class
>white
>female
>fat
>ugly
these people just can't stop themselves from being walking cliches, can they?

It's bad, just not as bad.

> I used to work as a programmer, but couldn't find a job
Bitch, doing codeacademy isn't working.

>BC
blaq Coq?

Does the BC with NLL let you borrow multiple mutable references?
If not, it's treating you like a drooling retard.

What's wrong with leaking memory again?

Been working on this. gist.github.com/anonymous/76b49b64175bdc8a65ae4b3749b73167
Weighted unions have been implemented. Next up is path compression. Loving Nim so far.
screenshots.firefox.com/BmOrAYbvyd2zq3T5/null

>What's wrong with leaking memory again?
There's literally nothing wrong with leaking memory and crashing. Didn't you read what I said? It's not an invalid result. It's just a valid side-effect.

>multiple mutable references
Of course not, it's unsafe, and if you still think it's a good idea you should go back to producing security vulnerabilities in C or whatever language is primitive enough not to intimidate you.

Ops, wrong screenshot.
Memory leaking and crashing are not results, so they can't be either valid or invalid. It is a side-effect though.

>it's unsafe
See? BC treats you like a drooling retard who can't responsibly handle unsafety.
Not to mention that the BC is sometimes just outright wrong about your programs correctness even in trivial situations.
The BC is shit.

> Rust niggers don't even know how a goddamn conditional statement works
Like clockwork

That's right. They're not results, so they can't be valid or invalid, so there's literally nothing wrong with leaking memory and crashing. When it comes to actual things that matter, Rust doesn't compile programs that produce incorrect results. Anyone who refuses to use Rust is just asking for bugs, and is probably a C++ retard.

>strict compiler makes up for my lack of discipline
wow, still looking for a controlling husband even after all the feminism she consumed (literally, it looks like)

dude, separate your nimposting from your rustposting
Otherwise I can't pretend that nimposters are sane well adjusted individuals whose work I wholeheartedly support.

Segfaults aren't results. Are segfaults valid side-effects in Rust?

> Gun safety treats you like a drooling retard who can't responsibly handle guns
That's because no one can reliably all the time. If you think otherwise you should try writing something more complex than FizzBuzz.

Sometimes my Rust programs wipe out every writable file on the user's system, but it's just a side effect, and side-effects can't be invalid.

Eh, Rust is a bit too difficult for me, I tried it before. I think it pays off but I am not a systems dev.

Bad luck for you I suppose.

Not only rust in general, but side-effects cannot be valid/invalid.

I wrote a fucking kernel, you have no idea what you're talking about. Nigger.

>gist.github.com/anonymous/76b49b64175bdc8a65ae4b3749b73167
Looking nice

github.com/godotengine/godot/issues/16020

Because BC's job is to guarantee safety, not to warn you and move on.
You should use RefCell if you cannot guarantee proper static borrow checking.

Does the language library code make system calls? Or does it just ask the kernel to make a system call?

I thought syscalls were used by user code to communicate with and request from the kernel.

>Better performance than C++ (in most cases, not all)
HAHAHA

>Because BC's job is to guarantee safety
It's too course so it's shit.
>You should use RefCell if you cannot guarantee proper static borrow checking.
Proof that it's too coarse.

>You should use RefCell if you cannot guarantee proper static borrow checking.
Are there any jobs that pay to know this?

Seems to me, that when you get a job in the industry, no one gives a rat's ass about this

I see that you are still salty from the anal rape you received few threads back.

Could someone make a new thread?
"/cvsr/ - Eternal C++ vs. Rust thread"

Every /dpt/ is getting derailed with the same stupid discussion over and over again.

It's literally the gatekeeper weeb with its new anti-Rust fixation

First one
This, it's gotten old real fast

"Asking the kernel to make a syscall" doesn't make sense. A syscall IS how you ask the kernel to do something.
Yes, standard library code (and some other libraries) do make syscalls.
Syscalls are done by just putting some arguments in registers (or on the stack) and raising a specific software interrupt (int 0x80 on i386).

>It's too course so it's shit.
There are some situations where BS can be pain in ass, but with NLL they are not longer an issue.
>Proof that it's too coarse.
How do you imagine static BC checking borrows that depends on runtime?

>Are there any jobs that pay to know this?
Basically any Rust job? It's basics.
Good luck in finding one though.

is there a real difference between these two methods, or is it just preference?
pastebin.com/vuhCdDFc

What do you mean? I'm agreeing with you that side-effects are neither valid nor invalid, and are, therefore, irrelevant to the correct operation of a program. Also, I agree that it's impossible to compile a Rust program that produces incorrect results. Why are you attacking me?

>How do you imagine static BC checking borrows that depends on runtime?
By not having borrows that depend on runtime? A perfectly fine grained BC should be able to do that.

Shut the fuck up dude

cuck

>he gets mad because people agree with what he said
Wow... I didn't know our community had unwelcoming members like you...

brilliant argument.

He wasn't arguing, he's thinking his posts are remotely funny/though provoking.

>By not having borrows that depend on runtime?
How would limiting your options and removing RefCell fix BC or improve developing in Rust in any way?

>Autism rust

How is it an argument for anything? Is your toy kernel somehow free of bugs and vulnerabilities?

Doesn't Nim have methods?

>Is your toy kernel somehow free of bugs and vulnerabilities?
Of course not. I should've written it in Rust, which doesn't compile programs that produce incorrect results. Just look at Redux: it's perfect. Only a few side-effects.

github.com/redox-os/redox/issues/1136

Memes aside, what makes multiple mutable references unsafe? I don't think it's about multithreading, because they have send and sync for that, right?

Most of those "issues" are just side-effects. It doesn't prove anything. Side-effects are irrelevant to the correct operation of a program.

Okay, so the general idea of path compression is going higher in the tree.
proc root*(structure: UFStruct; n: int) =
## **Worst case: O(n)**
##
## Finds the root of a value in a component
var result = n
while structure.id[result] != result:
structure.id[result] = structure.id[structure.id[result]]
result = structure.id[result]

proc union*(structure: var UFStruct; p, q: int) =
## Attach the the smaller tree to the bigger tree.
## This proc determines whether p or q belongs to the bigger tree.
## This involves finding roots to both p an q. Are you looking for the quickUnion proc?
var
rootP = structure.root(p)
rootQ = structure.root(q)

if rootP == rootQ:
return
if structure.sz[rootP] > structure.sz[rootQ]:
structure.id[rootQ] = rootP
inc(structure.sz[rootP])
return
structure.id[rootP] = rootQ
inc(structure.sz[rootQ])

proc quickUnion*(structure: var UFStruct; longTree, shortTree: int) =
## Attaches the short tree to the long tree
var
rootL = structure.root(longTree)
rootS = structure.root(shortTree)
if rootL == rootS:
return
structure.id[rootL] = rootS
inc(structure.sz[rootL])

let v = vec![1, 2, 3];
let r = &mut v[0];
v.push(4); // Second mutable reference is created during call. Adding new value to a vector may realocate it
println!("{}", r); // r might be pointing to old, freed memory

I see.
Fuck that shit, this is why I use GC.

Yes

en.coursera.org/learn/data-structures/lecture/Q9CVI/path-compression

cs.princeton.edu/courses/archive/spring13/cos423/lectures/UnionFind.pdf

cs.princeton.edu/courses/archive/spr09/cos423/Lectures/path-compression.pdf

cs.cmu.edu/afs/cs.cmu.edu/academic/class/15859-f09/www/handouts/seidel-unionfind.pdf

algs4.cs.princeton.edu/15uf/QuickUnionPathCompressionUF.java.html

>been working on prototype page/app that can be controlled by dialogue with an robot using natural language for few days
>have fun exploring speech recognision, parsing grammar etc
>client suddenly decides it's too ambitious
>they only want generating text descriptions for listings from provided data
>it can be created from string templates, but they want to use some shit bloated buzzword filled nonsense proprietary technology so I have to go through whole api documentation to understand what does it actually do
kill me Sup Forums

Or you can use language who slaps you in the face when you make such a non trivial mistakes.

>keeps references to the internals of a data structure
>w-wow the reference is invalid when the implementation reallocates the buffer behind my back
>better disallow multiple mutable references

>cs.princeton.edu/courses/archive/spr09/cos423/Lectures/path-compression.pdf
>comic sans
Why do universities do this?

You can still go unsafe or use refcounting afaik. IDK what you are bitching about

>putting a EOF at the end of you password gives you a root shell is correct operation
I used to think cutting off your balls to learn rust was a mene

JUST

Your particular example is a non-problem artificially created by Rust.

Yes, it's dangerous and not trival. It's a very good thing your language prevents you from doing that.
Especially when you have so many other ways to do it that will guarantee correctness, RefCell, Rc, using index. And there is also unsafe and raw pointers if you are a chad.

>dangling pointers is non-problem artificially created by Rust
Are you a JS programmer?

C++ doesn't have this problem

Invalid reference is a problem.
Either C++ is too inefficient or it uses refcounting or you don't know what you are on about.
Protip: it's the last one

It's the same problem in C++, idiot. C++ reallocates Vectors and uses references the same way.
Except C++ will allow you to compile it(static checked might warn you but it's not guaranteed nor standard) and your program will crash randomly and you'll spend hours debugging it.

subscript operators return a reference. Once the capacity of the container is reached, it allocates more memory and copies the values to the new container.

.at() operator basically copies . You don't want that, do you?

>rewrite rust
High performance computing graphs
*block your path*

underrated

>operator
function*

No reference counting here
std::vector foo{1,2,3,4};
std::vector &bar = &foo;
foo.push_back(5); // doesn't actually change the location of vector, but where the data is pointing to

Doesn't do the same thing, do they?

Rust's solution is useless. It basically downgrades the vector into a constant-sized array in every non-trivial case.

Point of is that the BC would reject that I think. Still have the argument of volatility tho.

...

...

>Invalid reference is a problem.
It's a problem with Rust programmers who take a reference to the internals of a data structure and then trigger reallocation in the same scope, probably because they're brain-dead.

>2018
>still no better C

>.at() operator basically copies .
In what lang? Rust or C++? std::vec::Vec doesn't have a at method according to the rust playground, and T& std::vector::at(size_t index); in C++ doesn't necessarily copy the T since it returns a normal lvalue reference. Don't get your point sry

>It's a problem with Rust programmers who take a reference to the internals of a data structure and then trigger reallocation in the same scope, probably because they're brain-dead.
So you are one of those c00l boys that never dereferenced an invalid pointer in non trivial project, right?

>C++ doesn't necessarily copy the T since it returns a normal lvalue reference.
In that case .at() has the same problem too.

>write programm in Scheme
>compile to C with modern compiler
>programms still run within 2 times the speed of raw C
>avoid C++/Rust hell alltogether

What problem? What is your point? I don't understand the words that come out of your mouth bro

>within 2 times
kek more like 20*

With PHPs pcntl_fork, what controls the output? (I.e. output in parent or child thread)
Is it the scheduler?

What's a good guide / book for python?
Don't feel like going through 1000 pages books or documentation.

Invalid reference? Are you even the same guy I was talking to or did you fly out of nowhere?

>dereferenced an invalid pointer
Occasionally, and it's always in cases that Rust has no adequate solution for.

Vector works the exact same way as in Rust.
If you created an reference to data inside vector, you'll get an undefined behavior in C++ or invalid Rust code.

>It basically downgrades the vector into a constant-sized array in every non-trivial case.
It doesn't. It prevents you from undefined behaviors.
I've created a game in Rust that used many vectors for various things that kept changing and never had an issue with borrows. Just use RefCell, Mutex and Arc when needed.

Just because the example is simple, doesn't mean dangling pointer problem is trivial.

Explain the problem.