Example of Rust code

Paulo Pinto pjmlp at progtools.org
Sun Aug 12 01:02:35 PDT 2012


Am 11.08.2012 20:37, schrieb Peter Alexander:
> On Saturday, 11 August 2012 at 18:04:29 UTC, Paulo Pinto wrote:
>> On Saturday, 11 August 2012 at 16:12:14 UTC, Peter Alexander wrote:
>>> On Saturday, 11 August 2012 at 14:45:55 UTC, Russel Winder wrote:
>>>> On Sat, 2012-08-11 at 02:19 +0200, David Piepgrass wrote:
>>>> […]
>>>>> I hope someday to have a programming system whose features are not
>>>>> limited to whatever features the language designers saw fit to
>>>>> include -- a language where the users can add their own features,
>>>>> all the while maintaining "native efficiency" like D. That language
>>>>> would potentially allow Rust-like code, D-like code, Ruby-like code
>>>>> and even ugly C-like code.
>>>>>
>>>>> I guess you don't want to be the one to kickstart that PL. I've
>>>>> been planning to do it myself, but so far the task seems just too
>>>>> big for one person.
>>>>
>>>> <quasi-troll>
>>>> Isn't that language Lisp?
>>>> </quasi-troll>
>>>
>>> You missed the native efficiency part :-)
>>>
>> You mean like the Common Lisp compilers that are able to beat FORTRAN
>> compilers
>> in floating point computations?
>>
>> http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.54.5725
>>
>> --
>> Paulo
>
> Not sure where you read that in the paper.
>
>  From the conclusion:
>
> "We have demonstrated that the speed of compiled Common Lisp code,
> though today somewhat slower than that of the best compiled Fortran,
> could probably be as efficient, and in some ways superior."
>
> Probably is the operative word there.

Should have re-read the paper. It has been a few years since I fully 
read it. Still I think Common Lisp code is pretty efficient.

>
>> Most modern Lisp implementations employ JITing one way or another, so
>> you do get native code. Just not on the first run through a bit of code.
>
> JIT has its limits. A dynamically typed language is still dynamically
> typed once compiled. Sure the JIT may be able to deduce the types in
> some cases, but not all.
>
> I do see your point, but in general it's still not as fast as optimised C.

I imagine you wanted to answer to Russel's post.

On Lisp's case, most systems available today only JIT when using the 
REPL, as you can always compile to native code.

Type annotations help improve the speed in hotspot areas of your code,
in case you really need the extra speed for the application use case.

As for the speed of native code produced by JITs for dynamic languages,
I think Cog(Smalltalk), Self(Smaltalk ended up becoming JVM Hotspot),
PyPy (Python), V8(JavaScript), LLVM(Julia) prove that you can get pretty 
close to C for the majority of use cases that matter to the common user.

Actually a running assumption among the dynamic languages advocates is that
if dynamic languages had had as much money and research support as the
static languages field, the compilers would be much better by now.

--
Paulo



More information about the Digitalmars-d mailing list