Forum Moderators: phranque

Message Too Old, No Replies

Who invented programming languages?

and why did the ' become end of string?

         

txbakers

8:02 pm on Apr 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Probably the most frustrating thing about programming with databases is dealing with the single quote (and sometimes double quotes).

Way back, after the dinosaurs, but before the Beatles broke up, we learned that a single quote was the End of String character.

Which was great until Sean O'Malley tried to type in his name.

You'd think that in the XX years since then someone would come up with a better way to deal with end of strings.

And while we're on the subject, why is the ' still the comment character for VB?

What Genius decided this?

2by4

8:10 pm on Apr 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



why is the ' still the comment character for VB?

All kidding aside, my guess is that the internal microsoft culture simply does not allow certain common sense things, but insists on doing it their own way. Just look, for example, at \ as a path separator. Why? Because unix uses /. Forget that / is easier to type and reach than \, what matters is that it be different. I had an MS programmer friend who used to complain about having to type that \ constantly when programming.

So why do asp/vb only support a commenting syntax nobody else, as far as i know, uses? I'd guess the same reason. They didn't want vb or asp to look like other programming languages, they made up their own rules so they would be different.

I have to admit, every time I even look at asp or vb code it's the commenting stuff that makes me swear never to use it. Why on earth have they not implemented block commenting? /* because they don't want to look like a real programming language */, there's no rational reason for it as far as I can see.

Anyway, I'm sure someone will come up with some excuse as to why bad ideas are actually good, but that's what it looks like from what I've seen dealing with MS.

Couldnt' think of a better way to end a string than ' off the top of my head, I guess ~ string ~ or something, but any character will cause issues at some point or other, you'd always have to protect against it, and stuff like: beginstring...... endstring take too long to type.

kaled

9:38 pm on Apr 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A common character was necessary - bear in mind that that operating systems like Unix (and the programming languages that created them) date back to the sixties/seventies and teletypes, etc. Provided a means is available to insert the string delimiters, it doesn't really matter what character is used.

Kaled.

BigDave

11:39 pm on Apr 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I thought 0x00 was end of string and double quotes were what enclosed a string. Single quotes are what you put around a character. Or if I think back to SPL all the strings had and integer stringlength before the start of the actual text. Then back in the days of basic, strigs ended with a $ if I recall.

You have to provide some subset of special characters, and every language I know of provides some way to escape those characters. It is the nature of the beast.

Just look, for example, at \ as a path separator. Why? Because unix uses /. Forget that / is easier to type and reach than \, what matters is that it be different.

The reason for going with \ instead of slash had nothing to do with being different. It had to do with MS hiring a lot of old VMS programmers away from DEC in the early days of DOS. VMS used '/' for command line options insted of '-'. At the time DOS was using the flat directory structure of CP/M so there was no need for a path separator. When that need did come about, since / was already taken, they did not see a problem with using \ at the time. They never thought that the machines would work together.

I heard from a friend that was there at the time, that there were some really interesting discussions about that, but the most entertaining was the meeting where they were trying to explain '..' to billg. He just didn't understand the concept.

pinterface

11:53 pm on Apr 11, 2006 (gmt 0)

10+ Year Member



You mean we haven't come up with better ways to deal with strings?

Perl has the q// and qq// operators, allowing things like:

qq(I'm a hippopotamus (really!), I lounge about all day.)

Python has very handy triple-quotes:

"""I saw Sally and she said "You, sir, are poorly dressed." before she ran away."""

Nevermind heredoc syntax, allowing for lovely things such as:

my $string = <<<END_GILBERT_AND_SULLIVAN;
I am the very model of a modern Major-General
I've information vegetable, animal, and mineral
I know the kings of England, and I quote the fights historical
From Marathon to Waterloo, in order categorical
END_GILBERT_AND_SULLIVAN

(Admittedly, Perl probably has the nicest heredoc syntax of any language I've come across; it's a bit painful in other languages.)

As for databases, most any language I know has libraries providing database abstraction facilities allowing something along the lines of:

$db->query("INSERT INTO oven (one, tasty, duck) VALUES ?, ?, ?", $x, $y, $z);

where all the quoting and escaping is handled automagically.

With all that I don't see the quotes surrounding strings as an issue anymore. But then, they never really bothered me, so maybe I'm just used to them?

zCat

11:55 pm on Apr 11, 2006 (gmt 0)

10+ Year Member



You'd think that in the XX years since then someone would come up with a better way to deal with end of strings.

Voila, I present you Perl:


print "\"This is a 'string'\"";
print '"This is a \'string\'";
print q¦"This is a 'string'"¦;
print q("This is a 'string'");
print q{"This is a 'string'"};
print q/"This is a 'string'"/;
print q\"This is a 'string'"\;
...

(Replace q with qq for variable interpolation).

For longer strings, or those which will contain every possible symbol character, there's also this option:


print <<END_OF_MY_MULTILINE_STRING;
"This is a 'string'", he said.
"$%(&/)=¦{] Micro'Soft", said the gibbering sysadmin.
END_OF_MY_MULTILINE_STRING

2by4

12:00 am on Apr 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



bigdave, today seems to be the day for interesting factoids, I should post more, LOL... nice one though, I've never heard that.

BananaFish

5:24 pm on Apr 14, 2006 (gmt 0)

10+ Year Member



The reason for the single quote deal is so that hackers can sql inject the sites of people that have no understanding of how they work.

VB's single quote comments are just plain idiotic, I guess they couldn't use // or # because that's what people are used to.

john_k

5:40 pm on Apr 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



VB inherited the comment syntax from BASIC.

As for the difficulty of dealing with apostrphes or quotation marks embedded in a string, the two most common methods for escaping them are pretty easy to implement:

For non-MS stuff, it is usually the \ character.
'O\'Malley'

For MS stuff, just double up the character.
SQL Server: 'O''Malley'
VB: "I said ""YES!"""

john_k

5:52 pm on Apr 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh yea - one other thing. I always get a kick out of the phrase "single quote." (Sorry tx)

Single quote: "Et tu Brutus?"
Single quotation mark: "
Not a single quote: '
Apostrophe: '
Double quote: She said he said "That one blowed up real good!"
Double quotation mark: ""
Not a double quote: ''
Double apostrophes: ''

Please use the terms "apostrophe" and "quotation mark" in these types of discussions. The term "double quote" is ambiguous and can be interpreted as either of these
""
''

2by4

9:44 pm on Apr 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Looks like it might be entering the language though.
[foldoc.org...]
[foldoc.org...]

and so on
google [google.com]

or at php.net [us3.php.net]

I think when people are talking code, they know what is being referred to, and it's not unclear to use the term single or double quote, it's not ambiguous in that context.

And in fact, if you told me to surround a string with apostrophes, I'd have to really think about what you were saying: you mean, I should add an apostrophe to each end of the string before inserting it between the single quotes? That's how I'd interpret that statement.

Surround it with single quotes, or double quotes, it's pretty clear. I'd say this has gotten well past the stage of a mere convention now, and could be considered as the correct way to speak about single and double quotes in the context of programming and code.

Sometimes language changes, slowly, to adapt to new useage patterns, like this case. That always annoys people who like to get annoyed about such things. But there is no 'proper' language, it's always evolving and changing, that's just how it is. Especially with technical things that are evolving very fast.

So I'll stick to using single and double quotes to mark off string ends and beginnings, and I'll escape quotation marks and apostrophes within those strings as required, even when those strings may or may not contain quotes, or quotes of quotes.

When a term is used frequently, it's common for shorthand version of that term to evolve, like in this case.

Now I'm going to go back to 'surfing' the 'web' while staring at my 'monitor' and 'typing' on my 'keyboard' and occasionally using my 'mouse', either 'single-clicking' or 'double-clicking' as may be required by the 'website' I'm visiting.

It's fun watching language evolve.

txbakers

11:05 pm on Apr 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



speaking of evolving language....

how many people on this board know the meaning of:

splashdown

or a

rumble seat

zCat

11:12 pm on Apr 14, 2006 (gmt 0)

10+ Year Member



splashdown

The activity I associate with that is the landing of a Mercury, Gemini or Apollo capsule on / in the sea.

2by4

1:20 am on Apr 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



An old friend of mine told me about driving to the dances with his buddies crammed into the rumble seat. Sounds fun.

BigDave

3:17 am on Apr 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



john_k,

It seems that the OED and the history of the word "quote" disagrees with you.

Here is part of their definition of "quote":

b. A quotation mark.
1888 JACOBI Printers' Vocab. 109. 1891 Scot. Leader 2 Apr. 6 The portion of this quotation which we have put within quotes. 1895 Nation (N.Y.) 14 Mar. 191 Lodge's “Americanism”..will get the “double quotes” every time. 1920 WODEHOUSE Coming of Bill I. ii. 24 Below the signature, in what printers call ‘quotes’, a line..‘Bear the torch and do not falter.’ 1937 Daily Express 4 Feb. 6/3 New use for ‘quotes’ (‘inverted commas’) came to light at the Scottish Literary luncheon in London yesterday. 1955 T. H. PEAR Eng. Social Differences iii. 90 The upper class fashion of speaking in ‘quotes’{em}‘I don't mind if I do’ (in a pronounced Cockney accent). 1969 ‘J. MORRIS’ Fever Grass ii. 24 He'd have witnesses if I put him in the dock. Witnesses in quotes, I mean. 1976 New Yorker 16 Feb. 37/1 Freezes over close quote, paragraph.

It actually seems that "quote" was first shorthand for the marks, and only in recent times did is become shorthand for "quotation"

On the other hand, "apostrophe" actually refers to the missing letters in a word, and the mark that is in their place has taken on their name when used to replace those letters. While on a standard keyboard it may be the same character as single quotes, in the typographic world they are distinctly different marks.

john_k

5:16 am on Apr 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It seems that the OED and the history of the word "quote" disagrees with you.

Damn. I hate it when that happens.