HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

What are the characteristics of a typeless programming language?

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
thewhatareprogramminglanguagetypelesscharacteristics

Problem

Assume that we have an imaginary programming language that allows you to assign a Literal to a variable, but does not allow you to set the the data type of the variable, for example

Allocate4Bytes   an_int_variable        123456;
Allocate2Bytes   a_short_int_variable   123;
Allocate4Bytes   a_float_variable       2.1;


And this programming language also provides different operators to work with different data types, for example:

  • The + operator is used to add an int to a short int.



  • The #+ operator is used to add a float to an int.



  • the = operator is used to assign an int to an int.



  • the #= operator is used to assign a short int to a short int.



  • etc.



So it is the job of the programmer to keep track of the data type of each variable and use the appropriate operator on it.

Is this programming language considered to be a typeless programming language, or can we say that this programming language have data types (even though it does not have operator overloading and type safety, etc.)?

Solution

It depends on what happens if the programmer tries to do something like add two things with the wrong operator. If it causes a compile-time error, the language is probably statically typed. If it throws a runtime error complaining that the two have the wrong type, the language is probably dynamically typed. If it doesn't throw an error and just tries to add those two things (possibly resulting in gibberish), it might be untyped.

To put it another way, it depends how those operations are implemented. If they are implemented to keep track of the type of the variables and check that those types match what is expected, it is typed. If it doesn't keep track of types, then it is untyped or weakly typed.

See https://en.wikipedia.org/wiki/Type_system and https://www.sitepoint.com/typing-versus-dynamic-typing/.

Context

StackExchange Computer Science Q#108587, answer score: 7

Revisions (0)

No revisions yet.