Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
What is a typeless programming language?
I have read that several programming languages, listed below are considered "typeless":
- Forth
- Brainfuck
- B
- MUMPS
- BLISS
- Lucid
- BCPL
I have shared this data with a programmer who clued that such languages don't lack a type, rather, they lack a type system;
They do have one type which is byte size per ASCII character with which one could create data types (I guess he meant --- as we know them from say, JavaScript).
1 answer
‘This language doesn't have types’ and ‘This language only has one type’ are English sentences that communicate the same underlying concept: a typeless language doesn't have a way to distinguish categories of values from each other, either statically (before running the program) or dynamically (while running the program).
It's not entirely clear to me, but you or that person might be conflating types (which are categories of values) with data structures (which are arrangements of data in memory that can store values). Basically all programming languages have data structures, because all programming languages need to represent values in some way if they want to have any practical use. How types interact with the data structures supported by the language will vary.
It sounds like you're familiar with JavaScript, so here's how that language breaks down: JavaScript has dynamic types, which is the feature that makes it possible for the language to throw a friendly error if you try to use a number as if it were a function. If JavaScript had static types, it would be possible for the language to tell you before it even starts running that your program tries to use a number as if it were a function. If JavaScript were truly typeless, using a number as a function would probably result in some random part of memory being ‘executed’, which would immediately crash the entire process. But even a hypothetical typeless JavaScript would let you create numbers and functions and objects and arrays that contain each other; those are data structures. The categories that the language groups them into, statically or dynamically, are types. If the language treats all values equally, it's typeless.
(A type system usually refers to the rules for how types are defined, checked, and related to each other. A language with types has a type system, even if it's an extremely basic one defining a fixed set of types which are not related in any way to each other. But more powerful type systems allow for complex types and complex rules for judging whether a program uses values of those types correctly. As a matter of terminology, whether we say a language ‘has types’ or ‘has a type system’ depends only on where we want to put emphasis: on the types themselves, or on the ways they interact and get checked.)
1 comment thread