News for hackers. Stuff that matters.
Re:Rust in 2017: what we achieved by pohl on Thursday December 21, 2017 @01:53PM (#15981675)
The first thing I did when my holiday break started was to configure Visual Studio Code with RLS and work through the examples in the O'Reilly Programming Rust book. There are some rough edges, but it's amazing how far the tooling has come.
Re:Rust in 2017: what we achieved by rhexs on Thursday December 21, 2017 @06:14PM (#15983799)
How's the O'Reilly book so far? I made it through the second edition of the rust book but found it a bit lacking as a novice. I think a second time through the Rust book after writing a few programs will be really useful, but I wouldn't mind trying the O'Reilly one as well.
Re:Rust in 2017: what we achieved by pohl on Thursday December 21, 2017 @07:19PM (#15984160)
I’m happy with it. I totally agree with mlevental‘s assessment of the intro. Just getting through that boosted my feeling of competency a lot. I’ve been anticipating this book for a long time, and I’m not disappointed at all.
Re:Rust in 2017: what we achieved by steveklabnik on Thursday December 21, 2017 @06:20PM (#15983837)
I’m pumped to get my paper copy shortly after the new year :)

If you’ve got some time to elaborate on how you struggled with the book, I’d be interested in hearing about it!

Re:Rust in 2017: what we achieved by rhexs on Thursday December 21, 2017 @07:26PM (#15984222)
I think my original statement came off a bit harsh. For more context, I'm a C programmer who managed to avoid C++ and templating for...too long. Rust just has a lot of new (to me) ideas that will probably take a bit longer for me to grasp than other programmers.

As an example, reading the official documentation at first was an absolute struggle due to all the terminology and syntax I was only vaguely familiar from the book. It's getting easier as I practice more.

The more documentation -- the merrier. Thanks a ton for your work!

Re:Rust in 2017: what we achieved by steveklabnik on Thursday December 21, 2017 @09:09PM (#15984734)
Cool cool, no worries. You’re quite welcome!
Re:Rust in 2017: what we achieved by sohkamyung on Thursday December 21, 2017 @07:58PM (#15984407)
I've just started reading it and it looks good. The chapters on ownership and borrowing really clarify how it works in Rust.
Re:Rust in 2017: what we achieved by cevn on Thursday December 21, 2017 @02:13PM (#15981863)
Can you use a debugger yet? This was a major roadblock for me when I tried to learn rust. (other than lldb)
Re:Rust in 2017: what we achieved by tromey on Thursday December 21, 2017 @06:25PM (#15983883)
Rust support landed in gdb 7.12 (released October 2016). It has some rough edges; and some missing spots (mostly caused by insufficient debuginfo).

I'm working full time on Rust debugging now. My basic plan is to write a Rust plugin for lldb (WIP branch https://github.com/tromey/lldb/tree/rust); then update LLVM, rustc, lldb, and gdb in sync to add support for missing features.

I'm interested in bug reports and other constructive feedback.

Re:Rust in 2017: what we achieved by mikebenfield on Thursday December 21, 2017 @04:38PM (#15983027)
LLDB works well enough to sometimes be useful. I've used it with the VS Code native debugger extension [1].

I've encountered a couple annoyances:

A. Using rustc to link somehow removes debugging information from static libraries I wrote in assembly [2]. This is extremely annoying, but I haven't had time to really look into it and it seems others can't reproduce it.

B. There seem to be some occasional oddball problems when stepping through code. Like it'll skip lines, or stay on the same line for many steps. And also an annoyance regarding how that VS Code extension handles "Step Into" for functions you don't have the source for: you can easily get into an infinite popup situation and have to restart the debugger.

IMO the sad truth is that if a great debugger is a prerequisite to use a language, then you're limited to about 5 total languages.

[1] https://marketplace.visualstudio.com/items?itemName=webfreak...

[2] https://github.com/rust-lang/rust/issues/45218

Re:Rust in 2017: what we achieved by bluejekyll on Thursday December 21, 2017 @04:45PM (#15983089)
> Like it'll skip lines, or stay on the same line for many steps.

I've never hit these problems, though I have the source for everything I'm compiling in Rust in general.

Re:Rust in 2017: what we achieved by syn_rst on Thursday December 21, 2017 @06:03PM (#15983708)
I've run into it before, but it's not usually too serious. It only usually happens on lines with compound expressions or chained calls like this:

  foo.into_iter().map(|x| x+1)
     .filter(|y| y > 2)
My working theory is that it's related to situations where there's multiple statements on the same source line (or inside a block inside a lambda).
Re:Rust in 2017: what we achieved by bluejekyll on Thursday December 21, 2017 @06:17PM (#15983816)
Yeah, quite possibly. I feel like I've stepped through some pretty gnarly iterator chains and it's worked surprisingly well. It is rare that I actually need to turn to the debugger, so I could be mistaken.
Re:Rust in 2017: what we achieved by pohl on Thursday December 21, 2017 @03:57PM (#15982674)
So far I haven't encountered a problem that wasn't caught at compile-time.

However, your question prompted me to see if I could set a breakpoint and step through a program, and I was able to do it without much effort.

I have the "LLDB Debugger" extension in VSC installed. After that, the trick was to configure its launch.json to have the "program" property set to "${workspaceRoot}/target/debug/mandelbrot".

That's all it took.

Maybe I'd encounter some shortcoming trying to actually use it in anger, but I was happy to be able to do this much.

Re:Rust in 2017: what we achieved by shabbyrobe on Thursday December 21, 2017 @05:52PM (#15983623)
This is encouraging! In my experience, getting to this stage - where you've actually seen the thing successfully hit a breakpoint - is 95% of the hard work with debugging. I'm not a heavy debugger user, I prefer trace logging, rich type systems and tests for most problems, but then that one time when you have no choice but to "use it in anger", it simply has to be there.

I seem to run afoul of some obscure, ungooglable edge case almost every time I try to start a debugger I don't use very often, regardless of the platform. Of course this happens when I'm frustrated enough to be considering using a debugger in the first place, which is exactly when you don't want to be rage-googling why your debugger refuses to print symbol names, but only when you start it with exactly the arguments you need to start it with to trigger the bug. Or when you try to send an email more than 500 miles away Or print on a Tuesday. By that point, your debugger problem is worse than your original bug.

There's a strong sense from a vocal portion of the software development community that debuggers aren't really needed (not suggesting that this is you, just a general observation). Coupled with the fact that building a functioning debugging tool is no easy task, we end up in a situation where far too many platforms treat debugging as a second class citizen when it's really an essential feature, even if for some of us it's a feature of last resort.

Re:Rust in 2017: what we achieved by steveklabnik on Thursday December 21, 2017 @02:15PM (#15981890)
Newer GDBs have native support; Visual Studio (not Code, but also Code)'s debugger works too (we generate pdb files). Older gdbs and lldb can use a plugin/script.
Re:Rust in 2017: what we achieved by Manishearth on Friday December 22, 2017 @12:11AM (#15985399)
When was this? Rust has been able to pretend to be C for years, now, and debugs pretty ok. However until last year you could not do things like call functions (in gdb, lldb doesn't have support yet).

We're now moving towards making Rust have Rust-specific debuginfo for a better debugging experience. tromey (who has commented below) is working on this both for lldb and gdb.

Re:Rust in 2017: what we achieved by gattr on Thursday December 21, 2017 @06:32PM (#15983923)
I'm an Eclipse guy and when writing this [1] for fun, debugging in Eclipse worked fine (I'm on Fedora). Code completion via Racer mostly works (except some cases like recognizing the type of the try! macro's result).

[1] https://github.com/GreatAttractor/libskry_r

Re:Rust in 2017: what we achieved by bluejekyll on Thursday December 21, 2017 @04:42PM (#15983057)
I've been using LLDB for well over a year with integration into VSCode for GUI based stepping through code, etc.

There's a minor inconvenience of setting up targets for the LLDB to launch tests, etc, but for when it's needed this isn't a huge effort to get going.

I've not yet tried IntelliJ's CLion integration, which I think I've heard is good.

Re:Rust in 2017: what we achieved by arianvanp on Thursday December 21, 2017 @05:23PM (#15983400)
GDB works like a charm! Works nicely with VSCode or any other visual tool for GDB as well
Re:Rust in 2017: what we achieved by atomashpolskiy on Thursday December 21, 2017 @05:44PM (#15983564)
For some reason I can't see sources in GDB (both in tui and terminal modes). I've tried different versions from 6.x to 8.0.1 with no luck.
Re:Rust in 2017: what we achieved by Scarbutt on Thursday December 21, 2017 @04:07PM (#15982757)
Is a debugger really a hard requirement for learning a language?
Re:Rust in 2017: what we achieved by dboreham on Thursday December 21, 2017 @04:21PM (#15982878)
Learning no. Using, I think yes.
Re:Rust in 2017: what we achieved by burntsushi on Thursday December 21, 2017 @04:44PM (#15983075)
For what it's worth, while I would regularly use a debugger for C code, I've never once tried or had the urge to use a debugger on Rust code. (I've been using Rust for almost 4 years.)
Re:Rust in 2017: what we achieved by accatyyc on Thursday December 21, 2017 @05:14PM (#15983342)
I usually don’t use the debugger to debug language features, but rather my own logic. It’s very useful to step and inspect parameters when you can’t really see your own logic errors.
Re:Rust in 2017: what we achieved by vvanders on Thursday December 21, 2017 @05:39PM (#15983519)
I have to say that my own experience over the last two years matches burntsusih's pretty close.

In the case of logic stuff Tagged Union/Enum types help me force logic at compile time. If I've got a particularly intractable logic problem a good coverage of unit tests works well to flush out any bugs and give me confidence when it comes to refactoring.

There's been a handful of times that I've wanted to reach for the debugger but a couple inspect()/println!() calls did the trick in those cases.

Re:Rust in 2017: what we achieved by slezyr on Thursday December 21, 2017 @02:23PM (#15981934)
clion, atom(not sure), visual code support debugging
Re:Rust in 2017: what we achieved by mlevental on Thursday December 21, 2017 @02:47PM (#15982171)
and that book, programming rust, is very good. I was able to write a microservice (thin wrapper around redis) after just having read the intro.