473,786 Members | 2,705 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 7095
On 1 Jun 2004 15:29:53 GMT, Da*****@cern.ch (Dan Pop) wrote:
In <40bafec8.17233 5531@news-server> oz****@bigpond. com (ozbear) writes:
On 29 May 2004 19:35:09 -0700, re********@yaho o.com (red floyd) wrote:
Da*****@cern .ch (Dan Pop) wrote in message news:<c9******* ***@sunnews.cer n.ch>...
In <bu************ *************** *****@4ax.com> Alan Balmer <al******@att.n et> writes:

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 (or was it 8?), with a '*' in
column 6(7) as continuation...

DISCLAIMER : It's been nigh onto 25 years since I've done FORTRAN IV.
My info on the specific columns may be incorrect.


Column 6 was for the continuation. Your code had to fit in columns
7 through 72. 73 through 80 was for a card sequence number, and
ignored by the compiler, IIRC.

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.


Why? None of these examples count as indentation being semantically
significant. You're merely confusing the fixed format of certain
languages and indentation.

FYI: I've used both fixed format Fortran and fixed format assemblers,
but fixed format has nothing to do with *indentation* being semantically
significant.


Nope. "Fixed format" is just a ruse to cover up what is actually
fixed indentation. If those rules were violated you didn't even
get to what was semantically equivalent because you never got past
compilation.

If you put your Fortran continuation character in the wrong column
you could easily end up with errors.

The point is that those columns had meaning to the compiler hence one
had to indent, hence indentation had meaning.

Oz
--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Nov 14 '05 #121
In article <ln************ @nuthaus.mib.or g> Keith Thompson <ks***@mib.or g> writes:
....
C grew out of the same history as Pascal; they're both descendents of
Algol, though C is less of a direct descendent.


Lessee. C if offspring from Jovial and the kind, which is offspring from
Algol 58. Pascal became because in the depelopment of Algol 68 Wirth did
not agree with the direction the committee was going.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Nov 14 '05 #122
On Tue, 1 Jun 2004 21:06:34 +0600, "I. Appel"
<ia****@rol.kil l.the.spammers. ru> wrote:
Well, I had to place more IMO's, but check this:

foo = lambda x, y: [str (i+j) for (i,j) in zip(x,y)]

Well, it's not very clear, but how many lines of code in C
would be required to reproduce it? Types of x and y can be
either lists of lists, lists of strings, lists of numbers
or strings. And it maybe used for all that stuff.

I don't understand, how several dozens lines of code can be
better than ONE line of code in non-esoteric language.


As you said, it's not very clear ;-) Actually, you'll have to define
"better" before you're qualified to offer an opinion.

--
Al Balmer
Balmer Consulting
re************* ***********@att .net
Nov 14 '05 #123
On Wed, 2 Jun 2004 12:21:48 +0600, "I. Appel"
<ia****@rol.kil l.the.spammers. ru> wrote:

I've seen code in C and Java written by several Python-haters. Most of them
don't use indents at all, so their code is pretty hard to read. See below.
You need to expand your circle of acquaintances :-) Most C and Java
programmers (in fact, all) that I know use indents, whether or not
they hate Python.
As for the indentation-oriented syntax, I strongly advise against it.
To me, it's very unnatural. In the huge majority of languages (natural
or programming ones), spaces are meant to be separators and esthetic
elements. Even if indenting has become natural for most programmers
when writing different code blocks in most languages (C, Pascal, Ada...)
I still think it's a visual improvement for readability - and shouldn't
be anything else. I really can't figure out the whole rationale behind
the Python syntax. And even if you claim that "such problems as leaving
behind tabs or spaces, it's generally no problem", it's not quite what
I have in mind in terms of "syntactic robustness".


Well, main idea behind Python's syntax is "we use indentation anyway (most
of
us at least), so what's the reason to make syntax redundant and to use
_both_
indents and delimiters?"

Are you agree?

Nope.

--
Al Balmer
Balmer Consulting
re************* ***********@att .net
Nov 14 '05 #124
In <40bd955e.34195 7500@news-server> oz****@bigpond. com (ozbear) writes:
On 1 Jun 2004 15:29:53 GMT, Da*****@cern.ch (Dan Pop) wrote:
In <40bafec8.17233 5531@news-server> oz****@bigpond. com (ozbear) writes:
On 29 May 2004 19:35:09 -0700, re********@yaho o.com (red floyd) wrote:

Da*****@cer n.ch (Dan Pop) wrote in message news:<c9******* ***@sunnews.cer n.ch>...
> In <bu************ *************** *****@4ax.com> Alan Balmer <al******@att.n et> writes:

> 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 (or was it 8?), with a '*' in
column 6(7) as continuation...

DISCLAIME R: It's been nigh onto 25 years since I've done FORTRAN IV.
My info on the specific columns may be incorrect.

Column 6 was for the continuation. Your code had to fit in columns
7 through 72. 73 through 80 was for a card sequence number, and
ignored by the compiler, IIRC.

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.


Why? None of these examples count as indentation being semantically
significant . You're merely confusing the fixed format of certain
languages and indentation.

FYI: I've used both fixed format Fortran and fixed format assemblers,
but fixed format has nothing to do with *indentation* being semantically
significant .


Nope. "Fixed format" is just a ruse to cover up what is actually
fixed indentation. If those rules were violated you didn't even
get to what was semantically equivalent because you never got past
compilation.

If you put your Fortran continuation character in the wrong column
you could easily end up with errors.

The point is that those columns had meaning to the compiler hence one
had to indent, hence indentation had meaning.


You're confusing fixed format and indentation. No amount of indentation
past column 7 has any semantic meaning in any Fortran version I'm familiar
with. Fixed format Fortran *completely* ignores any space character that
is not part of a "string literal". Because of this, it is sheer idiocy to
claim that indentation plays any *semantic* role in fixed format Fortran.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #125
"Alan Balmer" <al******@att.n et> wrote in message
news:f3******** *************** *********@4ax.c om...
Well, I had to place more IMO's, but check this:

foo = lambda x, y: [str (i+j) for (i,j) in zip(x,y)]

Well, it's not very clear, but how many lines of code in C
would be required to reproduce it? Types of x and y can be
either lists of lists, lists of strings, lists of numbers
or strings. And it maybe used for all that stuff.

I don't understand, how several dozens lines of code can be
better than ONE line of code in non-esoteric language.


As you said, it's not very clear ;-) Actually, you'll have to define
"better" before you're qualified to offer an opinion.


What is the reason to have syntax that is clearer-per-line, if it
requires to write several times more lines of code?

Ivan.
Nov 14 '05 #126
"Alan Balmer" <al******@att.n et> wrote in message
news:b9******** *************** *********@4ax.c om...
As for the indentation-oriented syntax, I strongly advise against it.
To me, it's very unnatural. In the huge majority of languages (natural
or programming ones), spaces are meant to be separators and esthetic
elements. Even if indenting has become natural for most programmers
when writing different code blocks in most languages (C, Pascal, Ada...) I still think it's a visual improvement for readability - and shouldn't be anything else. I really can't figure out the whole rationale behind
the Python syntax. And even if you claim that "such problems as leaving
behind tabs or spaces, it's generally no problem", it's not quite what
I have in mind in terms of "syntactic robustness".


Well, main idea behind Python's syntax is "we use indentation anyway (mostof
us at least), so what's the reason to make syntax redundant and to use
_both_
indents and delimiters?"

Are you agree?

Nope.


Well, it's a matter of taste and habits (some of had to tell that :-))), so
let's stop discussion here. I like syntaxes of both C and Python, while I
consider,
that both have their disadvantages.

Ivan.
Nov 14 '05 #127

On Wed, 2 Jun 2004, I. Appel wrote:

"Alan Balmer" <al******@att.n et> wrote...

[I. Appel, watch your attributions! ISTR *you* wrote:]

foo = lambda x, y: [str (i+j) for (i,j) in zip(x,y)]

Well, it's not very clear, but how many lines of code in C
would be required to reproduce it?


As you said, it's not very clear ;-) Actually, you'll have to define
"better" before you're qualified to offer an opinion.


What is the reason to have syntax that is clearer-per-line, if it
requires to write several times more lines of code?


Let's suppose C is five times clearer per line than your brand
of (is that obfuscated Haskell?), and it takes five times as many
lines of C code to write the same thing as you can write in
(whatever language that is).
Five times clearer per line, multiplied by five times as many
lines, yields twenty-five times the clarity. Hence, C is better
than Haskell. Q.E.D.

[that was a joke, son]

And now can you take the language wars off to comp.lang.misc or
somewhere else that actually *needs* the traffic?

-Arthur,
nonce equitur
Nov 14 '05 #128

"Old Wolf" <ol*****@inspir e.net.nz> wrote in message

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?

Microsoft was built on BASIC interpreters, so I imagine they keep the
langauge going for sentimental reasons.
Nov 14 '05 #129
"Dr Chaos" <mb************ ****@NOSPAMyaho o.com> wrote in message
news:sl******** *************** ********@lyapun ov.ucsd.edu...
Malcolm <ma*****@55bank .freeserve.co.u k> wrote:

"Dr Chaos" <mb************ ****@NOSPAMyaho o.com> wrote in message
Profound anti-intellectualism among practitioners, and cargo-cult
imitation. This spurious idea being that "gee, C was popular; so
why don't we make our language with Cish syntax so we might be
popular too."

Or maybe "C is popular so let's use a syntax that most programmers are
already familiar with".


Actually I think that's can be a worse idea---suggesting something
that 'almost works' the same, but in fact is subtly different is quite
dangerous.

Like, in the USA you might want to give your buddy who's had too much
to drink "a ride" home, but if you try offer that to your mates in
Sydney (as opposed to a "lift") you're likely to get socked. At least
in most straight bars.


Just don't "knock me up" in the morning!

When I began programming I used "Business BASIC" which compiled into an .exe
and (shockingly) didn't require line numbers unless you were going to "GOTO"
it. In those days a compile used to take 40 minutes or an hour or so. You
would "desk check" your code quite thoroughly, so after the compile it
actually worked. Programmers would time their builds - i.e. "You gonna
compile today?" "Yeah, I about an hour" "OK, meet you out back. See if Carl
is ready and we can play some craps..." "'K"

Then I learned Pascal and it was my language of choice for programming.
Remember Borland's "Turbo Pascal"? Compile times of 1 or 2 minutes, or less
for small stuff. It was amazing and I stopped losing so much money to Carl.
:-)

Anyhow, the point is that when I learned C, it was quite a lot like Pascal.
In fact it was TOO alike. I loved Turbo Pascal but the syntax was just about
the same as C, but it was hard to keep both in my brain. I finally had to
pick C and I've never looked back.

I see new developments like C# as a similar "problem". You can be a C++
"generic OS" programmer, or you can buy into the Microsoft World (tm) and go
with C#, but I believe it will be hard to keep the two in one's mind at the
same time. This is where the programmer will have to make a conscious
decision. (Best Darth Vader voice) "Feel the Power of the Dark Side."

--
Mabden
Nov 14 '05 #130

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

Similar topics

699
34241
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
3433
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
2316
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
2610
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
2976
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
7625
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
16253
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
9496
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
10363
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
10164
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...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9961
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
8989
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
7512
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
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3669
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.