D and Nim

Ary Borenszweig via Digitalmars-d digitalmars-d at puremagic.com
Mon Jan 5 06:40:17 PST 2015


On 1/5/15 8:01 AM, bearophile wrote:
> Ary Borenszweig:
>
>> Are there proofs of percentage of bugs caused by incorrectly mutating
>> variables that were supposed to be immutable?
>
> I don't know, probably not, but the progress in language design is still
> in its pre-quantitative phase (note: I think Rust variables are constant
> by default, and mutable on request with "mut").
> It's not just a matter of bugs, it's also a matter of making the code
> simpler to better/faster understand what a function is doing and how.

You said "Computer Science has found that the right
default for variables is to have them immutable". I don't think "Rust == 
Computer Science". Otherwise their compiler would be fast (Computer 
Science knows how to do fast compilers).

At least I like that they are introducing a new feature to their 
language that none other has: lifetimes and borrows. But I find it very 
hard to read their code. Take a look for example at the lerp function 
defined in this article:

http://www.willusher.io/2014/12/30/porting-a-ray-tracer-to-rust-part-1/

Rust:
~~~
pub fn lerp<T: Mul<f32, T> + Add<T, T> + Copy<T>>(t: f32, a: &T, b: &T) 
-> T {
     *a * (1.0 - t) + *b * t
}
~~~

C++:
~~~
template<typename T>
T lerp(float t, const T &a, const T &b){
     return a * (1.f - t) + b * t;
}
~~~

>
>> I don't remember having such bug in my life.
>
> Perhaps you are very good, but a language like D must be designed for
> more common programmers like Kenji Hara, Andrei Alexandrescu, or Raymond
> Hettinger.

I don't think those are common programmers :-)


More information about the Digitalmars-d mailing list