Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > If you could change the C or C++ or Java syntax, what would you like different?

Reply
Thread Tools

If you could change the C or C++ or Java syntax, what would you like different?

 
 
Juha Nieminen
Guest
Posts: n/a
 
      10-10-2010
In comp.lang.c++ ClassCastException <(E-Mail Removed)> wrote:
> What, only five replies? What, nobody's even SUGGESTED operator
> overloading in Java yet?


I think the question was about *syntax*, not features. In other words,
which of the *existing* features of the language would you prefer being
able to write using a different syntax.
 
Reply With Quote
 
 
 
 
Rui Maciel
Guest
Posts: n/a
 
      10-10-2010
BartC wrote:

> This was the biggest problem I had, when trying to code a sizeable C
> project a couple of years back.
>
> The syntax I normally used had for ":=" for assignment, and "=" for
> equality.


That statement leads to believe that you delved into a "sizeable C project" without even knowing how
to program in C, which clearlly is not a problem related to the design of the C programming
language.


Rui Maciel
 
Reply With Quote
 
 
 
 
Michael Angelo Ravera
Guest
Posts: n/a
 
      10-10-2010
On Oct 8, 12:09*pm, Alexander <(E-Mail Removed)> wrote:
> Please share your oppinion on anything you do not like in the C or C++
> or Java syntax (they're quite similar).
>
> In order to maintain the integrity of the discussion (have everything
> at the same place) please respond on comp.lang.c.


Taking your post at face value, I'd like to see the ability to have a
sparse parameter list to a function, but this is kind of "out there".
You need first function with variable arguments and then a large
number of variable arguments and then a function that allows a large
number of arguments many of which aren't often needed, but might be
needed in any combination.

The API on an OS for which I write frequently has a function FIELINFO
with variable arguments, many of which you often don't need. If you
frequently need only either the file handle for the open file or a
filename for one that need not be open and these are the first two
nominal arguments. It would be cool not to have to count the damn
commas in the call:
FILEINFO (FNum,,,,,,,,, &rec_len); and instead to use a syntax like:
FILEINFO (fnum:FNum, lrecl:&rec_len); I picked colon because that is
how I think of it, we could just as eaily use accent grave or sharp or
dollar sign or even at sign
FILEINFO (fnum`FNum, lrecl`&rec_len);
FILEINFO (fnum$FNum, lrecl$&rec_len);
FILEINFO (fnum#FNum, lrecl#&rec_len);
FILEINFO (fnum@FNum, lrecl@&rec_len);
or even
FILEINFO (@fnum=FNum, @lrecl=&&rec_len);

using a colon seems most natural to me (equal sign would be more
natural, but things could get confusing in a hurry.)

By the way, yes there are better ways to design an API, like creating
an argument that specifies a list of the stuff that you want and an
argument into which to store the stuff that you want. In fact, that
idea was used for functions that were created later and which had more
values to return, but I will tell you that it is not any much easier
to use. Especially, if you only want 3 or 4 of the available pieces of
information returned.

 
Reply With Quote
 
BartC
Guest
Posts: n/a
 
      10-10-2010
"Richard" <(E-Mail Removed)> wrote in message
news:i8r4ne$pd6$(E-Mail Removed)-september.org...
> "BartC" <(E-Mail Removed)> writes:
>
>> "August Karlstrom" <(E-Mail Removed)> wrote in message
>> news:i8qsd9$ihp$(E-Mail Removed)...
>>> On 2010-10-08 21:09, Alexander wrote:
>>>> Please share your oppinion on anything you do not like in the C or C++
>>>> or Java syntax (they're quite similar).
>>>
>>> The assignment operator `=' will confuse any newcomer with a basic
>>> knowledge of mathematics. You can only imagine how many bugs it has
>>> caused
>>> in C and C++ when being inadvertently used as an equality operator
>>> instead
>>> of `=='.

>>
>> This was the biggest problem I had, when trying to code a sizeable C
>> project
>> a couple of years back.

>
> If that was the biggest problem then you should not have been anyhere
> NEAR a sizeable C project.


It was the biggest *practical* problem, amongst others, due to programming
in two syntaxes at once and getting the syntax muddled.

Of course there were also the usual kinds of problems of coding and getting
the thing working..

>> But, yes, the use of "=" and "==" in C I don't think were the best
>> choices,
>> but they have propagated through to too many other languages now.

>
> Is this some kind of sick joke going on here?
>
> Most common languages use "=" for assignment.


"=" and ":=" are both common, but yes I believe "=" is winning out. I
happened to have used ":=" for a few decades.

> And people manage just fine.


Using exclusively one syntax then it wouldn't be an issue.

--
Bartc

 
Reply With Quote
 
BartC
Guest
Posts: n/a
 
      10-10-2010
"Ian Collins" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On 10/10/10 03:46 PM, Richard Harter wrote:
>> On Sun, 10 Oct 2010 12:27:26 +1300, Ian Collins
>> <(E-Mail Removed)> wrote:
>>
>>> On 10/10/10 12:15 PM, Richard Harter wrote:
>>>> On Sat, 09 Oct 2010 16:35:36 +0100, Ben Bacarisse
>>>> <(E-Mail Removed)> wrote:
>>>>
>>>>
>>>>> I'd be prepared to say that "mixed" declarations (declarations with
>>>>> multiple forms of declarator) were considered idiomatic in "old" C. I
>>>>> remember coming across the advice of having one declarator per
>>>>> declaration quite late and thinking it rather odd and fussy.
>>>>
>>>> Count me as odd and fussy. I'm of the school that believes that
>>>> variables should have a well defined meaning and that that
>>>> meaning should be documented.
>>>
>>> And the best way to do that is to give them a meaningful name and
>>> declare them when they are needed. That way the use is obvious.

>>
>> Some people actually believe that.

>
> The truth is like that.


So if you were to write a novel, you wouldn't bother with any content, just
give it a very, very long title?

--
Bartc

 
Reply With Quote
 
Nick Keighley
Guest
Posts: n/a
 
      10-10-2010
On 9 Oct, 11:51, "BartC" <(E-Mail Removed)> wrote:

<snip>

> (C) Type declaration syntax. I'm surprised no-one has mentioned this
> elephant in the room.


me too!

> I find it utterly impossible once I go beyond the
> basics. I always need to try random combinations with CDECL until I get what
> I want, then safely lock the result away until I might need it again.


use typedef (which should be called typealias) and build your complex
type out of simpler components

<snip>

 
Reply With Quote
 
Nick Keighley
Guest
Posts: n/a
 
      10-10-2010
On 10 Oct, 02:24, Richard <(E-Mail Removed)> wrote:
> August Karlstrom <(E-Mail Removed)> writes:
> > On 2010-10-08 21:09, Alexander wrote:


<snip>

> > The assignment operator `=' will confuse any newcomer with a basic
> > knowledge of mathematics. You can only imagine how many bugs it has
> > caused in C and C++ when being inadvertently used as an equality
> > operator instead of `=='. In code comments it also makes the usage of

>
> Oh for goodness sake. It takes about a minute to learn what it does.


quite right

<snip>

> > It's a shame that a left arrow is not in the (7 bit) ASCII table. IMHO
> > `:=' is second best to the left arrow.

>
> Why does an obviously intelligent person keep harping on about language
> features that wont change and that are there for historical reasons?


the subject of the thread is "If you could change the C or C++ or Java
syntax, what would you like different?". If you aren't interested in
the topic then don't post to it.

> := would be a LOT worse in a language featuring ";" as a core part.


I've programmed in Algol-60, CORAL and Pascal and I noticed no
problem. Doesn't Ada do it this way as well?

> Lets move on to how Z=a?b:c; is impossible for ANYONE to understand....
>
> (I think its nice)


me too, though a lot of people don't for some reason. I've even seen a
programming standard that advised against its use. And had people
comment in code reveiws. And I don't nest them or use them in a hard
to understand manner.
 
Reply With Quote
 
BartC
Guest
Posts: n/a
 
      10-10-2010
"Richard" <(E-Mail Removed)> wrote in message
news:i8r4jh$pd6$(E-Mail Removed)-september.org...

> Why does an obviously intelligent person keep harping on about language
> features that wont change and that are there for historical reasons?
>
> := would be a LOT worse in a language featuring ";" as a core part.


Why?

--
Bartc

 
Reply With Quote
 
Nick Keighley
Guest
Posts: n/a
 
      10-10-2010
On 10 Oct, 11:44, "BartC" <(E-Mail Removed)> wrote:
> "Ian Collins" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...
>
>
>
>
>
> > On 10/10/10 03:46 PM, Richard Harter wrote:
> >> On Sun, 10 Oct 2010 12:27:26 +1300, Ian Collins
> >> <(E-Mail Removed)> *wrote:

>
> >>> On 10/10/10 12:15 PM, Richard Harter wrote:
> >>>> On Sat, 09 Oct 2010 16:35:36 +0100, Ben Bacarisse
> >>>> <(E-Mail Removed)> * wrote:

>
> >>>>> I'd be prepared to say that "mixed" declarations (declarations with
> >>>>> multiple forms of declarator) were considered idiomatic in "old" C. *I
> >>>>> remember coming across the advice of having one declarator per
> >>>>> declaration quite late and thinking it rather odd and fussy.

>
> >>>> Count me as odd and fussy. *I'm of the school that believes that
> >>>> variables should have a well defined meaning and that that
> >>>> meaning should be documented.

>
> >>> And the best way to do that is to give them a meaningful name and
> >>> declare them when they are needed. *That way the use is obvious.

>
> >> Some people actually believe that.

>
> > The truth is like that.

>
> So if you were to write a novel, you wouldn't bother with any content, just
> give it a very, very long title?


a program isn't a novel. A variable name can be perfectly clear and
short. I campaign for single letter variables if their type is
sufficiently clear.

void add_block_to_queue (Queue *q, Block *b)
{
some code
}

you analogy is a strawman




 
Reply With Quote
 
August Karlstrom
Guest
Posts: n/a
 
      10-10-2010
On 2010-10-10 03:29, Richard wrote:
> Over commenting tends to be the suck blanket for the incompetent.
>
> Comments are the *Last* thing that get updated in future maintenance
> since they're invariably already wrong or make no sense. Let the code do
> the talking and annotate with comments in only the most complicated
> areas. Clearly each function needs a terse docstring however. Possibly
> many variable declarations too.
>
> But anyone that writes code like this:
>
> int loopcount=0; /* the loop counter */
>
> needs a stern lecture.


Well said. From what I have seen, overly long identifiers and
meaningless prose tends to be quite common in the Java community.


/August

--
The competent programmer is fully aware of the limited size of his own
skull. He therefore approaches his task with full humility, and avoids
clever tricks like the plague. --Edsger Dijkstra
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
If you could change the C or C++ or Java syntax, what would you like different? Alexander C++ 68 11-08-2013 01:23 PM
don't like, so don't waste your time thinking and buy them. You know,if you don't like one thing, it means nothing for you.</p> fashion t shirts seller Cisco 0 06-13-2011 02:01 AM
If you could change the C or C++ or Java syntax, what would you like different? Alexander Java 60 11-04-2010 05:36 AM
Incredible - I bet you would like a camera like this! ~BD~ Computer Security 1 02-26-2009 09:45 PM
Would you like to host a website about Java programming? Jaga Java 0 12-02-2003 06:12 PM



Advertisments