Reputation: 101
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
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
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:
Upvotes: 3
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:
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
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