October 16, 2013
On 10/16/2013 08:46 AM, simendsjo wrote:
>
> No.. Give me a language that catches obvious bugs at compile-time, makes
> code self-documenting and doesn't let me worry about performance.
> ...

Why just obvious bugs?
October 16, 2013
On Wednesday, 16 October 2013 at 10:37:28 UTC, Timon Gehr wrote:
> On 10/16/2013 08:46 AM, simendsjo wrote:
>>
>> No.. Give me a language that catches obvious bugs at compile-time, makes
>> code self-documenting and doesn't let me worry about performance.
>> ...
>
> Why just obvious bugs?

Hehe. Sure - let the compiler catch *all* my bugs!

scope, const, immutable, pure, nothrow, safe, ... D makes it harder to shoot yourself in the foot, but you are aiming at your foot by default..

Too bad I have to add a lot of annotations
  void f(Class i) {}
to
  void f(in Class i) const pure nothrow @safe {}

I would rather have to write
  void f(@(mutable, escapes) Class i) @(impure mutable throws unsafe) {}

If @mutable and @impure existed, I could just add some annotations at the top of each module, but it wouldn't help on parameters.
October 16, 2013
On Wednesday, 16 October 2013 at 10:52:47 UTC, simendsjo wrote:
> On Wednesday, 16 October 2013 at 10:37:28 UTC, Timon Gehr wrote:
>> On 10/16/2013 08:46 AM, simendsjo wrote:
>>>
>>> No.. Give me a language that catches obvious bugs at compile-time, makes
>>> code self-documenting and doesn't let me worry about performance.
>>> ...
>>
>> Why just obvious bugs?
>
> Hehe. Sure - let the compiler catch *all* my bugs!
>
> scope, const, immutable, pure, nothrow, safe, ... D makes it harder to shoot yourself in the foot, but you are aiming at your foot by default..
>
> Too bad I have to add a lot of annotations
>   void f(Class i) {}
> to
>   void f(in Class i) const pure nothrow @safe {}
>
> I would rather have to write
>   void f(@(mutable, escapes) Class i) @(impure mutable throws unsafe) {}
>
> If @mutable and @impure existed, I could just add some annotations at the top of each module, but it wouldn't help on parameters.

I wonder how easy it would be to write a little pre-processor using https://github.com/Hackerpilot/Dscanner that would effectively add those keywords.
October 16, 2013
On Wednesday, 16 October 2013 at 10:52:47 UTC, simendsjo wrote:
> On Wednesday, 16 October 2013 at 10:37:28 UTC, Timon Gehr wrote:
>> On 10/16/2013 08:46 AM, simendsjo wrote:
>>>
>>> No.. Give me a language that catches obvious bugs at compile-time, makes
>>> code self-documenting and doesn't let me worry about performance.
>>> ...
>>
>> Why just obvious bugs?
>
> Hehe. Sure - let the compiler catch *all* my bugs!
>
> scope, const, immutable, pure, nothrow, safe, ... D makes it harder to shoot yourself in the foot, but you are aiming at your foot by default..
>
> Too bad I have to add a lot of annotations
>   void f(Class i) {}
> to
>   void f(in Class i) const pure nothrow @safe {}
>
> I would rather have to write
>   void f(@(mutable, escapes) Class i) @(impure mutable throws unsafe) {}
>
> If @mutable and @impure existed, I could just add some annotations at the top of each module, but it wouldn't help on parameters.


The problem, which I know well from other languages with annotations, is that eventually you reach annotation hell, specially in the enterprise world.

--
Paulo
October 16, 2013
On Wednesday, 16 October 2013 at 11:05:25 UTC, PauloPinto wrote:
> On Wednesday, 16 October 2013 at 10:52:47 UTC, simendsjo wrote:
>> On Wednesday, 16 October 2013 at 10:37:28 UTC, Timon Gehr wrote:
>>> On 10/16/2013 08:46 AM, simendsjo wrote:
>>>>
>>>> No.. Give me a language that catches obvious bugs at compile-time, makes
>>>> code self-documenting and doesn't let me worry about performance.
>>>> ...
>>>
>>> Why just obvious bugs?
>>
>> Hehe. Sure - let the compiler catch *all* my bugs!
>>
>> scope, const, immutable, pure, nothrow, safe, ... D makes it harder to shoot yourself in the foot, but you are aiming at your foot by default..
>>
>> Too bad I have to add a lot of annotations
>>  void f(Class i) {}
>> to
>>  void f(in Class i) const pure nothrow @safe {}
>>
>> I would rather have to write
>>  void f(@(mutable, escapes) Class i) @(impure mutable throws unsafe) {}
>>
>> If @mutable and @impure existed, I could just add some annotations at the top of each module, but it wouldn't help on parameters.
>
>
> The problem, which I know well from other languages with annotations, is that eventually you reach annotation hell, specially in the enterprise world.

I don't have any enterprise experience, but with UDAs, this can already happen.
What I think is bad is that I have to add a lot of built-in annotations to get help from the compiler catching bugs.
But there would be fewer annotations if you were able to negate some annotations.
If 95% of your functions are pure, why should you have to say pure for all those rather than impure for 5%?
October 16, 2013
On Wednesday, 16 October 2013 at 10:58:04 UTC, John Colvin wrote:
> On Wednesday, 16 October 2013 at 10:52:47 UTC, simendsjo wrote:
>> On Wednesday, 16 October 2013 at 10:37:28 UTC, Timon Gehr wrote:
>>> On 10/16/2013 08:46 AM, simendsjo wrote:
>>>>
>>>> No.. Give me a language that catches obvious bugs at compile-time, makes
>>>> code self-documenting and doesn't let me worry about performance.
>>>> ...
>>>
>>> Why just obvious bugs?
>>
>> Hehe. Sure - let the compiler catch *all* my bugs!
>>
>> scope, const, immutable, pure, nothrow, safe, ... D makes it harder to shoot yourself in the foot, but you are aiming at your foot by default..
>>
>> Too bad I have to add a lot of annotations
>>  void f(Class i) {}
>> to
>>  void f(in Class i) const pure nothrow @safe {}
>>
>> I would rather have to write
>>  void f(@(mutable, escapes) Class i) @(impure mutable throws unsafe) {}
>>
>> If @mutable and @impure existed, I could just add some annotations at the top of each module, but it wouldn't help on parameters.
>
> I wonder how easy it would be to write a little pre-processor using https://github.com/Hackerpilot/Dscanner that would effectively add those keywords.

Even if it were super simple and worked fine, I wouldn't use it. It would in effect be a custom "Safe D" compiler that isn't compatible with regular D.
October 16, 2013
PauloPinto:

> The problem, which I know well from other languages with annotations, is that eventually you reach annotation hell, specially in the enterprise world.

There are research papers that explore the algebra of effects, and also contain better syntax and some better inference. With such ideas the control of those effects seems to improve.

Bye,
bearophile
October 16, 2013
On 2013-10-16 12:52, simendsjo wrote:

> If @mutable and @impure existed, I could just add some annotations at
> the top of each module, but it wouldn't help on parameters.

We need a general way to turn off attributes. This "!@attribute" has been proposed before.

-- 
/Jacob Carlborg
October 16, 2013
On Wednesday, 16 October 2013 at 11:36:30 UTC, Jacob Carlborg wrote:
> On 2013-10-16 12:52, simendsjo wrote:
>
>> If @mutable and @impure existed, I could just add some annotations at
>> the top of each module, but it wouldn't help on parameters.
>
> We need a general way to turn off attributes. This "!@attribute" has been proposed before.

How would that relate to non-binary attributes like @system, @trusted, @safe?
Seems like it would only work on binary built-in attributes.
October 16, 2013
> There are research papers that explore the algebra of effects, and also contain better syntax and some better inference. With such ideas the control of those effects seems to improve.

An example, from the Koka language:
http://research.microsoft.com/en-us/projects/koka/2012-overviewkoka.pdf

Bye,
bearophile