These are chat archives for rust-lang/rust

18th
Aug 2016
Erik Hedvall
@Ogeon
Aug 18 2016 00:02
@rprotasov Nice! :smile:
Mark Fulop
@fulopm
Aug 18 2016 10:30
Hey, how good alternative is Rust against Erlang? For a multithreaded TCP socket server with database access.
Zakarum
@omni-viral
Aug 18 2016 12:36
They are so different. Both have pros and cons.
Erlang (as I know) was designed for high parallelism
While Rust was designed for zero-cost everything
Of course you can use Rust for multithreaded TCP socket server with database access.
There are some good crates for multithreading, netwoking, databese access
Check on crates.io
Zakarum
@omni-viral
Aug 18 2016 12:41
Also check awesome-rust
Mark Fulop
@fulopm
Aug 18 2016 12:42
thanks @SCareAngel
Robert Deusser
@iamthemuffinman
Aug 18 2016 13:43
@SCareAngel High paralleism was certainly a goal, but I believe Erlang was designed with the "always up" mentality.
ousado
@ousado
Aug 18 2016 13:48
.. and they both go hand in hand
LeonineKing1199
@LeonineKing1199
Aug 18 2016 14:55
Erlang's concurrency is an interesting approach, given its usage of a vm.
But still, you don't see Nvidia writing their CUDA API in Erlang.
Though it seems like Erlang would be really good for writing a http server.
Romet Tagobert
@amPerl
Aug 18 2016 14:57
Something like http://www.phoenixframework.org/ ? :)
Robert Deusser
@iamthemuffinman
Aug 18 2016 14:58
@amPerl Phoenix is written in Elixir which is built on the Erlang VM (BEAM). :)
LeonineKing1199
@LeonineKing1199
Aug 18 2016 14:58
I was just on the wiki and it seems like Erlang is a popular choice for distributed databases.
Robert Deusser
@iamthemuffinman
Aug 18 2016 14:58
@LeonineKing1199 You wouldn't use Erlang for something that low-level. http://whyerlang.com/
LeonineKing1199
@LeonineKing1199
Aug 18 2016 14:59
The way it's supposed to offer communication between it's pseudo-processes is appealing.
Robert Deusser
@iamthemuffinman
Aug 18 2016 15:00
It really is. The BEAM VM is a thing of beauty.
LeonineKing1199
@LeonineKing1199
Aug 18 2016 15:00
I feel like "lightweight concurrency" should be in quotes.
"lightweight"
I bet Rust and C++ threads are more "lightweight"
Because they're actual threads.
Robert Deusser
@iamthemuffinman
Aug 18 2016 15:00
I think it would be awesome if Python ran on the BEAM VM.
Sergey Noskov
@Albibek
Aug 18 2016 15:01
N:M threading is very controversial, there are still many debates about green threads vs native threads. Green hreads map to nativs(i.e. OS) threads anyways. In Rust you can have green threads, but you need to write custom scheduler or use the existing one. In erlang you just don't think about things like that. It's sometimes convenient, but sometimes unapplicable.
LeonineKing1199
@LeonineKing1199
Aug 18 2016 15:02
Seems interesting though. And a much more palatable functional language than Haskell.
Robert Deusser
@iamthemuffinman
Aug 18 2016 15:02
Erlang is hard to stomach.
LeonineKing1199
@LeonineKing1199
Aug 18 2016 15:02
To me, its main draw is its ability to work distributed.
Robert Deusser
@iamthemuffinman
Aug 18 2016 15:02
Elixir is a little better.
I love that Erlang processes are independent of the OS.
Sergey Noskov
@Albibek
Aug 18 2016 15:03
The Erlang itself is pretty easy in terms of syntax, but you have to learn OTP principles after that
Robert Deusser
@iamthemuffinman
Aug 18 2016 15:03
The syntax is just weird. It doesn't really flow with me.
LeonineKing1199
@LeonineKing1199
Aug 18 2016 15:04
I'm a dinosaur, the only syntaxes that make sense to me are the C-like ones.
Robert Deusser
@iamthemuffinman
Aug 18 2016 15:04
@LeonineKing1199 Same here.
LeonineKing1199
@LeonineKing1199
Aug 18 2016 15:04
Computers do one thing and then the other! The language should reflect that! XD
I would've super gotten into Haskell if it was more low-level.
Rurst seems appealing in this regard because it seems like it supports functional stuff better than the other statically compiled languages.
Btw, what IDE do you guys use for Rust?
All I could find was an Atom plugin T_T
@LeonineKing1199 really? I had the impression that FP support was largely on the level of Java 8.
the borrow checker hates you really fast if you keep chaining combinators with lambdas.
LeonineKing1199
@LeonineKing1199
Aug 18 2016 15:07
XD
I haven't really used Java all that much though.
Robert Deusser
@iamthemuffinman
Aug 18 2016 15:09
@LeonineKing1199 I use Vim.
LeonineKing1199
@LeonineKing1199
Aug 18 2016 15:09
Lame. lol.
I tried out Rust the other day and then I was like, "Um... What IDE do I use?" O_o
ven
@vendethiel
Aug 18 2016 15:10
To be fair, there's not much boilerplate, so ..:)
Robert Deusser
@iamthemuffinman
Aug 18 2016 15:10
Hey, vim is the way to go.
ven
@vendethiel
Aug 18 2016 15:15
surely this is not a good place to start an editor war..
Robert Deusser
@iamthemuffinman
Aug 18 2016 15:15
Haha, good point.
Zakarum
@omni-viral
Aug 18 2016 15:26
@soc the borrow checker don't hate you. The borrow checker is your friend. Chain combinators with lambdas without borrowing errors next time and you'll see )
yeah, that's the point. if you write perfect code 100% of the time, you will never have issues with anything.
in the other case, you need a good compiler that can pinpoint what's wrong.
LeonineKing1199
@LeonineKing1199
Aug 18 2016 15:32

surely this is not a good place to start an editor war..

I was mostly just looking for any Rust-focused IDE

And not just an Atom plugin (I don't like Atom)
Robert Deusser
@iamthemuffinman
Aug 18 2016 15:32
What don't you like about Atom? Just curious.
Zakarum
@omni-viral
Aug 18 2016 15:42
@soc And Rust compiler (with borrow checker) helps you to write that perfect code.
@LeonineKing1199 I was using Visual Stuido Code for a while, also tried Subleme Text and Atom.
Robert Deusser
@iamthemuffinman
Aug 18 2016 15:43
@SCareAngel That's one of the biggest reasons I use Rust. What editor do you use now?
Zakarum
@omni-viral
Aug 18 2016 15:48
@iamthemuffinman I'm gonna try vim now
I heard of the learning curve. Maybe I'll find enough patience )
Robert Deusser
@iamthemuffinman
Aug 18 2016 15:49
I love using it.
I'll show you what I use.
(I'm going to boil all this down because it's important)
This for vim with customisation (it has the rust-vim plugin): https://github.com/spf13/spf13-vim
Thomas Koehler
@Bastacyclop
Aug 18 2016 15:52
I've been using neovim for a while, haven't had any issue yet and it feels fresh
Robert Deusser
@iamthemuffinman
Aug 18 2016 15:52
@Bastacyclop I've yet to try neovim.
Thomas Koehler
@Bastacyclop
Aug 18 2016 15:53
really didn't change my config much
Robert Deusser
@iamthemuffinman
Aug 18 2016 15:55
And this tmux config: https://github.com/gpakosz/.tmux
with some customization.
All that tied together makes for a beautiful coding experience.
Thomas Koehler
@Bastacyclop
Aug 18 2016 15:55
combined with this https://github.com/junegunn/vim-plug everything feels faster xd
Robert Deusser
@iamthemuffinman
Aug 18 2016 15:56
Ooooohhh.
It looks pretty too.
James Lucas
@AtheMathmo
Aug 18 2016 16:12

Apologies if this isn't the right place to discuss this.

I'm trying to profile a piece of code in a library right now (crate A). I made a new binary project (crate B) which calls the function I'm profiling in main. In the profiler output I see 93% of my time in main and some other time spent in functions in dependent crates C,D,E,... but no breakdown of the functions in crate A.

Is there any reason why this might be expected? Or is it probably something I'm doing wrong?

Oh one other thing - crate B is linking to crate A via a local path in it's manifest
James Lucas
@AtheMathmo
Aug 18 2016 16:19
Found the issue... I forgot that I had force-inlined a lot of the functions :D
Mark Fulop
@fulopm
Aug 18 2016 19:35
In the third line, the vector's mutable ownership is automatically borrowed?
let mut vs = vec![1,2,3,4];
for v in &vs {
    vs.pop();
}
of course if the immutable one hadn't borrowed by the loop
Thomas Koehler
@Bastacyclop
Aug 18 2016 20:33
@fulopm I don't understand your question
Mark Fulop
@fulopm
Aug 18 2016 20:46
@Bastacyclop, The simplified question is something like this: if I access a variable (like in the loop body), I'm automatically borrowing the ownership of the variable's data?
Thomas Koehler
@Bastacyclop
Aug 18 2016 20:47
it depends of how you access it
have you read the Book ?
Mark Fulop
@fulopm
Aug 18 2016 20:50
not yet
but I'll do
Thomas Koehler
@Bastacyclop
Aug 18 2016 20:54
the owernship stuff begins here https://doc.rust-lang.org/book/ownership.html
then there is References, Borrowing and Lifetimes
Mark Fulop
@fulopm
Aug 18 2016 20:58
thanks, I'll look into it
Sergey Noskov
@Albibek
Aug 18 2016 20:58
Ownership is a big part of compiler and language semantics, that's why you'd better read those chapters in the book