473,836 Members | 2,136 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 7122
Justin Rogers wrote:
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?
Good question! :-)
Well, because he
thought they provided the most power for the language without denying users
access to some commonly used programming tools.


I also wonder to what extent he was required to keep the language
looking like C++/Java, and therefore attractive to current C++/Java
programmers. This is pure speculation on my part, of course; but I see
signs of it in the language, with an example being the 'switch'
construct. The syntax of 'switch' constructs is very different to that
of other syntactical elements of C#, and it seems to stick out like a
sore thumb. It appears that it was copied straight from C (although
with a difference in that C#'s version doesn't allow implicit fall-through).

<snip>
Nov 14 '05 #71
> --"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."


he-he.
C is not functional too.
Try rand() function.

--
Dmitry Zamotkin
Nov 14 '05 #72
I'll actually bite on the below since I have some input. There was a Java
to IL compiler written before C# made it's first test runs, so I can't see
Java being the *look*. Managed C++, while syntactically appearing to
be a hack, was powerful enough to handle the C++ style syntax.

The reason for the way the switch statement in C# is works is the manner
in which the underlying IL construct works. In IL a switch is nothing more
than a simple jump table. They don't provide fall through because that
would require automatic generation of goto statements within the case
statement body. In most cases fall-through in C led to unexpected results
as users failed to close the syntax when that is what they meant to do.

As for the strange look of a switch, it is a balance of verbosity and function.
You might say that each case statement could indeed be it's own block and
should use french braces the way the rest of the language does, but that
doesn't allow for any form of fall-through.

case 10 { block } case 20 { block }

Where do you fall through in the above block? How do you have the
equivalent limited fall through syntax that C# does allow?

case 10:
case 20:
break;

Note, you are also building from the concepts of a label, each case
statement is terminated by a colon, something you don't find anywhere
else in C#, yet it is there. Each case statement semantically becomes a
label of some sort, a jump table label if you will. No different from having
an OUTER: label within a loop so that you can break out of the internal
loop and continue processing the outer loop.

What I'd highly recommend is write a lexer/parser that targets C# and then
change the language the way you'd like to see it changed. See how hard/easy
it is to format the code in your new manner and see how scalable that is for
adding new features. Would, for instance, you changes to the language have
affected the almost transparent addition of generics? What about namespace
aliasing and anonymous delegates? The future of the language is just as
important
as it's past, and C# is quickly becoming a very unique and promising language in
many ways.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

I also wonder to what extent he was required to keep the language
looking like C++/Java, and therefore attractive to current C++/Java
programmers. This is pure speculation on my part, of course; but I see
signs of it in the language, with an example being the 'switch'
construct. The syntax of 'switch' constructs is very different to that
of other syntactical elements of C#, and it seems to stick out like a
sore thumb. It appears that it was copied straight from C (although
with a difference in that C#'s version doesn't allow implicit fall-through).

<snip>

Nov 14 '05 #73
Keith Thompson wrote:
Grumble wrote:
#define if if (
#define then )

int main(int argc, char **argv)
{
if argc-1 == 0 then return 666;
return 0;
}


Yes, that's very clever.


CPP - Exercice #1
http://www.infop6.jussieu.fr/cederom...al-in-cpp.html

:-)

Nov 14 '05 #74
"Michael Voss" <mi**********@l vrREMOVE.deCAPS > wrote:
<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 ?
The first hit googling for "functional language faq"
(without the quotes) is:

http://www.cs.nott.ac.uk/~gmh//faq.html

See section 2.1
</COMPLETELY OFF TOPIC EXCEPT FOR C.L.F> 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.smal ltalk and comp.lang.funct ional. Please remove the C /
C#-groups.


Done.

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
Nov 14 '05 #75
"E. Robert Tisdale" <E.************ **@jpl.nasa.gov > wrote in message
news:c9******** **@nntp1.jpl.na sa.gov...
C# Learner 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"? 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...


This is an obvious troll. Please Ignore it.


This is an obvious troll-responder. Please ignore it. ;-)
Nov 14 '05 #76
Justin Rogers wrote:

<snip>
Would, for instance, you changes to the language have
affected the almost transparent addition of generics? What about namespace
aliasing and anonymous delegates?
Well, I'm not really thinking /that/ much into it -- I'm just thinking
about very basic syntax.

In any case, I look forward to generics, which I feel will make for
slightly more readable code, and perhaps more efficient code.

Anonymous delegates look nice too -- I read an article awhile back about
the ability to use them in an elegant fashion to marshall calls from a
worker thread onto the UI thread.
The future of the language is just as
important
as it's past, and C# is quickly becoming a very unique and promising language in
many ways.


Yeah, definitely. These are exciting times for programmers.
Nov 14 '05 #77
In <c9**********@o ravannahka.hels inki.fi> Joona I Palaste <pa*****@cc.hel sinki.fi> writes:
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.


It has nothing to do with the language. It's a common (albeit not
universal) typographic convention to leave more space after the
punctuation sign terminating a sentence then after punctuation signs
inside a sentence. Examine a few printed books carefully and you may
notice it (it's not twice as much, so it's not immediately obvious).

The only way to follow this convention in a plain text document is by
using two spaces instead of one. This is what I'm consistently doing,
no matter in which of the three languages I'm familiar with I'm writing.
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?


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

ton enfant ? quel age?

:-)

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #78
In <84************ **************@ posting.google. com> ol*****@inspire .net.nz (Old Wolf) writes:
Da*****@cern.c h (Dan Pop) wrote:

None of the programming languages assigning semantics to indentation
has ever become mainstream. There must be a reason...


The language of makefiles?


Indentation per se is meaningless there. It's just that the language
syntax requires a TAB character as the first character on a line in
certain contexts.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #79
> >>I'd say Delphi has the clearest syntax.

Delphi is boring. IMO syntax of C is much more funny.


<my opinion>
Delphi code is, in general, much more readable than C code. Therefore,
Delphi coders have an easier life than C coders.
</my opinion>


Well, yes. But Python or Visual Basic code is IMO even more readable.
Nov 14 '05 #80

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

Similar topics

699
34347
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
3439
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
2320
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
2613
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
2544
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
2983
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
3788
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
7631
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
16257
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
9810
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
10527
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
10241
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...
1
7773
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
6973
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
5642
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...
0
5812
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4441
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4001
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.