Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Roberto Ierusalimschy makes an interesting point on this in an interview[1] last year.

> When we started Lua, the world was different, not everything was C-like. Java and JavaScript did not exist, Python was in an infancy and had a lower than 1.0 version. So there was not this thing when all the languages are supposed to be C-like. C was just one of many syntaxes around.

> And the arrays were exactly the same. It’s very funny that most people don’t realize that. There are good things about zero-based arrays as well as one-based arrays.

> The fact is that most popular languages today are zero-based because of C. They were kind of inspired by C. And the funny thing is that C doesn’t have indexing. So you can’t say that C indexes arrays from zero, because there is no indexing operation. C has pointer arithmetic, so zero in C is not an index, it’s an offset. And as an offset, it must be a zero — not because it has better mathematical properties or because it’s more natural, whatever.

> And all those languages that copied C, they do have indexes and don’t have pointer arithmetic. Java, JavaScript, etc., etc. — none of them have pointer arithmetic. So they just copied the zero, but it’s a completely different operation. They put zero for no reason at all — it’s like a cargo cult.

[1] - https://habr.com/en/company/mailru/blog/459466/



I'm confused. Lisp does 0-based indexing. Lisp predates C and C-like languages by decades.


They don't say that C was the first. The claim is that C's influence was responsible for the proliferation.

(Bit of a tangent: Lisp predates C by at most 2 years if you count McCarthy's original 1960 paper, but afaict their respective implementations both got their first public distribution in 1962. Of course, Lisp was set to gain momentum from that time until the AI winter, while C was practically confined to UNIX until the 80s...)


Historically, everyone who studied computing seriously learned assembly language, and it was much more widely used.

In early computing, assembly language saw a lot of use. The navigation program that sent the Apollo mission to the Moon was written in assembly language. During the micro-computer boom, which echoed the history of big iron boom, a lot of applications and systems were written in assembly language again. Most commercial video games for 8 bit micros were written in assembly language. The famous WordPerfect word processor for the IBM PC was assembly language. The VMS operating system: assembly language.

C became easily popular because it gave a nice notation, and a sprinkling of type, to assembly language memory manipulation concepts that most professional programmers already knew how to use.


C wasn't from 1972? Basically a decade later?


Oof yes, that's correct. The manual is dated 12 June 1972, which seems to be the release date.


Lisp isn't the reason modern-day languages are all offset-indexed though; that's Cs fault




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: