If you could change the C or C++ or Java syntax, what would you like different?

Discussion in 'C Programming' started by Alexander, Oct 8, 2010.

  1. Alexander

    Alexander Guest

    Please share your oppinion on anything you do not like in the C or C++
    or Java syntax (they're quite similar).

    In order to maintain the integrity of the discussion (have everything
    at the same place) please respond on comp.lang.c.

    Cheers,
    Alexander
     
    Alexander, Oct 8, 2010
    #1
    1. Advertising

  2. Re: If you could change the C or C++ or Java syntax, what would youlike different?

    Alexander wrote:
    > Please share your oppinion on anything you do not like in the C or C++
    > or Java syntax (they're quite similar).
    >
    > In order to maintain the integrity of the discussion (have everything
    > at the same place) please respond on comp.lang.c.
    >
    > Cheers,
    > Alexander


    ....and thus began a long, pointless and heated debate :)

    Doesn't sound like a good plan to me:

    1) It will annoy the regulars in comp.lang.c with lots of off-topic
    stuff about C++ and Java.
    2) It won't be actionable -- if you were serious about changing the
    syntax, you'd need to get on the standards committees and spend about a
    decade of effort working on the details.
    3) The syntax of each of the languages is different (despite a certain
    amount they have in common) -- it's very hard to have a productive
    discussion about three different languages at once.

    If I were a betting man, I'd say you were a troll.

    Regards,
    Stu
     
    Stuart Golodetz, Oct 8, 2010
    #2
    1. Advertising

  3. Alexander

    Dann Corbit Guest

    In article <f3bfce1a-e3d9-48e9-9c84-
    >, says...
    >
    > Please share your oppinion on anything you do not like in the C or C++
    > or Java syntax (they're quite similar).
    >
    > In order to maintain the integrity of the discussion (have everything
    > at the same place) please respond on comp.lang.c.


    If I wanted to change the features of the language, I would post to
    news:comp.std.c where the design of the language is discussed.

    If I were to add any feature to C, it would be a totally safe string
    type, that carries its length.

    But that is neither here nor there.
     
    Dann Corbit, Oct 8, 2010
    #3
  4. Alexander

    red floyd Guest

    Re: If you could change the C or C++ or Java syntax, what would youlike different?

    On Oct 8, 12:43 pm, Stuart Golodetz <> wrote:
    > Alexander wrote:
    > > Please share your oppinion on anything you do not like in the C or C++
    > > or Java syntax (they're quite similar).

    >
    > > In order to maintain the integrity of the discussion (have everything
    > > at the same place) please respond on comp.lang.c.

    >
    > > Cheers,
    > > Alexander

    >
    > ...and thus began a long, pointless and heated debate :)
    >
    > Doesn't sound like a good plan to me:
    >
    > 1) It will annoy the regulars in comp.lang.c with lots of off-topic
    > stuff about C++ and Java.
    > 2) It won't be actionable -- if you were serious about changing the
    > syntax, you'd need to get on the standards committees and spend about a
    > decade of effort working on the details.
    > 3) The syntax of each of the languages is different (despite a certain
    > amount they have in common) -- it's very hard to have a productive
    > discussion about three different languages at once.
    >
    > If I were a betting man, I'd say you were a troll.


    Or else some guy posting his homework question.
     
    red floyd, Oct 8, 2010
    #4
  5. Alexander

    Lew Guest

    Re: If you could change the C or C++ or Java syntax, what would youlike different?

    Alexander wrote:
    >>> Please share your oppinion on anything you do not like in the C or C++
    >>> or Java syntax (they're quite similar).


    I don't like the way people start flame wars about something that doesn't
    amount to a hill of beans in this world.

    >>> In order to maintain the integrity of the discussion (have everything


    *What* integrity?

    >>> at the same place) please respond on comp.lang.c.


    Stuart Golodetz wrote:
    >> ...and thus began a long, pointless and heated debate :)
    >>
    >> Doesn't sound like a good plan to me:
    >>
    >> 1) It will annoy the regulars in comp.lang.c with lots of off-topic
    >> stuff about C++ and Java.
    >> 2) It won't be actionable -- if you were serious about changing the
    >> syntax, you'd need to get on the standards committees and spend about a
    >> decade of effort working on the details.
    >> 3) The syntax of each of the languages is different (despite a certain
    >> amount they have in common) -- it's very hard to have a productive
    >> discussion about three different languages at once.
    >>
    >> If I were a betting man, I'd say you were a troll.


    red floyd wrote:
    > Or else some guy posting his homework question.


    I wouldn't bet against Stuart. The question doesn't really smell like
    homework, but it reeks of troll doo-doo.

    --
    Lew
    If you get on this discussion, you're going to regret it. Oh, not right away,
    but soon and for the rest of your life.
     
    Lew, Oct 8, 2010
    #5
  6. Re: If you could change the C or C++ or Java syntax, what would youlike different?

    On 10/08/2010 03:09 PM, Alexander wrote:
    > Please share your oppinion on anything you do not like in the C or C++
    > or Java syntax (they're quite similar).


    Let me try int &c in C, List<List<Foo>> in C++, or int *x; in Java. Oh wait.

    There is a not-insignificant amount of difference between C, C++, and
    Java. The primary things that are really the same between the languages
    is the use of curly braces for scope definition, semicolon-terminated
    statements, the use of `\' as an escape character, and the function
    calling syntax of func(args). The latter two are common even in those
    languages which are not curly-braced delimited (e.g., python), and
    aren't really anything that people would complain about.

    That pretty much leaves the curly-brace-delimited and
    semicolon-delimited natures as the only truly common parts of syntax
    which are arguable, and probably anyone who would be inhabiting these
    newsgroups are not going to be arguing against those.

    I would like to note that many of my... issues with C++ and Java
    syntaxes are of those constructs which are (more or less) unique to
    those languages [1], so "they're quite similar" isn't good enough.

    > In order to maintain the integrity of the discussion (have everything
    > at the same place) please respond on comp.lang.c.


    That sounds nice until you realize that many people on the other
    newsgroups don't follow comp.lang.c, such as yours truly.

    [1] Java generics and C++ templates are sufficiently different that I am
    going to call them unique constructs.

    --
    Beware of bugs in the above code; I have only proved it correct, not
    tried it. -- Donald E. Knuth
     
    Joshua Cranmer, Oct 9, 2010
    #6
  7. Re: If you could change the C or C++ or Java syntax, what would youlike different?

    On Oct 8, 6:26 pm, Lew <> wrote:
    > red floyd wrote:
    > Stuart Golodetz wrote:
    > > > If I were a betting man, I'd say you were a troll.

    > > Or else some guy posting his homework question.

    >
    > I wouldn't bet against Stuart.  The question doesn't really smell like
    > homework, but it reeks of troll doo-doo.


    I'd bet on a guy with "I'm gonna design a better
    language and write a compiler" day dreams.

    KHD
     
    Keith H Duggar, Oct 9, 2010
    #7
  8. Re: If you could change the C or C++ or Java syntax, what would youlike different?

    On Oct 9, 2:09 am, Alexander <> wrote:
    > ... anything you do not like in the C ... syntax.


    I'll offer 2 cents worth:

    (1) I happen to *love* C syntax. You might prefer
    Pascal syntax but, at the risk of sounding rude,
    why don't you just then go code in Pascal? :)

    (2) Some will mention the second-class nature of arrays
    as being bad. Some will mention the expression decay
    (foo[0] becomes *foo) as being confusing. *I think these
    facts result from a unique and wonderful elegance in
    the C language*.

    (3) That ==, etc. have precedence over & or | is annoying, but
    easy to remember once you get used to it. (Ritchie explains
    this is vestige of an early dialect which didn't distinguish
    & and &&.)

    (4) Declarations like char* a, b, c;
    are confusing: a is a pointer but b and c are not.
    (It's little problem for most of us, who write instead
    char *a, b, c;
    )

    Problem (4) seems like a problem that might afflict any
    linear language which, unlike Lisp, is not fully
    parenthesized.

    Uh oh. Someone's going to have the wonderful idea of
    2-D languages where editing is done with a click-based
    interface to open/close syntax nodes and get a "friendly"
    2D-like effect. Fortunately I won't be around to see it. :)

    James Dow Allen
     
    James Dow Allen, Oct 9, 2010
    #8
  9. "James Dow Allen" <> wrote in message
    news:...
    On Oct 9, 2:09 am, Alexander <> wrote:
    > ... anything you do not like in the C ... syntax.


    <--
    I'll offer 2 cents worth:

    (1) I happen to *love* C syntax. You might prefer
    Pascal syntax but, at the risk of sounding rude,
    why don't you just then go code in Pascal? :)

    (2) Some will mention the second-class nature of arrays
    as being bad. Some will mention the expression decay
    (foo[0] becomes *foo) as being confusing. *I think these
    facts result from a unique and wonderful elegance in
    the C language*.

    (3) That ==, etc. have precedence over & or | is annoying, but
    easy to remember once you get used to it. (Ritchie explains
    this is vestige of an early dialect which didn't distinguish
    & and &&.)

    (4) Declarations like char* a, b, c;
    are confusing: a is a pointer but b and c are not.
    (It's little problem for most of us, who write instead
    char *a, b, c;
    )

    Problem (4) seems like a problem that might afflict any
    linear language which, unlike Lisp, is not fully
    parenthesized.

    Uh oh. Someone's going to have the wonderful idea of
    2-D languages where editing is done with a click-based
    interface to open/close syntax nodes and get a "friendly"
    2D-like effect. Fortunately I won't be around to see it. :)
    -->

    the only notable syntax alteration I would likely want to make would be be
    to make the syntax non-ambiguous in the face of missing prior type
    declarations (say by using a more Java or C#-like declaration syntax, as in
    effectively requiring a single 'type name' which effectively terminates the
    type part of a declaration, and with no modifiers which may follow it). this
    is not likely to much effect the general look of the language much, or
    likely even impact all that much code (except obscure cases). however,
    as-is, absent typedefs the syntax is ambiguous and there is no real good
    solution within the confines of the standard (it would necessarily break
    standard conformance and cause some subset of otherwise conforming code to
    break).

    another would be to not require that, semantically, headers always behave as
    if they were lexically included (although this is less certain as there are
    many nifty things one can do with #if and #ifdef, and headers in general,
    which could be impacted...). (as is, there are only a few scenarios in which
    precompiled headers may be safely used).

    possibly, less ugly function pointers (especially when returning function
    pointers), but it is unclear what would be a solidly better syntax (many of
    my ideas could add ambiguities, or require backtracking, which is not good).

    so, alas, there is no solid way to "improve" the syntax in a general sense,
    as most possible changes would also come with many costs...

    or such...
     
    BGB / cr88192, Oct 9, 2010
    #9
  10. Alexander

    Ian Collins Guest

    Re: If you could change the C or C++ or Java syntax, what would youlike different?

    On 10/ 9/10 08:02 PM, James Dow Allen wrote:
    > On Oct 9, 2:09 am, Alexander<> wrote:
    >> ... anything you do not like in the C ... syntax.

    >
    > (4) Declarations like char* a, b, c;
    > are confusing: a is a pointer but b and c are not.
    > (It's little problem for most of us, who write instead
    > char *a, b, c;
    > )


    No problem at all for those of us who declare our variables at the point
    of initialisation.

    --
    Ian Collins
     
    Ian Collins, Oct 9, 2010
    #10
  11. Alexander

    Tim Streater Guest

    In article
    <>,
    James Dow Allen <> wrote:

    > (4) Declarations like char* a, b, c;
    > are confusing: a is a pointer but b and c are not.
    > (It's little problem for most of us, who write instead
    > char *a, b, c;
    > )


    Doesn't stop it being rubbish syntax. Along with the crap preprocessor
    it was one of the irritations I endured when first writing in C. It
    makes no sense that when I think I'm declaring a char, it turns out that
    some of the things I'm declaring are not, in fact, chars, but rather
    pointers to char (or, possibly, far worse).

    Too late to change now, though.

    --
    Tim

    "That excessive bail ought not to be required, nor excessive fines imposed,
    nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
     
    Tim Streater, Oct 9, 2010
    #11
  12. Ian Collins <> writes:

    > On 10/ 9/10 08:02 PM, James Dow Allen wrote:
    >> On Oct 9, 2:09 am, Alexander<> wrote:
    >>> ... anything you do not like in the C ... syntax.

    >>
    >> (4) Declarations like char* a, b, c;
    >> are confusing: a is a pointer but b and c are not.
    >> (It's little problem for most of us, who write instead
    >> char *a, b, c;
    >> )

    >
    > No problem at all for those of us who declare our variables at the
    > point of initialisation.


    Eh? How does char* a = 0, b = 0, c = 0; make the syntax any less
    error-prone? Did you mean "for those of us who declare our variables
    one per declaration"?

    For the record, I *like* C's declaration syntax and, left to my own
    devices, I'd be very happy to declare

    char buf[SIZE], *start = buf, c = *buf;

    Part of the reason I like it is that it is compact. The more of the
    semantically important code I can take in at once, the happier I am.

    I don't recall any hard bugs being due to a mistaken declaration. I'd
    imaging that most get found at the first compile. I agree that the
    layout is important. I can't abide either char* a; or char * a;.

    --
    Ben.
     
    Ben Bacarisse, Oct 9, 2010
    #12
  13. Alexander

    Ian Collins Guest

    Re: If you could change the C or C++ or Java syntax, what would youlike different?

    On 10/ 9/10 11:12 PM, Ben Bacarisse wrote:
    > Ian Collins<> writes:
    >
    >> On 10/ 9/10 08:02 PM, James Dow Allen wrote:
    >>> On Oct 9, 2:09 am, Alexander<> wrote:
    >>>> ... anything you do not like in the C ... syntax.
    >>>
    >>> (4) Declarations like char* a, b, c;
    >>> are confusing: a is a pointer but b and c are not.
    >>> (It's little problem for most of us, who write instead
    >>> char *a, b, c;
    >>> )

    >>
    >> No problem at all for those of us who declare our variables at the
    >> point of initialisation.

    >
    > Eh? How does char* a = 0, b = 0, c = 0; make the syntax any less
    > error-prone? Did you mean "for those of us who declare our variables
    > one per declaration"?


    Maybe "at the point of first use (which happens to be the point of
    initialisation)" would have been clearer?

    --
    Ian Collins
     
    Ian Collins, Oct 9, 2010
    #13
  14. Alexander

    Ian Collins Guest

    Re: If you could change the C or C++ or Java syntax, what would youlike different?

    On 10/ 9/10 11:12 PM, Ben Bacarisse wrote:
    > Did you mean "for those of us who declare our variables
    > one per declaration"?


    That too!

    --
    Ian Collins
     
    Ian Collins, Oct 9, 2010
    #14
  15. Alexander

    BartC Guest

    "Ben Bacarisse" <> wrote in message
    news:...
    > Ian Collins <> writes:


    >> No problem at all for those of us who declare our variables at the
    >> point of initialisation.

    >
    > Eh? How does char* a = 0, b = 0, c = 0; make the syntax any less
    > error-prone? Did you mean "for those of us who declare our variables
    > one per declaration"?


    Perhaps he means at the point of first use. Although this doesn't help much
    here:

    fn(&a);

    where fn is expected to initialise a which has not yet been declared.

    > For the record, I *like* C's declaration syntax and, left to my own
    > devices, I'd be very happy to declare
    >
    > char buf[SIZE], *start = buf, c = *buf;


    This is actually confusing; I wasn't sure what sort of pointer c was
    supposed to be at first, as I read it as c = &buf..

    > Part of the reason I like it is that it is compact.


    Not needing to declare variables is even more compact...

    If you mean you can declare arrays, pointers and single characters all in
    the same statement, then I suppose it might be. But not everyone would agree
    it's a good thing.

    --
    Bartc
     
    BartC, Oct 9, 2010
    #15
  16. Alexander

    Rui Maciel Guest

    Dann Corbit wrote:

    > If I were to add any feature to C, it would be a totally safe string
    > type, that carries its length.


    You can always write a library that wraps all string-handling functions from the standard library so
    that it can use a customized string data type (i.e., struct c_string {};). No matter how you cut
    it, the solution to that issue (which isn't necessarily a problem) will always assume that form.


    Rui Maciel
     
    Rui Maciel, Oct 9, 2010
    #16
  17. Alexander

    BartC Guest

    "James Dow Allen" <> wrote in message
    news:...
    > On Oct 9, 2:09 am, Alexander <> wrote:
    >> ... anything you do not like in the C ... syntax.

    >
    > I'll offer 2 cents worth:
    >
    > (1) I happen to *love* C syntax. You might prefer
    > Pascal syntax but, at the risk of sounding rude,
    > why don't you just then go code in Pascal? :)


    The languages don't do the same thing. Some people want to have the same
    coding freedom C provides, but with a different, perhaps more formal,
    syntax.

    I'm not a C programmer. But from attempting to compile other people's open
    source projects, it seems to me that a C programmer needs to know 4
    languages:

    (A) The C syntax itself

    (B) The preprocessor language, which at first looks ultra-simple, just a few
    #-directives, until you start using macros. This can lead to code which is
    no longer C, and horrendous to decipher if you are not the author.

    (C) Type declaration syntax. I'm surprised no-one has mentioned this
    elephant in the room. I find it utterly impossible once I go beyond the
    basics. I always need to try random combinations with CDECL until I get what
    I want, then safely lock the result away until I might need it again.

    (D) Make-file syntax. If you're trying to build an application, and no other
    instructions exist to assemble the project, then you're at the mercy of this
    syntax. Especially if the make-syntax is not compatible with your compiler,
    or you need to make changes.

    Taken all together, the whole thing can look a mess to anyone who doesn't
    deal with this every day and who thinks nothing of it.

    These comments apply to C. For C++, you can probably add (E) and (F). In
    other words, a nightmare.

    Java I don't know anything about; I understand it's big (having once spent
    ages downloading a 28MB version (as 20 chunks at 9.6Kbaud), then finding I
    needed another 20MB to download the docs before I could do anything).

    --
    Bartc
     
    BartC, Oct 9, 2010
    #17
  18. Alexander

    Felix Palmen Guest

    * Ian Collins <>:
    > On 10/ 9/10 11:12 PM, Ben Bacarisse wrote:
    >> Ian Collins<> writes:
    >>> No problem at all for those of us who declare our variables at the
    >>> point of initialisation.

    >>
    >> Eh? How does char* a = 0, b = 0, c = 0; make the syntax any less
    >> error-prone? Did you mean "for those of us who declare our variables
    >> one per declaration"?

    >
    > Maybe "at the point of first use (which happens to be the point of
    > initialisation)" would have been clearer?


    Which would be -- in the general case of first using them somewhere in
    the middle of a scope block -- illegal in C89.

    In fact, I like this C89 restriction. The beginning of a scope block is
    also a good place to document the variables that are needed inside with
    an appropriate comment. I even employ this in languages that would allow
    declarations anywhere, like C#.

    Regards,
    Felix

    --
    Felix Palmen (Zirias) + [PGP] Felix Palmen <>
    web: http://palmen-it.de/ | http://palmen-it.de/pub.txt
    my open source projects: | Fingerprint: ED9B 62D0 BE39 32F9 2488
    http://palmen-it.de/?pg=pro + 5D0C 8177 9D80 5ECF F683
     
    Felix Palmen, Oct 9, 2010
    #18
  19. Alexander

    Felix Palmen Guest

    * Tim Streater <>:
    > Doesn't stop it being rubbish syntax. Along with the crap preprocessor
    > it was one of the irritations I endured when first writing in C. It
    > makes no sense that when I think I'm declaring a char, it turns out that
    > some of the things I'm declaring are not, in fact, chars, but rather
    > pointers to char (or, possibly, far worse).


    Well, I have to admit it surprised me, too, because I first looked at C
    after programming some object pascal, so I was used to the concept that
    the attribute "pointer" applies to the type. But I think the C point of
    view, that the notion of a type only relates to the stored data and the
    attribute "pointer" instead applies to the individual variable, is
    equally valid.

    Regards,
    Felix

    --
    Felix Palmen (Zirias) + [PGP] Felix Palmen <>
    web: http://palmen-it.de/ | http://palmen-it.de/pub.txt
    my open source projects: | Fingerprint: ED9B 62D0 BE39 32F9 2488
    http://palmen-it.de/?pg=pro + 5D0C 8177 9D80 5ECF F683
     
    Felix Palmen, Oct 9, 2010
    #19
  20. Ian Collins <> writes:

    > On 10/ 9/10 11:12 PM, Ben Bacarisse wrote:
    >> Ian Collins<> writes:
    >>
    >>> On 10/ 9/10 08:02 PM, James Dow Allen wrote:
    >>>> On Oct 9, 2:09 am, Alexander<> wrote:
    >>>>> ... anything you do not like in the C ... syntax.
    >>>>
    >>>> (4) Declarations like char* a, b, c;
    >>>> are confusing: a is a pointer but b and c are not.
    >>>> (It's little problem for most of us, who write instead
    >>>> char *a, b, c;
    >>>> )
    >>>
    >>> No problem at all for those of us who declare our variables at the
    >>> point of initialisation.

    >>
    >> Eh? How does char* a = 0, b = 0, c = 0; make the syntax any less
    >> error-prone? Did you mean "for those of us who declare our variables
    >> one per declaration"?

    >
    > Maybe "at the point of first use (which happens to be the point of
    > initialisation)" would have been clearer?


    I'm not sure. If the following line is

    while (a != c) ...

    then the "point of first use" is the declaration I wrote. Similarly, if
    you need:

    char buf[SIZE], *start = buf, c = *start;

    I can't think of a form that is closer to declaring them at "the point
    of first use" than this! I accept that some people don't like this
    form, but I don't think it's related to initialising things just prior
    to use.

    --
    Ben.
     
    Ben Bacarisse, Oct 9, 2010
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex
    Replies:
    0
    Views:
    411
  2. Jaga
    Replies:
    0
    Views:
    368
  3. Hassan Bobo

    I would like to change my job

    Hassan Bobo, Sep 5, 2008, in forum: C++
    Replies:
    3
    Views:
    322
    Hassan Bobo
    Sep 8, 2008
  4. Alexander
    Replies:
    68
    Views:
    1,550
  5. Alexander
    Replies:
    60
    Views:
    1,487
    Thomas G. Marshall
    Nov 4, 2010
Loading...

Share This Page