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

L

luser- -droog

(e-mail address removed) (Felix Palmen) writes:
* Juha Nieminen <[email protected]> [comp.lang.c]:
It's a too-overloaded token: dos/windows paths,
 Did you know that you can use '/' to separate paths in dos/windows
as well? (Well, at least with all compilers I know.)
The compiler doesn't matter here. Most windows api functions accept
'/' nowadays (but not all). You're better off using '\' for the
windows platform, because there are still cases '/' won't work.
But then, it was Microsoft's awkward decision to use '\' as a path
separator with the rest of the world using '/'. It probably came back
on them the instant they built web functionality (browser, server) in
their OS.
My understanding is that early versions of MS-DOS didn't support
directories (or maybe it was CP/M).  By the time they decided to add
directories, they were already using '/' as an option delimiter (like
'-' in Unix).
Correct. MS-DOS 2.x introduced directories. Before that, MS-DOS, like
the other 8 bit OSen (FLEX, FLEX-09, CP/M, etc.), just had a flat list
of file names which was OK because few of its users could afford disks
big enough for the lack of directories to be a problem.

It's about to happen again. In the mid-80s we reached the scaling limits
of flat file lists and went to hierarchical directories. Now we're
approaching the scaling limits of hierarchical directories. I haven't
seen a modern system that doesn't have some ludicrously long full-path-
names of files, highly deeply nested directory structures, and human
trouble navigating the wilderness of files and keeping track of what
files are for what purpose. Applications come with numerous files; on
Windows systems they tend to be bundled with it in Program Files (with
some libraries being elsewhere, or else duplicated wastefully); on Unix
systems all kinds of config and other files get scattered to the four
winds, /usr, /etc, /bin, and ~/.appname. Documents might end up anywhere,
at least on Windows machines.

Another tension is between organizing by program and organizing by higher
level task. Say someone's throwing together a report and presentation.
The report is made in Word, the presentation in PowerPoint, both using
data from an Excel spreadsheet, and some of the graphs were copied,
pasted into Photoshop, prettied up, and then embedded as .png files. Oh,
and the whole thing is also HTMLized using FrontPage and posted to the
company LAN as well as the PP presentation presented at the Friday
afternoon general staff meeting and the printed report handed to the boss
afterward in the hall outside the conference room. And the guys that
couldn't attend the meeting in person phone-conferenced with those that
were while consulting the copy on the LAN's internal website.

So you've got Photoshopped pngs along with xls, doc, pp, and other files,
that logically are part of one project. The user wants to file them as
"2010 2nd quarter budget report" or whatever, under "2010 budget
reports", under "budget reports", ideally; the programs all would like to
keep track of their own files, docs with docs, xlses with xlses; and
Windows itself would dearly love it if you'd just shove the whole mess in
"My Documents" along with every single other file the user ever creates,
thus turning back the clock to 1982 and flat file lists again.

Unix users get nearly the analogous treatment with ~/ substituting for
"My Documents" and the gimp for Photoshop and other more or less
straightforward substitutions.

Add to that how every kind of browser, file sharing tool, or similar
client for downloadable content ends up with its own preferred
directories for storing received files, plus iTunes, plus various sync
folders for your phone and laptop, and so on, and so forth, and we're
rapidly heading straight back into file management hell.

What's our savior going to be? I'm beginning to suspect we're going to
soon see a wave of new file management tools, at first appearing as third-
party "knowledge manager" programs and eventually superseding Explorer-
style shells as those have superseded the old C:\ prompt. These will
provide their own nonhierarchical, link-based file management ability,
probably with the ability to easily convert any subnetwork of stuff into
web pages, or even acting as a web site itself; a locally-hosted web app
that can easily adapt to make some stuff publishable remotely. Hyperlinks
will creep into everything and become easy to create via drag and drop;
no copying and pasting (or worse, memorizing and typing) long filenames.

We already see hints of this with the big commercial websites. When was
the last time you saw a human-readable URL at a major news or corporate
site instead of something likehttp://site.example.com/html/content/
cms/1.45.907/08102010/58120156-18856-ac78f9d107bb8088.htm or similarly.
Occasionally you might see something like that but with a -report-on-iraq-
casualties just before the .htm, but dollars to doughnuts you can delete
that from the url or replace it with -report-on-stolen-doughnuts and it
will still fetch the same page.

Filenames and paths are becoming a layer increasingly managed by
automation instead of manually, now by big website CMSes and soon by
Windows 8 and Gnome 2015 I expect. The user will not type paths or even
drill down through folders, he will follow hyperlinks.

And when he needs to make a nonlocal jump he will use search. Faster,
more incremental, and better search than we have so far.

Vista already has raised the bar. I use some Vista machines and almost
never click Programs after Start, unlike when forced to use an older XP
box. Programs is slow, balky, unwieldy, and has shoddy ergonomics. It
worked at first and didn't scale, despite being hierarchical. Vista's
start menu has a nice fat incremental search box at the bottom just
begging for your input, and you can find something like Calculator much
faster by typing "calc" into it and then clicking one of the few
remaining items above than by clicking Programs, then Accessories, etc.
and waiting for each level of menu to unfold. Vista also makes it easy to
tag photographs and search by tag, just by typing e.g. tag:(budget OR
finance) into an Explorer window's upper-right-corner search box.

Two things still scale poorly: the searches aren't especially fast,
particularly on large tagged photo libraries, and photo tagging is itself
one tag at a time one image at a time with poor support for copy, paste,
or mass tagging (it would be nice to be able to select a large group of
images and assign a tag to the lot with one command).

The knowledge managers can beat Explorer by providing their own facility
for associating any imported object with metadata, including metadata,
and using suitable lightweight local database software to make it fast to
search. This allows tagging images that aren't JPEG or TIFF (so don't
have EXIF metadata) and tagging non-images, as well as doing so in a
uniform manner. (EXIF tags and other document-format-supported metadata,
like mp3 ID3 tags, could be imported when a file is first seen by the
system.) Metatagging is most important, of course, for nonverbal data
such as audio, still pictures, and video. (Advanced tools could
potentially attempt voice recognition on audio and OCR on stills and
video to extract what verbal content is in there, but fuzzy-matching
would have to be used for this to be searchable I expect, and even then
an unlabeled photo of an apple would not be found by searching for
"apple" without solving some hard problems in AI and machine vision.)

So your documents become much more searchable and you can link them into
a web of interrelatedness. Something like this almost HAS to replace
Explorer-style shells in the very near future, I'm thinking, if only
because of the stupendous explosion of user-generated audiovisual content
that has to be searchable and the general scaling problems happening with
users' documents nowadays.

Sounds like Xerox Star!
 
L

luser- -droog

I thought you were suggesting one.


I'd prefer a keyword that included "type" in it because alias is a very
general word, but I agree that there might be a better word.  I don't
agree (given the C language we have) that the #define you posted makes
anything better.


#define typealias typedef

?
 
R

Rui Maciel

Jon said:
Stop lying: you're a "shoot-from-the-hip gunslinger". I know what you're
thinking:

"Did he fire six shots or only five?" Well, to tell you the truth, in all
this excitement I kind of lost track myself. But being as this is C, the
most powerful programming language in the world, and would blow your
finger clean off, you've got to ask yourself one question: "Do I feel
lucky?" Well, do ya, punk?

Are you high?


Rui Maciel
 
R

Rui Maciel

ClassCastException said:
There's one way in which the collision can bother *the C coder*, though:
the backslash has to be escaped in string literals, unlike the forward
slash, and paths are commonplace string literals, so on systems that use
the backslash the coder may be inconvenienced by the need to do much more
escaping than on systems that use the forward slash path separator.

I see what you mean but I don't believe that to be a problem. If a programmer decides to, for
example, rely on a CPP macro to specify text strings, including paths, that extend for multiple
lines then he will expect the trailing backslash. Even if the programmer has difficulties
remembering this, he only needs to start using any text editor which implmeents syntax highlighting.


Rui Maciel
 
N

Nick Keighley

A "safe string type" is not necessarily, nor it needs to be, a string literal.

and you can initialise a "safe string" from a string literal.

std::string s ("pippo");
Safe_string s = ss_create ("pippo");
 
N

Nick Keighley

It's a too-overloaded token: dos/windows paths, line continuation,
escape... making for unnecessary contextual analysis by parsers.

continuation lines are sorted out before the parser gets a look in.
And \ in strings also don't need parsing.
 
N

Nick Keighley

terrible advice.

Look, this whole thread is a contrafactual. *if* we'd been sitting at
Dennis Ritchie's right hand when he was designing C what would we have
suggested to him?. There's no suggestion that any of these changes to
C are actually real.
I thought you were suggesting one.


I'd prefer a keyword that included "type" in it because alias is a very
general word, but I agree that there might be a better word.  I don't
agree (given the C language we have) that the #define you posted makes
anything better.

my original suggestion was "typealias" not "alias"
 
N

Nick Keighley

I have no idea how far from universal "pretty much universal" is but I
can think of:

    B C++ C# Objective-C D Haskell Java PHP (two equality operators
    neither of which is =) Perl Python Fortran (again two, == and .eg.)
    Ruby Lua Scala Erlang (two again) Algol 68 (one the two is not =)
    Prolog TCL

and probably others.  How many would make it not pretty much universal?

Scheme

(set! i 1)
 
N

Nick Keighley

It is NOT a definition. It is a claim. It reads: "x equals y + 1". Of
course, whoever writes anything like that is convinced that the claim
really is true. But whent it comes to expression evaluation, it's just
natural to check the claim and assign a boolean value to it.

Assignment is something completely different. You see assignment in
mathematics when defining a function:

f: x -> x²

I can't see an assignment there. I see a definition. Does f change
during the course of the proof (computation?)
 
N

Nick Keighley

Scheme

    (set! i 1)

nonsense of course. I'm confusing assignment with equality (see it
*is* confusing!)

scheme has various ways of testing for equality

(= i 1)
(eq? i 'red)
(string=? i "red yellow")

etc.
 
N

Nick Keighley

You are joking?

why? I've always thought it quite a reasonable idea. What's the
problem?

But then I always thought having to explicitly take the address of
something to mimic pass by reference was bizzare.

swop (&i, &j);
 
N

Nick Keighley

I want to know when its a pointer.

I realise its the new fad to make C look like some hackup like Java but
I want to know what I am dealing with.

"->" tells me just that.

so you're in favour of specially operators for floating point numbers?

i = i + 1;
d = d +d 1.0;

because I too want to know if I'm dealing with an integer or a
floating point

Couldn't you just look at the definition, which will be close by, if
you are momentarily confused about the type of a variable?
 
B

Ben Bacarisse

Jon said:
Pfft. I know better than to "suggest" a change to the ISO C standard in
this ng.

Eh? I know you didn't. You suggested a #define. I was commenting on
only on that and, in particular, the value you claimed it would have for
new programmers.

<snip>
 
B

Ben Bacarisse

luser- -droog said:
#define typealias typedef

?

Jokes are best flagged in some way (a smiley or maybe a few !!s). If
this was not a joke (it certainly made me smile) the I refer you to the
previous posts from Keith Thompson and myself.
 
B

Ben Bacarisse

Nick Keighley said:
and you can initialise a "safe string" from a string literal.

std::string s ("pippo");
Safe_string s = ss_create ("pippo");

For the C version, you can't do this at file scope (but that may not
matter much). If you don't have C99 things are worse -- you can't use
this method to initialise an element of an aggregate.
 
B

Ben Bacarisse

Nick Keighley said:
nonsense of course. I'm confusing assignment with equality (see it
*is* confusing!)

scheme has various ways of testing for equality

(= i 1)
(eq? i 'red)
(string=? i "red yellow")

Yes, one of which is, in fact, = so I left it out. I should have left
Algol 68 out for the same reason.
 
M

Martin Gregorie

* Keith Thompson said:
But then, it was Microsoft's awkward decision to use '\' as a path
separator with the rest of the world using '/'. It probably came back
on them the instant they built web functionality (browser, server) in
their OS.
[early MS-DOS]
The Unix convention probably wasn't as widespread then as it is now, so
using '\' wasn't an obviously absurd choice at the time. (VMS, for
example, uses '.' to separate directory names.)

Maybe it wasn't too obvious back then that interoperability could matter
some day. But, (we're talking about 1980...) Unix was already used a
lot. Only 5 years later, AmigaOS had the "standard" path separator (and
also, to some extent, the concept of mounting devices).
....and Microware OS-9, which appeared in 1980 thus preceding MS-DOS, used
the UNIX convention of / in pathnames and -options and provided system
support for holding text (error messages etc.) independently of programs.
Its still alive and well in the realtime embedded OS world. Indeed, some
of us still run it on desktops. I have the 1992 vintage OS-9 v2.4 and
have yet to find a bug in the OS, utilities or development tools. I was
and am impressed with that record.
 
K

Keith Thompson

luser- -droog said:
#define typealias typedef

?

I agree that "typedef" was not a good choice of name for the semantics.
Perhaps "typealias" would have been better.

But "typedef" is in the language, and it's not going away. Every C
programmer needs to understand that "typedef" doesn't define a type
(just as "const" doesn't mean constant).

Adding an obfuscating macro *does not help*, any more than
#define BEGIN {
#define END }
#define IF if (
#define THEN ) {
and so on.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,123
Messages
2,570,718
Members
47,284
Latest member
LeroyOlver

Latest Threads

Top