HNHacker News
TopNewBestAskShowJobs

dikaiosune

4,199 karma · joined December 10, 2014

http://blog.adamperry.me
submissionscomments
dikaiosune··on Images of New MacBook Pro with Magic Toolbar Leaked in MacOS Sierra 10.12.1
If I understand your suggestion, ctrl+c doesn't work in all the contexts where I use escape (modal dialogs, editor autocomplete popups, etc).
dikaiosune··on Images of New MacBook Pro with Magic Toolbar Leaked in MacOS Sierra 10.12.1
Do you never use the Esc key without looking?
dikaiosune··on Librsvg gets Rusty
Awesome!

I wonder if instead of using a boolean field in the Segment struct, better results might be attained by using a tagged union (enum in Rust-speak):

    struct Point {
        x: f64, y: f64
    }

    enum Segment {
        Degenerate {
            p1: Point,
        },
    
        Full {
            p1: Point,
            p2: Point,
            p3: Point,
            p4: Point,
        }
    }
    
    impl Segment {
        fn upgrade(&mut self, 
                   p2: Point, 
                   p3: Point, 
                   p4: Point) {
    
            match *self {
                Segment::Degenerate { p1 } => {
                    *self = Segment::Full {
                        p1: p1,
                        p2: p2,
                        p3: p3,
                        p4: p4,
                    };
                }
                
                _ => ()
            }
        }
    }
I wonder if you could also get away without using the has_first_segment variable by using the Vec::len method:

    if segments.len() > 0 {
        segment_number += 1;
    }
Of course, that's assuming the author doesn't find a better way to represent the pattern of accessing the previous, half-built segment. I suspect you could perhaps do so by creating a mutable partial Segment on the stack from an iterator's first element, and then actually looping over the remaining items in the iterator to actually construct segments, adding them to the Vec as you go.

EDIT: It doesn't look like this thread is going anywhere, but I saw a comment on the Rust subreddit to use a Point struct which I quite liked, and incorporated here.

dikaiosune··on 2017 Rust Roadmap
Swift still has automatic memory management. It may not have a tracing GC, buy that's not super relevant from an ergonomics perspective (except that potential cycles require extra work/annotations).
dikaiosune··on 2017 Rust Roadmap
There's certainly a difference between writing one's own unsafe blocks and relying on functionality which was implemented using unsafe in a community project (which has hopefully been vetted by some community members).
dikaiosune··on 2017 Rust Roadmap
I definitely haven't seen anything as comprehensive as the linked PDF for Rust (although that shouldn't be surprising given the extreme thoroughness of that guide and the age of C++). Probably a good project!

When doing very performance sensitive things in Rust, I usually find myself asking questions a lot on IRC and looking at disassembly in perf.

To answer some specific examples you cited above: I'm pretty sure that enums are (almost?) always equivalent to tagged unions. If you have an enum which doesn't contain any data, then I believe it's representation is just the tag. Iterators are just structs with methods, the various generic functions they implement are monomorphized and then optimized by LLVM.

dikaiosune··on 2017 Rust Roadmap
FFI through a C ABI is how Rust <-> C++ currently works, but IIUC it's quite limiting when one might want to make use of C++ specific features. Especially important when a given C++ project doesn't have a fully-featured C API, or any C API at all.
dikaiosune··on 2017 Rust Roadmap
I would offer a counterpoint -- Rust's guarantees and strong typing offer a different kind of productivity to an intermediate or experienced user. One where a compiled program is much more likely to be "correct" than in any other mainstream-esque language I've used. The properties which combine to create this effect make refactoring much less scary, allow easier navigation in large codebases (IMO), and allow for other valuable properties for productivity.
dikaiosune··on 2017 Rust Roadmap
Is there an equivalent guide to the compile-time representation of important constructs for those trying to learn C/C++? I haven't seen anything like that and it seems like most devs in that realm instead rely on experience and tribal knowledge (which is, AFAICT, how it often works in Rust-land right now). I agree it'd be great for Rust to have clearer official docs about some of these things, but it doesn't seem to me like this is readily available for most languages or runtimes.

Re: unsafe, I think that's tough. My personal feeling is that many of Rust's selling points rely on minimizing the use of unsafe (i.e. limiting segfault-relevant portions of the code), and that there are frequently ways to make things work and also make them fast without using unsafe. What's an example where you found yourself thinking about using unsafe instead of a more complex safe construct?

(Somewhat related to this, and especially for anyone reading who might try Rust, I cannot recommend getting on IRC strongly enough. The Rust IRC channels are by and large incredibly friendly and helpful, and for better or worse that's where a lot of the knowledge in the community is currently collected, not as much SO or blogs)

dikaiosune··on 2017 Rust Roadmap
Is this based on your experience learning lifetimes in Rust? I very rarely find myself needing to do convoluted lifetime tricks -- most of the code I write doesn't even need explicit annotations. So I'd be curious to hear what project you may have worked on as a beginner where lifetime management because a serious obstacle.
dikaiosune··on 2017 Rust Roadmap
It's important to note that this is an RFC which has been proposed, and there's likely to be a good deal of discussion and revision before it's merged/adopted as the official 2017 roadmap.

The conversation can be followed/joined/whatever here: https://github.com/rust-lang/rfcs/pull/1774

dikaiosune··on Fixing Python Performance with Rust
I would wager this has more to do with the potential for 2 GCs to interact poorly than with GC in general.
dikaiosune··on Fixing Python Performance with Rust
I'm glad it helped! Sorry if it came on strong.
dikaiosune··on Fixing Python Performance with Rust
I'm referring to the definitions of the Rust functions.

As far as I know, `#[no_mangle]` disables name-mangling but doesn't change the ABI of a function. That's what `extern "C"` is for in Rust -- to declare a function with the C ABI. You can have a Rust ABI function with an unmangled name (what it looks is done in the post) and you can have a C ABI function in Rust with a mangled name (by using `extern "C"` but not `#[no_mangle]` -- for example for C callbacks).

Based on my limited understanding of C++, `extern "c"` in C++ is equivalent to using both `#[no_mangle]` and `pub extern "C"` in Rust. I would guess that much of the time failing to specify a C ABI would work out fine unless you try to accept or pass non-FFI types (enums, references, etc) but I'm not sure.

It's confusing as hell. There was a thread about the mixed up semantics somewhat recently on the internals forum: https://internals.rust-lang.org/t/no-no-mangle/3973 (edit: and also https://internals.rust-lang.org/t/precise-semantics-of-no-ma...).

If you look at the LLVM IR generated from https://is.gd/Hfup3X you can see that the extern "C" fn differs in that it's given a `nounwind` attribute, among other things.

dikaiosune··on Fixing Python Performance with Rust
Super cool!

Is there a reason the Rust-exported functions aren't marked with `extern "C"`?

dikaiosune··on Yarn – A new package manager for JavaScript
Cargo definitely allows two dependencies to rely on different versions of a transitive dependency. If those deps expose a type from that dependency in their API, you can very occasionally get weird type errors because the "same" type comes from two different libraries. But otherwise it Just Works(tm).
dikaiosune··on A Hoare Logic for Rust
I know of a few efforts to better specify Rust in addition to ticki's (OP):

* https://github.com/nikomatsakis/rust-memory-model * http://plv.mpi-sws.org/rustbelt/ * https://kha.github.io/2016/07/22/formally-verifying-rusts-bi...

The first isn't using formal methods AFAIK, the second is, and the third is as well, but I think they're targeting safe code only.

dikaiosune··on Exponent – Build native apps in JS that work across both iOS and Android
So please correct me if I'm wrong, but aren't these papercuts the exact motivating reason for something like Exponent?
dikaiosune··on Ripgrep – A new command line search tool
Compiling it to try right now...

Some discussion over on /r/rust: https://www.reddit.com/r/rust/comments/544hnk/ripgrep_is_fas...

EDIT: The machine I'm on is much less beefy than the benchmark machines, which means that the speed difference is quite noticeable for me.

dikaiosune··on Sublime Text 3 Build 3124
Very cool to see a screenshot from servo's codebase.
dikaiosune··on 'Mr. Robot' may be fiction, but its hacking plots are all too real
Are normal people actually that mean and uncaring? It's not been my personal experience.
dikaiosune··on 22nd Century C

    fn main() {
        println!("hello, world");
    }
I kid, I kid. This looks cool!
dikaiosune··on How I Used and Abused My Tesla – What a Tesla Looks Like After 100,000 Miles
Are you also in Flagstaff? I've been surprised by the number of Tesla's I see given that one likely has several hours of charging to look forward to to get to Phoenix and back.
dikaiosune··on Docs.rs – documentation hosting for the Rust ecosystem
Very exciting! Per-platform docs (platform dropdown in the doc section), a built-in source browser, a rendered copy of README.md (if present), semver compatible URLs, documentation for previous versions, and probably other things I haven't found yet. Looks like there's an about page under the "Rust" menu:

https://docs.rs/about

dikaiosune··on GitMonitor on Elixir
I'm beginning to wonder how many developers have no clue how much performance a modern computer can achieve. I certainly didn't until recently.
dikaiosune··on NLRB rules graduate students are employees
Don't most graduate students fund themselves using TA/RA budget lines where they are employed by the university? It's the norm everywhere I've seen.
dikaiosune··on Bay Area Startups Find Low-Cost Outposts in Arizona
It's a lot like many places without significant industry and nice quality of life. Less expensive than more "hot spot" areas, but wages are out of whack with the cost of living for most people. You definitely pay a premium relative to general wages to live in a nice place like this.

That said, there are many people who do quite well for themselves here, and they seem to love it. But it's not really a place where you can advance quickly by moving between companies. Most employees here seem to be lifers.

In terms of tech, there's not much to report. I got my current job through a personal recommendation, but was preparing to move away right before that happened. There are a couple of smaller tech companies, but otherwise developers pretty much work for the university, the hospital, W.L. Gore, Deckers Outdoor, or they work remotely (last year I met a principal architect from Blackboard who apparently lives here and works remotely for them). There are no meetups that I know of, and almost all of the jobs are .NET/JVM enterprise-y integrations and IT stuff. I'm sure there are little pockets that I'm not aware of, but there's only like 70k people who live here anyway.

So, uh, I guess my view of the economy is rather dim :). But that's not why one moves to this area -- it's the urban trail system, the backyard national forest, the easy access to the entire southwest, the low crime rates, the fresh air, the friendly people, the liberal mountain town vibe, the microbreweries, etc.

dikaiosune··on Python JITs are coming
Is there anything blocking Jython from using this same approach?
dikaiosune··on Bay Area Startups Find Low-Cost Outposts in Arizona
I live in Flagstaff, and while going to Prescott for In-n-Out is nice, I have a hard time imagining living there vs. Flagstaff for the exact reasons you mention.
dikaiosune··on Bay Area Startups Find Low-Cost Outposts in Arizona
Flagstaff and Prescott are quite pleasant from extensive personal experience, but unfortunately they're not where the formerly-Bay Area jobs are flowing.
← PreviousPage 5 of 22Next →