
A Rust FFI adventure in unsafety - fanf2
https://travisf.net/capstone-rs-unsafety-adventure
======
Accipitriform
Excellent and detailed post!

Up until now I've been focusing on Julia and Swift for projects that can use a
new language, as the Rust pain/productivity ratio has looked too high.

Perhaps things are changing...correctness is certainly a worthy goal!

~~~
ilovecaching
I've been using Rust in production for a little over half a year, and my team
and I have run into very few issues. We're also calling through the FFI to an
SGX SDK and a large C++ codebase, and that's been delightfully painless.

We're all extremely glad we chucked C++ and Go and switched to Rust. Rust
isn't just a safer C++, it's a language that stands on it's own as extremely
productive, safe, and fun to write. We combat the learning curve by giving
people the O'Reilly book and the main Rust book, and we find new team members
becoming productive in about a week. The Rust community is also amazing, and
Cargo + RLS are the _best_ ecosystem tools I've seen in any language.

I highly recommend Rust. If you have any questions, feel free to ask here.
We're extremely bullish on Rust continuing to accelerate.

~~~
Nelkins
What do you use as your development environment?

~~~
ilovecaching
vim + w0rp/ale, ale has LSP support and I now use it as a one stop shop for go
to dec, find refs, and autocomplete. It has support for linting with cargo,
rustc, rls, and autoformatting with rustfmt. rustup makes installing rls
extremely painless.

~~~
imc
mind sticking up the relevant sections of your vimrc somewhere so I could take
a look?

the rust stuff in my vim dates to v. early post 1.0 and would love to link ale
+ rls up.

~~~
ilovecaching
Sure, install w0rp/ale using your favorite plugin manager, install rustup and
run:

    
    
      rustup component add rls-preview rust-analysis rust-src --toolchain nightly
    

then add this to .vim/ftplugin/rust.vim:

    
    
      let b:ale_linters = {'rust': ['rls','cargo','rustc']}
      let g:ale_fixers = {'rust': ['rustfmt']}
      let g:ale_completion_enabled = 1

~~~
imc
perfect, thanks!

------
wyldfire
> We wanted a primitive that would guarantee that initialization of the global
> variables would happen exactly once.

IIRC, At one time, there was a "lazy_static!" that fit this use case? But
maybe you can't do that here if what you need is the side-effect of the
library call.

~~~
epage
Also, there is `once_cell` that seems to be a more general form

[https://crates.io/crates/once_cell](https://crates.io/crates/once_cell)

------
undefined_user4
See, this is why you need the lines above and below the letter I. I thought
this was a Rust remake of Final Fantasy 1. So disappointing...

~~~
kbenson
> the lines above and below the letter

Serifs is the word you are looking for.

Hmm, from examining the font style in the stylesheet, and playing around it
looks like Verdana is preferred, and then it falls back to Geneva, and then
some default sans-serif.[1] Verdana has serifs though, and Geneva either
doesn't or I don't have Geneva, so that seems an odd choice of preferences and
fall backs.

1: The CSS is "font-family:Verdana, Geneva, sans-serif;"

~~~
undefined_user4
Looks like you've outnerded me. Well done.

~~~
kbenson
Hmm, what was lost in revising that comment was the sentence noting that I
have swrifs on every device I view HN on, so I was wondering what you were
viewing it on. It seems odd that it would change that much between devices
when explicitly defined with fallbacks, which is why it's an odd config.

