C Syntax

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • E. Robert Tisdale

    #46
    Troll Alert: C Syntax

    C# Learner wrote:
    [color=blue]
    > Why is C syntax so uneasy on the eye?
    >
    > In its day, was it _really_ designed by snobby programmers to scare away
    > potential "n00bs"? If so, and after 50+ years of programming research,
    > why are programming languages still being designed with C's syntax?
    >
    > These questions drive me insane. Every waking minute...[/color]

    This is an obvious troll. Please Ignore it.

    Comment

    • Keith Thompson

      #47
      Re: [OT] Re: C Syntax

      Grumble <a@b.c> writes:[color=blue]
      > C# Learner wrote:
      >[color=green]
      > > Simply:
      > > 1) Remove the need to specify parentheses for test conditions --
      > > substitute a test condition terminator, such as Python's ':'.[/color]
      >
      > #define if if (
      > #define then )
      >
      > int main(int argc, char **argv)
      > {
      > if argc-1 == 0 then return 666;
      > return 0;
      > }[/color]

      Yes, that's very clever. Please don't do it in any code that I might
      ever have to maintain, or read -- or that anyone else might ever have
      to maintain or read.

      --
      Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
      San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
      We must do something. This is something. Therefore, we must do this.

      Comment

      • Keith Thompson

        #48
        Re: Chinese Syntax

        qed@pobox.com (Paul Hsieh) writes:
        [...][color=blue]
        > C has plenty of ambiguity:
        >
        > - Braces are optional if there is only one statement for if() or for() or
        > while(). (But not for do ... while(), switch, or structure/union
        > declarations.)[/color]

        That's not an ambiguity, it just means there's more than one way to
        write a given program. The fact that braces are optional in many
        contexts does not imply that there is any C program that can be
        interpreted in any of two or more ways; the interpretation is
        unambiguous in each case.

        --
        Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
        San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
        We must do something. This is something. Therefore, we must do this.

        Comment

        • Keith Thompson

          #49
          Re: [OT] Chinese Syntax

          C# Learner <csharp@learner .here> writes:[color=blue]
          > Kieran Simkin wrote:[/color]
          [...][color=blue][color=green]
          > > Obviously this entire post is off-topic. Python is not C, C will never be
          > > Python and you've cross-posted to C# which is not C either.[/color]
          >
          > Hmm... I have to disagree. I feel that this discussion is about C's
          > basic syntax and its ubiquity in popular modern-day languages.
          >
          > If such a discussion is off-topic for comp.lang.c, then I honestly
          > don't know quite where it would be /on/-topic. In fact, I even
          > considered renaming the subject of this post to 'Re: C Syntax', but
          > didn't want to enrage people by doing so.[/color]

          Discussion of how other languages have influenced C would be topical
          in comp.lang.c. Discussion of how C has influenced a hypothetical
          language Foo would be topical (I presume) in comp.lang.foo. But if
          you want to discuss how C has influenced other languages in general,
          that's probably a good topic for comp.lang.misc.

          --
          Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
          San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
          We must do something. This is something. Therefore, we must do this.

          Comment

          • Old Wolf

            #50
            Re: [OT] Chinese Syntax

            Dan.Pop@cern.ch (Dan Pop) wrote:[color=blue]
            >
            > None of the programming languages assigning semantics to indentation
            > has ever become mainstream. There must be a reason...[/color]

            The language of makefiles?
            (Before you say "it isn't a language", it seems to be as much
            a language as Prolog is)

            Comment

            • Joona I Palaste

              #51
              Re: Chinese Syntax

              Mark McIntyre <markmcintyre@s pamcop.net> scribbled the following:[color=blue]
              > On Thu, 27 May 2004 21:11:28 +0100, in comp.lang.c , C# Learner
              > <csharp@learner .here> wrote:[color=green]
              >>Mark McIntyre wrote:[color=darkred]
              >>> Okay, I'll bite. Why on earth do you consider this in any way an
              >>> improvement? What difference does it make to anything?[/color]
              >>
              >>I believe that it'd improve code readability.[/color][/color]
              [color=blue]
              > I disagree. The delimiter helps mark the ends of the various parts of the
              > statement. With only whitespace to work with, compound statements become
              > almost impossible to correctly read.[/color]
              [color=blue][color=green]
              >>Have you noticed how, in
              >>langauges which use such syntax,[/color]
              > ....[color=green]
              >>they use spaces because of the fact that parentheses are used both
              >>in test conditions and function calls. As far as I see, when doing so,
              >>they're just attempting to work around a syntactical design flaw of the
              >>language.[/color][/color]
              [color=blue]
              > Gonads. This is nothing more than a style thing. French people put two
              > spaces after a full stop. English people don't. Same idea.[/color]

              I've seen plenty of English-speakers (at least USAns) write two spaces
              atfer a full stop. Now the French, they put a space before an
              exclamation or question mark. Like this: "Regardez moi ! Je suis
              français !". What's with that, then?

              --
              /-- Joona Palaste (palaste@cc.hel sinki.fi) ------------- Finland --------\
              \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
              "Hasta la Vista, Abie!"
              - Bart Simpson

              Comment

              • Keith Thompson

                #52
                Re: Chinese Syntax

                C# Learner <csharp@learner .here> writes:[color=blue]
                > Mark McIntyre wrote:
                >[color=green]
                > > On Thu, 27 May 2004 00:56:59 +0100, in comp.lang.c , C# Learner
                > > <csharp@learner .here> wrote:
                > >[color=darkred]
                > >> One of the biggest flaws in C syntax, in my opinion, is the
                > >> required parentheses for test conditions.
                > >>[/color]
                > >[color=darkred]
                > >> if (FooBar(Parse(P rocess(GetInput ())))
                > >> DoSomething();[/color]
                > > (he prefers)[color=darkred]
                > >> if FooBar(Parse(Pr ocess(GetInput( ))):
                > >> DoSomething();[/color]
                > > Okay, I'll bite. Why on earth do you consider this in any way an
                > > improvement? What difference does it make to anything?[/color]
                >
                > I believe that it'd improve code readability. Have you noticed how,
                > in langauges which use such syntax, people often write something like:
                >
                > if ( FooBar(Parse(Pr ocess(GetInput( ))) )
                >
                > i.e. they use spaces because of the fact that parentheses are used
                > both in test conditions and function calls. As far as I see, when
                > doing so, they're just attempting to work around a syntactical design
                > flaw of the language.[/color]

                I'm beginning to think your argument boils down to
                I like Python.
                I don't like C.

                If you'd stated it that way, I'm sure everyone here would be in
                complete agreement with you. We all agree that you like Python, and
                we all agree that you don't like C.

                Yes, I'm oversimplifying your argument and having a little fun at your
                expense.

                I think there's a valid point in here somewhere. Perhaps what you're
                really looking for is a language with something like C's relatively
                low-level semantics, but with Python's <OPINION>superi or</OPINION>
                syntax. I'm not aware that any such language exists. If it did, I
                might prefer it to C myself. But of course it would be off-topic
                here.

                Another valid question is why C's <OPINION>ugly </OPINION> syntax has
                had such an effect on later languages. As I mentioned elsethread,
                that's probably a good topic for comp.lang.misc; you might check the
                Google archives of that newsgroup.

                Significant changes to C's syntax are not possible due to the need to
                accomodate existing code. And such changes would be considered
                undesirable by most C programmers, who either have gotten used to C's
                quirks or actually like them. There are certainly some things I would
                do differently if I were designing C from scratch today, but that's
                probably very different from the set of changes someone else would
                want to make.

                --
                Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
                San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
                We must do something. This is something. Therefore, we must do this.

                Comment

                • Keith Thompson

                  #53
                  Re: [OT] Chinese Syntax

                  C# Learner <csharp@learner .here> writes:
                  [...][color=blue]
                  > a) Valid C syntax:
                  >
                  > if (foo &&
                  > bar) {
                  > foobar();
                  > }
                  >
                  > b) Similar code to the above but using my suggested syntax changes:
                  >
                  > if foo &&
                  > bar:
                  > foobar();
                  >
                  > Why wouldn't (b) be feasible here?[/color]

                  I don't believe that Python has the ?: operator. C does. I don't
                  know whether it would cause any genuine ambiguities for the proposed
                  "if ... :" syntax, but it could certainly cause confusion.

                  If I were going to propose such a change (I'm not), I might suggest
                  dropping the parentheses and making the braces around the controlled
                  statement mandatory. For example:

                  if foo &&
                  bar
                  {
                  foobar();
                  }

                  I think similar changes could consistently be made for other compound
                  statements.

                  Of course, it's never going to happen.

                  --
                  Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
                  San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
                  We must do something. This is something. Therefore, we must do this.

                  Comment

                  • C# Learner

                    #54
                    Re: Chinese Syntax

                    Keith Thompson wrote:
                    [color=blue]
                    > [...] There are certainly some things I would
                    > do differently if I were designing C from scratch today, [...][/color]

                    This is basically what I've had set in my mind while participating in
                    this thread.

                    I think I've finally found someone who's tuned into my wavelength,
                    perhaps; in any case, someone who truly understands my motive.

                    :-)

                    Comment

                    • Justin Rogers

                      #55
                      Re: Chinese Syntax

                      "C# Learner" <csharp@learner .here> wrote in message
                      news:%23f322iHR EHA.132@TK2MSFT NGP09.phx.gbl.. .[color=blue]
                      > Keith Thompson wrote:
                      >[color=green]
                      > > [...] There are certainly some things I would
                      > > do differently if I were designing C from scratch today, [...][/color]
                      >
                      > This is basically what I've had set in my mind while participating in
                      > this thread.
                      >
                      > I think I've finally found someone who's tuned into my wavelength,
                      > perhaps; in any case, someone who truly understands my motive.
                      >
                      > :-)[/color]

                      While Keith points out there are some things he would do differently, C#
                      is in essence the attempt at an entirely new language, and yet they kept all
                      of the older syntax. Anders was a Pascal guy, and yet he chose the
                      constructs he did in his custom tailored language why? Well, because he
                      thought they provided the most power for the language without denying users
                      access to some commonly used programming tools.

                      The first tool is debugging and error assessment. The strict language
                      guidelines
                      of C# make it very easy to discover the root of a lexical or parsing error. At
                      the same time they make it easy to point out and find common programming
                      mistakes.

                      Verbosity or the lack thereof as a tool:
                      Take language constructs like begin...end to designate blocks... They
                      are verbose, why not just type { and }, after all this is much shorter. Why do
                      I need to separate my code by all that whitespace:

                      if something:
                      foobar

                      When I could easily write it on one line without all of that crappy whitespace

                      if ( something ) { foobar; }

                      What about intellisense and other features users have grown to love? Are they
                      easier,
                      faster, more efficient when written against a C type language? Does the explict
                      bounding of statement/expression/block scopes help the underlying intellisense
                      processor
                      to more accurately understand what the user is doing? Does it remove levels of
                      ambiguity
                      that would otherwise exist? When does whitespace become important, when is it
                      not,
                      does tabs to spaces or spaces to tabs affect the compilation of your
                      application? What
                      happens to whitespace nested blocks when I use two spaces per indent, but
                      convert to
                      tabs that are 4 to 8 spaces per indent? Does my code resize properly or do all
                      of my 2/4/6
                      spaces get turned into a single tab. Does a tab count as a single indention
                      character or
                      multiple? For instance, does a single space or a single tab have the same
                      nesting depth?

                      There are so many more aspects to programming today than loading up your
                      favorite
                      text editor and hacking away in the most efficient form that you can manage.
                      Code generators,
                      intellisense, auto-complete, are all tools taking up precious processor time
                      trying to figure
                      out what you want to do, and I think the trade-off between some extra semantics
                      versus
                      confusing the hell out of the computer that is making my life a bit easier, is
                      something I'm quite
                      happy with.


                      --
                      Justin Rogers
                      DigiTec Web Consultants, LLC.
                      Blog: http://weblogs.asp.net/justin_rogers


                      Comment

                      • Michael Voss

                        #56
                        Is Smalltalk a functional language ?

                        From a thread started in comp.lang.c

                        Irrwahn Grausewitz wrote:[color=blue]
                        > "Michael Voss" <michael.voss@l vrREMOVE.deCAPS > wrote:[color=green]
                        > >
                        > >Irrwahn Grausewitz wrote:
                        > >[...snip...][color=darkred]
                        > >> Smalltalk is a functional language.[/color]
                        > >
                        > >How do you define "functional language" ?[/color]
                        >
                        > I don't - others already did. If you're interested in this subject
                        > I suggest to Go Ogle for the comp.lang.funct ional FAQ - it contains
                        > a nice explanation of functional vs. procedural programming paradigms.[/color]

                        <COMPLETELY OFF TOPIC EXCEPT FOR C.L.F>
                        My Google search revealed nothing except that other people are searching the
                        c.l.f FAQ, too. Any hint where I could find them ?
                        </COMPLETELY OFF TOPIC EXCEPT FOR C.L.F>

                        [color=blue]
                        > Ob the portion you snipped: While both C++ and Smalltalk are OO
                        > languages, the former is a mere procedural, the latter a mere
                        > functional language.[/color]

                        If a functional language is defined as:

                        --"The idea of functional languages is that functions are
                        --completely determined by their parameters. If you put
                        --the same parameters to a function, then you must get the
                        --same return values. So a function which does not take any
                        --parameters should always return the same result."
                        (Christian Szegedy (szegedy@nospam .or.uni-bonn.de) in comp.lang.funct ional
                        at 2004-03-19 07:19:21 PST),

                        In my eyes and regarding the above definition, Smalltalk is not a functional
                        language.

                        Since I crossposted this to comp.lang.small talk and comp.lang.funct ional:
                        What do you think ? Is Smalltalk an object-oriented "mere functional"
                        language ?


                        Since this is completely off-topic for c.l.c and m.p.d.l.c, and my
                        newsreader does not support a proper followup-to (blush): Please followup to
                        comp.lang.small talk and comp.lang.funct ional. Please remove the C /
                        C#-groups.

                        Thanks,
                        Michael


                        Comment

                        • Richard Bos

                          #57
                          Re: [OT] Chinese Syntax

                          C# Learner <csharp@learner .here> wrote:
                          [color=blue]
                          > a) Valid C syntax:
                          >
                          > if (foo &&
                          > bar) {
                          > foobar();
                          > }
                          >
                          > b) Similar code to the above but using my suggested syntax changes:
                          >
                          > if foo &&
                          > bar:
                          > foobar();
                          >
                          > Why wouldn't (b) be feasible here?[/color]

                          Because it is _not C_. If you want to design your own language, fair
                          enough. Hundreds if not thousands of people have done so before. Hey,
                          why don't you try to get M$ to change their Stolen-Java-with-an-
                          inappropriate-name syntax to include your pet love? At least then you
                          wouldn't have to convince so many people to change code that's been
                          working correctly for years or even decades.
                          [color=blue][color=green]
                          > > As you study and understand the language, you'll find that it's all
                          > > nicely consistent, and that there are good reasons for most of the
                          > > features which seem odd to you.[/color]
                          >
                          > The only way in which they seem odd to me is that they make code much
                          > less readable than it could be, in my opinion.[/color]

                          _Your_ opinion does not count for much (any more than mine) against an
                          existing language with probably tens (if we count all hobbyists,
                          hundreds) of thousands of users all over the world.
                          [color=blue]
                          > Okay, if you don't agree with the 'if'..':' idea, then how about
                          > changing the parentheses required for test conditions for a different
                          > pair of characters?[/color]

                          No.
                          [color=blue]
                          > An ideal pair would be a pair that isn't used
                          > elsewhere in the language, for readability's sake.[/color]

                          Name one.
                          [color=blue][color=green]
                          > > Also, think about the fact that language inventors and implementers
                          > > are, by and large, a pretty bright bunch. In general, they probably
                          > > have more and wider experience in the field than you do, and some of
                          > > them might even be as smart ;-)[/color]
                          >
                          > So those who invented C's syntax are necessarily brighter than those who
                          > invented, say, Python's syntax?[/color]

                          Not necessarily, though I must say I find Python's forced indentation a
                          veritable pain in the butt, and it is one of the main reasons why I
                          don't use the language.
                          [color=blue][color=green]
                          > > Those features which have passed
                          > > through to modern languages have done so for a reason.[/color]
                          >
                          > I honestly wonder what that reason is.[/color]

                          People found them useful. Better programmers than you found them useful.

                          Richard

                          Comment

                          • Richard Bos

                            #58
                            Re: Chinese Syntax

                            C# Learner <csharp@learner .here> wrote:
                            [color=blue]
                            > Keith Thompson wrote:
                            >[color=green]
                            > > [...] There are certainly some things I would
                            > > do differently if I were designing C from scratch today, [...][/color]
                            >
                            > This is basically what I've had set in my mind while participating in
                            > this thread.[/color]

                            Then I suggest you bloody well _do_ so, instead of bothering the users
                            of two existing languages, only related to eachother in name, about it.
                            If your language really does turn out to be superior to the existing
                            candidates, I'm sure you'll have no problems getting people to program
                            in it.

                            Richard

                            Comment

                            • The Real Andy

                              #59
                              Re: [OT] Re: C Syntax

                              On Wed, 26 May 2004 20:42:39 -0400, Lew Pitcher
                              <lpitcher@sympa tico.ca> wrote:
                              [color=blue]
                              >-----BEGIN PGP SIGNED MESSAGE-----
                              >Hash: SHA1
                              >
                              >C# Learner wrote:
                              >| Why is C syntax so uneasy on the eye?[/color]

                              %<

                              I am a former embedded programmer. I started programming with
                              assembler. C was a godsend. If you think the C syntax is uneasy on the
                              eye, then try learning 10 different assembler languages and using them
                              on a day to day basis. Try then to go back a year to maintain the
                              flavour of assembler from that period.

                              Comment

                              • C# Learner

                                #60
                                Re: [OT] Chinese Syntax

                                Justin Rogers wrote:
                                [color=blue]
                                > While Keith points out there are some things he would do differently, C#
                                > is in essence the attempt at an entirely new language, and yet they kept all
                                > of the older syntax. Anders was a Pascal guy, and yet he chose the
                                > constructs he did in his custom tailored language why?[/color]

                                Good question! :-)
                                [color=blue]
                                > Well, because he
                                > thought they provided the most power for the language without denying users
                                > access to some commonly used programming tools.[/color]

                                I also wonder to what extent he was required to keep the language
                                looking like C++/Java, and therefore attractive to current C++/Java
                                programmers. This is pure speculation on my part, of course; but I see
                                signs of it in the language, with an example being the 'switch'
                                construct. The syntax of 'switch' constructs is very different to that
                                of other syntactical elements of C#, and it seems to stick out like a
                                sore thumb. It appears that it was copied straight from C (although
                                with a difference in that C#'s version doesn't allow implicit fall-through).

                                <snip>

                                Comment

                                Working...