• (cs) in reply to Harrow
    Harrow:
    Working with the various computer languages I learned that array numbering seems to fall into three categories:

    (1) Array indices always start with zero. This is most comfortable for assembler programmers first learning a compiled language. It also simplifies coding for multidimensional arrays if the compiler doesn't handle them.

    (2) Array indices always start with one. This feels natural and comfortable at first, but it fools many people into thinking they are programmers when they are not.

    (3) Array indices can start with any integer. This flexibility comes at a small cost -- every time you declare an array, you must declare its starting index. Usually you must declare its final index also.

    The basing of array indices is one of the best interview discussion topics. For example, a candidate who looks at the three categories above and says that (2) is a special case of (3) is probably a keeper.

    -Harrow.

    The one who says "Nice historically, but I don't bother with arrays much any more - I use Lists and ArrayLists and stuff like that" is probably beyond help.

  • Meep (unregistered) in reply to Harrow
    Harrow:
    Working with the various computer languages I learned that array numbering seems to fall into three categories:

    (1) Array indices always start with zero. This is most comfortable for assembler programmers first learning a compiled language. It also simplifies coding for multidimensional arrays if the compiler doesn't handle them.

    (2) Array indices always start with one. This feels natural and comfortable at first, but it fools many people into thinking they are programmers when they are not.

    (3) Array indices can start with any integer. This flexibility comes at a small cost -- every time you declare an array, you must declare its starting index. Usually you must declare its final index also.

    The basing of array indices is one of the best interview discussion topics. For example, a candidate who looks at the three categories above and says that (2) is a special case of (3) is probably a keeper.

    -Harrow.

    I put them in two categories: languages that use 0-based indexing and languages that I do not want to use.

    Non 0-based indexing indicates that the language designer doesn't understand how abstract data types work, and the separation between interface and implementation.

  • fgjh (unregistered) in reply to Severity One
    Severity One:
    David:
    Anyway, everything will be just like America soon, and all these quibbles over minor cultural differences will just go away and you can be happy.
    Yeah, like the Imperial measurements...

    The other day, I looked up a description of how to make wine from oranges (since we have three orange trees in what passes for our front and back gardens, using the word loosely). All the measurements were Imperial, and my brain just kind of switched off.

    Don't get me wrong, it must be equally baffling for Americans, all this metric nonsense, but it's just so damn inconvenient when a country decides to do it a different way from everybody else, minus the Liberians and the Burmese.

    The Brits managed. Took one or two generations, and in a few years time nobody will care about ounces and pounds (other than sterling) and yards any longer.

    You just need to teach kids metric units in school, but with the crazily fractured and devolved government in the USA, chances of that are poor at best.

    Companies are very successful creating their own standards instead of following others - somethimes to the point where standards start to follow them.... I'm looking at YOU MS, COMPAQ, Apple....

  • Yoshi (unregistered) in reply to Herr Otto Flick
    Herr Otto Flick:
    C-Derb:
    Herr Otto Flick:
    I think part of the reason that traditionally the UK has had better intrinsic programming skill than the US ....
    Really? I know I'm going to come across as a thin-skinned defensive US programmer, but I've never, ever heard anything about the "traditionally" superior talent on the other side of the pond. Care to support this? Or maybe I'm just getting trolled....

    How far do you want to go back?

    Babbage invented the concept of a computer. Turing invented the modern computer. Spectrum, BBC Micro, Acorn, ARM all came out of making computers that real people can afford. As a consequence, in the 80s, we we're all writing software, whilst you played on your NES. Almost everyone in the UK was taught programming at school. As a consequence of that, most of the most groundbreaking games produced between 1985 and 2000 were made in Britain, by British programmers. Elite, Dizzy, Lemmings, Worms, Wipeout, the entire GTA series, Tomb Raider, Hitman, Deus Ex all built by visionaries like Jeff Minter, Peter Molyneux, The Bitmap Brothers leading to still world leading studios like Codemasters, Lionhead, Llamasoft, EDGE, Eidos, CORE, Bullfrog, et al. Next time you play a game, have a look, it was probably written in Britain.

    I'm also basing this upon my experiences working in the US With US programmers.. some of my classmates from primary school (sorry, 'grade school'?) could program better than these guys.

    Something about a programmable loom in the 19th century.....

  • Dottore Ferrari (unregistered) in reply to jay
    jay:
    David:
    jay:
    They invented calculus

    Nope, that was the germans. The brits independently developed an inferior version that they somehow browbeat everyone into using. Presumably out of sheer malice.

    Yes yes, the Newton/Leibniz debate. Regardless of who got there first, there is every reason to believe that the two men each invented calculus independent of the other. If we're talking about the intellecutal prowess of a culture, I don't think the fact that someone else accomplished the same thing at about the same time detracts from the impressiveness of the achievement. If a man with no legs manages to crawl 100 miles across a desert, that's an impressive achievement, even if another man with no legs did the same thing the week before.

    What about if a cyclist wins numerous World Class events? Is it still impressive if it turns out he's the biggest cheat in history?
  • Jimmy the Greek (unregistered) in reply to Meep
    Meep:
    Harrow:
    Working with the various computer languages I learned that array numbering seems to fall into three categories:

    (1) Array indices always start with zero. This is most comfortable for assembler programmers first learning a compiled language. It also simplifies coding for multidimensional arrays if the compiler doesn't handle them.

    (2) Array indices always start with one. This feels natural and comfortable at first, but it fools many people into thinking they are programmers when they are not.

    (3) Array indices can start with any integer. This flexibility comes at a small cost -- every time you declare an array, you must declare its starting index. Usually you must declare its final index also.

    The basing of array indices is one of the best interview discussion topics. For example, a candidate who looks at the three categories above and says that (2) is a special case of (3) is probably a keeper.

    -Harrow.

    I put them in two categories: languages that use 0-based indexing and languages that I do not want to use.

    Non 0-based indexing indicates that the language designer doesn't understand how abstract data types work, and the separation between interface and implementation.

    AND you can always use 0-based arrays as 1-based if you really, really wanted to (create an array of size X+1 and never use the first slot)....but not so easy the other way around

    <disclaimer> I do not endorse doing this </disclaimer>
  • Shark8 (unregistered) in reply to Severity One
    Severity One:
    David:
    Anyway, everything will be just like America soon, and all these quibbles over minor cultural differences will just go away and you can be happy.
    Yeah, like the Imperial measurements...

    The other day, I looked up a description of how to make wine from oranges (since we have three orange trees in what passes for our front and back gardens, using the word loosely). All the measurements were Imperial, and my brain just kind of switched off.

    Don't get me wrong, it must be equally baffling for Americans, all this metric nonsense, but it's just so damn inconvenient when a country decides to do it a different way from everybody else, minus the Liberians and the Burmese.

    The Brits managed. Took one or two generations, and in a few years time nobody will care about ounces and pounds (other than sterling) and yards any longer.

    You just need to teach kids metric units in school, but with the crazily fractured and devolved government in the USA, chances of that are poor at best.

    If you're a programmer and don't like imperial you're in the wrong business, imperial makes sense on computers: 1 Gallon = 128 oz 1 Quart = 32 oz 1 Pint = 2 Cups = 16 oz 1 Cup = 8 oz

  • Shark8 (unregistered) in reply to Meep
    Meep:
    I put them in two categories: languages that use 0-based indexing and languages that I do not want to use.

    Non 0-based indexing indicates that the language designer doesn't understand how abstract data types work, and the separation between interface and implementation.

    Ah! As a counter-example I suggest you look at Ada; Ada's arrays start at anywhere you need to, but provides such attributes as 'First, 'Last, 'Range and 'Length so that you can manage the array effectively. The 'Range attribute is particularly nice because you can then write for-loops like:

    -- The following type is an array the indexes of which are 
    -- positive, and which can take any values thereof; we're
    -- using it to represent a bit-pattern.
    Type Array_Type is (Positive Range <>) of Boolean;
    
    -- But we're only interested in bits 24..32 of this hardware.
    SubType Interesting_Lines is Positive Range 24..32;
    
    -- We need to set bit 28 & 31, all others should be unset.
    Array_Variable : Array_Type(Interesting_Lines):= 
       (28 | 31 => True, others => False);
    
    -- We need to ensure the compiler puts Array_variable in the
    -- correct location.
    For Array_Variable'Address Use HARDWARE_ADDRESS;
    
    [...]
    
    -- Finally we need to process the information.
    For Index in Array_Variable'Range loop
      Some_Operation( Array_Variable(index) );
    end loop;
    

    The array example above has been doable since the beginning (Ada83) and combined with Ada's type/subtype system can be quite useful; such as having arrays of enumerations (which are NOT integers themselves and so cannot start at either 0 or 1) and the use of unconstrained arrays in parameters means you can write generalized functions which operate on sections of an array w/o monkeying about with translating indecision.

    {The new Ada2012 has an even more generalized for-loop which can operate on the containers.}

    Also, take a look at Ada's package spec/body separation; nicely done.

  • (cs) in reply to jay
    jay:
    The original post I replied to said "UK". I said "Britons". Last I checked, Scotland was part of both the UK and Britain.
    The last time I checked, Britain was part of Europe, but preciously few people on that island seem to acknowledge that fact.
  • (cs) in reply to Matt Westwood
    Matt Westwood:
    The one who says "Nice historically, but I don't bother with arrays much any more - I use Lists and ArrayLists and stuff like that" is probably beyond help.
    You obviously haven't used arrays in Java, or you are in a state of denial.

    Yes, of course ArrayList is backed by an array. But I struggle to come up with an advantage of T[] over List<T>.

  • anonymous (unregistered)

    int _x[256]; int * x = _x+1;

  • (cs)

    Ah, so Java got pointers now? Cool.

  • Neil (unregistered) in reply to da Doctah
    da Doctah:
    Harrow:
    Working with the various computer languages I learned that array numbering seems to fall into three categories:

    (1) Array indices always start with zero. This is most comfortable for assembler programmers first learning a compiled language. It also simplifies coding for multidimensional arrays if the compiler doesn't handle them.

    (2) Array indices always start with one. This feels natural and comfortable at first, but it fools many people into thinking they are programmers when they are not.

    (3) Array indices can start with any integer. This flexibility comes at a small cost -- every time you declare an array, you must declare its starting index. Usually you must declare its final index also.

    The basing of array indices is one of the best interview discussion topics. For example, a candidate who looks at the three categories above and says that (2) is a special case of (3) is probably a keeper.

    You missed one:

    (4) APL. Arrays may begin with one or with zero, but not with any other values. Which starting point is in effect at any given moment is determined by the setting of a particular system variable, which also affects such tangential matters as random-number generation and the calculation of factorials.

    As I recall, Perl 5 also does this; Perl 4 was a variant of case (3) where all arrays probably had to start with the same index, since the start index was a global, although it was a variable, so you could for instance use it as the low water mark for a newsgroup because it hadn't occurred to you that Perl might be able to handle an array of 10 elements starting at 10,000 just as easily as one starting at 1.

  • (cs) in reply to Dottore Ferrari
    jay:
    David:
    jay:
    They invented calculus
    Nope, that was the germans. The brits independently developed an inferior version that they somehow browbeat everyone into using. Presumably out of sheer malice.
    Yes yes, the Newton/Leibniz debate. Regardless of who got there first, there is every reason to believe that the two men each invented calculus independent of the other.
    Actually, Newton & Leibniz corresponded on the calculus (and, likely, other matters), so there was likely cross-pollination. Fortunately, the world adopted Leibniz's algebraic notation rather than Newton's more cumbersome geometric notation. As far as "who got it first", all you have to do is consult the British Royal Society's decision on the matter: Newton. The fact that Newton was the head of the deciding committee had nothing to do with the outcome, of course.
  • Norman Diamond (unregistered) in reply to Shark8
    Shark8:
    If you're a programmer and don't like imperial you're in the wrong business, imperial makes sense on computers: 1 Gallon = 128 oz 1 Quart = 32 oz 1 Pint = 2 Cups = 16 oz 1 Cup = 8 oz
    That is not imperial. It does make sense on computers but it is not imperial.

    Imperial: 1 Gallon = 160 oz 1 Quart = 40 oz 1 Pint = 2.5 Cups = 20 oz 1 Cup = 8 oz

    Imperial has the advantage that dry measurements are the same as liquid measurements (except that a gallon is called a bushel in dry measurements).

    In the US, dry measurements are the same as imperial. Only US liquid measurements are WTFs, which make sense on computers but which are still WTFs because they differ from everything else.

    1 imperial ounce = 1 US dry ounce = 28.35 ml. 1 US ounce by weight = 28.35 grams, oh look, consistency. 1 US liquid ounce = 29.4 ml. 1 troy ounce by weight = 31.1 grams.

    Well, metric also has the advantage that dry measurements are the same as liquid measurements. And there's only one version throughout the world. None of that nonsense like 1 ml differing from 1 cc in the sixth decimal place because the measurement of an underlying object had improved between the times of those two definitions ... ooops.

  • (cs)

    This may not actually be a WTF, at least not directly. It looks like the panels were redesigned at some point, which in some way changed all of the indices. Rather than figure out where the panels were referenced and do the translation there, they thought it would be easier to make this map to translate from old panel index to new panel index.

    Assuming this is the case, the real WTFs are:

    • What on earth were they changing about the panels that required reassigning all of the indices?
    • What kind of IDE doesn't have refactoring support anymore?
  • Jeremy Friesner (unregistered)

    I'm going to guess that they needed to expand the number of pages, while also retaining backwards compatibility with some not-so-well-thought-out legacy numbering scheme. If so, that would have been good to mention in the comment, though.

  • Peter Joosten (unregistered)

    Don't ask, the answer is 42 anyways.

  • (cs) in reply to Yoshi
    Yoshi:
    Coyne:
    Some people continued to design for cards long after they were dead and buried.

    And those, of course, would be the old programmers...

    I call shenanigans - how can you keep designing for cards when you're dead and buried?
    Me, I just take it as a sign that I need better grammar. See, what I might have written was:

    Some people continued to design for cards long after that technology was dead and buried.
    But despite my best efforts: That I have no gooder grammar from time-to-time I prove.

    :-)

  • Dhores (unregistered) in reply to Coyne

    hahaha. I Work there currently FML

  • Chris (unregistered) in reply to TheSHEEEP

    Could just as easily be JavaScript.

Leave a comment on “Ask the Index”

Log In or post as a guest

Replying to comment #:

« Return to Article