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
"C# Learner" <cs****@learner .here> wrote in message
news:eu******** ******@TK2MSFTN GP10.phx.gbl... One of the biggest flaws in C syntax, in my opinion, is the required parentheses for test conditions.
Without the parens you would need a "then" keyword of some kind. It seems
like an even trade.
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.
OTOH, C not using whitespace to mean anything gives programmers lots of
flexibility in how they format their source code to improve readability.
Block begin/end markers are very useful, and having such things explicit
arguably makes things easier for both the compiler and subsequent coders.
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?
That depends on the reader; the C version is far clearer to me. You also
put error-checking into the C version that's not in the Python one, which is
unfair when considering code length.
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
"C# Learner" <cs****@learner .here> wrote in message
news:eS******** ******@TK2MSFTN GP09.phx.gbl... These are trivialities. Learn five or six computer languages (or three or four that are entirely unrelated to each other), /then/ formulate your
opinion. Well, I have learned BASIC, C-like languages (C and C++), Delphi (formerly named 'Object Pascal') and Smalltalk.
So, basically, I've learned a couple of procedural languages, and a couple of OO ones.
And which one do seems you the best?
Which one seems to have the best syntax?
All your languages are Algol-derivative, so they share equivalent
syntactic constructs and all them are similar.
Try to learn something truly alternative. Try FORTRAN 77, the language
without any flame wars about indentation. Try LISP, the language with
syntax based on two symbols. Then come back.
When personally I met C, I already knew BASIC and Pascal and I was amused
by the expressiveness and brevity of C's syntax. I still think that
for (i=0;i<10;i++) {...}
is much better than
for i:=0 to 9 do begin ... end;
Some languages are exceedingly suscinct (i.e. APL or RPG), and some are very verbose (i.e. COBOL, SNOBOL, PL/I, Assembly (any
processor)). Some languages are procedural, some are OO, some are list processors, some are macro languages. Learn a few, see what they do and where they are used.
Only then can you conduct a reasonable conversation on the topic.
I don't understand why I'd need to learn a few more languages to understand that C's basic syntax could be nicer.
Suggest some improvements and I'll say you, why you're wrong ;-)
[I'll do the courtesy of a reply at the risk of getting flamed by the
comp.lang.c police.]
I. Appel wrote: "C# Learner" <cs****@learner .here> wrote in message news:eS******** ******@TK2MSFTN GP09.phx.gbl...
These are trivialities. Learn five or six computer languages (or three or four that are entirely unrelated to each other), /then/ formulate your opinion.
Well, I have learned BASIC, C-like languages (C and C++), Delphi (formerly named 'Object Pascal') and Smalltalk.
So, basically, I've learned a couple of procedural languages, and a couple of OO ones.
And which one do seems you the best? Which one seems to have the best syntax?
I'd say Delphi has the clearest syntax.
[...]
I don't understand why I'd need to learn a few more languages to understand that C's basic syntax could be nicer.
Suggest some improvements and I'll say you, why you're wrong ;-)
Simply:
1) Remove the need to specify parentheses for test conditions --
substitute a test condition terminator, such as Python's ':'.
2) Remove begin/end code block markers and require indentation instead.
C# Learner <cs****@learner .here> wrote: [I'll do the courtesy of a reply at the risk of getting flamed by the comp.lang.c police.]
[No police around, only conscious people.]
I. Appel wrote:
"C# Learner" <cs****@learner .here> wrote:
<snip> Well, I have learned BASIC, C-like languages (C and C++), Delphi (formerly named 'Object Pascal') and Smalltalk.
So, basically, I've learned a couple of procedural languages, and a couple of OO ones.
<snip>
Note:
"Procedural " and "OO" are not mutually exclusive language concepts.
Smalltalk is a functional language.
I don't understand why I'd need to learn a few more languages to understand that C's basic syntax could be nicer.
Suggest some improvements and I'll say you, why you're wrong ;-)
Simply:
1) Remove the need to specify parentheses for test conditions -- substitute a test condition terminator, such as Python's ':'.
2) Remove begin/end code block markers and require indentation instead.
Who or what is keeping you from designing a language incorporating the
worst of BASIC/Pascal/Python/FORTRAN/etc. worlds? Not that it will
ever have a fighting chance to be used by anyone for anything but as
an example of a language with a syntax "uneasy to the eye".
"Doctor, it hurts when I look at C."
"Well, then don't."
Regards
--
Irrwahn Grausewitz (ir*******@free net.de)
welcome to clc: http://www.ungerhu.com/jxh/clc.welcome.txt
clc faq-list : http://www.faqs.org/faqs/C-faq/faq/
clc OT guide : http://benpfaff.org/writings/clc/off-topic.html
Lew Pitcher wrote: I resemble that remark! :-)
You resemble[1] that remark? Are you intangible?
Do you also resent[2] that remark?
[1] to be like or similar to
[2] to feel or express annoyance or ill will at
C# Learner <cs****@learner .here> wrote: Why is C syntax so uneasy on the eye?
Beware the troll! This is cross-posted inappropriately .
Richard
"Justin Rogers" <Ju****@games4d otnet.com> wrote: 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.
C has plenty of ambiguity:
- Braces are optional if there is only one statement for if() or for() or
while(). (But not for do ... while(), switch, or structure/union
declarations.)
- If a statement has multiple side effects, the order in which those side
effects take place can be unknown.
- The right shift operator may or may not sign extend signed integers. Its
implementation defined.
- The size of an integer is platforms specific.
- The number of bits in a bytes is platform specific.
- Try this one on for size:
char a = -1, b = -2;
unsigned short x = (1 > 0) ? a : b;
printf ("x = %d\n", x);
What do you think is printed out? Explain it.
--
Paul Hsieh http://www.pobox.com/~qed/ http://bstring.sf.net/
Paul Hsieh wrote: "Justin Rogers" <Ju****@games4d otnet.com> wrote: 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.
C has plenty of ambiguity:
- Braces are optional if there is only one statement for if() or for() or while(). (But not for do ... while(), switch, or structure/union declarations.)
The braces are also optional on switch and do-while statements:
do something(); while (not_finished() );
switch (expression)
statement;
Struct or union declarations are not relevant: their components are
declarations, not statements.
None of your other examples were syntactically ambiguous.
Jeremy.
In <uL************ **@TK2MSFTNGP11 .phx.gbl> C# Learner <cs****@learner .here> writes: Why is C syntax so uneasy on the eye?
Uneasiness is in the eye of the beholder...
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
C# Learner wrote: Simply:
1) Remove the need to specify parentheses for test conditions -- substitute a test condition terminator, such as Python's ':'.
#define if if (
#define then )
int main(int argc, char **argv)
{
if argc-1 == 0 then return 666;
return 0;
} This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
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):
|
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
|
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.
| |
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
|
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.
|
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...
|
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...
|
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...
|
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,...
| |
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...
|
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,...
|
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...
|
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();...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |