Jump to content
Die Holländer

Delphi and "Use only memory safe languages"

Recommended Posts

4 minutes ago, Lars Fosdal said:

hey kept start index 1 to stay compatible with the short strings. At some point it might be desirable to change it, but ... well... Bye bye backwards compatibility.

The mobile platform was a failed experiment to move string to be zero based. 

Share this post


Link to post

Since Delphi is kind of a legacy programming language nowadays, backwards compatibility is very important. You don't want to throw away millions lines of proven code because they don't work any more, or even worse, because they are now buggy. So trying to change strings to be zero based was a bad idea, even if it was "just for mobile platforms".

  • Like 2

Share this post


Link to post
1 hour ago, dummzeuch said:

Since Delphi is kind of a legacy programming language nowadays, backwards compatibility is very important. You don't want to throw away millions lines of proven code because they don't work any more, or even worse, because they are now buggy. So trying to change strings to be zero based was a bad idea, even if it was "just for mobile platforms".

I don't disagree with that point. My point is that it was a bad idea in the first place to make strings 1 based.

Share this post


Link to post
3 hours ago, David Heffernan said:

I don't disagree with that point. My point is that it was a bad idea in the first place to make strings 1 based.

Depends. Back then (in the 1970ies *1) it made a lot of sense to store strings that way. And when moving from Pascal to Delphi (>20 years later) and introducing longstrings (Delphi 2?) it already was a decision between keeping backwards compatibility to Pascal vs. being compatible with C.

 

Edit: (*1: I'm not sure when strings were introduced into Pascal: Was it an addition in Turbo Pascal (1986) or did they already exist in the original Pascal?)

Edited by dummzeuch

Share this post


Link to post
1 hour ago, David Heffernan said:

I don't disagree with that point. My point is that it was a bad idea in the first place to make strings 1 based.

This was due to Turbo Pascal legacy. 

Share this post


Link to post
1 hour ago, Dalija Prasnikar said:

This was due to Turbo Pascal legacy. 

ISO7185 (anno 1982) would like a word with you about that:

Quote

Any type designated packed and denoted by an array-type having as its index-type a denotation of
a subrange-type specifying a smallest value of 1 and a largest value of greater than 1, and having as
its component-type a denotation of the char-type, shall be designated a string-type.

 

There weren't, to my knowledge, any formal standards before this (the ANSI standard came 1983) but strings has been 1-based since the beginning.

Share this post


Link to post
2 hours ago, Anders Melander said:

ISO7185 (anno 1982) would like a word with you about that:

 

There weren't, to my knowledge, any formal standards before this (the ANSI standard came 1983) but strings has been 1-based since the beginning.

That is in no contradiction with what I said, as TP started as extension of Standard Pascal. 

 

Anyway, 1-based string types never caused any problems until they introduced 0-based strings for mobile compilers and the whole hell broke lose. 

Share this post


Link to post
57 minutes ago, Dalija Prasnikar said:

Anyway, 1-based string types never caused any problems until they introduced 0-based strings for mobile compilers and the whole hell broke lose. 

 

Also until developers did not start to use multiple languages.

Share this post


Link to post
15 minutes ago, Lajos Juhász said:

Also until developers did not start to use multiple languages.

Should that matter? I started learning Pascal 35 years ago and C the following year. Not once have I written

c := (a < b) ? a : b;

or

if (a == b) { doSomething(); }

while writing Pascal code.

  • Like 1

Share this post


Link to post
1 hour ago, Lajos Juhász said:

Also until developers did not start to use multiple languages.

I have never ever confused Pascal Strings with C char* types. (And I have done quite a lot C programming at the beginning of my career, parallel to using Turbo Pascal and Visual Basic, before I chose Delphi as my main programming tool.)

Share this post


Link to post
1 hour ago, JonRobertson said:

Should that matter? I started learning Pascal 35 years ago and C the following year. Not once have I written


c := (a < b) ? a : b;

or


if (a == b) { doSomething(); }

while writing Pascal code.

This is a strange post. The issue with multiple languages is the mix of zero based and one based indexing. 

Share this post


Link to post
1 minute ago, David Heffernan said:

This is a strange post. The issue with multiple languages is the mix of zero based and one based indexing.

Different languages have different rules and syntax. Is that really an issue?

 

I see the "issue" as developers using the incorrect syntax for the language they are currently using.

 

If I toured Italy, I imagine my trip would be more enjoyable if I spoke Italian. Which I don't. :classic_ohmy:

Share this post


Link to post
36 minutes ago, JonRobertson said:

Different languages have different rules and syntax. Is that really an issue?

 

I see the "issue" as developers using the incorrect syntax for the language they are currently using.

 

If I toured Italy, I imagine my trip would be more enjoyable if I spoke Italian. Which I don't. :classic_ohmy:

I mean I broadly agree. I was just trying to explain to Thomas what the post he was responding to actually said.

 

For me it's crazy that dynamic arrays are zero based but strings are one based. Obviously I can see how we got here.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×