7 votes

Language Design: Stop using <> for generics

5 comments

  1. [3]
    skybrian
    Link
    I find this unconvincing because it asserts that array syntax is unimportant without any explanation.

    I find this unconvincing because it asserts that array syntax is unimportant without any explanation.

    12 votes
    1. 9000
      Link Parent
      Yeah, I feel like arrays as a data structure have been pretty consistent for a really long time, and their syntax hasn't changed much? What syntax would they prefer, getters and setters? Like, I...

      Many languages used [] [... for ...] array lookup (array[0]), adding pointless complexity to the language for very little benefit – as such built-in syntax usually becomes dead weight a few years down the road, as the preferred choice of data structure implementation evolves.

      Yeah, I feel like arrays as a data structure have been pretty consistent for a really long time, and their syntax hasn't changed much? What syntax would they prefer, getters and setters?

      Like, I get the first part of their point. I just recently implemented a parser for part of the C++ spec, and yeah, there are shift/reduce conflicts when you see <<, because it's not immediately clear whether it is the bitshift operator or the opening of a nested generic. But, I've never heard anyone else complain about brackets for array look ups, especially without offering a preferred syntax.

      6 votes
    2. ducc
      Link Parent
      I was confused about that part too. Maybe I'm misreading, but it seems to imply that square-bracket array lookup syntax is pointless and complex? Either way, IMO, <> is better for generics because...

      I was confused about that part too. Maybe I'm misreading, but it seems to imply that square-bracket array lookup syntax is pointless and complex? Either way, IMO, <> is better for generics because it's visibly different than array lookups.

      4 votes
  2. cwagner
    (edited )
    Link
    As with so many of these, I wonder: Does the author not use syntax highlighting? He offers no solution (besides taking away array/list syntax for… reasons?) and a proper text editor would void the...

    As with so many of these, I wonder: Does the author not use syntax highlighting? He offers no solution (besides taking away array/list syntax for… reasons?) and a proper text editor would void the user side of the problems (I have no idea about parsers/compilers, but making parsing a little harder does not seem like a big issue to me, maybe I’m wrong?)

    edit: spelling

    2 votes
  3. vakieh
    Link
    I've never had an issue reading < > in code. If the person who wrote this has an issue, it might be a personal difficulty? (call it a mini-dyslexia) - they should change their font to one with...

    I've never had an issue reading < > in code. If the person who wrote this has an issue, it might be a personal difficulty? (call it a mini-dyslexia) - they should change their font to one with larger < > symbols.

    As for the compiler... the workarounds work. Far less expensively than the cost to retrain developers for near zero practical benefit, too.

    2 votes