473,770 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C Syntax

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...
Nov 14 '05
177 7079

On Mon, 31 May 2004, Dr Chaos wrote:

Arthur J. O'Dwyer <aj*@nospam.and rew.cmu.edu> wrote:

Not that I'm disagreeing, but *is* there any ambiguity avoided
by requiring parens around the condition in a 'do...while' loop?[1]
I don't know about C, but it may have been a holdover from Fortran,
where it does matter:


The Fortran 'DO' is somewhat different from the C 'do', if I
understand correctly. And neither of them is spelled 'if', as
in your examples below, which makes me suspect you didn't really
grasp the point.
! fortran
if (condition = something) then

because
if condition = something

can be also

ifcondition = something

an assignment.
s/can be also/actually means/, of course.
In C I don't see the issue, I admit.


Obviously, that

if foo (bar);

could be treated as either a conditional on foo with (bar); in the body,
or as a conditional on foo(bar) with a null statement in the body.
Requiring an extra set of parentheses around the condition disambiguates
the syntax.

-Arthur
[1] - leaving in the disclaimer for the benefit of jumpers-in...
(Also, there's no ambiguity avoided by the requirement of a semicolon
following the label of a 'goto'. Just defusing potential "do you
know you're being utterly ridiculous" responses. ;)

-Arthur

Nov 14 '05 #101

On Mon, 31 May 2004, ozbear wrote:

re********@yaho o.com (red floyd) wrote:
Da*****@cern.ch (Dan Pop) wrote:
None of the programming languages assigning semantics to indentation
has ever become mainstream. There must be a reason...


Not true. You're living in the present. In the past, when punch card
input was the norm, indentation had a meaning. In particular, FORTRAN
IV required input to begin in column 7 [...], with a '*' in
column [six] as continuation...


Cobol also (originally) used column-positional syntax, Area A,
Area B, and so on.

Columns 1 through 6 (or 7) was for sequence numbers, followed by
Area A for paragraph names, and Area B for code, but its been a long
time.

At any rate, Dan is incorrect.


No, as far as I can tell Dan is correct in this case (depending
on your definition of "mainstream "). Neither Fortran nor COBOL were
*free-form* languages, but they certainly weren't indentation-sensitive.
See the RPG language for another slightly more modern (but much less
"mainstream ") example, IIRC.

Fortran was not indentation-sensitive; in fact, one of the most
widespread anecdotes about Fortran is the "DO20I = 1.10" incident,
which hinges on the fact that Fortran didn't recognize anything
special about whitespace *at* *all*! You could write[1]

C WITH INDENTATION
DO 50 I=1, 99
BOTTLS = 100-I
PRINT 10, BOTTLS
10 FORMAT(1X, I2, 31H BOTTLE(S) OF BEER ON THE WALL.)
50 CONTINUE
STOP
END

or equally

C WITHOUT ANY INDENTATION
DO 50 I=1, 99
BOTTLS = 100-I
PRINT 10, BOTTLS
10 FORMAT(1X, I2, 31H BOTTLE(S) OF BEER ON THE WALL.)
50 CONTINUE
STOP
END

The fact that punch cards in the Good Old Days Before I Was
Born(TM) had designated areas in which it was okay to punch holes
representing code, or line numbers, or comments, has nothing to
do with the concept of "indentatio n."
See thread
http://groups.google.c om/gr************* ************@on line.de
in comp.lang.misc for some discussion tangentially related to
this topic. In fact, I'd suggest this whole discussion move
there, if you want to keep arguing about what's "indentatio n"
and what's not. Followups set.

-Arthur

[1] - Shamelessly nicked from the 99 Bottles of Beer project
and shortened with a blunt instrument. No warranties on
correctness.
Nov 14 '05 #102
Mark McIntyre <ma**********@s pamcop.net> writes:

|> >|> Yet another bogus generalisation coming from Joona. Quoting
|> >|> from a post from a French mailing list:

|> >|> ton enfant ? quel age?

|> >Doubtlessly a typo. Or simply incorrect use.

|> The second is a typo. I work for a french bank, and the vast
|> majority of french expats use spaces before and after emphatic
|> punctuation. Only the anglicised french omit the space.

|> Remind me what this has to do with C....

The French also put spaces before the semicolons in C programs:-).

--
James Kanze
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France +33 (0)1 30 23 00 34
Nov 14 '05 #103
Dr Chaos <mb************ ****@NOSPAMyaho o.com> wrote:

Besides, how many former Visual Basic programmers were really long-time
"regular" BASIC programmers? Not that large a fraction.


Why do you say that? I thought the whole raison d'etre of VB
was so that people who grew up with BASIC would still be in the
familiar. Why else would anybody use such a horrible language?
Nov 14 '05 #104
> The second is a typo. I work for a french bank, and the vast majority of
french expats use spaces before and after emphatic punctuation. Only the
anglicised french omit the space.


Well, in fact, both are wrong and right at the same time.

Typographically speaking, the kind of spacing that should be used just
before a punctuation mark such as a question mark or an exclamation mark
is NOT the same as the spacing used between two words, for instance.
It should be a "quart de cadratin", which is much less wide.
Unfortunately, plain ASCII text doesn't have much notion of typographic
spacing. It only knows of a basic space, which is as wide as can be.

Thus, I consider putting extra spaces before punctuation marks
a typo when using plain ASCII text, and more esthetically pleasing
to the eye to omit them. French or not.

I especially hate those who put a space before a period. Like this:
"This is fucked up ."

It's just confusing, ugly, and makes no typographic sense.
Nov 14 '05 #105
"Arthur J. O'Dwyer" <aj*@nospam.and rew.cmu.edu> wrote in message
news:Pi******** *************** ***********@uni x49.andrew.cmu. edu...
Obviously, that

if foo (bar);

could be treated as either a conditional on foo with (bar); in the body,
or as a conditional on foo(bar) with a null statement in the body.
Requiring an extra set of parentheses around the condition disambiguates
the syntax.


Consider the meanings of

if (foo)(bar);

and

if (foo) (bar);

That one little space changes things drastically.

S

--
Stephen Sprunk "Stupid people surround themselves with smart
CCIE #3723 people. Smart people surround themselves with
K5SSS smart people who disagree with them." --Aaron Sorkin

Nov 14 '05 #106
On Mon, 31 May 2004 13:56:01 -0700, Old Wolf wrote:
Dr Chaos <mb************ ****@NOSPAMyaho o.com> wrote:

Besides, how many former Visual Basic programmers were really long-time
"regular" BASIC programmers? Not that large a fraction.


Why do you say that? I thought the whole raison d'etre of VB
was so that people who grew up with BASIC would still be in the
familiar. Why else would anybody use such a horrible language?


Because Microsoft sells it, and anything they sell for that much money
must be worth buying?

:: Wait for laughter ::

Some schools teach VB. I guess they think it will be an easy language to
learn. Of course, since Python doesn't have a shiny IDE, it isn't a real
language. Besides, that nice Mr. Gates says open source is The DEVIL!

--
yvoregnevna gjragl-guerr gjb-gubhfnaq guerr ng lnubb qbg pbz
To email me, rot13 and convert spelled-out numbers to numeric form.
"Makes hackers smile" makes hackers smile.

Nov 14 '05 #107
Dr Chaos <mb************ ****@NOSPAMyaho o.com> wrote:
On Wed, 26 May 2004 22:02:42 +0100, C# Learner <cs****@learner .here> wrote:
Why is C syntax so uneasy on the eye?

In its day, was it _really_ designed by snobby programmers to scare away
potential "n00bs"?


No, but the programmers who designed it didn't care about "n00bs";
their target audience was people who worked at Bell Labs. They were
all very very smart.


Erm...
If so, and after 50+ years of programming research,
why are programming languages still being designed with C's syntax?


Profound anti-intellectualism among practitioners, and cargo-cult
imitation.


....don't you think these two statements are contradictory?

Richard
Nov 14 '05 #108
"I. Appel" <ia****@rol.r u> wrote:

[ Please do not snip attribution lines of people whose text you leave in
your replies. I have no idea who wrote the following: ]
Well, rephrasing Paul Graham, I should say "Don't wait until C will
become as clear as Python, use Python instead".


If you really think Python has clearer syntax than C, well, think twice.


Python programs are easier to read and understand, that's what I understand
as "clear".


Pardon me: _you_ consider Python programs to be easier to read and
understand. Other people, amongst whom the twice-quoted contributer
above and myself, disagree.

Richard
Nov 14 '05 #109

On Tue, 1 Jun 2004, Stephen Sprunk wrote:

"Arthur J. O'Dwyer" <aj*@nospam.and rew.cmu.edu> wrote...
if foo (bar);
could be treated as either a conditional on foo with (bar); in the body,
or as a conditional on foo(bar) with a null statement in the body.
Requiring an extra set of parentheses around the condition disambiguates
the syntax.


Consider the meanings of
if (foo)(bar);
and
if (foo) (bar);

That one little space changes things drastically.


For the benefit of jumpers-in: That one little space changes things
drastically only in some hypothetical language that is NOT C. C not
only treats most whitespace the same as a single space; it also ignores
most of it. Spaces around parentheses, for example, don't mean squat.
And I wouldn't want to risk programming in a language that *did* assign
critical meaning to single spaces, especially unobtrusive ones like
that.

-Arthur,
signing off
Nov 14 '05 #110

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
34231
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro capabilities, unfortunately. I'd like to know if it may be possible to add a powerful macro system to Python, while keeping its amazing syntax, and if it could be possible to add Pythonistic syntax to Lisp or Scheme, while keeping all of the...
22
3432
by: Tuang | last post by:
I'm checking out Python as a candidate for replacing Perl as my "Swiss Army knife" tool. The longer I can remember the syntax for performing a task, the more likely I am to use it on the spot if the need arises. If I have to go off and look it up, as I increasingly have to do with Perl's ever hairier syntax, I'm more likely to just skip it, making me even less likely to remember the syntax the next time. So I hear that Python is easier...
14
2315
by: Sandy Norton | last post by:
If we are going to be stuck with @decorators for 2.4, then how about using blocks and indentation to elminate repetition and increase readability: Example 1 --------- class Klass: def __init__(self, name):
16
2609
by: George Sakkis | last post by:
I'm sure there must have been a past thread about this topic but I don't know how to find it: How about extending the "for <X> in" syntax so that X can include default arguments ? This would be very useful for list/generator comprehensions, for example being able to write something like: instead of the less elegant explicit loop version that has to check for the length of each sequence. What do you think ? George
23
2539
by: Carter Smith | last post by:
http://www.icarusindie.com/Literature/ebooks/ Rather than advocating wasting money on expensive books for beginners, here's my collection of ebooks that have been made freely available on-line by their authors. There are lots of them out there but this selection cuts out the junk. If you know of any other good books that are freely available please post a link to them here and I'll consider adding them to the site.
19
2975
by: Nicolas Fleury | last post by:
Hi everyone, I would to know what do you think of this PEP. Any comment welcomed (even about English mistakes). PEP: XXX Title: Specialization Syntax Version: $Revision: 1.10 $ Last-Modified: $Date: 2003/09/22 04:51:49 $ Author: Nicolas Fleury <nidoizo at gmail.com> Status: Draft Type: Standards Track
4
3785
by: Jeremy Yallop | last post by:
Looking over some code I came across a line like this if isalnum((unsigned char)c) { which was accepted by the compiler without complaint. Should the compiler have issued a diagnostic in this case? (I think it's not required to, but I'd like confirmation). Jeremy.
4
7624
by: Bob hotmail.com> | last post by:
Everyone I have been spending weeks looking on the web for a good tutorial on how to use regular expressions and other methods to satisfy my craving for learning how to do FAST c-style syntax highlighting in C# but I have yet to find anything useful I know there are people at MS that know this stuff like the front of their hand and I know there are many people out on the web that are proficient in doing this as well but it seems nobody...
3
16251
by: Manuel | last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using devc++. So I've imported the glut32.dsp into devc++, included manually some headers, and start to compile. It return a very strange error. In your experience, where I should looking to find the real error? Surely the sintax of glut is correct... gcc.exe -c glut_bitmap.c -o glut_bitmap.o -I"C:/Dev-Cpp/include" -I"../../include" -D__GNUWIN32__ -W -DWIN32 -DNDEBUG...
0
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10260
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10102
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9910
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6712
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.