473,889 Members | 1,674 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 7144
Mark McIntyre <ma**********@s pamcop.net> scribbled the following:
On Thu, 27 May 2004 21:11:28 +0100, in comp.lang.c , C# Learner
<cs****@learner .here> wrote:
Mark McIntyre wrote:
Okay, I'll bite. Why on earth do you consider this in any way an
improvement? What difference does it make to anything?
I believe that it'd improve code readability. 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. Have you noticed how, in
langauges which use such syntax,

....
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.

Gonads. This is nothing more than a style thing. French people put two
spaces after a full stop. English people don't. Same idea.


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 (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Hasta la Vista, Abie!"
- Bart Simpson
Nov 14 '05 #61
C# Learner <cs****@learner .here> writes:
Mark McIntyre wrote:
On Thu, 27 May 2004 00:56:59 +0100, in comp.lang.c , C# Learner
<cs****@learner .here> wrote:
One of the biggest flaws in C syntax, in my opinion, is the
required parentheses for test conditions.

if (FooBar(Parse(P rocess(GetInput ())))
DoSomething();

(he prefers)
if FooBar(Parse(Pr ocess(GetInput( ))):
DoSomething();

Okay, I'll bite. Why on earth do you consider this in any way an
improvement? What difference does it make to anything?


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.


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) ks***@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.
Nov 14 '05 #62
C# Learner <cs****@learner .here> writes:
[...]
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?


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) ks***@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.
Nov 14 '05 #63
Keith Thompson wrote:
[...] There are certainly some things I would
do differently if I were designing C from scratch today, [...]


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.

:-)
Nov 14 '05 #64
"C# Learner" <cs****@learner .here> wrote in message
news:%2******** *******@TK2MSFT NGP09.phx.gbl.. .
Keith Thompson wrote:
[...] There are certainly some things I would
do differently if I were designing C from scratch today, [...]


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.

:-)


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
Nov 14 '05 #65
From a thread started in comp.lang.c

Irrwahn Grausewitz wrote:
"Michael Voss" <mi**********@l vrREMOVE.deCAPS > wrote:

Irrwahn Grausewitz wrote:
[...snip...]
Smalltalk is a functional language.
How do you define "functional language" ?


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.


<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>

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.


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 (sz*****@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
Nov 14 '05 #66
C# Learner <cs****@learner .here> wrote:
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?
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.
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.


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.


_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.
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?
No.
An ideal pair would be a pair that isn't used
elsewhere in the language, for readability's sake.


Name one.
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 ;-)


So those who invented C's syntax are necessarily brighter than those who
invented, say, Python's syntax?


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.
Those features which have passed
through to modern languages have done so for a reason.


I honestly wonder what that reason is.


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

Richard
Nov 14 '05 #67
C# Learner <cs****@learner .here> wrote:
Keith Thompson wrote:
[...] There are certainly some things I would
do differently if I were designing C from scratch today, [...]


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


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
Nov 14 '05 #68
Joona I Palaste <pa*****@cc.hel sinki.fi> wrote:
Mark McIntyre <ma**********@s pamcop.net> scribbled the following:
Gonads. This is nothing more than a style thing. French people put two
spaces after a full stop. English people don't. Same idea.


I've seen plenty of English-speakers (at least USAns) write two spaces
atfer a full stop.


USAnians != English, and I believe you know Inform? Guess what its -d
option is for?

Richard
Nov 14 '05 #69
On Wed, 26 May 2004 20:42:39 -0400, Lew Pitcher
<lp******@sympa tico.ca> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

C# Learner wrote:
| Why is C syntax so uneasy on the eye?


%<

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.
Nov 14 '05 #70

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

Similar topics

699
34429
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
3444
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
2322
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
2619
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
2548
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
2985
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
3792
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
7635
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
16266
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
9969
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
9810
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
11203
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
10794
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
9612
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...
0
7151
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
6029
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4251
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3257
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.