News for hackers. Stuff that matters.
Re:Why you should, actually, rewrite some of it in Rust by naasking on Thursday July 13, 2017 @12:45PM (#14762816)
> The unsafe approach would be to do use an array representation, use indices instead of pointers, and roll your own garbage collector. Or manually remove unnecessary reference count updates whenever you can prove that they are unnecessary. Both of which cannot be easily hidden behind a safe zero-cost API.

There are potentially many unsafe approaches, and possibly even some safe ones.

> The entire Wirth family of languages qualifies, too. Or Eiffel [1]. Or Fortran [2]. Or Modula-3 [3]. As do more recent languages such as Nim [4] and D [5].

[1] Doesn't support expressing stack allocation patterns, which are essentially to achieving true zero-cost abstractions.

[2] Oh yeah, that'll be easy and maintainable to program.

[3] Doesn't support 64-bit Windows. Verbose like Ada. Abstraction is weak compared to Rust. Also doesn't support expressing stack allocation.

[4] Nim requires a GC, so not zero cost. It also has surprising runtime semantics. For instance, fields that are are guarded by a clause raise runtime exceptions. These would require different cases which are checked for exhaustiveness statically in Rust.

[5] D is not memory safe for non-trivial programs if you're not using the GC.

Clearly you and I have a different understanding of zero-cost abstraction.

> In addition, parametric polymorphism cannot ever have a zero-cost abstraction (or rather, the term has no meaningful definition in this context), because you pay for it either in runtime overhead (shared generics) or code size (specialization).

Code size is not a problem when discussing zero-cost abstractions. Honestly, it just seems like you're grasping for something to nitpick on.

> I also wouldn't bring up syntactic and semantic costs; that's throwing stones while sitting inside a glass house. Rust is probably one of the worst offenders in this regard.

I have no idea what you're talking about. Once they removed all the special syntax for pointer types years back, Rust is very readable to anyone from a brace-based language tradition.

Re:Why you should, actually, rewrite some of it in Rust by pjmlp on Thursday July 13, 2017 @01:25PM (#14763205)
> Doesn't support expressing stack allocation patterns, which are essentially to achieving true zero-cost abstractions.

Says someone that never wrote a single line of Eiffel.

That is what local variables defined as expanded classes are for.

    local
       array: expanded ARRAY[INTEGER];
    do
       array := <<1,3,2>>
       sorter.sort(array)
       ....
    end
> Doesn't support 64-bit Windows. Verbose like Ada. Abstraction is weak compared to Rust. Also doesn't support expressing stack allocation.

Says someone that never wrote a single line of Modula-3.

    TYPE
       Time = RECORD
          seconds: INTEGER;
          milliseconds: [0..999]
       END; 

    PROCEDURE MyProc =
    VAR
       t: Time; (* Stack Allocated *)
    BEGIN
       t.seconds := 0;
       t.milliseconds := 0   
    END MyProc;

Being verbose is a virtue in large scale software development.