FoundABetterName
FoundABetterName

Reputation: 101

Are there any programming languages which have no concept of Arrays or use something else instead?

Arrays are one of the fundamental data structures and I was reading them up on LeetCode and saw the following -

They exist in all programming languages, and are used as the basis for most other data structures.

The claim that they exist in all programming languages seems a bit extravagant to me but maybe that's just because I am a beginner.

So are Arrays really present in all programming languages and I've seen some quite cryptic ones while exploring Code Golf pages which seem to be intentionally made so, so do they still use Arrays or are there any alternatives to arrays as well?

Upvotes: 1

Views: 1986

Answers (4)

cncmang
cncmang

Reputation: 9

FANUC Ladder III does not have arrays.

It also does not really have loops either, so you if you want to, say, loop through a table of data, you are responsible for keeping track of your position in said table, navigating through the code via JMP commands, which are basically GOTO commands.

It's a bit like assembly with random high-level function blocks sprinkled in.

For complicated functions that are not included functions of the language, spaghetti code is often hard to avoid.

Upvotes: 1

Hoopje
Hoopje

Reputation: 12932

Almost every claim about "all programming languages" is false, simply because of the fact that there are so many programming languages that for every claim there is a counter example.

So let's restrict to practical programming languages.

Then, yes, every practical programming language offers the possibility to collect things of similar type in an ordered collection.

However, depending in your definition of 'Array', and on the exact conditions when arrays 'exist' in a programming language, this need not be an array. For example:

  • Some scripting languages (such as Perl, if I remember correctly) only have dictionaries, and an array is simply a dictionary with numbers as keys.
  • Some languages only have linked lists (for example some functional and logical programming languages).
  • Some languages don't have arrays or lists, but are expressive enough that linked lists can be easily defined.

Upvotes: 3

John Alexiou
John Alexiou

Reputation: 29264

For me, an array is an abstraction that has a concept of the element count, and not necessarily maps it to contiguous memory. I think of Fortran arrays since it was the first programming language and it sets the expectations of what arrays are.

Here are some examples of (mainstream) languages without a concept of arrays:

  • Assembly Language
  • Logo, or turtle graphics.
  • XSLT
  • C

In lieu of arrays, some alternatives are pointers with offsets (C, assembly), linked lists, and other tree-like structures. Also, some languages may have the concept of a stack (assembly) which has some of the features of arrays. C++ does have arrays in the form of std::vector<T>, and other STL structures.

This is a community wiki, and so I hope the community can edit/add to this freely.

Upvotes: 1

Thierry Br&#233;mard
Thierry Br&#233;mard

Reputation: 899

you can find some home made language that do not respect any standard like the one used in the application ProRealTime: the name of the language is ProRealCode and is used to program indicators or scanners on financial markets. it has a feature to get older data with x[index], but you cannot create proper array and loop in to it.

The main problem of this home made language are: they can have some bugs (so you do not know if your code is buggy or the execution machine) you have no serious debugger

Upvotes: 1

Related Questions