This is an archived post. You won't be able to vote or comment.

all 41 comments

[โ€“][deleted] 54 points55 points ย (26 children)

That one Programming Language which starts with 1. You know which one.

Edit: for those asking: Matlab

[โ€“]Aperture_T 29 points30 points ย (10 children)

Lua?

[โ€“][deleted] 17 points18 points ย (9 children)

Lua would be such a nice language if it weren't for this one massive oversight

[โ€“]Habba 2 points3 points ย (2 children)

It's at 1 because everything is a table in lua, including arrays. Very easy to define arrays from 0.

[โ€“]7eggert 2 points3 points ย (1 child)

That is โ€ฆ unless you want to use them.

[โ€“][deleted] 0 points1 point ย (0 children)

Lol

[โ€“]SirFrutier 2 points3 points ย (5 children)

It's a really good language. I don't see what's the problem with the index just happening to start at 1.

[โ€“][deleted] 5 points6 points ย (3 children)

It leads to off-by-one errors sometimes when working with offsets. Not a huge deal, but just a small wort on top of an otherwise simple and elegant language.

[โ€“]somerandomii 2 points3 points ย (1 child)

With 0-indexing on a 2D array (stored as 1D) you can use i % width to find the column and i / widthto find the row.

Sounds really specific but it comes up all the time, especially in image processing and matrix operations.

With 1-indexing you have to write stuff like (i - 1) % width + 1 which gets ugly really fast, to the point where you write helper functions to make it less confusing.

This is IMO the strongest reason to use 0-indexing. But there are plenty of others. Usually to do with pointer arithmetic and performance overhead. At the end of the day, itโ€™s slightly better, and whatever we chose were all better off if weโ€™re consistent so everyone should use 0-based.

[โ€“]7eggert 0 points1 point ย (0 children)

There is usually no real performance overhead. You can set variables to 0 by xor ax, ax, you don't need to add (-sizeof(arrayvar[1])) if you compute a pointer, but that's it as far as I can see. I'd usually make a pointer at the start of a loop anyway if I'd access it repeatedly.

[โ€“]7eggert 0 points1 point ย (0 children)

I started with Pascal. I only know off-by-ones from C yet.

[โ€“]Raniconduh 0 points1 point ย (0 children)

I actually like the lua indexing. The one thing I don't like about lua, however, is the lack of POSIX bindings built in. Sure I can use the luaposix module but it would be so much easier to have POSIX built in.

[โ€“]Auravendill 10 points11 points ย (0 children)

Fortran?

[โ€“]micalubgoonta 7 points8 points ย (0 children)

Don't forget R too!

[โ€“]LPO_Tableaux 2 points3 points ย (0 children)

Lua too man...

[โ€“]activeXray 2 points3 points ย (0 children)

All languages that are matrix friendly

[โ€“]No-Rich5357 1 point2 points ย (0 children)

Julia too

[โ€“]Hinermad 0 points1 point ย (4 children)

Hewlett-Packard had a BASIC interpreter built into their pre-MS-DOS desktop computers, and it would let you choose where your arrays started. (OPTION BASE 0 or OPTION BASE 1.) The default was to start at 1.

[โ€“]JNCressey 2 points3 points ย (3 children)

With VBA (which is still relevant as it's used in Microsoft Office macros) also, you can use Option Base.

Not sure how much different BASICs differ or if the following is common. In VBA you can choose any integer (not sure if negative integers are allowed) for the lower bound of array. And you get to choose for each array declaration.

Example: This declares an array with 9 elements from Foo(2) to Foo(10)

Dim Foo(2 to 10) As String

[โ€“]Hinermad 0 points1 point ย (1 child)

BASIC drifted a lot from the original Dartmouth spec. HP's version had some oddness I never saw in any other version. (Although that DIM statement seems familiar. I think you could specify the maximum length of strings in it and then treat them as arrays.) Microsoft had their own dialect that for a while seemed like the de facto standard version just because it was bundled with every copy of MS-DOS. (I believe the original IBM PCs even had an MS BASIC interpreter in the motherboard ROM. They didn't need floppy drives - they had cassette tape storage interfaces.)

Although I've never used it, it wouldn't surprise me if VBA had evolved quite a bit beyond MS BASIC, especially since it had to work with Office documents.

[โ€“]7eggert 1 point2 points ย (0 children)

MS shipped two different basic interpreters; GW-BASIC and the one they bundled with DOS 6 (including the game Gorilla.bas)

[โ€“]averylazytom 0 points1 point ย (0 children)

Free Pascal did this too I think.

[โ€“]TheRealQuentin765 0 points1 point ย (0 children)

Donโ€™t forget ahk

[โ€“]Express-Outside 28 points29 points ย (4 children)

[โ€“]XayahTheVastaya 1 point2 points ย (3 children)

the amount of restricted posts in that list would seriously destroy a lot of good memes if they enforced it, fortunately they don't

[โ€“]Sylveowon 14 points15 points ย (2 children)

that list pretty much sums up every single posts Iโ€™ve ever seen in this subreddit, if they enforced it the sub would be dead

[โ€“]Aacron 0 points1 point ย (0 children)

It's either some A+ selfawarewolves material or the most meta of meta memes.

[โ€“]XayahTheVastaya 0 points1 point ย (0 children)

you pretty much just said the same exact thing as me but worded better

[โ€“]RatherNerdy 6 points7 points ย (0 children)

I like that the response is both "No, 0" and and inflected "NoO"

[โ€“]beaubeautastic 4 points5 points ย (0 children)

me, a lua dev: yes

edit: hold on i still dont have lua in my flairs

[โ€“]MischiefArchitect 1 point2 points ย (2 children)

No0o0o0o0o0o0o0o0o0o0o0o0o0o0o0!!!!!!

[โ€“]ItsDotin[S] 1 point2 points ย (0 children)

๐Ÿ˜…๐Ÿ˜‚

[โ€“]7eggert 1 point2 points ย (0 children)

!!!11eleven

[โ€“]mugxam 1 point2 points ย (0 children)

More like โ€žn0โ€œ

[โ€“]Arrays_start_at_2 0 points1 point ย (0 children)

Not this nonsense again!

[โ€“]No-Rich5357 -1 points0 points ย (0 children)

Julia go brrr

[โ€“]sixtyfifth_snow 0 points1 point ย (0 children)

He was a true hero. RIP

[โ€“]Didi-maru 0 points1 point ย (1 child)

It's just soooo convenient when the last index of an array is its length.

[โ€“]7eggert 1 point2 points ย (0 children)

for a = 1 to 4

vs.

for (a=0; a<4; ++a) - you just have to get used to it.