Re: Chinese Syntax
From: Justin Rogers (Justin_at_games4dotnet.com)
Date: 05/27/04
- Next message: C# Learner: "Re: [OT] Re: Chinese Syntax"
- Previous message: Lew Pitcher: "Re: C Syntax"
- In reply to: C# Learner: "Re: Chinese Syntax"
- Next in thread: Paul Hsieh: "Re: Chinese Syntax"
- Reply: Paul Hsieh: "Re: Chinese Syntax"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 26 May 2004 17:16:38 -0700
As a long time programmer of many languages I've always found the explicit
statement bounding in C to be quite nice. For me it improves readability as
my seasoned internal tokenizer is capable of finding code blocks more quickly
by using the braces and parenthesis than by scanning whitespace. Whitespace
also breaks down quite fast when you start using non fixed width fonts and
mixing tabs and spaces. Arguably you could say, don't do that, but at least
with something of the nature of C and it's explit block scoping you can easily
write a pretty printer and avoid any ambiguity that would otherwise exist.
Take the following excerpt from a Python tutorial:
Tuple syntax
>From a syntax viewpoint, you create a tuple by placing a sequence of items
inside a pair of enclosing parentheses and separating them by commas. Note that
the parentheses can be omitted when such omission will not lead to ambiguity.
Note that they point out you can leave out parens only when it won't lead to
ambiguity. C doesn't make that mistake. They make sure there is no ambiguity,
and if you leave out a parens it doesn't make the statement ambiguous, it makes
it
a different or erroneous statement altogether.
-- Justin Rogers DigiTec Web Consultants, LLC. Blog: http://weblogs.asp.net/justin_rogers "C# Learner" <csharp@learner.here> wrote in message news:euOxH13QEHA.3744@TK2MSFTNGP10.phx.gbl... > 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?!
- Next message: C# Learner: "Re: [OT] Re: Chinese Syntax"
- Previous message: Lew Pitcher: "Re: C Syntax"
- In reply to: C# Learner: "Re: Chinese Syntax"
- Next in thread: Paul Hsieh: "Re: Chinese Syntax"
- Reply: Paul Hsieh: "Re: Chinese Syntax"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|