Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C vs Rust

Name: Anonymous 2015-02-13 1:07

C:
int main(int argc, char **argv) {
int r;
if(argc > 1) {
r = atoi(argv[1]);
} else {
usage();
exit(EXIT_FAILURE);
}
}


Rust:
fn main() {
let argv: Vec<Result<String,OsString>> = std::env::args()
.map(|x| x.into_string())
.collect();

let r = match argv.get(1) {
Some(x) => match x.parse::<i32>() {
Ok(v) => v,
Err(_) => {
show_usage();
panic!()
},
},
None => {
show_usage();
panic!()
}
}
}


Type explosion is to be expected. Do notation could have been used to keep the control logic as clean as C, but Rust is not HASKAL and never will be anything like HASKAL and you're an asshole for wanting to write readable code you filthy shit fuck.

Name: Anonymous 2015-02-16 3:25

>>37
Doesn't Rust have optional GCC through one of its @ pointer type?

Name: Anonymous 2015-02-16 8:36

>>41
It has GC via the RC and ARC types ((atomic(?)) reference counted) but the linear type system is clearly better than GC, and I'm pretty sure cdr was being facetious when shim said it is essential.

Name: Anonymous 2015-02-16 8:37

>>39
You forgot LtU.

>>41
No, @-pointers were removed and the planned GC was never implemented. You can use Rc<T> but I don't think there's a cycle collector.

Name: Anonymous 2015-02-16 8:44

oh and what's up with everyone converting to reference counting to 'get away from the GC'

refcounting is a form of GC and is far, far slower than a proper GC, and there's no real proper way to defer cleaning up refcounting for an 'opportune' time like with a 'real' GC unless you... introduce a 'real' GC.

The idea that malloc/free has no overhead is absolutely ridiculous too, as if GCs suddenly make memory management slow. Realtime programming is done by never using anything except stack memory and preallocated buffers, GC or not.

rust feels like a meme language made by people who have never really done any form of low level programming

t. someone who writes embedded software for medical devices in pascal for a living

Name: Anonymous 2015-02-16 8:55

The only people who shill Rust are people who haven't actually used it.

Yes the safety mechanisms are great in theory.

Yes we need a modernized version of C++.

But try to actually write something bigger than FizzBuzz in the fucking language and you'll quickly see why it'll never take off: Working in Rust is a bitch. It's inconvenient, has convoluted non-intuitive syntax and is just simply not fun.

Name: Anonymous 2015-02-16 8:58

>>44
I don't know why you would think that. We know RC is a form of GC, so there's no "getting away from GC" in using RC. RC is a cheap way of GC-ing select pieces of data without having to irreversably munge the whole damn runtime to use GC everywhere.
Therefore Rust's GC is "oh, if you insist you really want GC, here's something". Plus Apple have been using RC'd GC for years.

Name: Anonymous 2015-02-16 9:01

>>45
I agree. 95% of using Rust is wrestling with the godawful module/crate system.

Name: Anonymous 2015-02-16 9:25

The guy who was trying to make an OS in Rust gave up, and switched to the Nim language.

https://github.com/ckkashyap/rustix/issues/8

>>47
Like SJWs trapping you with their political correctness, Rust traps you in its boilerplate bureaucracy.

Name: Anonymous 2015-02-16 9:26

>>48
Nim is full of leaky abstractions. I wouldn't use it.

Name: Anonymous 2015-02-16 10:07

>>48
there were multiple guys doing that and at least one lady

Name: Anonymous 2015-02-16 10:47

Low level programming does not make you a good programmer. Write good strong software instead of checking for null pointers or buffer overflows.

Name: Anonymous 2015-02-16 21:58

>>51
What?

Name: Anonymous 2015-02-16 22:34

>>44,48
Rust is handicapped because it is a Mozilla project. All posturing to the contrary, making the language suitable for use in unhosted applications like kernels does not add a lot of value for Mozilla. Mozilla isn't writing kernels, they're writing a browser and they want a simpler safer alternative to C++ for that purpose. Once that is understood it should no longer be surprising that things like decoupling from libc are in fact a complete mess in Rust.

This is a sad situation if you're actually looking for a practical alternative to C in non-userland code, because there really is a lot of room for improvement there.

Name: Anonymous 2015-02-17 23:30

Rust is unarguably better than HTML.

Name: Anonymous 2015-02-17 23:42

You know what's even better than both Rust and HTML? check'em!

Name: Anonymous 2015-02-17 23:48

The solution, as always is Lisp Machines

Name: Anonymous 2015-02-18 0:07

>>54
Bullshit.
My HTML code runs faster and is more readable than Rust could ever be.

Name: Anonymous 2015-02-18 0:35

>>57
Prove it, nigger. Post code & benchmarks.

Name: Anonymous 2015-02-18 6:19

>>53
It's not so bleak. The libc business is something you can work out and will probably become saner in the future if people actually want to use it that way. If you're targeting ARM http://zinc.rs probably has you covered already.

Name: Anonymous 2015-02-18 7:14

>>59
will probably become saner in the future if people actually want to use it that way

If so it will be the first Mozilla project I know of to have that success.

That link gives me some hope though - the principal author is bang on about the potential benefits global optimization can bring in this space. I am completely sick of having to pamper C compilers and their Byzantine unit-at-a-time linkage model. (And don't any of you dare bring up inlining as a solution - that's like conflating remission with metastasis).

Name: Anonymous 2015-02-18 9:11

If so it will be the first Mozilla project I know of to have that success.

If you don't hate ES, I would count it as a success in that area. If you do hate it, I can see how you'd see it the other way (eg. wanting a bytecode.)

If you check the committers for zinc.rs you'll find that most of them also have contributions to Rust. The Rust team has generally sided with making this kind of thing possible (and pleasant though it's not exactly a priority.)

Name: Anonymous 2015-02-18 12:18

>>53
Hey, this is pointless to say because you won't listen and you don't care, but Rust isn't a Mozilla-controlled project like Firefox. Mozilla sponsors Rust by hiring people who contribute to the project, so that they'll put as much energy as possible into further contributions. The actual development process is very transparent and there's no special status for Mozilla-employed contributors over random people with a lot of spare time. What matters is that you know your shit and you can write words and code to back it up.

Name: Anonymous 2015-02-18 15:33

>>62
Well, that's bullshit.

Signed,
Not >>53

Name: Anonymous 2015-02-18 15:39

>>61
I'm ambivalent on ECMAScript - I just didn't count it as a victory for Mozilla per se because it was already gaining ground when Netscape still existed.

>>62
I know what an open source project means. Having a lot of paid developers on the project confers influence and it's quite naive to maintain otherwise.

Name: Anonymous 2015-02-23 8:24

fn main() {
let r = match std::env::args().map(|x| x.to_string()).nth(1) {
Some(x) => match x.parse::<i32>() {
Ok(v) => v,
Err(_) => panic!("Argument must be an i32."),
},
None => panic!("No arguments were given."),
};
}

Name: Anonymous 2015-02-23 8:49

dubs get

Name: Anonymous 2015-02-23 9:33

Name: Anonymous 2015-02-23 10:54

Who is that shitter who keeps posting /prog/ to Reddit?

Name: Anonymous 2015-02-23 10:56

>>68
I think it's this guy: >>67

Name: Anonymous 2015-02-23 12:14

>>69
Negative. I noticed my shitpost was posted to the Rust subreddit by someone who works on Rust and Servo and decided to gloat. They hid the story immediately and I can't decide whether I feel ^ ^ or ; ; about that.

Name: Anonymous 2015-02-23 13:19

>>3
Haha, enjoy your <::>::<>::<>::><><::><::<>::-itis.
Haskell's syntax is so much better.

Name: Anonymous 2015-02-23 14:55

You do not need to annotate most types; I can't tell if this is b8 or you are actually this ignorant, because you are misrepresenting idiomatic rust with extreme prejudice. Just because you have not learned the language yet does not mean you can bash on it (in fact, quite the opposite…)

#![feature(env)]

use std::env::{args, set_exit_status};

fn main() {
let r = match args().nth(1) {
Some(a) => a.parse::<i32>().unwrap_or(0),
None => {
show_usage();
set_exit_status(1);
return;
},
};
}

Name: Anonymous 2015-02-23 15:51

>>72
imperative diarrhea

Name: Anonymous 2015-02-23 17:30

>>72
main :: IO Int
main = do
args <- getArgs
maybe (return 1) (read >>> return) $ listToMaybe args

Name: Anonymous 2015-02-23 18:12

>>74
[1 of 1] Compiling Main ( anus.hs, interpreted )

anus.hs:3:11: Not in scope: `getArgs'

anus.hs:4:26:
Not in scope: `>>>'
Perhaps you meant one of these:
`>>' (imported from Prelude), `>>=' (imported from Prelude)

anus.hs:4:40: Not in scope: `listToMaybe'
Failed, modules loaded: none.

Name: Anonymous 2015-02-23 18:42

>>75

Optimize your prelude!

Or add

import Control.Category
import System.Environment
import Data.Maybe


to the top.

Name: Anonymous 2015-02-23 19:13

>>76
Control.Category
Just use (.), check 'em!

Name: Anonymous 2015-02-23 19:16

>>77
No. I like writing left-to-right, because I am not a Jew.

Name: Anonymous 2015-02-23 20:43

>>78
Add this to your prelude
(&) :: (b -> c) -> (a -> b) -> a -> c
(&) = flip (.)

it's the only good thing from the lens library.

Name: Anonymous 2015-02-23 22:17

>>79
that's for object oriented faggots who can't learn a single new thing

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List