Type of data

What are data and what are data types. What are the common data types in programming languages ​​and the differences in their management in statically typed and dynamically typed languages.

In this article we are going to address a very important topic in the area of ​​programming such as data types. We will talk about data types in a general way, without referring to a particular programming language, because you should know that depending on the language you can find that they handle data types in different ways.

Before getting fully into the different types of data, I will give you the description of the data so that everything is clear from the beginning.

Fact

A piece of data is any element that we need to process in a program. The programs work with input datawhich are handled through processes computers to produce output data.

The data is closely linked to another concept that we need to know, which is “information”. Surely you have heard that computing is the automated processing of information. So what is information and what is data? To understand this difference we can go to some examples.

  • data examples: would be 0, 12, “sHadksdje2so”, “madrid”, “monday” and things like that. We do not know what these data refer to, they are simply numbers or strings of a certain value.
  • Examples of information: 0 (the number of Ferraris I have in the garage), 12 (the days of the month), “madrid” (capital of Spain)…

The data becomes information when we give it a context. The number 0 can be anything, but it already changes if I tell you that my birthday is 0 days away, right? in that case the 0 is information, on which you decide that you will have to congratulate me right now!

See also  Graphic formats for web pages

What are data types

A data type is a Set of values that have a characteristic in common and that respond to certain operations.

In a computer system we work with data and programming languages ​​need to know what the type of that data is, to know the possible values ​​they could have and the things they are allowed to do with them.

For example, 2 is an integer. I will be able to add, subtract and do other mathematical operations with other numbers. “madrid” is a character string, which I can compare with other strings, concatenate other strings, etc.

Depending on the programming language, you can work with some types or others. For example, there are languages ​​that distinguish between integers and decimal numbers and other programming languages ​​in which only the numeric data type is available, encompassing both decimals and integers in the same bag.

simple data types

Simple data types, also called primitive data types or basic data types, are those that contain a unique element of a particular data type and they cannot be decomposed into several independent data.

Here is a list of simple data types common to most programming languages, although it depends on the implementation of that language which data types it will handle:

  • Numeric
  • Whole Number
  • Real number (with decimals)
  • Character
  • character string
  • Boolean (true or false)
  • Enumerated (a limited set of values)

Within the basic data we can find static, derived data. Static is data that we generally handle, such as the ones mentioned in the list above. As derived data we find pointers that are hardly used today, unless programmed in C.

See also  Libraries to generate PDF from PHP

Composite Data Types

Then we have compound data types, which are also called complex data types or structured data types. These data types are made up of simple data type pools.

We can give some examples of compound data types:

  • array
  • structures
  • Objects

An array is a set of values ​​that are stored in the same memory reference and where in many languages ​​all its values ​​are of the same simple type. A structure is the union of several simple data types, but they can have different types. An object is a data type in which we can have different types of simple data, but where we also have operations associated with these objects. It is a little early to be able to provide more details about how they work.

These composite data types also depend on the programming language we are using. It depends on the language that implements one or the other complex data types.

Constants and Variables

Also closely associated with the concept of data type we find another such as variable, or constant. We will talk about them in more detail, but for now we can anticipate that the data handled in an algorithm must be associated with an identifier so that we can refer to it when necessary. That identifier is the name of the variable or constant.

Generally, that variable, or constant, will have different parts:

  • The name to refer to it, or identifier
  • The data type of the items you will be able to store
  • The value it contains at a given time.
See also  Ajax file upload with jQuery

A variable is defined as a memory location referenced by an identifier where a specific value can be stored (data type).

A constant is defined as a value that does not change throughout the entire execution of the program.

Static typing and dynamic typing

We also want to talk now about one of the most defining characteristics of programming languages, which is their ability to accept different types of data in a variable, or to fix the data type of the variable in such a way that it lasts over time. .

  • static typing: These are languages ​​where the data type of a variable is fixed at the time of its creation, and the data type of that variable cannot be changed over time.
  • dynamic typing: It is a characteristic of languages ​​that allow variables to contain any type of data and this type can change over time.

Languages ​​with static typing we have Java, C#, C. Languages ​​with dynamic typing we have PHP, Javascript, Python.

Loading Facebook Comments ...
Loading Disqus Comments ...