Re: Chinese Syntax

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: C# Learner (csharp_at_learner.here)
Date: 05/26/04


Date: Thu, 27 May 2004 00:56:59 +0100

Alex Moskalyuk wrote:

> Have you ever looked into Perl or Lisp code?
>
> C suddenly starts making perfect sense.
>
> What's uneasy to you? Curly braces, parentheses, keywords, or something
> else?

One of the biggest flaws in C syntax, in my opinion, is the required
parentheses for test conditions.

Here's a very simple example:

     void Foo
     {
         if (FooBar(Parse(Process(GetInput())))
             DoSomething();
     }

Imagine if, instead, we could write the following:

     void Foo
     {
         if FooBar(Parse(Process(GetInput())):
             DoSomething();
     }

Python uses such a construct for test conditions.

Another nicety about Python is the fact that whitespace is used for
defining code blocks. This makes code much clearer than the equivalent
C code, which requires block being/end markers.

Here's a very simple Python code sample:
http://www.kernelthread.com/hanoi/html/py.html .

Try staring at it for one minute.

After having done so, take a look at this:
http://www.kernelthread.com/hanoi/html/c.html .

Even if one's accustomed to C syntax, the former is still clearer and
easier-to-read, don't you think?

Every time I see code that conforms to C's basic syntax, I cringe; yet I
write such code every day.

Why C? Why?!



Relevant Pages

  • Re: Chinese Syntax
    ... Curly braces, parentheses, keywords, or something ... One of the biggest flaws in C syntax, in my opinion, is the required ... Python uses such a construct for test conditions. ... This makes code much clearer than the equivalent ...
    (comp.lang.c)
  • Re: Chinese Syntax
    ... the parentheses can be omitted when such omission will not lead to ambiguity. ... > One of the biggest flaws in C syntax, in my opinion, is the required> parentheses for test conditions. ... > Python uses such a construct for test conditions. ...
    (comp.lang.c)
  • Re: Chinese Syntax
    ... the parentheses can be omitted when such omission will not lead to ambiguity. ... > One of the biggest flaws in C syntax, in my opinion, is the required> parentheses for test conditions. ... > Python uses such a construct for test conditions. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: [OT] Chinese Syntax
    ... > defining code blocks. ... This makes code much clearer than the equivalent ... > Here's a very simple Python code sample: ... Maybe I'm just used to C syntax. ...
    (comp.lang.c)
  • Re: [OT] Chinese Syntax
    ... > defining code blocks. ... This makes code much clearer than the equivalent ... > Here's a very simple Python code sample: ... Maybe I'm just used to C syntax. ...
    (microsoft.public.dotnet.languages.csharp)