[ / / / / / / / / / / / / / ] [ dir / agatha2 / animu / ausneets / b2 / choroy / dempart / freeb / vichan ][Options][ watchlist ]

/tech/ - Technology

You can now write text to your AI-generated image at https://aiproto.com It is currently free to use for Proto members.
Email
Comment *
File
Select/drop/paste files here
Password (Randomized for file and post deletion; you may also set your own.)
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Expand all images

File (hide): be2acba3b129149⋯.png (46.86 KB, 625x582, 625:582, WTFRust.png) (h) (u)

[–]

 No.1065595>>1066670 [Watch Thread][Show All Posts]

When I comment out the line in pic related, Rust will fail with the error


thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 11, kind: WouldBlock, message: "Resource temporarily unavailable" }', libcore/result.rs:1009:5

upon running, but when I let it print, it runs completely fine. What kind of fucking language panics or doesn't based on whether or not something prints?

 No.1065608>>1065610

We have dedicated help and consumer stickies you know.


 No.1065610>>1065877

>>1065608

This isn't a help or consumer post, it's a criticism of a language.


 No.1065639>>1065898 >>1066670

I have no idea about Rust, but you're probably invoking undefined behavior, especially since multithreading appears to be involved. Printing likely has a lock that accidentally prevents the bug.


 No.1065841

That has nothing to do with Rust. That's EAGAIN, and is returned by the OS. It's a side-effect of you filling up a non-blocking buffer: http://man7.org/linux/man-pages/man3/errno.3.html

This can happen if you aren't properly interacting with non-blocking sockets or other filehandles. I can't tell, because you aren't showing us all your code, or where you are calling "unwrap".

> What kind of fucking language panics or doesn't based on whether or not something prints?

When you're working with buffered IO and multithreading, any language when you're on the right OS and making the right calls. You're depending on stuff that's difficult to predict. Handle your non-blocking IO. If you want better help, you'll need to present a MCVE so we can reproduce your issue. As is, your question is basically useless: https://stackoverflow.com/help/minimal-reproducible-example


 No.1065877

>>1065610

Thanks for admitting that you're shitposting. Reported.


 No.1065898>>1065916 >>1065920 >>1066468 >>1066670

std::thread::spawn uses pthread_create on Unix.

RTFM you fucking faggot.

http://man7.org/linux/man-pages/man3/pthread_create.3.html

>>1065639

>I have no idea about Rust

Why are you posting then?

>you're probably invoking undefined behavior

Yes, you have no idea about Rust. It is impossible to invoke UB in safe Rust.


 No.1065916>>1065989

File (hide): 9bcb92398544e17⋯.png (96.49 KB, 255x255, 1:1, 1433547542992.png) (h) (u)

>>1065898

Technically speaking, without a specification the entire Rust language is undefined behavior.


 No.1065920

>>1065898

Because 9/10 times, "I have this Rust issue pls halp" turns out to have nothing to do with Rust. As was the case here, even though I didn't guess right this time.


 No.1065989>>1066037

>>1065916

Nice neme, faggot. But you're wrong. UB is a thing only in C/C++ world. Without a spec Rust is technically implementation defined.


 No.1066037>>1066071

>>1065989

>UB is a thing only in C/C++ world

>Without a spec Rust is technically implementation defined

So if it isn't C or C++, it magically doesn't have UB even if said behaviour is undefined. Got it.

>but it's implementation defined

Aka "we're too lazy to write an actual spec so anything this compiler does is defined behaviour."


 No.1066071>>1066329 >>1066475

>>1066037

>hurr durr muh spec

>everything without a spec is undefined

You're so fucking retarded. Even more so than C/C++.

Look at any specified language other than C/C++. Does it have UB? Protip: no

"C was originally developed at Bell Labs by Dennis Ritchie between 1972 and 1973 [...]"

"C has been standardized by the American National Standards Institute since 1989 [...]"

"In 1985, the first edition of The C++ Programming Language was released, which became the definitive reference for the language, as there was not yet an official standard."

"The C++ programming language was initially standardized in 1998 [...]"

Kill yourself, you utter retard.


 No.1066329>>1066387

>>1066071

>Look at any specified language other than C/C++. Does it have UB?

Yes, provided it's an actual language standard rather than "implementation is the standard ecks dee" bullshit. Even Common Lisp has it and there is a good reason for it to exist: It gives the implementation freedom to optimize. C/C++ don't suck because they have undefined behavior; they suck because the specified part is so useless that you can't get around undefined behavior in nontrivial programs.


 No.1066387>>1066399 >>1066405 >>1066475 >>1066540

>>1066329

>Even Common Lisp has it

That's an interesting claim, unfortunately I can't verify it because the standard isn't free. LMAO

So let's take a look at other languages:

C# (https://ecma-international.org/publications/standards/Ecma-334.htm): 8 cases of UB, all require the explicit use of unsafe.

JavaScript (https://www.ecma-international.org/publications/standards/Ecma-262.htm): 0 cases of UB

Java (https://docs.oracle.com/javase/specs/index.html): 0 cases of UB

Dart (http://www.ecma-international.org/publications/standards/Ecma-408.htm): 0 cases of UB

Eiffel (http://www.ecma-international.org/publications/standards/Ecma-367.htm): 0 cases of UB

UB is peak braindamage.


 No.1066399>>1066406

>>1066387

if only C++ wasn't specified, it wouldn't have undefined behavior, because GCC would define it


 No.1066405

>>1066387

I'm just now entering this discussion, but I can give a brief summary of the manner of undefined behaviour Common Lisp has.

Some functions aren't defined to freshly cons (allocate) a result; the result may be reused, so it's undefined what happens if it's modified. Several SEQUENCE manipulating functions accept a :TEST and a :TEST-NOT parameter; the latter is deprecated, but it's undefined what happens if you specify both for a call to such a function. A list can be circular or end improperly, but some functions may or may not detect this; it's undefined what happens if you call LENGTH on a circular list, instead of LIST-LENGTH which specifically detects this case, so an implementation may signal an error or loop indefinitely; a list manipulating function may signal an error if it's used on an improper list, but may not if it gets its result before it reaches the issue. It's undefined what happens if you manipulate a list that's been specified literally, since that may be made constant by the implementation as an optimization.

This is a summary of some of what's in Common Lisp. As you can see, it's nothing particularly unreasonable, unlike C.


 No.1066406

>>1066399

I don't understand what you are trying to say.


 No.1066409

>having multiple places in a spec saying that implementations are free to fuck up your shit if you don't follow some convoluted rules to a T is the same as having no spec

The absolute state of anti Rust shills.

Cniles are so desperate to argue against their beloved languages deprecation that they praise the worst thing in the history of computer science.


 No.1066416>>1066417

If you aren't programming in straight asm inside a monitor program you're a cuck weenie tbh.


 No.1066417>>1066418

>>1066416

>LARPing


 No.1066418

>>1066417

Cnile detected. I bet this cuckaroo still uses a MMU lmao.


 No.1066468>>1066492

>>1065898

>It is impossible to invoke UB in safe Rust.

assuming the implementers did everything correctly protip: they didn't


 No.1066475>>1066492

>>1066387

>>1066071

Without a proper spec, Rust is tied to whatever the fuck its reference compiler does and everyone else has to play catchup.


 No.1066492

>>1066468

Yes, you are right. Thanks to LLVM you can invoke UB in safe Rust. C/C++ strikes again.

>>1066475

Correct. Which means Rust is imlementation define, not undefined.

Also nobody cares about a spec.


 No.1066540

>>1066387

So is C's standard, that doesn't mean it's difficult to find its draft. Three of the five languages you listed are strongly related and one (JS) errs too much in the other direction, where an implementation must implement completely retarded things (e.g. integers as FP) to stay conformant. I don't know Eiffel, so I'll skip that one.

You already got an answer about some things in Common Lisp, but here you go, see "§1.4.2 Error Terminology". Other examples of undefined behavior in CL are wrong type declaration, since those exist for optimization reasons, and assigning to a constant. For some reason I remember that a FORMAT call with too few arguments is undefined too, but I can't seem to find this in the standard. Maybe it was changed before standardization and is somewhere in CLtL. However, a lot of the problems as in C are avoided because the safety level of compilation is adjustable, so implementations will very dutifully check for errors at max safety and let hell break loose if you lower it. Common Lisp, like Ada, is generally a very well-designed language -- unlike the garbage you see nowadays where supposed high-level languages don't even have a fucking rational number type because wah wah that's not in C.


 No.1066541

Stop eating my attachments, you big gay.


 No.1066670

>>1065898

>>1065595 (OP)

>>1065639

Rust is correctly panicking instead of going off and fucking everything up in UB land.




[Return][Go to top][Catalog][Screencap][Nerve Center][Cancer][Update] ( Scroll to new posts) ( Auto) 5
26 replies | 2 images | Page ?
[Post a Reply]
[ / / / / / / / / / / / / / ] [ dir / agatha2 / animu / ausneets / b2 / choroy / dempart / freeb / vichan ][ watchlist ]