Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Why does coldfusion number arrays and dates from 1

Enthusiast ,
Nov 17, 2010 Nov 17, 2010

Why does coldfusion  number arrays and other structures from 1. Its pretty infuriating when the rest of the world mostly starts from 0?

1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Nov 17, 2010 Nov 17, 2010

Zero-based arrays are a legacy of the days of the system needing to work out the offset from the base memory address that the array is stored at to locate the start address of each element.  So it makes kinda sense that the first element is offset from the base address by a factor of zero.

There are languages that predate C (from which C++ sprouted as some sort of horrendous nightmare) which use 1 as the starting index... it's just C was pared down to minimise the translation from C to machine co

...
Translate
Guide ,
Nov 17, 2010 Nov 17, 2010

I can only assume it's to increase the usability of a Rapid Application Development (*shudder*) tool such as CF. If you had to explain arrays to a non-programmer it seems nonsensical to start with a zero; I'd guess in the early days it was assumed that if you wanted a tool that meant not having to learn a programming language then you probably weren't aware of C-style array offset notation, and didn't care to learn.

If you're thinking logically and numerically then technically CF is the *correct* way of doing it, and perhaps it's a shame the entire world doesn't use that. After all, what makes more sense than notating the first value as Array[1]? However once you get into things like C it makes more sense to use a zero, so you do.

One of those things I guess. It'd be nice if everyone drove on the correct side of the road (ahem, the left), spoke the same language and used the same currency. But then it'd be boring

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 17, 2010 Nov 17, 2010

ColdFusion's roots were to enable the development of server-side applications by HTML designers - at the time there were few tools for doing server side web development (PERL, etc), all of which were non-intuitive to someone with no programming language background.  Hence the tag-based syntax instead of a script-based language. In the real world very few things that are numbered start at 0.  Over the years ColdFusion has added more and more capabilities and until recently pretty much left the "real programming language" server-side technologies in its dust, but still has the reputation among many of not being a "real" programming language because of things like this.

-reed

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 17, 2010 Nov 17, 2010

It is interesting, though, isn't it, that C++ (which CF was written in

prior to CFMX) is 0-based, too?

http://go.microsoft.com/?linkid=8310949

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 17, 2010 Nov 17, 2010

Zero-based arrays are a legacy of the days of the system needing to work out the offset from the base memory address that the array is stored at to locate the start address of each element.  So it makes kinda sense that the first element is offset from the base address by a factor of zero.

There are languages that predate C (from which C++ sprouted as some sort of horrendous nightmare) which use 1 as the starting index... it's just C was pared down to minimise the translation from C to machine code, and in this case 0 makes more sense.  And other "curly bracket" languages just copied it.  It certainly - in modern times in which the source language is generally so far removed from machine language - makes little sense to persist with this sort of approach for any good reason other than copying what some other language has done.

In human terms, there is not a zeroth element in a  collection, and given there isn't really any processing saving any more  in just starting the array from a more human-friendly position, why  not?

I mean... how confusing is it really to remember which language does which?

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 17, 2010 Nov 17, 2010
I mean... how confusing is it really to remember which language does which?

Quite. For me it's normally this easy:

Me: myArr[0] = myStr;

CF: Array reference is out of bounds.

Me: Oh yeah, right.

EDIT: Really glad I spent time formatting that all in colours and fonts just for it to ignore it all when it displayed.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 18, 2010 Nov 18, 2010

Its also things like dates that confuse, sunday is 0

in as3, t-sql but 1 in CF. Stuff like that really annoyes me.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 18, 2010 Nov 18, 2010

1st class reasons everyone btw


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 18, 2010 Nov 18, 2010

1st class reasons everyone btw

Are you sure you don't mean 0th class reasons?

😉

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 18, 2010 Nov 18, 2010

Taxi!


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 18, 2010 Nov 18, 2010

Its also things like dates that confuse, sunday is 0

in as3, t-sql but 1 in CF. Stuff like that really annoyes me.

Whereas according to ISO - and indeed common usage (Sunday being in the week end) - , it should be 7.  So none of the ones you list there have that one right.

http://en.wikipedia.org/wiki/ISO_week_date

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 18, 2010 Nov 18, 2010

Not to burst your bubble, but I don't think that's all that interesting or surprising. Java is also zero-based. Both C++ and Java are strongly typed, unlike CF. Many languages are built in C, I think. But that doesn't mean they have to be C-like themselves.

Dave Watts, CTO, Fig Leaf Software

http://www.figleaf.com/

http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on

GSA Schedule, and provides the highest caliber vendor-authorized

instruction at our training centers, online, or onsite.

Read this before you post:

http://forums.adobe.com/thread/607238

Dave Watts, Eidolon LLC
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 18, 2010 Nov 18, 2010
LATEST

ColdFusion was originally intended for people who didn't have much (or any) programming experience. Without any programming experience, it's not immediately obvious why you'd want to start counting from zero instead of one. It's like COBOL for the web!

Dave Watts, CTO, Fig Leaf Software

http://www.figleaf.com/

http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on

GSA Schedule, and provides the highest caliber vendor-authorized

instruction at our training centers, online, or onsite.

Read this before you post:

http://forums.adobe.com/thread/607238

Dave Watts, Eidolon LLC
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources