These are chat archives for rust-lang/rust

30th
Nov 2017
rishflab
@rishflab
Nov 30 2017 08:59
How do read a specific chunk of a file without loading the whole file into memory?
Aleksey Kladov
@matklad
Nov 30 2017 08:59
You might also want to look into mmap: https://github.com/danburkert/memmap-rs
rishflab
@rishflab
Nov 30 2017 09:03
ok thanks ill have a look
Adil Ilhan
@adililhan
Nov 30 2017 14:35
Hi all
about threads.
according to the document, it should be mixed.
i copy/paste that code to play.rust-lang.org
Steve Klabnik
@steveklabnik
Nov 30 2017 14:36
it depends on your OS
Adil Ilhan
@adililhan
Nov 30 2017 14:37
it doesn't mix
i ran that code in my pc as well. i got same result
Steve Klabnik
@steveklabnik
Nov 30 2017 14:37
yeah
it's non-deterministic
it may happen in order, it may not. it entirely depends
it's up to your os
Adil Ilhan
@adililhan
Nov 30 2017 14:38
i click "play button", which runs same code on doc.rust-lang.org
i got same result on there as well
Steve Klabnik
@steveklabnik
Nov 30 2017 14:38
yes
that may happen
Adil Ilhan
@adililhan
Nov 30 2017 14:39
is it coincidence?
Steve Klabnik
@steveklabnik
Nov 30 2017 14:39
yup
Adil Ilhan
@adililhan
Nov 30 2017 14:39
i got same results on different 3 servers.
hmm
Steve Klabnik
@steveklabnik
Nov 30 2017 14:39
that is 100% reasonable
if the OS decides to sleep the new thread until join() is called, you get that behavior
but it doesn't have to, it could switch to the new thread immedaitely, it could switch back and forth
but you can't actually know
Denis Lisov
@tanriol
Nov 30 2017 14:40
Printing is fast, switching so often would be... not exactly expected :-)
hi number 3452 from the main thread!
hi number 3453 from the main thread!
hi number 1 from the spawned thread!
hi number 2 from the spawned thread!
hi number 3 from the spawned thread!
hi number 4 from the spawned thread!
hi number 5 from the spawned thread!
hi number 6 from the spawned thread!
hi number 7 from the spawned thread!
hi number 8 from the spawned thread!
hi number 9 from the spawned thread!
hi number 3454 from the main thread!
hi number 3455 from the main thread!
(this is from play.rust-lang.org)
Adil Ilhan
@adililhan
Nov 30 2017 14:45
i see
Wouter De Coster
@wdecoster
Nov 30 2017 15:31
Hi, I have experience in Python and would like to learn a second language for speeding up some more computationally heavy parts, while keeping it integrated with the Python code. Would something like that be possible with Rust?
Steve Klabnik
@steveklabnik
Nov 30 2017 15:32
very much so!
there are even companies doing this with real products that make money :)
This second look ultimately became the Milksnake Python library, which can (among other things) be used for building Python packages that include Rust code. We use this in production for all our Rust code now and feel confident sharing it with the wider world.
Wouter De Coster
@wdecoster
Nov 30 2017 15:33
Making money would be a nice side effect :D
Thanks for the link!
Steve Klabnik
@steveklabnik
Nov 30 2017 15:33
np. this isn't the only way to do it, but it is the most recent
Zakarum
@omni-viral
Nov 30 2017 15:55

Making money would be a nice side effect

With side effects like this I can see why some people don't like Haskell

Nikolay Kim
@fafhrd91
Nov 30 2017 16:01
I use it in production
Wouter De Coster
@wdecoster
Nov 30 2017 16:18
What can you say about the learning curve for rust?
Steve Klabnik
@steveklabnik
Nov 30 2017 16:19
  1. we're trying to lower it, generally
  1. most people experience some difficulty for a bit, and then it clicks
Zakarum
@omni-viral
Nov 30 2017 16:19
  1. You like rust in general.
  2. You hate borrow checker but like all other features.
  3. You love borrow checker.
Mac O'Brien
@cormac-obrien
Nov 30 2017 16:20
^^^
Michal 'vorner' Vaner
@vorner
Nov 30 2017 16:20
(and then most of the other programming languages seem inadequate and make no sense)
Zakarum
@omni-viral
Nov 30 2017 16:20
@vorner because there's no borrow checker
Wouter De Coster
@wdecoster
Nov 30 2017 16:20
hehe we'll see how it goes, I guess I start with going through "the book"?
Mac O'Brien
@cormac-obrien
Nov 30 2017 16:21
rust basically made me relearn to program and it's p great
Steve Klabnik
@steveklabnik
Nov 30 2017 16:21
@wdecoster i'd say yes but im a co-author and thus biased ;)
second edition for sure
Wouter De Coster
@wdecoster
Nov 30 2017 16:22
that's also something I hope to get out of this. I have been using Python and a bit of R for ~2.5y now and think I can get a deeper understanding of programming in general by learning another language
Michal 'vorner' Vaner
@vorner
Nov 30 2017 16:22
@wdecoster That's a good default way to learn Rust. Just expect it might not go 100% smooth.
Wouter De Coster
@wdecoster
Nov 30 2017 16:22
I haven't learned everything there is to learn in Python
I hate R :)
Zakarum
@omni-viral
Nov 30 2017 16:29
@wdecoster Python is nice an easy. Rust is strict and force you to define all invariants that compiler won't be able to guess.
But it allows you to express semantic of the program better
And program compiled will be as fast as it can possibly be
Michal 'vorner' Vaner
@vorner
Nov 30 2017 16:31
Well, that's not necessarily true ‒ you can write a slow program in Rust. But it gives you the tools to write a fast program.
Wouter De Coster
@wdecoster
Nov 30 2017 16:32
oh I will for sure write slow programs
Zakarum
@omni-viral
Nov 30 2017 16:32
@vorner Well. Of course. I meant "If you use it right"
Wouter De Coster
@wdecoster
Nov 30 2017 16:32
to start with
Ty Coghlan
@Ophirr33
Nov 30 2017 18:21
Could anyone glance over a quick script I made to check whether files in a directory are made of only the null byte? I tried to make the file processing parallel with rayon, and I wanted to get a second pair of eyes on it to make sure that I'm making it parallel correctly
Judson Lester
@nyarly
Nov 30 2017 20:41
@wdecoster Candidly, I really wish I'd paired with someone experienced for my first few Rust sessions.
And I basically never pair.
But there's weird new intuitions to develop. I keep chewing on what they are exactly.
I keep thinking "Rust has gravity" but no one else seems to think that makes sense.
Wouter De Coster
@wdecoster
Nov 30 2017 22:16
I don't think I have anyone who could do this, I don't know anyone using Rust.