Re:Rust in 2018: easier to use
by grnadav1 on Sunday January 14, 2018 @03:36AM
(#16143347)
A guy w/ 10 weeks Rust experiance and already gave a talk at RustConf?!
[ Parent
| on HN ]
Re:Rust in 2018: easier to use
by Manishearth on Sunday January 14, 2018 @04:17AM
(#16143444)
The closing keynote at RustConf is generally someone who is new to Rust or has never used Rust but can bring in an interesting perspective. Last year we had Joe Duffy, who I don't think has done much Rust aside from perhaps basic experimentation, but has a lot of relevant experience from running the Midori (Microsoft's safe systems language) project.
(also, the author isn't a "guy")
It's interesting because when I read about how Rust can rewrite iterators code into more performant direct loops I thought about Joe's blog posts that mentioned the same efforts for .NET. Also Span<T>. It seems .NET will have similar abstractions like Rust (of course not all can be migrated).
LuaJIT does the same, down to an absurd level.
From the luafun library readme (which uses iterators under the hood):
https://github.com/luafun/luafun
————
> Let's see an example:
> -- Functional style
> require "fun" ()
> -- calculate sum(x for x^2 in 1..n)
> n = 100
> print(reduce(operator.add, 0, map(function(x) return x^2 end, range(n))))
328350
> -- Object-oriented style
> local fun = require "fun"
> -- calculate sum(x for x^2 in 1..n)
> print(fun.range(n):map(function(x) return x^2 end):reduce(operator.add, 0))
328350
> Lua Fun takes full advantage of the innovative tracing JIT compiler
to achieve transcendental performance on nested functional expressions.
Functional compositions and high-order functions can be translated into
efficient machine code. Can you believe it? Just try to run the example
above with `luajit -jdump` and see what happens: -- skip some initilization code --
->LOOP:
0bcaffd0 movaps xmm5, xmm7
0bcaffd3 movaps xmm7, xmm1
0bcaffd6 addsd xmm7, xmm5
0bcaffda ucomisd xmm7, xmm0
0bcaffde jnb 0x0bca0024 ->5
0bcaffe4 movaps xmm5, xmm7
0bcaffe7 mulsd xmm5, xmm5
0bcaffeb addsd xmm6, xmm5
0bcaffef jmp 0x0bcaffd0 ->LOOP
---- TRACE 1 stop -> loop
> The functional chain above was translated by LuaJIT to (!) one machine loop
containing just 10 CPU assembly instructions without CALL.Most of the comments you've posted to HN have been unsubstantive. We ban accounts that do that, so could you please read https://news.ycombinator.com/newsguidelines.html and stop doing that?
This one was particularly uninformed.