[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Rust Supremacy Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 213
Thread images: 13

File: rust.png (101KB, 600x600px)
rust.png
101KB, 600x600px
We must secure the relevance of our language and a future for rust programmers.

Join the future of systems programming

https://www.rust-lang.org/
>>
>>60119490
Dude I like the language myself, but stop with this shilling. Do something with instead.
>>
https://blog.rust-lang.org/2017/04/27/Rust-1.17.html
545 points on HN, are other programming languages even trying?
>>
>>60119564
>545 points on HN

Relevance is inversely proportional with HN points.
>>
>>60119564
Hn is full of rust shills. Meanwhile rust has still 0 (zero) useful applications written in it. SAD!
>>
>>60119663

Both CERN and ESA use Rust.

Also Steve Klabnik is a qt.
>>
>>60119727
>X uses rust and I like x so it must be good
>Am gay
>>
>>60119727
Rust is shit for productivity, why would I waste my precious time
>>
File: 1472570130394.gif (1MB, 960x540px) Image search: [Google]
1472570130394.gif
1MB, 960x540px
>>60119490
I'm learning rust. I hate to admit, it is really a massive pain in the ass to do the simplest of the things. Maybe because C/C++/D made me very lazy.

For example try implementing a function that prints the sum of all square number under 1 Million.

On C:
#include <stdio.h>

int main()
{
size_t total = 0;
int i;
for (i = 0; i < 100000; i++)
{
int j;
for (j = 0; j < i / 2; j++)
{
total += (j * j == i) ? j : 0;
}
}

printf("%lu\n", total);
return 0;
}

On D:
import std.stdio;

void main(string[] args)
{
size_t total = 0;
for (int i = 0; i < 100_000; i++)
{
for (int j = 0; j < i / 2; j++)
{
total += (j * j == i) ? j : 0;
}
}

writeln(total);
}


Now let's see Rust's version, please follow the same algorithm for a level playing field. I want to bookmark the three languages now: in terms of code readability/productivity and speed.
>>
>>60119727
CERN does most of their work in C++ using the ROOT framework
There is also a shit ton of legacy FORTRAN they use.
>>
>>60121353
fn main() {
let mut total = 0;
for i in 0 .. 100_000 {
for j in 0 .. i / 2 {
total += if j * j == i { j } else { 0 };
}
}
println!("{}", total);
}


As written, it sums all squares under one hundred thousand, not one million. Is that what you intended?
>>
>>60122001
>100_000

C really is the best
>>
>>60119490
1/10 made me respond as someone who'd like C to go.

Saged, reported, hidden, called the mods, emailed chinkmoot, emailed the admin, called the cops, called the state police, called the county sheriff, called your ISP, called the District Attorney, called Interpol, called the NYPD, called the State Attorney, called the LAPD, called Child Protective Services called the FBI, called US Homeland Security, called the CIA, called the NSA, called the US Marshals, called the local courthouse, called your State Constable, called London Metropolitan Police, called the German Police, called the TSA, called the US President, called the attorney general, called the National Guard, called the US marines, called the US Navy, called the US Air Force, called the US army, called the Royal Navy, called the governor of every state, called the Federal Air Marshals, called every sheriff deputy, called the Coast Guard, called the US Customs and Border Protection, called the RCMP, called every park ranger, called the mayor of every city in France, called the British Army, called the Queen, called NATO, called the Russian Air Force, called the Federal flight deck officers, called the UN, called the Corrections Department for every state, called the Australian Federal Police, called SWAT, called the Supreme Court, called the Mexican Police, called the White House, called the DEA, called the inspector general, called the Secret Service, called CNN, called ABC, called the vice president, called the senators for every state, called congress, called the pope, called CHP, called the Department of Fish and Wildlife for every state, called the internet police, called the US Capitol Police, and called the Party Van.
>>
>>60122001
>100_000
this is haram
>>
https://internals.rust-lang.org/t/diversity-on-the-governance-teams/2048
>Diversity on the governance teams
>the level of diversity on the teams is low: in particular there appear to be no women on any of the sub-teams
>As a member of the moderation team, I really really think this must change. There are many reasons, but for the moderation team in particular I don't think we can be maximally effective at helping to uphold the Code of Conduct without a more diverse team. For example, gender bias and gendered harassment are a huge problem in online communities and open source. The moderation team is explictly supposed to fight sexism, racism, and other discrimination. We could see, anticipate, and respond to such issues much better if we had more than just male perspectives on the team.
>women and minorities are under-represented in the Rust project and broader community. This is not an excuse; it points to a bigger problem that we also need to solve.
>We can and should build a team now that can best serve the diverse community we want to welcome.
>This means looking beyond the group of people who have been most active or visible in the past, and creating more opportunities for new people to come into the project to build its future.
>I want the best possible moderation team for the Rust community, and I believe that means replacing a too-narrow process with a more inclusive one.
>I personally would be happy to be replaced by someone picked from a larger pool of qualified candidates, and want to find the best way to make this happen.
>I don't however want to succumb to the common problem of asking women, people of color, and other victims of discrimination to do disproportionate or unpaid work to fix problems they didn't create.
>>
>>60122024
>>60122036
This is pure supremacy. Even more so if you place it like 1_00_0000_0_1_00000 in somefucks else codebase.
>>
>>60122080
>I was struggling to come up with more than 4 not-cis-man active members (that is, publicly not-cis-man, there may be people who have kept their gender private) of the Rust community, and this was when I included people who used to be active but aren't anymore. That's doubleplusungood.
>Diversity on the mod team is very important, and I hope we can work towards a solution to that.

https://github.com/rust-lang/rust-www/issues/268
>Gender Identity & Expression in the Code of Conduct
>I just filled in an issue over in Node.js about including 'gender identity and expression' into their Code of Conduct: nodejs/inclusivit
>I know that Node effectively adopted the Rust CoC so I thought I should come over here and suggest the same thing
>I am proposing that we include 'gender identity and expression' in the Code of Conduct used for all of Rust. I've managed to include this in the Codes of Conducts for several event and online communities of a smaller nature
>Solely referring to 'gender' does not recognise the non-binary or agender folk. (As often, 'gender' is widely regarded as the popular idea of man/woman). Gender identity feels like a clearer and more inclusive term.
>I realise the CoC says 'similar personal characteristic', but it feels like it'd be good to have things explicitly said rather than assumed. The Contributor Covenant has a lot of really useful things in it too (like age, technology choices, lack of religion), which we could consider co-opting things from.

>this is clearly within the spirit and intent of the original CoC, and I have no objection to spelling it out more explicitly.

>It's really encouraging to see so many +1's thank you all.
>>
>>60122036
>>60122024
I wish I had that in C
>>
>>60122001
>
for j in 0 .. i / 2 

>i/2
>u32/i32
hmm
>>
>>60119490
/tmp$ cat main.rs 
fn main(){
println!("Hello world");
}
/tmp$ time rustc main.rs
real 0m0.387s
user 0m0.288s
sys 0m0.108s


~0.3 seconds to compile hello world? You can't be serious. it's worse than C (0.03) and two C++(one 0.06 with printf, second 0.15 with iostreams) combined.

Fast compiler where?
>>
>>60122191
Compilation speed is none of Rust's concern

And it takes me like .02 seconds here, go be a poorfag somewhere else
>>
>>60122191
>benchmarking compiler startup times
>>
File: IMG_0016.png (25KB, 1200x1200px) Image search: [Google]
IMG_0016.png
25KB, 1200x1200px
>>60119490
Fuck you all!
>>
>>60122221
Ayyyy
>>
>>60119490
Now I definitely will never use it. Its essentially going to produce another generation of shit programmers JUST LIKE JAVA DID!
>>
>>60122226
>Its essentially going to produce another generation of shit programmers JUST LIKE JAVA DID!
Elaborate
>>
>>60122226

No it won't, because nobody uses rust in enterprise.
>>
>>60122001
>
for j in 0 .. i / 2 

Try again. It crashes the program
>>
>>60122208
> Implying that dropping probably more than half of my CPU's cores to have slightly better time on fewer cores is a good choice

>>60122213
> Ignoring that slow compilation time was always rust problem
> Pretending e.g. https://github.com/rust-lang/rust/issues/40858 does not exist
> being in such of the denial
>>
>>60119490
>Rust

Why do they always give languages such shitty names? It should be something awesome, like XxXbLaD3xXx2004
>>
>>60122274
>Ignoring that slow compilation time was always rust problem
It sure is, just not for hello worlds.
>>
>>60122274
Slow compiler is not a Rust only problem. Also, as I just said, compilation time is none of Rust's goal. You are just wasting your energy there
>>
>>60122288
>It should be something awesome, like XxXbLaD3xXx2004
>>
>>60121353
>i/2
wat?

also
>not using bit shift operator
>>
>>60122325
If the root doesn't exist in the first half of multipliers it doesn't exist in the rest half
>>
>>60122333
range of i is already known, why do you need to check half? limit it to 1000
>>
>>60122385
Manual optimizations would decrease the performance gap in benchmarking though
>>
>>60122402
learn to think clearly first
>>
>>60122445
huh?
>>
>>60122221
>a language that competes with python in speed
Aren't you in the wrong thread?
>>
>>60119663
Donald pls go
>>
>>60119490

There is no god but Rust! Steve Klabnik is the messenger of Rust!
>>
>>60119490
At work I program C for Cortex M devices, using a non-userspace RTOS. I was searching for embedded OSes for Rust, and only this one came up: https://www.tockos.org/
Has anyone here tried it? It seems board support is pretty lacking.
>>
>>60124346
Hi! :)
Please remove your post because it satirizes Islam and we don't tolerate Islamophobia in our community.
Bye! :)
>>
>>60124346
dude looks like skrillex
>>
>>60124448
rust and things made in rust are both pretty immature still

probably the big unspoken reason why nobody is using it outside of a few meme companies yet
>>
>>60124736
>unspoken
It is well known that changing your companys development language is huge leap.
>need to train your workforce
>maintain old code
>interface between new lang and old code
>all the other problems that come with new lang
>>
Rust has potential but the politics are killing the kind of adoption is needs to become really popular
>>
>>60121353
fn main() {
let total = (1..100000).map(| i | (0..(i/2)).filter(|&j| j*j==i).sum()).sum();
println!("{}",total);
}
>>
File: confuspupper.jpg (59KB, 408x439px) Image search: [Google]
confuspupper.jpg
59KB, 408x439px
>>60122174
>>60122247
What?
>>
>>60125035
consider giving `total` a type
| cannot infer type for `_`
>>
>>60125061
Right, that's just a
let total : i64 = ...

Which should work for any particular integer type you want. The solution is generic.
>>
>>60125113
Still doesn't compile though


Okay the results are in:
user0@primary:~/devel/proj/test-c$ cat test.c && gcc -O2 test.c && time -p ./a.out
#include <stdio.h>

int main()
{
size_t total = 0;
for (int i = 0; i < 100000; i++)
{
for (int j = 0; j < i; j++)
{
total += (j * j == i) ? j : 0;
}
}

printf("%lu\n", total);
return 0;
}
50085
real 8.15
user 8.15
sys 0.00
user0@primary:~/devel/proj/test-c$

user0@primary:~/devel/proj/test-d$ cat main.d && ldc2 -O2 -release main.d && time -p ./main
import std.stdio;

void main(string[] args)
{
size_t total = 0;
for (int i = 0; i < 100_000; i++)
{
for (int j = 0; j < i; j++)
{
total += (j * j == i) ? j : 0;
}
}

writeln(total);
}
50085
real 7.53
user 7.52
sys 0.00
user0@primary:~/devel/proj/test-d$

user0@primary:~/devel/proj/test-rs/test1/src$ cat main.rs && rustc -O main.rs && time -p ./main
fn main() {
let mut total: i32 = 0i32;
for i in 1..100_001 {
for j in 1..i {
total += if (j*j) == i {j} else {0i32};
}
}
println!("{}", total);
}
50085
real 2.61
user 2.61
sys 0.00
user0@primary:~/devel/proj/test-rs/test1/src$



Very controversial
>>
>>60124462
>didn't read the op
>literally white supremacist wording
>waaahh dont insult muh islam get out of our "community"
this is why no one can take rust seriously along with shit compile times and pretending and failing to be memory safe.
>>
>>60125185
Ah sorry, the inner sum() needs a type hint as well. Serves me right for writing code without running it.

This works though:
fn main() {
let total = (1..100000).
map(|i| (0..(i)).filter(|&j| i==j*j).sum::<i64>())
.sum::<i64>();
println!("{}",total);
}
>>
>>60125221
meant 0..(i/2) ofc.
>>
>>60125221
Looks worse than >>60122001
desu
>>
>>60125221
what is this shit
>>
>>60125237
Eh, that's a matter of taste. A program written using map & filter is easier to break up into reusable functions. Both imperative and functional styles are valid approaches.
>>
>>60125221
Senpai could you please rustfmt that
>>
>>60119490
Is it actually good enough to use? Last I checked it seems like the designers might still suddenly change stuff around.
>>
rust seems like a low level scala. and by that i mean it has a steep learning curve. am i correct?
>>
>>60124971
Don't be fooled. Rust doesn't invent anything that wasn't already in Ada and C++. Its sole purpose is to be political.
Make sure you never use it. If your company wants to introduce it, quit.
>>
Rust is garbage. Never before have I seen a language with hundreds of thousands of shills shilling it everywhere they go.

https://freesoftwarefoundation.org/read/prog/1423793249
>>
>>60124940
It's not such a huge leap for smaller companies who built all their shit in something like Python or Ruby - they can replace parts of their backend with standalone Rust programs for huge performance gains with only modest effort.

Not so appealing if you're working on a huge C++ or Java codebase though
>>
(((Rust))) is made by the (((SJWs))) at (((Mozilla))).
>>
>>60126571

>Never before have I seen a language with hundreds of thousands of shills shilling it everywhere they go.

Golang is worse.

But I dislike both of them.
>>
>>60126557
Pattern Matching.
>>
>>60125186
u 8 the gr8 b8, m8
>>
>>60126353
>>60124736
>>60124971
I want to like it, but these. It needs to be more mature and feel more permanent.
>>
>>60126353
>Last I checked it seems like the designers might still suddenly change stuff around.
Yes, they do this frequently. Code that's more than a few weeks old will not compile.
>>
>>60119490
So where would i want to use rust? Shills are mostly saying it will replace C, but... It's unusable for embedded. It doesn't have the tooling C has to write safe code and, probably never will.
>>
>>60128983
It's good for hobby projects, and that's about it.
>>
>>60119490
>a future for rust programmers
hahahahahhahahah
>>
>>60128256
Golang is actually pretty sweet for backends. As with C, the lack of generics is not a problem. Biggest issue imho is the imports bullshit.
>>
>>60119727
they also use C, C++, python, java, javascript and a few more..
its almost like different tools for different jobs or something
>>
Complex languages never caught on. Why would Rust?
>>
>>60129444
>C++
>never caught on
>>
>>60129490
C++ isn't complex. It's C with bloat.
>>
>>60129503
If C++ isn't complex, neither is Rust.
>>
>>60129503
It's complex when people use that bloat together. Just got a new job working on an 18 years old C++ codebase where the leads thought it's a good idea to implement every goddamn bullshite feature of the goddamn language. Fml
>>
>>60129609
Rust has all kinds of arbitrary rules regarding memory management.
>>
>>60122113
Based on this alone Rust is dead to me and I will oppose it every where I can in every way I can, even if I have to resort to FakeInfo about its performance or suitability for a project.

Fuck Rust.
>>
>>60129650
Rust has the same rules as C++, but instead of enforcing them in your head the compiler does it for you.
>>
>>60128938
That's literally wrong.
>>
>>60129870
That's not true. The borrow checker is known to reject valid, memory safe, code.
>>
>>60129910
And this happens because the borrow checker is overly conservative, since not being conservative enough would be useless.

It is a trade-off I am willing to make, but I understand other people might not want to.
>>
>>60129944
>overly conservative
No, it's just too dumb to understand the context.
>>
rust is a good language to learn from but its either going to need a decade to refine or Rust++ to do its borrow checker better.
>>
>>60129965
I agree with you.

What I mean by "overly conservative" is that if the borrow checker can't reach the conclusion (because it is dumb) then it will reject the program.
>>
>>60129997
So, why would I entrust memory safety to a faulty borrow checker?
>>
>>60130020
Because it won't accept a memory unsafe program (unless you use an unsafe block).

It isn't faulty in the sense that it will accept an unsafe program, it's fault because it rejects a subset of safe programs. This is more useful than the inverse (for me).
>>
>>60130035
>Because it won't accept a memory unsafe program (unless you use an unsafe block).
There's never been formal proof of that.
>>
>>60130043
You are correct, and someone in Europe is working on proving that (among other things) at this moment.
>>
>>60130084
Every time there's a problem with Rust, the standard response is "someone's working on it." Meanwhile there are stable languages you can get jobs with. Have fun with your vaporware.
>>
>>60130084
I don't think the borrow checker will pass. If it does though, chapeau.
>>
Hey guys, rate my fizzbuzz:

fn fbString(i : i64) -> (*const str, Option<Box<String>>) {
match (i%3,i%5) {
(0,0) => ("FizzBuzz" as *const str,None),
(0,_) => ("Fizz" as *const str,None),
(_,0) => ("Buzz" as *const str,None),
_ => {let x = i.to_string();
let px = &x as &str as *const str;
let bx = Box::new(x);
(px,Some(bx))}
}
}


fn main() {
let n = 50;
for i in 0..n {
let (poutput,tehBox) = fbString(i);
let output = unsafe {&*poutput};
println!("{}", output);
} // Box contents are nuked here.
}
>>
>>60130221
not idiomatic enough.
>>
>>60130221
>
Option<Box<String>>

Not enough layers, you need to go deeper
Option<Rc<RefCell<Box<String>>>>
>>
>>60130221
Changing tehBox to _ causes this to dereference a dangling pointer, but keeping it named is safe. Well done.
>>
>>60130113
obviously the other language is 50 years old and rust hit 2 last week, you dumb fuck
>>
>>60125185
wtf I like rust now
>>
>>60130221
I prefer this version:

#![no_std]
#![feature(asm, lang_items, libc, no_std, start)]

extern crate libc;

const LEN: usize = 413;
static OUT: [u8; LEN] = *b"\
1\n2\nFizz\n4\nBuzz\nFizz\n7\n8\nFizz\nBuzz\n11\nFizz\n13\n14\nFizzBuzz\n\
16\n17\nFizz\n19\nBuzz\nFizz\n22\n23\nFizz\nBuzz\n26\nFizz\n28\n29\nFizzBuzz\n\
31\n32\nFizz\n34\nBuzz\nFizz\n37\n38\nFizz\nBuzz\n41\nFizz\n43\n44\nFizzBuzz\n\
46\n47\nFizz\n49\nBuzz\nFizz\n52\n53\nFizz\nBuzz\n56\nFizz\n58\n59\nFizzBuzz\n\
61\n62\nFizz\n64\nBuzz\nFizz\n67\n68\nFizz\nBuzz\n71\nFizz\n73\n74\nFizzBuzz\n\
76\n77\nFizz\n79\nBuzz\nFizz\n82\n83\nFizz\nBuzz\n86\nFizz\n88\n89\nFizzBuzz\n\
91\n92\nFizz\n94\nBuzz\nFizz\n97\n98\nFizz\nBuzz\n";

#[start]
fn start(_argc: isize, _argv: *const *const u8) -> isize {
unsafe {
asm!(
"
mov $$1, %rax
mov $$1, %rdi
mov $0, %rsi
mov $1, %rdx
syscall
"
:
: "r" (&OUT[0]) "r" (LEN)
: "rax", "rdi", "rsi", "rdx"
:
);
}
0
}

#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
#[lang = "eh_personality"] extern fn eh_personality() {}
#[lang = "panic_fmt"] extern fn panic_fmt() {}
>>
>>60130113
rust obviously has a long way to go but that doesn't mean it or something like it shouldn't exist
>>
>>60121353
>For example try implementing a function that prints the sum of all square number under 1 Million.
Are you printing the sum of all integer square roots that square to a value < one million? Or all perfect squares < one million?

Your description is the latter but it appears you're trying to solve the former. In either case your code is wrong and incredibly slow. (I know this is a "muh RUST!" thread but the code samples are driving me up a wall.)

Sum all perfect squares in the range 0 <= n < max.
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

typedef unsigned long long llu;

int main()
{
// Sum all perfect squares in the range 0 <= n < max.
llu max = 1000000;
llu c = floor(sqrt(max--));
llu sum = 1;

for (llu i = 2; i <= c; i++){
llu sqr = i*i;
sum += sqr;
}

printf("%llu\n", sum);
return 0;
}


Sum all positive integer square roots that square to a value < max.
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

typedef unsigned long long llu;

int main()
{
// Sum all positive integer square roots that square to a value < max.
llu max = 1000000;
llu c = floor(sqrt(max-1));
llu sum = 0;

for (llu i = 0; i <= c; i++){
sum += i;
}

printf("%llu\n", sum);
return 0;
}
>>
>>60130927
If you're not going to solve a problem correctly, you might as well not even try.
>>
>>60130934
>
llu c = floor(sqrt(max--));

Please don't try to be a smartass
>>
>>60130943
these things take a lot of time and testing. name a single programming language that accomplished everything it set out to do on the first pass
>>
>>60130964
And what is wrong with that line of code?
>>
>>60131012
abstractions
>>
>>60130934
There is a much better way to solve this though:

int main() {
llu max = 1000000;
printf("%llu\n", n*(n+1)*(2n+1)/6);
return 0;
}
>>
>>60131025
>
    llu max = 1000000;

Nice unused variable
>>
>>60131025
Don't expect C babies to understand anything but the most basic math.
>>
>>60131012
The code is trying to reduce the input (max) by one because the problem is exclusive of max. It should be:
llu c = floor(sqrt(--max));


Probably better to just write it like this so there's no confusion over --max vs max--:
max--;
llu c = floor(sqrt(max));
>>
>>60131012
It takes the square root of max, not the intended (max - 1)
>>
>>60131025
Good memory but you didn't edit it correctly to compile and work.

#include <stdlib.h>
#include <stdio.h>
#include <math.h>

typedef unsigned long long llu;

int main()
{
// Sum all perfect squares in the range 0 <= n < max.
llu max = 1000000;
max--;
llu n = floor(sqrt(max));
printf("%llu\n", n*(n+1)*(2*n+1)/6);
return 0;
}


>>60131050
>expecting everyone to remember a math formula most haven't seen in decades
OK
>>
>>60131224
>>expecting everyone to remember a math formula most haven't seen in decades
Not everyone, just anyone doing serious performance-oriented programming (the only justifiable reason to use C in the first place, aside from back-compat)
>>
>>60131224
>> Not deriving that formula yourself.
Just make the ansatz that the correct formula is a polynomial P(N), with the property that P(N+1) - P(N) = (N + 1)^2
>>
>>60131224
>both pointlessly pedantic about syntax and a self-admitted retard
these are the people who post here. shameful, /g/
>>
>>60131321
>expecting a code post to actually compile and work for testing
>"pedantic"
>>
>>60131445
Yes, correcting obvious typos to appear smart on gee is pedantic.
>>
>>60125035
Does rust convert "map" to a normal foreach when compiling or does this do the usual inefficient indirect function calls at runtime?
>>
>>60131268
>Not everyone, just anyone doing serious performance-oriented programming (the only justifiable reason to use C in the first place, aside from back-compat)
No one else in this thread even caught the error. They were too busy shit posting.
>>
>>60131513
That's not the argument you think it is.
>>
>>60131503
>Yes, correcting obvious typos to appear smart on gee is pedantic.
>max is unused
>n is not declared
>"obvious typos"
>>
>>60131534
Considering a single token switch of max to n fixes both problems and is obviously what the poster intended - a three line program is not exactly difficult to parse - yes, it is pedantic.
>>
>>60131522
Neither is "muh performance!" Formula or loop will complete in under 1/1,000th of a second with no optimizations and an input of 10 billion.
>>
>>60131585
Those DeVry credits aren't going to transfer. Better hurry up and graduate before the government shuts it down.
>>
>>60131579
>Considering a single token switch of max to n fixes both problems
Yet the code still won't compile because of 2n. Fix that and it gives the wrong answer because the answer is exclusive of max. The post you're being a whiny little bitch about was not sarcastic or shitty to the guy who posted the formula, and it did include valid fixes so that someone could copy and test.

So why, exactly, are you being a whiny little bitch?
>>
>>60131633
>says the guy who can't fizzbuzz
>>
>>60130934
>int main()
>sqrt(max--)
kys
>>
>>60131660
More small, extremely obvious fixes targeted at a code block intended to show a mathematical expression. You're still being pedantic, AND now you're being a butthurt idiot.
>>
>>60131671
*unzips dual stanford phd and $700k salary* heh... nothing personnel kid
>>
>>60131509
Map is an iterator adaptor, it works on lazy iterator objects, it takes an iterator and returns an iterator. It does this by mapping the result of the iterator's .next() method which is statically dispatched and can usually be inlined. It should give zero overhead as long as the .next() method isn't stupidly written. Usually it is an inline function.

Rust for loops are basically syntactic sugar for repeatedly calling the .next() method of the iterator, so it should have similar performance to maps and folds.
>>
>>60131699
You're nothing more than shitposter. You belong in /b/
>>
File: yeah_right.gif (1MB, 500x273px) Image search: [Google]
yeah_right.gif
1MB, 500x273px
>>60131724
>$700k salary
>shitposting on /g/
>on a weekend
>>
>>60131743
You're a grammar nazi who has the intelligence of an eighth grader. You belong in /r/programming.
>>
>>60131741
That's good. In most languages, I end up never using .map because all it does is make performance worse.In many languages, it doesn't even provide any readability benefits.

I'm glad rust isn't among them.
>>
>>60131775
>fixing programming mistakes
>"grammar nazi"
>>
>>60131764
>he doesn't test his NGO-funded AI shitpost bot on weekends
this is why you are small time. now fix my computer
>>
>>60131792
>i can't tell who is AI'ing who
>>
>>60131786
>every phrase in the english language has a single, literal meaning
Like I said: pedantic, and the intelligence of an eighth grader. Your posts are embarrassing, please stop making them.
>>
File: images.duckduckgo.com.jpg (1MB, 2163x3329px) Image search: [Google]
images.duckduckgo.com.jpg
1MB, 2163x3329px
>>60131815
This should help you out.
>>
>>60131825
Upvoted my good sir. It's really like I'm on the front page of the internet...
>>
>>60131777
https://godbolt.org/g/cj65Un

Example of for loops and .map compiling to basically the same assembly.
>>
>>60131960
I don't know, but both seem pretty awful actually. I wouldn't expect most of this in optimized code.
>>
>>60131995
Remove the call to println!() and the compiled assembly becomes a lot shorter.
>>
>>60132068
Hmm. Why would the print line macro expand to something so humongous? I mean, that's so much code, one call and ret wouldn't make much of a difference.
>>
Stupid code challenges are no way to compare two languages. If you must, try copying an existing C program and see how maintainable the result is.
>>
File: image.jpg (5KB, 300x57px) Image search: [Google]
image.jpg
5KB, 300x57px
>>60119727
look at rust only because of klabnik tbqfamafalman
>>
>>60132096
Random global optimizations kicking in apparently, due to assumptions about what can cause panics (throw exceptions).

When I ask Rust to just return the output, the assembly blows up again. But the C++ code example with O3 flags compiles to basically the same code using Clang as the Rust code does with Rustc. Most of the stuff is just generated by the LLVM backend I think.
https://godbolt.org/g/c0YLxJ
https://godbolt.org/g/lglzZK
>>
>>60132221
Rust and C both use curly braces so they're Turing-complete with respect to each other.
>>
>>60132708
#define { }


Who's laughing now, chump?
>>
>>60132750
Show me an example of any C program using that macro that will compile without errors under strict ANSI C89 mode.
>>
>>60132780
#if DERP
#define { }
#endif

int main(int argc, char** argv) {
return 0;
}
>>
>>60132750
lel are you pretending C has meta programming of any kind?
>>
>>60132826
That program doesn't ``use" the macro since it does not cause any transformation that survives the preprocessing stage.

>>60132833
You do realize that text-replacement macros are metaprogramming, right?
>>
>>60132908
#if JOKE
#define YOUR HEAD
#endif
>>
>>60132960
So then you admit that >>60132708 was correct?
>>
>>60131025
>>60131224
>>60131050
>remembering the right formula
>using it wrong and giving a wrong answer
Mathlet detected
>>
What do you guys think of RedoxOS? Written in Rust. It's a microkernel design OS.

https://www.redox-os.org/

https://www.youtube.com/watch?v=eH5JgMlNE8o
>>
>>60125185
C BTFO
>>
>>60134818
It's not written in rust, it's written in rust nightly like 100% of all rust projects.
>>
>>60136947
Well what does /g/ think about it?
>>
>>60137035
I think Rust is too immature for immediate use and thus all projects are similar. Those projects will pop up in a year or two being completely useable though. Rust stable is really unusable on its own, way too premature.
>>
>>60125185
>i32 in Rust code
>size_t is C code
The equivalent of i32 is int. I also printf arguments changed to get rid of warnings.

Then, comparing the assembly output of Rust's "-O" and GCC's "-O2", I found that "-O" is really equivalent "-O3" in this case.

lukasz@desktop:~/projects/scratch$ cat main.c && gcc -O3 main.c && time -p ./a.out
#include <stdio.h>

int main()
{
int total = 0;
for (int i = 0; i < 100000; i++)
{
for (int j = 0; j < i; j++)
{
total += (j * j == i) ? j : 0;
}
}

printf("%d\n", total);
return 0;
}
50085
real 1.35
user 1.34
sys 0.00


lukasz@desktop:~/projects/scratch$ cat main.rs && rustc -C opt-level=3 main.rs && time -p ./main
fn main() {
let mut total: i32 = 0i32;
for i in 1..100_001 {
for j in 1..i {
total += if (j*j) == i {j} else {0i32};
}
}
println!("{}", total);
}
50085
real 1.34
user 1.34
sys 0.00
>>
>>60137354
If rust is supposed to be based on safety, then why does their optimization default to O3?
>>
>>60137419
As the """C guy""", rust can probably infer more things about the code. It's completely irrelevant in a small example like this anyway.
>>
File: youropinion.gif (1MB, 480x270px) Image search: [Google]
youropinion.gif
1MB, 480x270px
>>60119490
>FreeBSD: Tier 2
>OpenBSD: Tier 3
>not working out of the box in RHEL 7
>>
>>60137491
So bottom line: Is it still safe with optimization?
>>
>>60137527
Since I don't know anything about Rust, sure why not.
>>
>>60137567
meh
>>
>>60137354
>"50085"
>people are still editing code that's incorrect
>>
>>60137064
this, everything looks promising in a "come back in a year or two" way
>>
Can I use rust for scripting?

I don't think I'd use rust for actual work but little scripts to replace python would be a nice start. Can I use it that way? Just a single code file in my ~/bin that will get compiled and run when I run it from the console?
>>
>>60119490
>pls be a faggy leftist

how about no?

pic related, the guy who shills rust, Steve Klabnik
>>
File: 1475781017382.png (197KB, 1920x1055px) Image search: [Google]
1475781017382.png
197KB, 1920x1055px
>>60137354
Yeah I get the similar results too. Good to see Rust is catching up.

>>60138413
Thank you anon for pointing that out. Here, I fixed it.

>>60138706
No other language is as productive as python. Rust is only about performance and safety, which you probable don't need.
>>
>>60138737
Rust user myself, I don't appreciate Steve's philosophy, you don't have to. Freedom of speech is one of the things we as a community respect.
Tldr, I learned how to agree to disagree.
>>
>>60139005
>probable
probably*
>>
>>60139027
>People I disagree with on a fundamental level develop something and actively use it to promote their own agenda
>I'm supposed to happily tak etheir cocks up my arse
>>
>>60139114
>>I'm supposed to happily tak etheir cocks up my arse
You don't have to. The technologies/products/services you use are made or invented by people who you may or may not agree with in terms of philosophy and that's fine.
>>
http://blog.steveklabnik.com/posts/2012-03-31-anti-capitalism-101

Steve Klabnik self-identifies as a commie.

This is the guy in charge of rust. Do you still want to use the language?

Fuck no.

Steve Klabnik can go die in a fire.


https://www.instagram.com/steveklabnik/

>>60139129

sure, but if my inclusion in their work forwards their agenda (which is harmful to what I believe) then I won't use what they make.
>>
>>60139150
> but if my inclusion in their work forwards their agenda
It won't. Unless of course if you actively push his agenda by yourself --which no one makes you do. Stop being childish, anon.

Computers are invented by a literal faggot. You are not one for using it.
>>
>>60139171
>It won't. Unless of course if you actively push his agenda by yourself
wrong, He'll get new users regardless.


>Computers are invented by a literal faggot. You are not one for using it.
Faggots are a-okay in my book.
>>
>>60139214
>He'll get new users regardless.
Rust is a community based project. It's not Steve's property.

>Faggots are a-okay in my book.
Not true for many others, including me.

Do you notice that you have no base line of argument left? The fact of life is, people that are able to grow thick skin are able to move on with their lives. It comes with age and maturity.
>>
>>60126557
Ada/C++ had lifetimes and borrow checking?
>>
>>60139241
>Rust is a community based project. It's not Steve's property.
So what? Stop changing goalposts.
>Not true for many others, including me.
okay


>Do you notice that you have no base line of argument left?
kek
I do have a base line left.
>The fact of life is, people that are able to grow thick skin are able to move on with their lives. It comes with age and maturity.

>implying political views are just intellectual masturbation even if they are put into action
Just because "Muh Freeze Peach" is real doesn't mean you should support every goddamned idea, or ignore it.

Growing a "thick skin", in your case, is to ignore reality.
>>
>>60139272
C++ stole some of the borrow checking ideas from Rust lately.
>>
>>60139315
Really? what did they steal?
>>
>>60139327
Borrow checks
>>
>>60139315
rust wouldn't exist if cramming more shit into c++ worked
>>
>>60139150
Wish he would allow comments on his blog. The example of the Kibbutzim de-collectivizing and adopting currencies after a few generations is the end-all argument for whether communism is natural: it isn't. However, once we have technocratic slavery, we'll have a society with more equal opportunity for humans.
>>
File: cancer.jpg (7KB, 201x81px) Image search: [Google]
cancer.jpg
7KB, 201x81px
>>60139483
>Wish he would allow comments on his blog. He has that cancer "Kudos" button.
>The example of the Kibbutzim de-collectivizing and adopting currencies after a few generations is the end-all argument for whether communism is natural: it isn't. However, once we have technocratic slavery, we'll have a society with more equal opportunity for humans.
What the FUCK did he mean by this?
>>
>>60139509
>He has that cancer "Kudos" button.
Kudos are like up-votes? I didn't see the button on the blog though, maybe it's my ad blocker or something.

>What the FUCK did he mean by this?
You mean me or his anti-capitalist tirade?
If you mean what I meant by technocratic slavery, I mean physical androids and machine learning AIs to do our bidding and gather information for us.
>>
>>60139541
>I don't see the button
http://words.steveklabnik.com/a-eulogy-for-my-20s
go to the end of the article. And these buttons are fucking retarded, they're basically social validation tools. If you really have balls you enable comments on your blog, and not some un-downvotable piece of crap.
>I mean physical androids and machine learning AIs to do our bidding and gather information for us.
Not really going to happen, it's either going to be super-buggy in most cases or borderline unconstitutional and creepy with all the data collection.

I, for one, would restrain myself from using that.
>>
>>60139573
>I, for one, would restrain myself from using that
At least it's better than connecting your mind to buggy ass hardware and software and risk dying or being placed in a situation of continuous torture or pain.
>>
>>60139592
>At least it's better than connecting your mind to buggy ass hardware and software and risk dying or being placed in a situation of continuous torture or pain.
yep.
Neural and body-machine interfaces are my personal nightmare. i don't see how they can ever be implemented well-enough.
>>
>go moves away from split stacks for stupid reasons
>Rust rapidly does the same thing

What's the point? Just use Go already. It's clear that Rust maintainers just copy what they do
>>
>>60121879
>FORTRAN

Python's Numpy allegedly also uses super-optimized fortran code for maths too. Where can I find this mythical code?
>>
>>60139830
BLAS (ATLAS, OpenBLAS, MKL and others) and stuff like LAPACK
>>
File: kek.jpg (4KB, 263x192px) Image search: [Google]
kek.jpg
4KB, 263x192px
>>60139816
>garbage collected
>>
>>60121879
The extent to which Cern uses C++ is absolutely horrifying. A lot of scripting is done with an in-house C++ interpreter. I wish I was kidding here.
>>
>>60140094
That's not the problem, D is GC'd too. However Go manages to produce slow binaries anyway.
>>
>>60139816
Maybe they made a good point for why do this so the others followed. Are you saying languages shouldn't evolve stealing the good ideas other languages brought?
>>
>>60140268
I mean you gotta respect Physicists they do the best data analysis in the business.
But God damn the coding practices are terrivle.
Atleast it is better than the engineers who do everything in fucking MATLAB.
>>
>>60121353
I too enjoy writing O(n^2) code to solve O(n) problems. Also, you picked an example that is basically the same in every language (with two flavors of looping or folding/recursion).
>>
What are some cool/nice things I can do with pattern matching?
>>
>>60143650
The goal is to benchmark, idiot, not to optimize. It's not O(n) it's O(1)
>>
>>60144443
get a gf
>>
>>60144957
The point of benchmarking isn't to write inefficient code. If you really want to micro benchmark something, then do something computationally difficult like calculating pi. The "benchmark" here is a measure of how well the compiler writes NOOP instructions for all those pointless iterations. Hell, you're not even measuring performance on heap allocated memory, which is where all these languages differ most.
>>
>>60139241
>rust is a community based project
their community is worse than node's
it seemed no one learned from the mistakes that javascript's ecosystem made.
fragmentation everywhere fucking hell.
>>
>>60140268
>using one of the fastest and best established languages
>"horrifying"
What's horrifying is the increase in the number of languages simply because every faggot thinks he is a special snowflake with special snowflake ideas about how a language should work.
>>
>>60144957
>The goal is to benchmark, idiot, not to optimize. It's not O(n) it's O(1)
The original problem description does not match what the code is doing. The problem description can be solved in O(1). What it appears to be doing requires O(n). And the guy you replied to is not the idiot. It's absolutely useless as a benchmark.

Also: isn't most of the code (>>60139005) benchmarking compiler+execution? WTF is the point of that?

>>60145514
This guy gets it.
Thread posts: 213
Thread images: 13


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.