August 31, 2012
On Friday, 31 August 2012 at 15:41:10 UTC, Steven Schveighoffer wrote:
> On Fri, 31 Aug 2012 00:54:07 -0400, Mehrdad <wfunction@hotmail.com> wrote:
>
>> On Thursday, 30 August 2012 at 19:00:58 UTC, Steven Schveighoffer wrote:
>>> And I edit x.h, how does it know the original source file which includes x.h does or doesn't define A before including x.h?  That is the issue I was having.
>>
>> I don't understand why that should be so difficult...
>>
>> Why can't the IDE just scan all the #include dependencies in an internal database, and update them accordingly?
>
> a.c:
>
> #define A
> #include "x.h"
>
> b.c:
>
> #include "x.h"
>
> Now, depending on whether you are editing x.h in terms of a.c or b.c, the #ifdef is active or not.  The IDE will be wrong no matter what choice it makes.
>
> This is why I like how external definitions and imports cannot affect D modules.
>
> -Steve


Ooh I see.

The IDE could just give you a warning though, and ask which ones you want to rename. It might be "wrong" but it'd still be very usable.
September 02, 2012
On Thu, 30 Aug 2012 09:35:31 -0400
"Steven Schveighoffer" <schveiguy@yahoo.com> wrote:
> 
> For example, I use netbeans to write php -- a dynamic language. There are no real variable type declarations, so when you start typing, auto-complete sucks unless you have told the IDE what a variable is.  You do so like this:
> 
> /**
>   @var Type
>   */
> var $varname;
> 
> And now the IDE assumes you have stored a Type into $varname, so when you type $this->varname->, it completes with the members of Type.
> 

Wow, so it's basically reinventing static typing poorly. You've got the boilerplate and verbosity of a poorly-made static type system, with very few of the benefits (ie, IDE-awareness and nothing else).

I'll never understand the dynamic world.

September 02, 2012
On 2012-09-02 03:21, Nick Sabalausky wrote:

> Wow, so it's basically reinventing static typing poorly. You've got
> the boilerplate and verbosity of a poorly-made static type system, with
> very few of the benefits (ie, IDE-awareness and nothing else).
>
> I'll never understand the dynamic world.

You can of course build a tool that does type checking if you use these kind of comments. Something like Dart seems to do, but Dart has built-in support for static types.

-- 
/Jacob Carlborg
September 04, 2012
On Sat, 01 Sep 2012 21:21:50 -0400, Nick Sabalausky <SeeWebsiteToContactMe@semitwist.com> wrote:

> On Thu, 30 Aug 2012 09:35:31 -0400
> "Steven Schveighoffer" <schveiguy@yahoo.com> wrote:
>>
>> For example, I use netbeans to write php -- a dynamic language.
>> There are no real variable type declarations, so when you start
>> typing, auto-complete sucks unless you have told the IDE what a
>> variable is.  You do so like this:
>>
>> /**
>>   @var Type
>>   */
>> var $varname;
>>
>> And now the IDE assumes you have stored a Type into $varname, so when
>> you type $this->varname->, it completes with the members of Type.
>>
>
> Wow, so it's basically reinventing static typing poorly. You've got
> the boilerplate and verbosity of a poorly-made static type system, with
> very few of the benefits (ie, IDE-awareness and nothing else).
>
> I'll never understand the dynamic world.

I have on occasion had the benefit of simply adding a member variable to instances of a class when I needed it without having to burden the rest of the code with knowing about that variable.  I felt dirty doing it...

But I think you are right -- "fake" static typing does not come close to actual static typing.  If I could count all the time I've wasted because I mistyped a member variable name, and it "just worked", blissfully reading null instead of the variable I've set, it would probably add up to days.  Thankfully, netbeans 7 is better at telling me that a variable is previously unset or is never used, but it can't be perfect, especially with this mess I inherited.  The original author thought "modularity" meant importing large pieces of functions from other files, which the IDE refuses to correctly interpret.

This, of course, all comes from two guys who really like static typing :)  We *may* have a biased view.

In any case, it is what it is -- the existing code-base is huge, and I have no real desire to rewrite all of it :)  The best I can do is add some typing comments and hobble through it (cursing as I go).  If I had a year of spare time, I could rewrite it all in D!

-Steve
September 04, 2012
On 2012-09-04 15:59, Steven Schveighoffer wrote:

> I have on occasion had the benefit of simply adding a member variable to
> instances of a class when I needed it without having to burden the rest
> of the code with knowing about that variable.  I felt dirty doing it...
>
> But I think you are right -- "fake" static typing does not come close to
> actual static typing.  If I could count all the time I've wasted because
> I mistyped a member variable name, and it "just worked", blissfully
> reading null instead of the variable I've set, it would probably add up
> to days.  Thankfully, netbeans 7 is better at telling me that a variable
> is previously unset or is never used, but it can't be perfect,
> especially with this mess I inherited.  The original author thought
> "modularity" meant importing large pieces of functions from other files,
> which the IDE refuses to correctly interpret.
>
> This, of course, all comes from two guys who really like static typing
> :)  We *may* have a biased view.

I can tell you this, I've wished many times that I had static typing in Ruby. I've also wished quite many times I had dynamic typing in D. I think optional static typing, like Dart, sounds like a good idea.

I'm currently updating a Rails project to Ruby 1.9 and I really wished I had static typing. Just that fact that it won't load file until it's actually needed is quite annoying. Finding all the corner cases can be quite a lot of work. For example, a partial that is loaded when the rendering is triggered by an Ajax request.

> In any case, it is what it is -- the existing code-base is huge, and I
> have no real desire to rewrite all of it :)  The best I can do is add
> some typing comments and hobble through it (cursing as I go).  If I had
> a year of spare time, I could rewrite it all in D!
>
> -Steve


-- 
/Jacob Carlborg
September 04, 2012
On Tuesday, 4 September 2012 at 19:18:05 UTC, Jacob Carlborg wrote:
> I've also wished quite many times I had dynamic typing in D.

I think we're *fairly* close with things like std.variant,
especially combined with some helpers. Take a look:

Variant a = 10;
string b = a; // can't, and I say that's good, usually
b = a.coerce!string; // works

But, to get a dynamic feel, you don't want to write
out coerce!type. I kinda want it to be auto. So,

Variant a = 10;
string b;

b.dset = a; // dset means dynamic set

This is pretty doable in D today.

auto dset(T, U)(ref T t, U u) {
        return t = to!T(u);
}

Then call with UFCS + property getter syntax.


The other thing is to do function calls. And we might
be able to pull that off too with something like

void foo(string a, string b) {}

auto dcall(alias func, T...)(T args) {
	import std.traits;
	ParameterTypeTuple!func typedArgs;
	foreach(i, ref arg; typedArgs)
		arg.dset = args[i];
	return func(typedArgs);
}

dcall!foo(a, b);



Thus your user code is pretty type-agnostic, with loose
types when requested.
September 04, 2012
On Tuesday, 4 September 2012 at 19:18:05 UTC, Jacob Carlborg wrote:
> On 2012-09-04 15:59, Steven Schveighoffer wrote:
>
>> I have on occasion had the benefit of simply adding a member variable to
>> instances of a class when I needed it without having to burden the rest
>> of the code with knowing about that variable.  I felt dirty doing it...
>>
>> But I think you are right -- "fake" static typing does not come close to
>> actual static typing.  If I could count all the time I've wasted because
>> I mistyped a member variable name, and it "just worked", blissfully
>> reading null instead of the variable I've set, it would probably add up
>> to days.  Thankfully, netbeans 7 is better at telling me that a variable
>> is previously unset or is never used, but it can't be perfect,
>> especially with this mess I inherited.  The original author thought
>> "modularity" meant importing large pieces of functions from other files,
>> which the IDE refuses to correctly interpret.
>>
>> This, of course, all comes from two guys who really like static typing
>> :)  We *may* have a biased view.
>
> I can tell you this, I've wished many times that I had static typing in Ruby. I've also wished quite many times I had dynamic typing in D. I think optional static typing, like Dart, sounds like a good idea.
>
> I'm currently updating a Rails project to Ruby 1.9 and I really wished I had static typing. Just that fact that it won't load file until it's actually needed is quite annoying. Finding all the corner cases can be quite a lot of work. For example, a partial that is loaded when the rendering is triggered by an Ajax request.
>
>> In any case, it is what it is -- the existing code-base is huge, and I
>> have no real desire to rewrite all of it :)  The best I can do is add
>> some typing comments and hobble through it (cursing as I go).  If I had
>> a year of spare time, I could rewrite it all in D!
>>
>> -Steve

The only experience I've had with dynamic typing (in Python), I can say I hated it. I prefer to write Java code, which I think tells a lot about my love for dynamic typing. I probably wouldn't mind writing some Lua code, but not in the large. Unless you are working in an environment which changes all the time, so that you need to adapt your code very quickly, dynamic languages are a waste of time above ~10,000 lines of code in my opinion.

September 04, 2012
On Tuesday, September 04, 2012 22:44:07 SomeDude wrote:
> The only experience I've had with dynamic typing (in Python), I can say I hated it. I prefer to write Java code, which I think tells a lot about my love for dynamic typing. I probably wouldn't mind writing some Lua code, but not in the large. Unless you are working in an environment which changes all the time, so that you need to adapt your code very quickly, dynamic languages are a waste of time above ~10,000 lines of code in my opinion.

Agreed. I avoid dynamic languages like the plague. I'll only touch them when I have to or when I need a script which won't require recompilation to run (and if D ever becomes widespread enough that you can reasonably rely on it being on a Linux system, then all of my scripts will probably be written in D). Dynamic typing is evil.

- Jonathan M Davis
September 04, 2012
On Tuesday, 4 September 2012 at 21:08:42 UTC, Jonathan M Davis wrote:
> Dynamic typing is evil.
> - Jonathan M Davis

This is now my email signature. Thanks.
September 04, 2012
Chris Cain:

> This is now my email signature. Thanks.

Fundamentalism has no place in engineering.

Bye,
bearophile
1 2 3 4 5 6 7 8 9 10
Top | Discussion index | About this forum | D home