Crystal

Denis Shelomovskij verylonglogin.reg at gmail.com
Sun Feb 17 01:29:28 PST 2013


17.02.2013 10:28, Ary Borenszweig пишет:
> Hello everyone :-)
>
> ...
>
> (you might remember me: I'm the author of Descent)

A Hero is here! Let me kowtow to you, a Descent Creator!

> ... Let's save this world's energy.

It's pleasantly to see this point of view at efficiency.

> But... do we really have to specify const pure safe nothrow and whatnot?
> Can't the compiler be smarter? I'm sure there must be a better way. Most
> new programming languages look like older ones. Newness comes slowly...
>
> One time I asked in this newsgroup if it was possible to have an "auto"
> keyword for function/method arguments. And... why not make all
> functions/methods be templates on the type of its arguments?
>
> I think nobody liked this idea. I said "Ruby is like this: you never
> specify types in method definitions".
>
> "But Ruby is not efficient". "Ruby is a dynamic language". "D is
> compiled, so it's faster". "Don't make the mistake of comparing a
> dynamic language with a static/systems programming language". This were
> some of the answers I got.
>
> I started thinking about this idea: a compiled language that looked like
> a dynamic language. Is it possible?

Looks like it is, by what is the reason?

I'd like to specify function attributes explicitly because I do want to 
get a compilation error when I e.g. use non-safe stuff in safe function 
instead of a just compiler silently changing the function (and all 
functions which use it) to unsafe. I also don't use type inference 
everywhere because sometimes I do want to see exact types (yes, IDE 
problem) and sometimes I just don't want a type to be accidentally 
changed because of some function signature change as in the worst case 
the code will still compile but will work incorrect.

Now about argument types. I do not understand the purpose of dynamic 
typing at all and consider such languages too dangerous to use in real 
projects. You proposal is a bit better as it will give CT errors 
(instead of RT in dynamic typing case) but still bad as the code can 
accidentally compile and work incorrect. Also this looks as a step back 
as your proposal is like making from a function something like C's 
preprocessor macro. And I remember how somebody defended C's macros and 
told "you can do it with macro", then he gave his code where he made a 
fatal mistake by passing two parameters to a macro in a wrong order. And 
that code accidentally compiled. Same thing can happen with every high 
templated code where it is hard to predict every possible argument 
combination.

I also have seen a lot of mistakes of any types in D templated code so I 
consider such code almost as dangerous as pointer arithmetic and you 
proposal to make everything a template looks as insane.

> ...
>
> Thanks for your comments,
> Ary
>
> P.S.: bin/crystal -e 'a = 0; 10.times { |i| a += i }; puts a' -O3 -ll

Sorry for such cruel comment, I it is just my opinion.

-- 
Денис В. Шеломовский
Denis V. Shelomovskij


More information about the Digitalmars-d-announce mailing list