python vs d

Nick Sabalausky via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 29 01:08:06 PDT 2014


On 4/28/2014 7:02 PM, bearophile wrote:
> Nick Sabalausky:
>
>> VB6 let you choose your starting index, too. It was rarely useful and
>> constantly made array-handling code a pain in the ass. Of course, VB
>> made pretty much everything a PITA...(I used to work at a VB6 house.
>> *shudder*)
>
> (As far as I know, and I am ignorant about Julia) in Julia you can't
> choose the start index of an array, they start from index 1. So the
> situation is not the same as VB.
>
> I have written more Delphi code than D code, and I've seen that being
> able to choose the index range is quite useful, you can use enumerations
> and characters to index arrays :-) You avoid "c - '0'" the idiom used in
> D, and associative arrays with enum keys, while keeping the code very
> efficient and generally not bug-prone.
>
> I don't know VB much, but all language features should not be abused.
> And they work or fail not just being good themselves, but in the context
> (and ecology) of all other features of a language. This means choosing
> arrays index types and start values is very good in Ada, it's rarely a
> PITA. But perhaps a similar feature is not good if used in VB. Ada has a
> very strong static typing, so being able to specify array index types
> gives you back lot of safety that probably is not available in VB. So
> the return of investment is probably different.
>

Yea. To be perfectly fair, "classic" VB made pretty much anything a 
pain. I imagine a better language could probably manage custom index 
ranges much better than VB6 did.

In VB6, it was a pain because of iterating over the elements. Since it 
lacked anything like foreach (as I recall), the simplest "iterate over 
an array" was something like (from memory, might not have it exact):

FOR index = 0 TO Len(myArray)

*But* that code was wrong. It would *usually* work, and then suddenly 
blow up whenever someone used a different starting index. So instead, it 
was best to use this syntactic mess every time you iterated:

FOR index = LBound(myArray) TO UBound(myArray)

Ugh, I don't miss VB. Worse still, it was so "simple" it encouraged 
companies (like the one where I worked) to use "programmers" who were 
absolute bottom-level and wrote the WORST code. I saw shit at that job 
that (I'm not exaggerating here) even CS 101 students know not to do. It 
was amazing any of our codebase even worked at all.

Back to the point though, having never looked at Julia, I assume it 
probably does a much better job of this stuff than VB did.



More information about the Digitalmars-d mailing list