The latest instance of the course can be found at: O1: 2024
- CS-A1110
- Supplementary Pages
- Glossary
Luet oppimateriaalin englanninkielistä versiota. Mainitsit kuitenkin taustakyselyssä osaavasi suomea. Siksi suosittelemme, että käytät suomenkielistä versiota, joka on testatumpi ja hieman laajempi ja muutenkin mukava.
Suomenkielinen materiaali kyllä esittelee englanninkielisetkin termit. Myös suomenkielisessä materiaalissa käytetään ohjelmaprojektien koodissa englanninkielisiä nimiä kurssin alkupään johdantoesimerkkejä lukuunottamatta.
Voit vaihtaa kieltä A+:n valikon yläreunassa olevasta painikkeesta. Tai tästä: Vaihda suomeksi.
Glossary
This page summarizes the meanings of some programming terms.
Many of the terms have additional or alternative meanings beyond those listed below. This page focuses on the meanings that are most pertinent for O1. Many of the definitions are informal and imprecise but sufficient for our purposes.
You may also want to take a look at Scala’s official glossary, which has some overlap with this one. We don’t follow it to the letter in O1, though.
Something missing?
Did you come to this page looking for something that isn’t here? Let the teacher know: juha.sorva@aalto.fi.
- abstract class
- abstrakti luokka a class that 1) may have abstract methods and variables; 2) may not be instantiated directly but only via its subclasses; 3) may take constructor parameters ¶ See Chapter 7.3 and cf. trait.
- abstract method
- abstrakti metodi a method whose signature is defined but whose body is not ¶ See Chapters 7.2 and 7.3. Traits and abstract classes, which may not be instantiated directly, may have abstract methods.
- abstract variable
- abstrakti muuttuja an instance variable whose data type is defined but whose value is not ¶ See Chapter 7.2. Traits and abstract classes, which may not be instantiated directly, may have abstract variables.
- abstraction
- abstraktio a generalization; a conceptualization; a model that leaves out unnecessary or undesirable details ¶ To program is to create and use abstractions; see, e.g., Chapters 1.6, 2.1, 2.3, 3.2, 6.1, 6.3, 6.4, 7.2, 7.3, and 9.1. There are different kinds of abstraction. For instance, adding a parameter to a function or class abstracts away that parameter’s specific values and makes the solution more generic. An interface, on the other hand, can abstract away the implementation of how a program component solves a problem; see level of abstraction.
- access modifier
- näkyvyysmääre
a reserved word that specifies a program component’s visibility ¶ For example, the
private
keyword is an access modifier that constrains access to a component. Also called a visibility modifier. - actual parameter
- todellinen parametri, argumentti another term for argument ¶ Contrasts with formal parameter.
- AI
- AI short for artificial intelligence
- algorithm
- algoritmi a stepwise method for solving a particular problem ¶ See Chapter 1.2. Not all algorithms involve computers or programs; for example, long division is an algorithm (that can be carried out by a person or implemented as a computer program).
- anchor
- ankkuri
(in O1Library:) a location at which a picture attaches when positioned relative to other
pictures ¶ E.g., “Put this pic’s anchor at the top-right corner of that pic.” A picture’s
anchor may be its middle point or one of its corners, for example. In O1Library, anchors
are represented by class
Anchor
. See Chapter 2.5 and that class’s documentation. - anonymous function
- nimetön funktio a function defined by a function literal and therefore without a name ¶ See Chapter 6.2. Also known as a lambda function.
- anonymous parameter
- nimetön parametri an unnamed parameter variable, denoted by an underscore in Scala’s abbreviated function literals ¶ See Chapter 6.2.
Any
- Any the top-level superclass of all Scala classes ¶ See Chapter 7.3.
AnyRef
- AnyRef
a superclass of most Scala classes ¶ See Chapter 7.3. The virtual machine that runs
Scala programs uses references to access objects of type
AnyRef
; cf.AnyVal
.AnyRef
is an immediate subclass ofAny
. See alsoObject
. AnyVal
- AnyVal
a superclass of certain Scala classes that have been optimized for efficiency ¶ See
Chapter 7.3 (and 3.5). The virtual machine that runs Scala programs doesn’t use
references to access objects of type
AnyVal
; cf.AnyRef
.AnyVal
is an immediate subclass ofAny
. - API
- API a software library that can be used for building various applications ¶ Short for “application programming interface”. Many programming languages are associated with an API that is applicable to a wide range of problems. Scala, too, has the Scala API.
- app
- sovellus, "äppi" short for application
- app object
- käynnistysolio (In Scala:) a singleton object within an application that defines what the computer should do when the application is launched ¶ In a sense, the app object represents the application as a whole. It provides an starting point for the program’s execution. See Chapter 2.7.
- application
- sovellus a computer program that is meant for end users to use for a specific purpose ¶ See Chapters 1.1 and 1.2.
- application programming interface
- see API
- apply
- apply
1) to instruct the computer to execute a function; to call, to invoke;
2) (in Scala:) a special name that makes it possible to call a method without explicitly
using its name ¶ See Chapters 5.3 and 6.2. A method named
apply
serves as the objects’ “default method”:myObj(params)
is shorthand for callingmyObj.apply(params)
and only works if the object has such anapply
method. In Scala programs,apply
methods are often used as factory methods as well as for other purposes. - argument
- argumentti 1) parameter expression; 2) parameter value ¶ This term is used widely outside of O1. Some use it (carelessly) as interchangeable with parameter. It’s common (and, some argue, the only correct usage) to speak of “arguments” when considering a function externally from its caller’s perspective (as in a function-calling expression) and of “parameters” when considering a function’s definition and implementation (especially: when speaking about parameter variables). In O1, we have deliberately avoided “argument” in order to make our terminology more consistent and the concepts hopefully easier to learn.
- array
- taulukko a mutable collection of fixed size that keeps its elements in order by their numerical index ¶ See Chapter 11.1 and cf., e.g., vector and buffer. In many programming languages, Scala included, the array is a sort of “basic collection type” that has been used to implement many other types of collection.
- artificial intelligence
- tekoäly, keinoäly 1) (traditionally:) a field of research that draws on multiple disciplines, including computer science and psychology, and that seeks to model the human mind and to imitate it in programs and computing devices; 2) (in casual current usage:) nearly any application that conveys an impression of intelligence when observed by a (present-day) human or that entrusts a computer with tasks that have been previously been carried out only by humans. ¶ Commonly abbreviated as AI. Applications that are intelligent in the second sense usually do not at all attempt to imitate human cognition. Many of the applications currently described as AI involve machine learning. AI is commonly divided into narrow and general AI or in weak and strong.
- assembly (language)
- symbolinen konekieli a programming language whose instructions directly correspond to machine code but are represented symbolically (as text) rather than in binary ¶ Also known as symbolic machine language.
- assign
- sijoittaa
to store a (new) value in a variable ¶ For instance, the Scala command
myVariable = 10
is an assignment. It assigns the new value ten to a (var
) variable, replacing the value that was previously stored in the variable. See Chapter 1.4. - base case
- perustapaus a part of a recursive algorithm or program, in which the (sub)problem’s solution can be worked out without a recursive call ¶ See Chapter 12.1.
- base class
- yliluokka a synonym for superclass
- bit
- bitti a basic unit of digital information, which may have one of exactly two values ¶ Short for “binary digit”. The two possible values of a bit are often referred to as zero and one; a sequence of bits can thus represent binary numbers. Computers represent different kinds of information as systematic combinations of bits; see Chapter 5.4
- block
- lohko (in Scala:) an expression that consists of a sequence of consecutive commands and that is written inside curly brackets ¶ For instance, when a function body consists of multiple commands in sequence, it is defined as a block. Similarly, the conditional branches of a selection command may be blocks. The block structure of a program affects scope. In particular: the scope of a local variable doesn’t extend beyond the block in which the variable is defined; see Chapter 5.6.
- body
- runko see function body, class body
Boolean
- Boolean, totuusarvo
Scala’s data type for representing truth values. ¶ There are just two values
of type
Boolean
:true
andfalse
. See Chapter 3.3; see also comparison operator and logical operator. - breakpoint
- keskeytyskohta a setting in a debugger that causes a program run to pause once it reaches a specified execution step ¶ See O1’s debugger tutorial.
- buffer
- puskuri a mutable collection that keeps its elements in order by their numerical index and supports the addition, removal, and replacement of elements ¶ See Chapter 1.5. Cf., e.g., array and vector.
- bug
- bugi a colloquialism for an error ¶ The word is especially often used of errors in what a program does when executed: runtime errors and logical errors.
- by-name parameter
- *by name* -parametri, evaluoimaton parametri a parameter that is not evaluated before it is passed to a function but whenever (or if) its value is actually used during the function call ¶ See Chapter 7.1. If the value of a by-name parameter isn’t used in all the possible scenarios, the parameter may be called non-strict. A by-name parameter isn’t evaluated lazily: it’s re-evaluated every time its value is needed. Cf. by-value parameter.
- by-value parameter
- *by value* -parametri a parameter that is evaluated strictly and gets a value before the function call begins ¶ In Scala, by-value is the usual, default way to pass parameters. Cf. by-name parameter.
- byte
- tavu a sequence of eight bits ¶ See Chapter 5.4.
- bytecode
- tavukoodi a name for some languages that are frequently used as intermediate languages ¶ See Chapter 5.4. For instance, the intermediate language that Scala programs are usually compiled to, which the Java Virtual Machine, executes is known as bytecode.
- call
- kutsua to instruct the computer to execute a function ¶ See function call. Synonyms: invoke, apply.
- call stack
- kutsupino a stack-like data structure that contains frames and that the computer uses to track active function calls during a program run ¶ See Chapters 1.7 and 1.8.
- case class
- tapausluokka
a Scala class that has been defined using the
case
keyword and that, as a consequence, implicitly gains certain characteristics ¶ There’s nothing unique about a case class in the sense that a regular class can also be programmed to do the same; however, thecase
keyword is a convenient shorthand for giving a class a set of characteristics that is frequently useful. The main ones are: 1) it’s easy to deconstruct an instance of case class and extract its contents in amatch
command (Chapter 4.4); 2) thenew
keyword isn’t needed when instantiating a case class (since the class implicitly has a companion object with anapply
factory method); 3) a case class’stoString
method produces more readable output than the default method that other objects have. catch
- catch
(in Scala:) a reserved word used in exception handling to start a block that is executed
in case a runtime error occurred during the
try
block ¶ Thecatch
block follows thetry
block and is executed after it but before a possiblefinally
block. - class
- luokka
1) a data type of a kind of objects; 2) the definition of such a data type as program code ¶ See
Chapters 2.1, 2.3, and 2.4. A class defines what a particular type of objects are like; this
constrasts with a singleton object that is defined separately from all other objects. Whereas an
object represents a single “thing”, a class represents a more general concept that objects of that
class are individual occurrences of. A class can be instantiated, creating a new object of that type,
an instance of the class. See also trait, abstract class. (Clarification: In O1, we say that a
Scala class or trait is a data type or that it defines a data type. This simplifies things slightly.
To be more precise, a class or trait may define one or more types. Class
Int
, for example, defines one data type, butBuffer
defines multiple data types that differ in the type parameter:Buffer[Int]
,Buffer[String]
, etc.) - class body
- luokan runko the main contents of a class definition ¶ A class body defines the class’s instance variables and methods. In Scala, it’s surrounded by curly brackets. Commands written directly into the body of a Scala class, outside the class’s methods, are executed when the class is instantiated; in other words, the class body serves as the class’s constructor.
- class file
- luokkatiedosto
a file that is meant as input to the Java Virtual Machine and that contains instructions in the
JVM’s intermediate language ¶ Scala programs are usually compiled into class files before
being run by the JVM. Class files have the
.class
suffix. - class hierarchy
- luokkahierarkia a whole formed by classes (and/or traits) that describe super- and subordinate concepts; a “family tree” of classes ¶ See Chapter 7.3 and superclass and subclass.
- class library
- luokkakirjasto a library that contains classes
- classpath
- luokkapolku a setting in some programming tools (including the JVM) that specifies which folders and files the tool should look in to find a program’s components ¶ In Eclipse, you can adjust a project’s classpath by selecting Project ‣ Properties ‣ Java Build Path. One reason for doing so is to make one project build on another; see Chapter 10.1.
- closure
- sulkeuma, klosuuri a data structure that comprises a function definition as well as access to specific variables defined in that function’s external context ¶ See Chapter 6.4.
- code
- koodi see program code
- coding conventions
- tyylikäytäntö see style conventions
- cohesion
- koheesio togetherness, wholeness; the extent to which a program component forms a single, unified, and cleanly delimited whole whose parts connect to one another ¶ For instance, a class is cohesive if it defines a single, distinct concept and doesn’t have members that are extraneous or unconnected to that well-defined purpose. Cohesion is a desirable characteristic in program design; see Chapter 9.1.
- collection
- kokoelma a data structure that provides access to multiple values of a particular type ¶ In Scala, collections are objects. The values stored in a collection are known as its elements. Collections come in many varieties that have different efficiency characteristics, among other differences. Some collections store elements in a specific order defined by numerical indices. Some collections are immutable, others mutable. Many collections are strict but some are non-strict. Many collection types take type parameters. The collection types that come up in O1 include buffers, strings, vectors, arrays, streams, maps, lists, and stacks. Cf. tuple.
- command
- käsky an instruction for the computer to do something ¶ In O1, we use this term in a loose and informal sense to mean pretty much any sort of instructions issued to the computer. For instance, statements that have an effect on program state are commands, as are effect-free expressions.
- command line
- komentorivi a text-based environment for using a computer ¶ A user who works at the command line launches programs by typing in the program’s name (and additional information as appropriate). Typically, the program will then print out some text in response. A command-line environment is often thought of as an alternative to a graphical user interfaces; on the other hand, a command-line environment may also appear within a GUI. Examples of command-line environments include Windows’s Command Prompt and Linux’s Terminal. Chapter 5.4 shows a few examples of using Scala programming tools at the command line.
- comment
- kommentti a section of source code that is meant for human readers and that the computer does not interpret as being part of the program that it executes ¶ Comments don’t affect what happens during a program run. Appropriate use of comments is good style. See Chapter 1.2 and O1’s style guide. See also documentation comment.
- companion object
- kumppaniolio a singleton object that is the “companion” of a specific class and represents that very class in an object-oriented program ¶ A companion object must have the same name as its class companion and must be defined in the same source file; see Chapter 5.3. The class and its companion have access to each other’s private members. One use for a companion object is to store constants associated with the class; it may also store other information that is associated with the general concept represented by the class but isn’t instance-specific.
- comparison operator
- vertailuoperaattori
an operator that compares two values and forms a
Boolean
value that indicates the result of the comparison ¶ For instance, the comparison operator<
can be used to construct the expression10 < 100
, whose value istrue
. See Chapter 3.3 and logical operator. - compile-time error
- käännösaikainen virhe an error that manifests itself when processing a program statically, that is, without running the program; especially: an error observed as the program is compiled ¶ See Chapters 1.8, 3.5, and 7.2 and cf. runtime error and logical error. Many compile-time errors are syntax errors.
- compiler
- kääntäjä an auxiliary program that takes in source code and translates it to another representation; especially: a program that does such translation statically, separately from any program run ¶ Programs can be compiled into an intermediate language or directly into machine language. Scala programs are most often compiled into an intermediate language that is compatible with the Java Virtual Machine. See Chapter 5.4 and cf. interpreter.
- component
- komponentti 1) (generally:) a part; 2) (specifically:) a GUI component
- computer
- tietokone a device that processes information by executing programs ¶ A computer isn’t electronic by definition but most computers are electronic. See also computer system.
- computer system
- tietotekninen järjestelmä a combination of computer hardware and software ¶ A computer system can be a general-purpose computer or an embedded system.
- concatenate
- katenoida, konkatenoida
to combine by putting one after the other ¶ In programming, the word is common in the context
of strings. For instance, the strings
"con"
and"catenate"
can be concatenated to produce the string"concatenate"
. - concrete class
- konkreettinen luokka a class that is not an abstract class (and not a trait, either) ¶ An “ordinary class”. A concrete class may not have abstract methods. A class doesn’t have to be abstract to serve as a superclass; classes may inherit from a concrete class too, as shown in Chapter 7.3.
- conformant
- tyyppiyhteensopiva see type compatible
- console
- konsoli see text console
- constant
- vakio
a variable whose value is known before the program is run and that permanently stands for that
value in the program ¶ See Chapter 2.6 and O1’s style guide. All
constants are fixed values. In Scala, practically all constants are
val
:gl:s <val variable>
. - constructor
- konstruktori, rakentaja a subprogram that is executed as part of the instantiation process ¶ The term refers to the code that gets run on a newly created instance after memory has been allocated for storing the instance. The primary purpose of a constructor is to initialize the instance’s state as appropriate for the class in question. Many constructors take parameters that specify what the new instance should be like, expanding on the general template of the class. In Scala, it’s not necessary to write a separate constructor method (as in some other languages); instead, the constructor comprises the instructions written directly into the class body; see Chapter 2.4. However, it is possible to give a Scala class a separate constructor in order to overload object creation; see, e.g., Chapter 4.1.
- constructor parameter
- konstruktoriparametri a parameter that is passed to a constructor ¶ See Chapters 2.3 and 2.4. Constructor parameters are used when instantiating a class, thereby creating new objects. The most typical thing to do with a constructor parameter is to assign its value to an instance variable, but some constructor parameters have other uses during object initialization.
- container
- säiliö a variable that is used for accessing and modifying a collection of elements ¶ This is one of the roles of variables. See Chapter 4.2.
- data structure
- tietorakenne any construct that is meant for organizing items of data ¶ The word is especially commonly (and sometimes exclusively) used of structures that are designed to hold large amounts of data so that the data can be efficiently processed; the implementations of collections are data structures in this sense. Files also have their own internal data structures. In O1, we use this term in a broad and loose sense that encompasses even relatively simple constructs; for example, we may refer to an object as a data structure.
- data type
- tietotyyppi
a definition of a particular form of data and what operations are available on that data ¶ See, e.g.,
Chapters 1.3 and 2.3. It’s common to speak of simply “types” rather than “data types”. Programming
languages come with a selection of predefined data types for common needs; for instance, Scala’s
Int
type represents integers and defines the fact that integers can be summed (among other things). Moreover, programmers can define custom data types in their programs. See also type parameter, static type, dynamic type, and class. - debug
- debugata to attempt to locate and fix errors in a program; especially: to look for runtime or logical errors
- debugger
- debuggeri an auxiliary program that help the programmer to examine a program’s execution step by step and examine the changing contents of memory ¶ A debugger can be used while debugging or to explore program behavior for some other reason. This ebook has a separate page on using a debugger.
- declarative programming
- deklaratiivinen ohjelmointi a broad programming paradigm in which problems are primarily thought of in terms of definitions, rules, constraits (etc.) rather than sequences of consecutive commands as in imperative programming ¶ See Chapter 10.2. Many rather different subparadigms are commonly listed as falling under the broad umbrella of declarative programming. Functional programming is arguably the most significant of these subparadigms.
- derived class
- aliluokka a synonym for subclass
- desk checking
- pöytätestaus assessing a program or algorithm manually and without running it ¶ For instance, a programmer may read a program’s source code onscreen or from a paper printout as they mentally work though the program’s logic.
- dialog (box)
- dialogi(-ikkuna) a kind of GUI element; a window that is temporarily displayed to the user and that plays a role in the “dialogue” between the user and the application ¶ See Chapter 12.3. Many applications have a large main window with smaller dialogs popping up as needed.
- dictionary
- sanakirja see map
- direct subclass
- välitön aliluokka a synonym for immediate subclass
- direct superclass
- välitön yliluokka a synonym for immediate superclass
do
loop- do-silmukka
a loop that has been formed using the
do
keyword and that repeats an operation one or more times ¶ See Chapter 8.3 and cf.while
loop. - documentation
- dokumentaatio one or more documents that explain a program to a human reader ¶ It’s especially common to write documentation about the interfaces between program components; see Chapters 3.2 and 3.5. See also Scaladoc.
- doc(umentation) comment
- dokumentaatiokommentti a comment that is formatted in a particular way, making it compatible with tools that generate documentation semi-automatically ¶ See Chapter 3.2. For instance, given a Scala program with documentation comments embedded in its source code, the Scaladoc tool generates web pages that document the program.
- domain
- aihealue, domain
the conceptual area that a program is concerned with; a problem space; the “world” of a
program ¶ For instance, the domain of a computer game encompasses the concepts and rules of the
game world. This sense of the word is not to be confused with network domains such as
aalto.fi
. - domain-specific language
- täsmäkieli a programming language that is not meant for general use but tailored to a specific application domain ¶ See Chapter 11.2. Commonly abbreviated as DSL.
- dot notation
- pistenotaatio
a notation for calling methods that is characterized by a period-dot written between
the expression that identifies the target object and the method name ¶ Example:
myObject.myMethod(myParam)
. Dot notation is common in many object-oriented languages, Scala included. See Chapters 2.1 and 5.2 and O1’s style guide. Cf. operator notation. Double
- Double (in Scala and various other languages:) a data type that represents decimal numbers as floating-point numbers ¶ See Chapters 1.3 and 5.4. The name is short for “double-precision floating-point number”.
- driver
- (laite)ajuri a program whose purpose is to govern the use of a particular auxiliary device, such as a mouse or a graphics card ¶ Drivers help the operating system access auxiliary devices.
- DRY
- DRY the principle of defining each aspect of a program in one place only ¶ Short for “don’t repeat yourself”. Applied to source code, the DRY principle encourages the programmer to avoid writing redundant code. Following the principle generally makes programs easier to modify. See, e.g., Chapters 1.4, 5.1, 7.2, and 9.1. There are various other programming principles that go by different names but express essentially the same sentiment. Antonym: WETWET.
- DSL
- DSL short for domain specific language
- dynamic
- dynaaminen associated with a program run or with the process of executing a program; defined only at runtime; non-static, changing ¶ There’s a duality to computer programs: they can be thought of as both static and dynamic; see, e.g., Chapters 1.2 and 2.1. Things that happen at runtime, such as the inputs that a program receives from its user, can impact on the program’s dynamic aspect but not its static one. See also dynamic type.
- dynamic binding
- dynaaminen sidonta the policy of choosing which function gets executed not before the program run (statically), but during it (dynamically) ¶ In object-oriented programming, the main implication of dynamic binding is that the system uses the dynamic type of the target object to decide which method implementation to run; this decision is made when the method call actually happens at runtime. That is, the choice of method implementation is affected by which subclass’s instance the message-receiving object is. See Chapters 7.2 and 7.3.
- dynamic dispatch
- dynaaminen sidonta see dynamic binding
- dynamic programming
- dynaaminen ohjelmointi an implementation technique in which subproblems’ solutions are stored in memory so that they can be efficiently retrieved and applied (perhaps multiple times) while solving the greater problem at hand ¶ Chapter 12.1 contains a simple example of dynamic programming. In this context, “dynamic” doesn’t mean quite the same thing as elsewhere in O1. The word appears in the name of this technique in part because it sounds fancy.
- dynamic type
- dynaaminen tyyppi the type of a value ¶ Determined dynamically during a program run. An expression or variable with a particular static type may have any value whose dynamic type is compatible with that static type; see Chapters 7.2 and 7.3.
- dynamically typed
- dynaamisesti tyypitetty (of a programming language:) having a type system that does not specify different static types for the parts of source code, instead checking only values’ dynamic types (at runtime) ¶ For instance, in a dynamically typed language, variables don’t have different types and any value can assigned any variable. Cf. statically typed. Dynamically typed languages include Python, JavaScript, and Ruby, among many others. Scala isn’t dynamically typed by default, but can be used in that way, too.
- Eclipse
- Eclipse an integrated development environment (IDE) ¶ See Chapters 1.2 and 5.4. Eclipse and its Scala IDE plugin are O1’s official (but not strictly mandatory) programming environment.
- editor
- editori an application for writing and modifying text
- effect-free function
- vaikutukseton funktio a function that never has an effect on program state ¶ See Chapters 1.6, 1.7, and 10.2 and cf. effectful function. Such functions are also called “side effects”. The reason to call an effect-free function is to obtain its return value. Effect-free functions resemble the functions that feature in school mathematics. Some of them are pure. See also referential transparency.
- effectful function
- vaikutuksellinen funktio a function that has (or may have) an effect on the program’s state ¶ See Chapters 1.6, 1.7, and 10.2 and cf. effect-free function. Effects include modifying the contents of a buffer, updating the value of an object’s instance variable, and printing out characters onscreen, among other things. In contrast, evaluating expressions, time passing during computation, and events on the call stack are usually not considered to be effects. More generally, a function is effectful in case calling it is significant beyond the fact that it returns a value. An effectful function can be useful even if it doesn’t return a meaningful value; on the other hand, an effectful function isn’t referentially transparent. Effects in this sense are also known as “side effects”.
- efficiency
- tehokkuus the extent to which a program fulfills its purpose without wasting resources ¶ The word especially often refers to how much time running a program takes and how much memory the program requires. Efficiency is not a focus in O1 (but is in various follow-on courses); nevertheless see, e.g., Chapters 5.5 and 12.1.
- element
- alkio a value in a collection or similar data structure ¶ See Chapter 1.5.
- element
- elementti 1) a data item in a collection; 2) a GUI element
- embedded system
- sulautettu järjestelmä a computer system that has a limited, relatively narrow purpose ¶ Automated teller machines (ATMs) and many robots are embedded systems, for instance, as are modern cars. Cf. general-purpose computer and see Chapter 1.1.
- empty string
- tyhjä merkkijono
a string that contains zero characters and whose length is therefore zero ¶ An empty string is
nevertheless an actual string (in Scala, it’s an object of type
String
) unlike anull
reference. See Chapter 4.1. - encapsulation
- kapselointi a word that refers to one or both of: 1) hiding information behind an interface using access modifiers; 2) bundling subprograms together with the data that they operate on (as in an object)
- error
- virhe 1) a defect in a program; a bug; a invalid, unintended, and/or problematic aspect of a program; 2) a shorter term for a runtime error ¶ Errors can be classified into compile-time errors, runtime-errors, and logical errors. In some technical contexts, the word refers specifically to runtime errors.
- evaluate
- evaluoida
to determine the value of an expression ¶ See, e.g., Chapter 1.3. What the computer does to
evaluate an expression depends on the expression. For instance, to evaluate the arithmetic
expression
1 + 1
, the computer needs to sum two integers; to evaluate an expression that consists of a variable’s name, it needs to access the value stored in that variable. A function-calling expression is evaluated by executing the function; the expression’s value is the function’s return value. Expressions may be evaluated strictly or non-strictly. - evaluation area
- evaluointialue a part of memory (within a frame) that the computer uses as it evaluates expressions ¶ See, e.g., Chapters 1.3 and 1.7. This term is seldom used outside of O1. The evaluation area plays a key role in the animations of program execution in this ebook. It’s a graphical abstraction of what the virtual machine does.
- event
- tapahtuma an action or occurrence that a program may react to ¶ Events that occur while the program is running may be passed on to the appropriate event listeners. Such event-driven design is common in graphical user interfaces, for instance. See also GUI event.
- event handler
- tapahtumankäsittelijä a program component, such as a function, that determines how the program should behave when a particular sort of event occurs ¶ For instance, an event handler may contain the program code that is executed whenever a user presses a key in an application’s graphical user interface. An event handler is typically part of an event listener; see Chapters 3.1 and 12.3.
- event listener
- tapahtumankuuntelija a program component, such as an object, that is notified whenever a particular sort of event occurs ¶ Event listerers typically react to observed events by running an appropriate event handler. See Chapters 3.1 and 12.3.
- exception
- poikkeus a term used of some runtime errors
- exception handling
- poikkeustenkäsittely
detecting runtime errors and reacting to them ¶ See Chapter 11.3 and
try
,catch
, andfinally
. - execute
- suorittaa, ajaa to run (a program)
- explicit
- eksplisiittinen specifically stated; expressly written in program code ¶ Antonym: implicit.
- expression
- lauseke
a piece of program code that has a value ¶ See, e.g., Chapter 1.3. Examples of expressions include
literals, arithmetic expressions such as
1 + 1
, the names of variables, and function calls written into program code. Determining the value of an expression is known as evaluating the expression. Cf. statement. - extend
- periä, liittää to mark a class or trait as being a subtype of another; to inherit; to mix in ¶ See Chapters 7.2 and 7.3. A subtype’s definition can be thought of as an extension of the supertype’s.
- factory method
- tehdasmetodi a method whose only purpose is to create a new object and return it (or a reference to it) ¶ See Chapter 5.3.
- field
- kenttä see member variable
- file
- tiedosto a resource where a computer stores data; especially: a data resource stored on the computer’s hard drive or in similarly persistent memory ¶ See also text file.
- filter
- suodin
(in digital imaging:) an operation that transforms an image or a part of an image ¶ For instance, a
grayscale filter takes in a color image and generates a variant of it where all the pixels are
various shades of gray. The word “filter” has further meanings in computing; as one example,
Scala’s collections have a higher-order method named
filter
. final
- final
a reserved word that 1) completely prohibits inheritance from a class, when used in front of a
class definition; 2) prevents overriding a method, when used in front of a method definition ¶
See Chapter 7.3. Cf.
sealed
. finally
- finally
(in Scala:) a reserved word used in exception handling to start a block that follows a
try
block and is executed after thetry
block (and a possiblecatch
block) irrespective of whether a runtime error occurred while running thetry
block - first-order function
- ensimmäisen asteen funktio a function that is not a higher-order function
- fixed value
- kiintoarvo
a variable whose value the program never updates once the variable has been initialized ¶ This is
one of the roles of variables. See Chapter 2.6 and cf. constant and
val
variable. - flag
- lippu
a variable or comparable data item that a program uses to indicate whether or not something is the
case ¶ See Chapter 5.6 and one-way flag. A
Boolean
variable can serve as a flag. - floating-point number
- liukuluku a way of approximating decimal numbers using a limited number of bits ¶ Common in digital technology. A floating-point number is a combination of a sign bit, a multiplicative factor known as a mantissa, a base number, and an exponent. The number two is usually used as the base; the other components depend on the number to be represented. Floating-point numbers are briefly discussed in Chapter 5.4.
for
loop- for-silmukka
a loop formed using the
for
keyword ¶ Thefor
loops in O1’s examples are so-called “foreach loops”, meaning that they traverse a particular collection and repeat an operation on each of that collection’s elements in turn; see Chapters 5.5 and 5.6.for
loops are often applied to strictly evaluated collections, in which case the number of repetitions and the targeted elements are known in advance; however, it’s possible to use afor
on a non-strict collection as well. Scala’sfor
construct is very versatile; for more information, see O1’s follow-on courses or other resources. - formal parameter
- muodollinen parametri another term for parameter variable ¶ Contrasts with actual parameter.
- frame
- kehys a part of computer memory that is reserved for keeping track of how a particular function call proceeds during a program run ¶ See Chapters 1.7 and 1.8. Typical contents of a frame include local variables, a memory area for evaluting expressions, and information about where in the program’s the function was called and where execution should thus resume once the function call is done. Each frame persists in memory while the function call is ongoing. Together, frames form a call stack.
- fully qualified name
- täydellinen nimi
a program component’s full name, which includes the name of the containing package ¶
For instance, the fully qualified name of Scala’s
Int
type isscala.Int
, and the fully qualified name of thesqrt
function isscala.math.sqrt
. - function
- funktio a subprogram; a part of a program that takes care of a specific task and that is executed whenever a program calls it ¶ See Chapters 1.6, 1.7, and 1.8. To define a function, the programmer defines its signature and its body. Where a function definition is available, it can be called, causing its program code to be executed. Functions can be effectful or effect-free. A method is a function associated with an object. See also higher-order function and anonymous function.
- function body
- funktion runko the part of a function’s definition that defines which instructions are to be executed when the function is called ¶ See Chapter 1.7. In Scala code, the body follows the signature and an equals sign in a function definition.
- function call
- funktiokutsu
1) an expression that is evaluated by executing the program code of a particular function;
2) the process generated by evaluating such an expression; the execution of a function’s program
code ¶ See Chapters 1.6 and 1.7. Many functions take parameters; the parameter expressions
are written into the function-calling expression. When a function call is executed, the computer
(in most cases) creates a frame to track the function activation and executes the instructions in
the function’s body. The value of a function-calling expression is the return value
produced by executing the function. In Scala, functions always return a value, although that value
may be just
Unit
to indicate the absence of a meaningful return value. - function literal
- funktioliteraali a literal that defines an anonymous function ¶ Scala has several alternative notations for writing function literals; see Chapter 6.2.
- functional programming
- funktionaalinen ohjelmointi a programming paradigm that relies on effect-free functions and immutable data and that tends to make extensive use of higher-order functions ¶ See Chapter 10.2 and cf. imperative programming. Functional programming is one of the main forms of declarative programming.
- garbage
- roska data stored in the computer’s memory that is inaccessible to the program that stored it ¶ For example, an object that no reference points to is garbage. In a correctly written program, only data that the program no longer needs should become garbage. Memory allocated to garbage should be released for other use via garbage collection.
- garbage collection
- roskankeruu the act of releasing memory taken up by garbage for other use ¶ Garbage collection can be automatized, and many modern programming platforms do automatize it, the Java Virtual Machine included. This prevents some memory leaks from happening.
- gatherer
- kokooja a variable that is used for gradually combining multiple individual values into a result of some kind ¶ For instance, a gatherer may store the accumulating sum of a sequence of numbers. This is one of the roles of variables. See Chapters 2.6 and 5.5.
- general AI
- yleinen tekoäly artificial intelligence that combines information broadly and is not tied to a specific application like narrow AI is. ¶ This term is closely related to strong AI. General AI is a fantastically ambitious goal; the existing practical applications that are currently referred to AI are narrow AI instead.
- general-purpose computer
- yleiskäyttöinen tietokone a computer that is not tied to a particular application domain and that is designed to be used for a variety of purposes ¶ For instance, the desktop and laptop computers that people commonly use are general-purpose computers. People make a general-purpose computer do specific things by having it run diverse applications. Cf. embedded system and see Chapter 1.1.
- graphical user interface
- graafinen käyttöliittymä a user interface that is based on not just text but also on graphical elements such as windows and buttons ¶ See Chapters 2.7, 3.1, and 12.3. Commonly abbreviated as GUI. Graphical user interfaces are very common in modern applications; they are especially common in applications whose users aren’t programmers themselves.
- GUI
- GUI short for graphical user interface
- GUI component
- GUI-komponentti an element of a graphical user interface; especially: an element that appears within a GUI window ¶ Buttons and text fields, for instance, are GUI components. The term is often used synonymously with GUI element to mean any piece of a GUI, but in some contexts, the term “component” only applies to those elements that compose the actual contents of a GUI window (excluding, e.g., dialogs and other windows).
- GUI element
- GUI-elementti a constituent part of a graphical user interface ¶ See GUI component.
- GUI event
- käyttöliittymätapahtuma an event associated with a graphical user interface ¶ Examples: a mouse movement or a press of a key on the keyboard. See Chapters 3.1 and 12.3.
- hardware
- laitteisto the physical parts of computers and related devices ¶ Constrasts with software.
- hierarchy
- hierarkia see class hierarchy
- high-level language
- korkean tason kieli a programming language that has a high level of abstraction and is independent of the specific characteristics of the computers that run programs written in the language ¶ The “level” of a language is a fuzzy term, but languages such as Scala are generally thought of as being quite high up in abstraction. Cf. low-level language and machine language. High-level languages tend to be more usable by humans than low-level ones.
- higher-order function
- korkeamman asteen funktio a function that operates on other functions: takes them as parameters or returns them ¶ See Chapter 6.1. Functions that aren’t higher-order functions may be referred to as first-order functions.
- I/O
- I/O communication between a program and the world external to it; reading input and writing output ¶ For instance, a program may interact with files (see Chapter 11.3), peripheral devices (e.g., a keyboard, a display), and other computers on a network. I/O is short for “Input/Output”.
- IDE
- IDE short for integrated development environment
- identifier
- tunnus a name given to a part of a program ¶ For instance, the names of variables, functions, and classes are sometimes called identifiers.
if
- if
a command that makes the computer select between two alternatives on the basis of what
a
Boolean
expression’s value is ¶ See Chapter 3.4. See alsomatch
. - immediate subclass
- välitön aliluokka a class that inherits directly from another class, with no intermediary classes in between; a class that is a single “generation” below another in a class hierarchy ¶ Cf. indirect subclasses, which are subclasses of a class’s immediate subclass.
- immediate superclass
- välitön yliluokka a superclass that another class inherits directly, with no intermediary classes in between; a class that is a single “generation” below another in a class hierarchy ¶ Cf. indirect superclasses, which are superclasses of a class’s immediate superclass.
- immutable
- muuttumaton (of a collection or other object or data structure:) one whose state never changes during a program run ¶ Vectors, for instance, are immutable collections: a vector, once created, always stores the same elements. In contrast, buffers are an example of mutable collections. See Chapters 4.2 and 10.2.
- imperative programming
- imperatiivinen ohjelmointi a common programming paradigm that relies on the manipulation of mutable data using ordered sequences of commands (statements) and effectful subprograms and where loops are the primary means of repetition ¶ See Chapter 10.2 and cf. functional programming.
- implementation
- toteutus 1) the way an abstract model, plan, or algorithm works in practice; 2) the part of a program component or other entity that the component’s users do not need to know in order to use it ¶ The word has a number of related meanings in programming. Examples: 1) a program or a subprogram can be an implementation of a generic algorithm; 2) a program component such as a class can have a public interface, which specifies how the component may be used, as well as a hidden implementation that specifies what the computer does when the component is used; 3) a function has a signature that outlines its usage and a body that serves as the function’s implementation and that the function’s caller doesn’t need to know. Of course, the verb “implement” has common meanings that also apply to programming (as in “I planned what my program would be like and then implemented the plan.”).
- implicit
- implisiittinen unexpressed; not specifically stated; only indirectly deducible; not explicit
- implicit coupling
- implisiittinen riippuvuus a circumstance where modifying one part of program code necessitates changes elsewhere in the program, but this necessity is not obvious ¶ As one example, magic numbers often result in implicit coupling. Programs with implicit coupling are generally harder to modify and prone to having bugs.
- indent
- sisentää to set a line of text in from the margin ¶ Consistent indentation is a cornerstone of good programming style; see Chapters 1.7, and 3.4 and O1’s style guide.
- index
- indeksi the ordinal number of an element in a collection that numbers its elements ¶ Vectors, buffers, and arrays are examples of numerically indexed collections. An element of such a collection is accessible via its index; see Chapter 1.5. In some programming languages, indices run from one upwards; that is, the first element is at index #1. In many other languages, including Scala, indices start at zero.
- infix operator notation
- operaattorinotaatio a more precise term for operator notation
- information hiding
- tiedon piilottaminen a principle of program design that seeks to separate interfaces from the underlying implementations ¶ “Hiding” refers to the notion that the user of a program component (such as a class) only needs to know about a “visible” interface. The user is allowed to “forget” about the underlying implementation or be wholly ignorant of it. When implementation details are hidden behind an interface, the implementor is free to change them as the program develops (e.g., to improve efficiency): as long as the interface remains constant, no changes are needed to other program components that use the changed component. See Chapter 3.2.
- inheritance
- periytyminen, perintä an object-oriented technique in which the relationship between a supertype and its subtypes is represented by defining a superclass for the subclasses that extend it ¶ See Chapter 7.3. Depending on one’s definition of inheritance, traits may be viewed as an altenative form of subtyping or as a form of inheritance.
- input
- syöte data that a program receives from an external source; especially: input that the program receives from its user (e.g., via a keyboard) ¶ See Chapters 2.7 and 11.3 and I/O. Data provided by an application’s user via their keyboard is one kind of input, for instance. Some programs read input from a file; see, e.g., Chapter 5.2. GUI events can be a sort of input, too.
- instance
- ilmentymä, instanssi an object created using a class as a template; an individual occurrence of the general concept that the class represents ¶ See Chapter 2.3. The concrete attributes of an instance are usually not detailed in program code like those of a singleton object. Instead, the attribute values are set when instantiating a class.
- instance variable
- ilmentymämuuttuja 1) a class’s member variable; 2) an instance-specific copy of a class’s member variable, stored in computer memory ¶ Instances’ attributes are stored in instance variables; see Chapter 2.4.
- instantiate
- instantioida
to create an object as an instance of a class ¶ In Scala, a class is instantiated using the
new
keyword; see Chapter 2.3. Upon instantiation, some memory is allocated for the new object, which is then initialized using the class’s constructor. An instantiation command is effectively a special kind of function call. - integrated development environment
- sovelluskehitin an auxiliary program that provides a collection of programming tools, which may include an editor, a compiler, or a virtual machine, for example ¶ See Chapters 1.2 and 5.4. Commonly abbreviated as IDE. Eclipse, which we use in O1, is an example of an IDE. As the name suggests, programmers use IDEs to develop new programs.
- interface
- rajapinta 1) the “façade” through which a program component or some other service is used; 2) (in some programming languages:) a programming construct similar to a trait; see separate entry ¶ In O1, only the first meaning is important. For example, one can say that a class has an interface that comprises its public aspects. To use a component, it’s necessary to know its interface but unnecessary to know its implementation. See Chapter 3.2 and cf. user interface.
- interface (programming-language construct)
- rajapintaluokka a construct that resembles abstract classes and especially traits ¶ This construct is not present in Scala but in some other languages, most prominently Java. Java’s interfaces differ from Scala’s traits primarily in that an interface can define only abstract methods on objects of that type, whereas traits do not have this limitation.
- intermediate language
- välikieli a language that source code is compiled to but that is not actual machine language; especially: a language used as the “machine language” of a virtual machine ¶ See Chapter 5.4.
- interpreter
- tulkki an auxiliary program that runs a given program, translating it into machine language as needed ¶ For instance, a bytecode interpreter is one of the key components of the Java Virtual Machine. See Chapter 5.4 and cf. compiler.
- invoke
- kutsua to instruct the computer to execute a function ¶ See function call. Synonyms: call, invoke.
- iteration
- iteraatio 1) repetition in which each cycle continues where the previous one left off; 2) the use of such repetition to implement programs; especially: using a loop to repeat commands ¶ Cf. recursion and see Chapter 12.1.
- iterator
- iteraattori an object that enables its user to traverse the contents of a collection non-strictly in a particular order ¶ See Chapter 11.3.
- Java
- Java 1) a programming language; 2) the so-called Java platform: a set of programming tools that includes the Java Virtual Machine and that was originally designed for use with the Java language ¶ Java the language is primarily designed for imperative object-oriented programming. Java programs are usually run in the Java Virtual Machine, as Scala programs are, and it’s easy for a Scala program to use libraries written in Java; see Chapters 5.4, 11.3, and 12.3.
- Java Virtual Machine
- Java-virtuaalikone a virtual machine ¶ See Chapter 5.4. Commonly abbreviated as the JVM. The Java Virtual Machine was originally designed for use with the Java programming language, but it has since become common to compile various other programming languages into bytecode that the JVM can run. Scala is one such language.
- JavaScript
- JavaScript a programming language ¶ JavaScript holds a de facto special position among programming languages in that modern web browsers are capable of running JavaScript programs. Consequently, JavaScript is in widespread use in programs embedded in web pages. It’s increasingly common to compile programs written in different languages into JavaScript; with the Scala.js toolkit, Scala programs, too, can be compiled into JavaScript instead of JVM bytecode. Despite its name, JavaScript is completely different from Java; the names are similar for historical marketing reasons.
- JVM
- JVM the Java Virtual Machine
- key
- avain a data item that can be used to locate or identify another data item; especially: a data item used in a map for accessing the corresponding value ¶ See Chapter 8.4 and cf. index.
- key–value pair
- avain–arvo-pari a pair formed by a key and a value ¶ Used especially in maps; see Chapter 8.4.
- label
- nimiö a simple GUI component whose purpose is to display some text and/or an image ¶ See Chapter 12.3.
- lambda expression
- lambdalauseke a function literal ¶ This term is common in languages where function literals are formed using the word “lambda” or the Greek letter of that name. Chapter 6.2 explains the term’s history.
- lambda function
- lambdafunktio an anonymous function ¶ This term is common in languages where anonymous functions are defined using the word “lambda” or the Greek letter of that name. Chapter 6.2 explains the term’s history.
- late binding
- myöhäinen sidonta used as a synonym for dynamic binding (among other things)
- lazy
- laiska
non-strict and avoiding of repeated evaluation ¶ See Chapter 7.1. This adjective
describes a policy for evaluating expressions. A lazy variable gets a value
from the assigned expression non-strictly: only when or if the variable’s
value is actually used. Once that happens, the value is stored in the lazy variable and
accessible to the program without re-evaluating the expression. In Scala, the keyword
combination
lazy val
defines a lazy variable. The elements of a lazy collection, such as a stream, aren’t necessarily formed at all; only those elements that are actually accessed are formed, after which the collection stores them in memory. - level of abstraction
- abstraktiotaso
(in O1 means especially:) the extent to which a solution is independent from implementation
details ¶ General-purpose programming tools such as a
do
loop or thefoldLeft
method are abstract in that they can be applied to different kinds of problems; they abstract over many more use cases than, say, thesize
method, which does the specific job of returning a collection’s size. However, from its user’s point of view,size
is at a higher level of abstraction than the general-purpose tools: its caller doesn’t need to know how it’s been implemented (with a loop, withfoldLeft
, or in some other way); it abstracts over different implementations. This ebook uses “level of abstraction” in the latter sense in several chapters, including 6.3, 6.4, and 8.3. See also high-level language and low level language. - lexical closure
- sulkeuma, klosuuri see closure
- library
- kirjasto a collection of subprograms, classes, or other program components that can be used for building different programs ¶ Some libraries, such as the Scala API, are deeply linked to a particular programming language. Some libraries are very generic while others are tailored to more specific needs.
- library function
- kirjastofunktio a function that is defined in a library ¶ This term is sometimes used to emphasize that a particular function isn’t custom-made for a particular application but comes from a general-purpose library.
- LIFO
- LIFO a principle obeyed by stacks, according to which only the element that has been in the collection for the shortest time may be removed ¶ Short for “last in, first out”. See Chapter 11.2.
- Liskov substitution principle
- Liskovin periaate a principle for defining data types, according to which it must be reasonable to use subtype values (e.g., instances of a subclass) in any context that calls for a value of a supertype (e.g., an instance of a superclass) ¶ See Chapter 7.3.
- list
- lista
1) (generally:) any series or listing of items; 2) (in Scala and various other languages:) an
immutable collection implemented as a linked chain of elements and suitable for traversing in
element order ¶ In Scala, lists are represented by class
List
; see Chapter 11.2 and O1’s follow-on courses. Streams are lazy lists. Different programming languages use the name “list” for different kinds of collections. - literal
- literaali
a simple expression whose value is written directly into program code ¶ For instance,
10
is an integer literal and"llama"
is a string literal. See also function literal. - llama
- laama a species of mammal largely irrelevant to programming
- local function
- paikallinen funktio a function that is defined within the body of another function and that can be used only by that containing function ¶ See, e.g., Chapters 6.4 and 12.1 and cf. local variable. See also closure.
- local variable
- paikallinen muuttuja a variable defined within a function for the use of that containing function alone ¶ A programmer can define local variables within a function’s body (see, e.g., Chapters 1.7 and 5.5); parameter variables can also be considered a kind of local variable. The values of local variables are stored within frames on the call-stack, so they only exist temporarily while a function call is running; however, see closure. See also scope.
- logical error
- looginen virhe an error that manifests itself as undesirable program behavior but not as an erroneous situation in the technical sense ¶ Examples: a program that uses the wrong formula to compute results; a program that greets the user with the wrong message; a program that fails to perform all the operations that it was designed to perform. Cf. compile-time error and runtime error.
- logical operator
- logiikkaoperaattori, looginen operaattori
an operator whose operands are truth values and that produces a truth value ¶ For instance,
&&
(“and”) and||
(“or”) are logical operators; see Chapter 5.1. - loop
- silmukka
1) a part of a program that is executed repeatedly; 2) a programming-language command that
defines such a repeating section of program code ¶ See Chapters 5.5, 5.6, and 8.3. In Scala,
loops can be defined using the
for
,do
, andwhile
keywords. Depending on the programming language, it may also be possible to use a jump command such asgoto
to form a loop (see Chapter 11.2). Loops are a common implementation technique for iterative algorithms. - low-level language
- matalan tason kieli a programming language that has a low level of abstraction and depends on the specific characteristics of the computers that run programs written in the language ¶ Machine languages, especially, are referred to as low-level languages. It’s possible to program in low-level languages and doing so may lead to improved program efficiency under the right circumstances, but high-level languages are much more practical for many purposes.
- machine code
- konekieli see machine language
- machine language
- konekieli a programing language that processors (of a particular sort) can execute without modification ¶ See Chapter 5.4. Machine languages generally operate at a very low level and are dependent on specific hardware. The machine-language instructions executed by the processor are (binary) numbers, but a machine-language program can also be expressed in symbolic form. These days, programs are usually written in a high-level language that is translated into machine language before being run. The term “machine language” is sometimes used in a broad sense that also encompasses symbolic machine code a.k.a. assembly and/or the virtual machine languages used in virtual machines.
- machine learning
- koneoppiminen a subdiscipline of computing in which a piece of software or a computer system uses input data to learn to make decisions, predictions, or other assessments about scenarios that resemble (but are not identical to) those in the training data and that the programmer has not explicitly detailed as code ¶ Since many modern applications of machine learning impress people, these applications are often labeled artificial intelligence.
- magic number
- maaginen luku a (numerical) literal whose purpose in program code is not obvious ¶ Magic numbers (and other “magic values”) can make a program harder to read, and repeated use of a magic number often creates implicit dependencies. One way to avoid magic numbers is to define constants instead; see, e.g., Chapter 2.6.
- main object
- käynnistysolio see app object
- map
- hakurakenne
a collection whose elements are key–value pairs and that provide access to the values via
its key ¶ See Chapters 8.4 and 9.2. Maps come in mutable and immutable varieties; in Scala, they
are implemented as
Map
. Maps go by a variety of names in different languages, including “dictionary”, “dict”, and “associative array”. This collection type is not to be confused with the lower-casemap
, which is a method on various collections. match
- match
a command that can make the computer select between two or more alternatives by inspecting which
of the cases written into the program corresponds to the value of a particular expression ¶
Each of the cases written into a
match
command defines a so-called pattern, that the computer attempts to match the expression’s value to. This pattern-matching relies on the value’s dynamic type. See Chapters 4.3 and 4.4 and cf.if
. - member
- jäsen a constituent part of a class or a singleton object ¶ Methods and member variables are members.
- member variable
- jäsenmuuttuja a variable that is a member of a class or singleton object ¶ The member variables of a class are commonly referred to as instance variables, since a copy of them is created in memory for each instance of the class; see Chapter 2.4.
- memory
- muisti a computer’s component or auxiliary device that is capable of storing data either temporarily or persistently (which depends on the memory hardware) ¶ The data that programs process is stored in memory, usually in the form of bits. Each part of memory has its own address, a unique number that identifies that specific memory location. In O1, the way programs use memory is depicted as abstract, animated diagrams from Chapter 1.3 onwards.
- memory leak
- muistivuoto a defect that causes a program not to release some of the memory that it reserves even after it no longer needs what is stored in that part of memory ¶ A program that leaks memory keeps reserving more and more memory (perhaps little by little), which can eventually lead to errors and program crashes once there is no more memory available. Failure to properly deal with garbage causes memory leaks.
- message
- viesti an instruction sent to an object; an invocation of an object’s method ¶ Object-oriented programming is based on the notion that each object is capable of receiving a limited set of messages and reacting to them; an object can also send such messages to other objects as it reacts to messages that it itself received. See Chapter 2.1.
- method
- metodi a function attached to an object ¶ What methods an object has determines what messages it can receive and how it behaves when it receives them; see Chapter 2.1. In Scala code, each method is defined as part of a singleton object or class’s (or trait’s) definition; see Chapter 5.2. When reading other resources on Scala, it’s good to be aware that all Scala programmers don’t delimit this term precisely like we do in O1 and as the official Scala glossary does.
- method body
- metodin runko see function body ¶ Methods are functions, too.
- method call
- metodikutsu a function call where the function is a method ¶ See Chapter 2.1. In Scala, method calls can be written using the dot notation or the operator notation.
- MIDI
- MIDI Musical Instrument Digital Interface, a standard for communicating with electronic musical instruments and programming them ¶ See Chapter 1.4.
- mix in (a trait)
- liittää (piirre) to mark a class or trait (or singleton) as being a subtype of a trait; to extend a trait ¶ See Chapter 7.2. Multiple traits can be mixed in at once (cf. there may be only a single immediate superclass).
- model
- malli 1) a representation; (especially:) a representation of a program’s domain; 2) the part of an application program that represents domain concepts (independently of any user interface) ¶ Programmers develop models of domains using the constructs available in the programming language, such as classes. An application can be seen as having a domain model and a user interface that provides a view to that model; see Chapters 1.2, 2.7, 3.1, and 9.1.
- modulo operator
- modulo-operaattori
an operator for computing the remainder of a division ¶ In Scala and many other programming
languages, the modulo operator is written as
%
. See Chapter 1.7. - most-recent holder
- tuoreimman säilyttäjä a variable that is used for storing the latest value in a sequence of values ¶ This is one of the roles of variables. For instance, a most-recent holder can be used for tracking the latest value assigned to an object’s attribute (Chapter 2.6) or the latest collection element that is being processed (Chapter 5.5).
- most-wanted holder
- sopivimman säilyttäjä a variable that is used for tracking which value best matches a particular criterion ¶ This is one of the roles of variables. See Chapters 4.2 and 5.5.
- multiple inheritance
- moniperintä inheritance from multiple immediate superclasses ¶ Scala doesn’t support multiple inheritance from superclasses but a class may extend multiple traits.
- mutable
- muuttuvatilainen (of a collection or other object or data structure:) one whose state may change during a program run ¶ Buffers, for instance, are mutable collections: a single buffer may have different contents at different times. In constrast, vectors are an example of immutable collections. See Chapters 4.2 and 10.2.
- narrow AI
- suppea tekoäly artificial intelligence that is limited to a specific application area ¶ For instance, a narrow AI may be specialized in translating text, improving search results, driving a car, or recognizing faces in an image. Antonym: general AI. Weak AI means almost the same.
- non-strict
- väljä such that parameter expressions are evaluated selectively ¶ See Chapter 7.1. This adjective describes a policy for evaluating expressions. A non-strict parameter gets its value from a parameter expression that is evaluated only in case its value is actually needed during the program run; by-name -parameters are often non-strict. A non-strict collection is a collection whose elements are only formed in case they are actually used; Scala’s streams are an example of a non-strict collection type. Antonym: strict. See also lazy evaluation.
None
- None
an
Option
-typed singleton object that does not contain a data item ¶ See Chapter 4.3 and cf.Some
. A reference to theNone
object cannot be assigned to just any variable, but it can be assigned to a variable of typeOption
. This is one of the ways in whichNone
is different from thenull
reference, which can technically appear as the value of (almost) any variable. null
- *null*-viittaus
a value that may be used to indicate the absence of data; a reference that does not specify any
actual location in the computer’s memory ¶ For instance, in Scala, the
null
reference is type compatible with nearly all data types (cf.Option
, which isn’t). Use of thenull
reference, although technically possible, is a common cause of bugs. Many Scala programmers steer clear ofnull
altogether. See Chapters 4.2, 4.3, and 12.1. NullPointerException
- NullPointerException
a type of runtime errors that occur when a program attempts to follow a
null
reference to access data that it points to (which data does not exist fornull
) ¶ For instance, if a Scala program attempts to invoke a method on a variable that stores anull
reference rather than a reference to an existing object, aNullPointerException
occurs; see Chapters 4.2 and 4.3. This sort of error has this name in several programming languages, including Scala and Java; other programming languages use other names for the same phenomenon. - O1
- O1 the nickname of this course, CS-A1110 Programming 1 ¶ An abbreviation of the Finnish name Ohjelmointi 1.
- O1Library
- O1Library a software library developed for the purposes of this course, O1 ¶ Many of O1’s example programs use this library. The library contains tools for building simple picture-based GUIs and generating MIDI sound, among other things. The chapters of this ebook introduce selected parts of O1Library. The library has documentation as Scaladocs, and there’s a short summary of O1Library’s main GUI tools in O1’s Scala Reference.
Object
- Object
(in the context of Scala:) an alternative name of class
AnyRef
when using Scala on the JVM - object
- olio an abstraction that represents a single “thing” or entity; a program component that is capable of receiving messages and reacting to them as specified by the programmer ¶ Objects are the mainspring of object-oriented programming; see Chapter 2.1. The programmer defines what functionality an object has by associating it with functions, known on an object as methods. Some objects have mutable state, others don’t. See also singleton object and class.
- object-oriented programming
- olio-ohjelmointi a common programming paradigm in which a program’s domain is represented as objects and message-passing between those objects ¶ See, e.g., Chapters 2.1 and 10.2. Often abbreviated as OOP. Scala is a pure object-oriented language: all information is represented as objects (see Chapters 5.2 and 5.3). Object-oriented programming is commonly associated with additional constructs such as classes and inheritance, but not all forms of OOP feature these concepts.
- one-way flag
- yksisuuntainen lippu a variable that has exactly two possible values and never changes in value once its been changed from its initial value to the other one ¶ This is one of the roles of variables, a sort of flag. See Chapter 5.6.
- OOP
- OOP short for object-oriented programming
- operand
- operandi
1) an expression that an operator is applied to; 2) the value of such an expression ¶ For instance,
in the expression
2 * (1 + 10)
the multiply operator’s operands are the literal2
and the arithmetic expression(1 + 10)
. - operating system
- käyttöjärjestelmä a software system that governs the use of computing devices, provides certain services to programmers, and lets end users launch applications ¶ Among its other responsibilities, an operating system takes are of devices (including memory, processors, files, networks, and various peripherals) and provides abstractions through which a programmer may use them.
- operator
- operaattori
a written character or combination of characters that, when used in source code, instructs the
computer to perform a particular operation ¶ For instance,
+
is an addition operator in many programming languages and<=
one of several comparison operators. Like operators, function calls also instruct the computer to perform operations, and the line between what counts as an operator and what doesn’t is not always clear-cut. Usually, when people speak of “operators”, they mean characters or short combinations of characters that are applied using a simple syntax that differs from typical function calls. In Scala, operators aren’t a distinct language construct at all; instead, one may use either the operator notation or the dot notation when calling a method (Chapter 5.2). Methods such as+
, on which it’s common to use operator notation, are often called “operators” in Scala, too. - operator notation
- operaattorinotaatio
a notation for calling methods that is characterized by the absence of punctuation
in the method-calling expression ¶ Examples:
myObject myMethod myParam
and1 + 1
. In Scala, operator notation can be used as an alternative to dot notation if the method is suitable; see Chapter 5.2 and O1’s style guide. See also operator. Option
- Option
a class whose purpose is to represent the possible absence — optionality — of a data item ¶
Each value of type
Option
is an object that either contains a single element of data (Some
) or is empty (None
); see Chapter 4.3. UsingOption
makes the possible absence of a value explicit in program code and helps programming tools provide error messages at compile-time in many situations that would result in a runtime failure ifOption
’s alternative, thenull
reference was used instead. AnOption
is a simple kind of collection; see Chapter 8.2. - overload
- (yli)kuormittaa to define, within a single program component (e.g., a single class), multiple functions that have the same name but that take different parameters and thus have different signatures ¶ See Chapters 1.6 and 4.1.
- override
- korvata to re-implement a member (a method or a variable) rather than relying on an existing, more generic definition ¶ A subclass may override a superclass’s method implementation with another that is appropriate for that specific subclass’s instances; see, e.g., Chapter 7.3. Overriding can also be done on just a single instance to make it behave differently than other instances of the same class; see, e.g., Chapter 2.4.
- package
- pakkaus a named bundle of program components ¶ For instance, a Scala program’s components are grouped into one or more packages; see Chapter 1.2. A single package cannot contain multiple components (e.g., multiple classes) that have the same name, but different packages can. Packages’ contents are often imported so that they can be used conveniently (without fully qualified names); see Chapters 1.3 and 1.5. A single Eclipse project may contain components that belong to several packages. See also Scala API and package object.
- package object
- pakkausolio a standalone object that represents a package and whose members constitute the contents of that package ¶ See Chapter 5.2.
- pair
- pari a tuple that has exactly two members ¶ Pairs are useful as key–value-pairs in maps. Another common use case is to return two values from a function: even though a (Scala) function can return only a single value, that value can be a pair. See Chapter 1.8 and especially Chapter 8.4.
- panel
- paneeli a GUI component that may contain various other components and that is used for grouping and laying out the other components ¶ See Chapter 12.3.
- parameter
- parametri a piece of information passed to a program component; especially: additional information that is passed to a function and that elaborates on what the function call should do ¶ See Chapters 1.3, 1.6, 1.7, and 2.1. The parameters that a function takes (zero or more) are defined as part of the function’s signature. When a function is executed, parameter expressions are evaluated, producing parameter values, which are then passed into parameter variables that are located within a frame that tracks the function call. (That applies to the usual case of strict evaluation. In non-strict evaluation, parameter expressions are evaluated later or not at all.) Different sources use different terminology about parameters; see argument for a discussion. See also parameter list and type parameter.
- parameter expression
- parametrilauseke, argumentti an expression that is written into a longer function-calling expression and that is evaluated to produce a parameter value ¶ See Chapters 1.3, 1.6, 1.7, and 7.1. Some others use the term argument or actual parameter for what we call “parameter expressions” in O1; see argument for a terminological discussion.
- parameter list
- parametriluettelo 1) a listing of parameter variables that is part of a function definition; 2) a listing of parameter expressions in a function-calling expression ¶ In Scala, parameter lists go in round brackets. A function may have one parameter list (see Chapters 1.6 and 1.7), or none (see Chapters 1.8 and 2.6), or several (see Chapter 6.1).
- parameter value
- parametriarvo, argumentti a value that is obtained by evaluating a parameter expression ¶ Under normal (strict) evaluation, parameter values are passed into parameter variables that are located within a frame that tracks the function call; see Chapters 1.3, 1.6, and 1.7. Some others use the term argument or actual parameter for what we call “parameter values” in O1; see argument for a terminological discussion.
- parameter variable
- parametri(muuttuja)
a local variable that is defined within a signature ¶ See Chapter 1.7. Also known as a
formal parameter or simply parameter. A parameter variable receives a parameter value when a
function call begins and stores it during the function’s execution. (At least that’s what usually
happens, but cf. by-name parameter.) In Scala, parameter variables are always
val
:gl:s <val variable>
. (In Scala’s official terminology parameter variables are actually parallel to local variables rather than a subordinate concept, but in O1 we use the term as described here.) Pic
- Pic a class for representing images, defined in O1Library ¶ See, e.g., Chapters 1.3, 2.3, and 2.5 and the class’s documentation.
- pixel
- a point in a digital image ¶ What you see on a computer monitor is composed of pixels. Images, written characters, etc. can be represented as combinations of differently colored pixels. The word is short for “picture element”.
- plain text file
- tekstitiedosto see text file
Pos
- Pos a class representing two-dimensional coordinates, defined in O1Library ¶ See, e.g., Chapters 2.5 and 3.1 and the class’s documentation.
- tulostaa (of a computer:) to write text ¶ In a programming context, the word often doesn’t refer to sending documents to a printer device. A program may print text onscreen or in a text file, for example.
- private
- yksityinen inaccessible to the outside; meant for internal use only; belonging to the implementation rather than the interface ¶ See Chapter 3.2 and cf. public.
- procedural programming
- proseduraalinen ohjelmointi a common programming paradigm in which a program’s domain is represented as subprograms that call further subprograms ¶ See Chapter 10.2 and cf. object-oriented programming, in which the domain is structured in terms of objects and subprograms (methods) are associated with those objects. Procedural programming is one of the main forms of imperative programming.
- procedure
- proseduuri 1) an effectful function; 2) (sometimes specifically:) an effectful function that does not return a value or returns only a contentless unit value
- program
- ohjelma 1) a combination of instructions meant for a computer to execute; 2) the dynamic process that arises as a computer follows such instructions ¶ Applications, operating systems, and drivers are different kinds of programs; see Chapter 1.2. Programs and their auxiliary resources are often referred to as software.
- program code
- ohjelmakoodi 1) a program text, source code; 2) a program encoded in machine language ¶ In O1, “program code” generally refers to source code written in Scala; machine language comes up briefly in Chapter 5.4.
- programming
- ohjelmointi the development of computer programs: their design and implementation ¶ See Chapter 1.2.
- programming language
- ohjelmointikieli an artificial language for writing or otherwise expressing programs ¶ Most programming languages are written as text, but other media are also possible; for instance, there are visual programming languages in which the program, or parts of it, are expressed as diagrams or other graphics.
- programming paradigm
- ohjelmointiparadigma a way of programming; a general approach to thinking about programs and solving programming problems ¶ See Chapters 2.1 and 10.2. O1 touches on object-oriented programming, imperative programming, functional programming, and (very briefly) procedural programming.
- programming style
- ohjelmointityyli a way of writing programs that follows certain practices, principles, or policies; (often in particular:) a way of formatting source code ¶ A good programming style helps people read and modify programs; see O1’s style guide. Programming styles can be set down as style conventions.
- project
- projekti a body of files and settings that forms a logical whole and helps programmers manage multiple programs ¶ See Chapter 1.2. Eclipse, for instance, supports this construct and expects the programmer to group their programs into projects; some other IDEs use a different term for what is essentially the same concept. The concept of project is a feature of a programming environment, whereas a package is a programming-language construct.
- pseudocode
- pseudokoodi a textual description of an algorithm or a program that is meant for human readers and more or less resembles programming language ¶ See, e.g., Chapter 2.5. Pseudocode is often less detailed than concrete program code. It is generally not suitable for execution by a computer. Pseudocode is used when planning programs and documenting them, among other things.
- pseudorandom number
- näennäissatunnaisluku, pseudosatunnaisluku a number produced by an algorithm that mimics true randomness ¶ See Chapter 3.6 and random seed.
- public
- julkinen externally visible; accessible to the entire program; belonging to an interface ¶ See Chapter 3.2 and cf. private. In Scala, members of classes and objects are public unless their visibility is adjusted with access modifiers.
- pure function
- puhdas funktio a function that is effect-free and, moreover, independent of program state and thus returns the same value every time it is called on the same parameter values ¶ It’s possible for a function to be effect-free but not pure: for example, consider an effect-free method whose return value depends on the state of a mutable object. If a function is pure, an expression that calls it is referentially transparent.
- random seed
- satunnaislukujen siemen a parameter that is passed to an algorithm that generates pseudorandom numbers and that the algorithm uses to initialize itself ¶ Each run of a pseudorandom algorithm on the same seed produces the same sequence of “random” numbers. See Chapter 3.6.
- read
- lukea 1) to receive data into a program from an external source (as part of I/O); 2) to access a variable to obtain its value (when evaluating an expression that uses the variable) ¶ See Chapter 11.3; see also input.
- recursion
- rekursio 1) defining, describing, or implementing something in terms of itself; (especially:) defining a a function so that it calls itself; 2) the use of such self-reference as an implementation strategy for programs ¶ A recursive program reduces the problem at hand to a simple base case by repeatedly solving a part of it with a recursive call; see Chapter 12.1 and cf. iteration. See also structural recursion.
- recursive call
- rekursiivinen kutsu a function call where the calling function and the called function are the same ¶ See recursion and Chapter 12.1.
- refactoring
- refaktorointi to edit a program or program component without changing what functionality it provides ¶ See, e.g., Chapters 3.1, 7.5, and 9.1. The purpose of refactoring is to improve program quality. It may result in the program being easier to extend and modify, for example.
- reference
- viittaus a value that indicates where in the computer’s memory a particular piece of data is located ¶ See, e.g., Chapters 1.5, 2.3, and 5.4. In Scala programs, references point to objects that are stored in the computer’s memory.
- referential transparency
- referentin läpinäkyvyys a property that some expressions have: such an expression can be replaced by its value without changing the program’s meaning ¶ As far as program correctness is concerned, it’s irrelevant whether a referentially transparent expression is evaluated once, several times, or not at all, as long as the program obtains the expression’s value. In order to be referentially transparent, any functions that the expression invokes must be effect-free and otherwise pure. This property can make programs easier to read and modify and is particularly central to functional programming. See Chapter 10.2.
- REPL
- REPL a programming environment where the user types instructions in a programming language, those instructions get executed one by one as soon as they are entered, and the value of each expression entered by the user is immediately reported onscreen ¶ REPL is short for “read–eval–print loop”. Using a REPL is common in Scala programming (and various other languages as well); see Chapter 1.3. A REPL is sometimes referred to as an “interpreter” or “interactive interpreter”; the Scala REPL is also known as “Scala Interpreter”.
- reserved word
- varattu sana
a word that has a specific meaning in a programming language or that is for other reasons
prohibited as an identifier in the language ¶ Scala has about fifty reserved words,
including
val
,def
,import
,true
,this
,object
,class
,new
,private
,if
,match
,case
, andfor
; see the end of O1’s Scala Reference for the whole list. The names of common types, such asInt
andString
, aren’t reserved words as such, but to avoid confusion, it’s nevertheless better to avoid them as identifiers. - return
- palauttaa
1) to end the ongoing function call, produce a return value, and convey it to the function’s
caller; 2) a command (
return
) that, when executed, terminates a function call and returns a value ¶ In Scala, thereturn
command is infrequently used; see Chapter 8.3. In some other programming languages, the corresponding command is used in all functions that return a value. - return type
- palautusarvon tyyppi the static type of a function’s return value ¶ May be marked explicitly in Scala code with a type annotation or may (in most cases) be left implicit due to type inference.
- return value
- palautusarvo, paluuarvo
the value that, upon completion of a function call, is conveyed to the function’s caller and
that becomes the value of the function-calling expression ¶ A function may use its return value
to communicate the result of a computation, for instance, or to signal whether an operation was
successful. Some functions have no meaningful return value; in Scala programs, such functions
return the
Unit
value. A Scala function’s return value is the value of the expression that was evaluated last during the function call (assuming the call wasn’t terminated due to a runtime error before a return value could be produced). See alsoreturn
. - RGB
- RGB a representation for colors in which each color is specified as a combination of red, green, and blue light ¶ Each of the three components is a number that indicates how much of that color there is in the combination. See Chapter 5.4.
- role (of a variable)
- (muuttujan) rooli a typical way of using a variable in programs; a brief decription of the way a variable is used in a program ¶ See, e.g., Chapters 2.6 and 5.5. Roles include fixed value, temporary, gatherer, most-recent holder, container, most-wanted holder, and one-way flag. Roles aren’t a technical feature of a variable; a role’s purpose is to summarize, to a human, how a variable is used in a program.
- routine
- rutiini a subprogram; in O1 and Scala’s terminology, a function
- run
- ajaa, suorittaa 1) to make a computer act as specified in a program; 2) to act as specified by a program ¶ Examples: “Aurora ran the program and found out there was a bug.”, “The computer runs the program, processing each instruction in turn.” Synonym: to execute.
- runtime error
- ajonaikainen virhe an error that manifests itself only when the program is executed, typically because the computer fails to perform some operation ¶ See Chapters 1.8, 4.2, and 4.3 and cf. compile-time error and logical error. In many programming languages, dividing an integer by zero produces a runtime error, as does the computer running out of available memory. Unless successfully prevented or handled, a runtime error usually causes the program run to “crash” and terminate.
- runtime type
- ajonaikainen tyyppi see dynamic type
- runtime type
- dynaaminen tyyppi see dynamic type
- Scala
- Scala a programming language ¶ Scala is designed to be a language that supports multiple programming paradigms and combines them in a particular way. The language emphasizes the object-oriented paradigm and lets the programmer combine OOP with imperative and/or functional; Scala’s design particularly encourages the latter. Please see O1’s FAQ for the reasons behind Scala’s adoption in this course. Programs written in Scala are often executed on the JVM, but Scala code can also be compiled into JavaScript.
- Scala API
- Scala API
an extensive multi-purpose API associated with the Scala programming language ¶ Known in
full as the “Scala Standard Library API”. Consists of packages whose names begin with
scala
. The contents of these packages are described as Scaladocs; see Chapter 3.2. A part of the Scala API — the package known simply asscala
— is an inseparable part of the programming language; see Chapter 1.5. - Scala IDE
- Scala IDE an add-on (plugin) for the Eclipse IDE that supports Scala programming in Eclipse ¶ See Chapters 1.2, 1.3, and 5.4.
- Scaladoc
- Scaladoc 1) an auxiliary program that takes in source code written in Scala and annotated with documentation comments and that generates documentation from that input; 2) documentation generated by that tool ¶ See Chapters 3.2 and 3.5. Scaladoc documents usually focus on detailing each program component’s public interface. The Scala API has been documented as Scaladocs. Many programming languages come with a similar tool, such as Javadoc (for Java) and Pydoc (for Python).
- scope
- käyttöalue, skooppi the part of the program within which an identifier (name) can be legally used to access a program component ¶ For instance, in Scala, the scope of a class’s public method is the entire program, whereas a private method’s scope is limited to the class itself (plus its possible companion object) and a parameter variable’s scope to the function body. The block structure of a program impacts on scope; see Chapter 5.6. See also Chapter 6.4.
- script
- skripti, komentosarja a program written in a high-level language that meets one or more of the following criteria: 1) its code is relatively short; 2) its code consists of a sequence of consecutive commands; 3) it is interpreted rather than compiled; 4) its primary purpose is to produce an output of some kind from given input data; 5) it is an external auxiliary to some existing program or system; 6) it is used for automating a batch of commands that might be otherwise entered manually; 7) it is written in a scripting language ¶ This term has many entangled connotations that have evolved over time. As things stand, it’s ambiguous enough that it might be best to avoid using it except where the intended meaning is clear from the context.
- scripting language
- skriptikieli a high-level language that is suitable for writing scripts ¶ PHP, Python, and Lua are examples of programming languages that are often called scripting languages. Scala, too, can be used as a scripting language.
- sealed
- suljettu
a class that cannot be directly extended except by code that is in the same
source-code file ¶ In Scala, the
sealed
keyword seals a class. See Chapters 7.2 and 7.3. Cf.final
. - seed
- siemen see random seed
- semantics
- semantics
the meanings of expressions in a programming language ¶ Commonly contrasted with syntax. For instance,
the Scala commands
x = x + 1
andx += 1
differ syntactically but their semantics is the same: each increments the variablex
by one. - short-circuited operator
- ehdollinen operaattori a logical operator whose second operand is not evaluated if the first operand is enough to determine the value of the logical expression ¶ See Chapter 5.1. In other words, a short-circuited operator is evaluated non-strictly.
- side effect
- sivuvaikutus an operation that modifies state; an effect on program state ¶ This term is common among functional programmers who seek to avoid effects.
- signature
- puumerkki, signatuuri 1) the part of a function’s definition that defines how the function may be called; 2) a similar definition for a program component other than a function ¶ A Scala function’s signature consists of its name, its parameter variables, and its return type. (Anonymous functions are an exception to this, since they have no name.) A function’s body isn’t part of its signature. Some other programming languages define signatures somewhat differently than Scala, but the basic idea is the same. In addition to knowing a function’s signature, any user of a function should of course know the function’s purpose and semantics. See also overloading.
- singleton object
- yksittäisolio 1) an object that is defined as an individual case rather than as an instance of a class; 2) the definition of such an object in program code ¶ See Chapters 2.1, 2.2, and 5.3 and cf. instance. In Scala, a singleton object may be either a class’s companion or a standalone object.
- software
- ohjelmisto a program or combination of programs, which may include auxiliary files in addition to the actual runnable program(s) ¶ Contrasts with hardware.
- software library
- ohjelmakirjasto see library
Some
- Some
a class that represents
Option
objects that do contain a single data item ¶ See Chapter 4.3 and cf.None
.Some
is a subclass ofOption
; see Chapter 7.3. - sorting
- järjestäminen placing the elements of a collection in order by some criterion ¶ For instance, one may sort a collection of numbers in ascending or descending numerical order; see Chapter 9.2. The sorted elements may be placed in an entirely new collection or, if the unsorted collection is mutable, sorting may also happen “in place”.
- source code
- lähdekoodi textual, uncompiled program code that is meant for a human to work with ¶ See Chapter 5.4. In O1, the we work with source code that’s written in Scala.
- stack
- pino 1) a collection that operates on the LIFO principle; 2) the call stack ¶ A stack can be either mutable or immutable.
- stack frame
- pinokehys see frame
- stack trace
- stack trace a report, typically produced when a runtime error occurs, that details which calls were active when the report was generated ¶ Stack traces help programmers debug their programs. See Chapter 4.2.
- standalone object
- itsenäinen yksittäisolio a singleton object that is not a companion object
- state
- tila
a body of data stored at a given moment of time ¶ In programming, the term refers especially to
data stored in the computer’s memory. A program execution, as a whole, has a state; effects such
as assigning to
var
-variables mutate that state, causing the program to be in a different state at different times while it executes. Functions can be classified as being either effectful or effect-free on the basis of whether they impact on state. In object-oriented programming, each object has a state (see, e.g., Chapter 2.1), which may be either immutable or mutable; objects’ states are part of the program’s overall state. Some programming paradigms differ from each other in how they represent state and changes thereof. - statement
- lause
a command that orders the computer to perform a particular operation ¶ For instance,
the print command
println(1 + 1)
and the assignmenta = 10
may be referred to as statements. A statement doesn’t necessarily have a meaninful value; a Scala statement, for instance, may evaluate to justUnit
and nevertheless be useful. A statement may contain expressions that are evaluated when the statement is executed: the statementprintln(1 + 1)
contains the expression1 + 1
, for instance. Even an individual expression may form a statement. Statements put in a sequence are executed one after the other, in order. In Scala, function and method definitions andimport
commands are officially considered statements, too; on the other hand, they aren’t expressions since they don’t evaluate to a value. (Cf. a print command is not only a statement but also an expression, since it evaluates to a value, even if that value is justUnit
.) The concept of statement is associated especially with imperative programming; in pure functional programming, the concept of expression usually suffices. In O1’s materials, this term is seldom used. - static
- staattinen 1) involving, or present in, program code; determinable from program code without running it; defined fully by program code; non-dynamic, unchanging; 2) associated with a class rather than its individual instances ¶ There is a duality to computer programs: they can be thought of as both static and dynamic; see, e.g., Chapters 1.2 and 2.1. Things that happen at runtime, such as the inputs the program receives from its user, can’t impact on the program’s static aspect. See also static type.
- static type
- staattinen tyyppi the data type of a piece of program code, which can be determined and checked statically, without running the program ¶ In statically typed languages such as Scala, expressions and variables have static types. For instance, the static type of a Scala variable constrains the values that can be assigned to a variable: an attempted assignment produces a compile-time error message if the source expression is not type compatible with the variable. See Chapters 7.2 and 7.3 and cf. dynamic type.
- statically typed
- staattisesti tyypitetty
(of a programming language:) having a type system that attaches a data type to parts of source code
(i.e., the parts of the program’s static form; expressions and variables in
particular), which type can be checked statically ¶ Scala is statically typed: variables
and expressions have static types (in addition to their values having
dynamic types). Scala is also typesafe, so an attempt to assign a
String
value to anInt
variable produces a compile-time error message. Other statically typed languages include Java, C#, and Haskell, among many others. Cf. dynamically typed. - stepper
- askeltaja a variable used for tracking the latest value while advancing along a sequence of known values ¶ This is one of the roles of variables. See Chapters 3.1 and 5.5. For instance, a stepper may keep track of a steadily incrementing ordinal number: 0, 1, 2, etc.
- stream
- virta
an immutable, lazy collection, implemented as a linked chain of elements and suitable for
traversing in element order ¶ Streams are essentially lists that are evaluated lazily.
In Scala, they are represented by class
Stream
. Since streams aren’t evaluated strictly, they may be infinite and a higher-order method or loop may traverse through an indefinite number of stream elements. See Chapters 7.1 and 8.3. The word “stream” also has other more or less related meanings within computing. - strict
- tiukka such that expressions are evaluated at least once ¶ See Chapter 7.1. This adjective describes a policy for evaluating expressions. A strict parameter gets its value from a parameter expression that is evaluated at least once irrespective of whether the value is actually used by the program. A strict collection is a collection whose every element is formed in memory irrespective of whether all of them will be actually used. Most programming languages rely on strict evaluation. Scala is primarily strict, too: function parameters are strictly evaluated by-value parameters unless otherwise specified, and most common collections (vectors, lists, maps, etc.) are strict. Antonym: non-strict.
- string
- merkkijono
an sequence of (written) characters ¶ For instance, the string
llama
consists of five characters in a specific order. Strings are one of the most common types of data that appear in computer programs. In Scala, the primary representation of strings is the type known simply asString
(Chapter 1.3), but there are alternative representations, too (see, e.g., Chapter 10.2). Many programming languages’ standard libraries provide subprograms for manipulating strings in various ways (see, e.g., Chapter 5.2 and O1’s Scala Reference). A string is a sort of collection with individual characters as elements (Chapter 5.6). - string interpolation
- merkkijonoupotus a programming technique in which expressions are embedded into string literals in order to create a string that contains descriptions of the embedded expressions’ values ¶ See Chapter 5.2.
- strong AI
- vahva tekoäly artificial intelligence that combines information broadly and is not tied to a specific application are like weak AI is. ¶ This term means almost the same as general AI. It often carries a further connotation of human-like consciousness, and perhaps feelings. Strong AI is a fantastically ambitious goal; the existing practical applications that are currently referred to AI are weak AI instead.
- structural recursion
- rakenteellinen rekursio a form of recursion in which the definition of a data structure (such as a class) refers to itself ¶ See Chapters 2.6 and 12.1. For instance, the definition of a person class might include the person’s parents, which are of that same person type. Often, a good way to process structurally recursive data is to use recursive calls that apply to ever smaller parts of the original data.
- style conventions
- tyylikäytäntö a set of recommendations on programming style ¶ Style conventions seek to promote better readability and otherwise improve code quality. Different programming languages are associated with their own style conventions, and even a single language will often have several alternative conventions; a commercial company may specify its particular recommendations or requirements, for instance. O1’s style guide describes one set of conventions for Scala.
- subclass
- aliluokka a class that inherits another class and represents a subordinate concept of what that superclass represents ¶ A subclass inherits the characteristics of its superclass; see Chapter 7.3. A subclass’s instances have the type defined by the superclass in addition to the type defined by the subclass. In many programming languages, Scala included, a subclass is defined by writing a class definition that specifies the class’s immediate superclass; in Scala, a class can only have a single immediate superclass. Cf. mixing in a trait and see multiple inheritance.
- subprogram
- aliohjelma see function
- subroutine
- rutiini a subprogram; in O1 and Scala’s terminology, a function
- superclass
- yliluokka a class that one or more classes inherit from and that represents a superordinate concept of what those subclasses represent ¶ The characteristics of the superclass are inherited by its subclasses; see Chapter 7.3. A class may have multiple immediate subclasses but (in Scala) only a single immediate superclass. Cf. trait.
- Swing
- Swing a library for programming graphical user interfaces ¶ There’s more than one Swing: a library of this name was originally developed for the Java programming language, but Scala has an identically named library (which is built on the Java one). See Chapter 12.3. See also O1Library.
- syntactic sugar
- syntaktinen sokeri
a syntactical feature of a programming language that does not make the language
more expressive, and is in that sense unnecessary, but that is intended to make program code
easier to read or write ¶ See Chapter 4.1. Examples of syntactic sugar in Scala include:
the option of defining instance variables and constructor parameters together (Chapter 2.4);
operators such as
+=
, which combine arithmetic with assignment (Chapter 4.1); various kinds of function literals (Chapter 6.2); andfor
loops (Chapters 5.5 and 6.3). - syntax
- syntaksi rules that govern how things are expressed in a programming language ¶ Syntax defines what pieces program code consists of and how the programmer may combine those pieces. Syntax is commonly constrasted with the semantics of what those expressions mean.
- syntax error
- syntaksivirhe an error that arises from a violation of the programming language’s syntax in source code ¶ See Chapters 1.8 and 3.5. Syntax errors are often detected at compile time.
- temporary
- tilapäissäilö a variable that plays an interim role within the implementation of an algorithm ¶ This is one of the roles of variables. See Chapter 2.6.
- testing
- testaus the assessment of a program in order to detect errors and other problems; especially: assessing a program or program component by running it so as to detect runtime errors and logical errors ¶ A simple form of testing is to run a program, function, or class on selected parameters or other inputs. A more sophisticated strategy is to write so-called unit tests, which can be run to check a program’s components systematically, repeatedly, and at least semi-automically; unit-testing tools are discussed in O1’s follow-on courses.
- text area
- tekstialue a GUI component where the user can enter and edit textual input; especially: a GUI component with that purpose that supports multi-line input ¶ Cf. text field.
- text console
- tekstikonsoli
an environment where a program’s output appears in text form and where some programs read
keyboard input ¶ Many programming environments include a text console; Eclipse, for
one, does. The output of a Scala program’s
println
commands typically shows up in the console. Some programs have a user interface that operates fully in a text console and isn’t graphical; see, e.g., Chapter 2.7. - text field
- tekstikenttä a GUI component where the user can enter and edit textual input; especially: a single-line GUI component with that purpose ¶ Cf. text area.
- text file
- tekstitiedosto a file whose data is meant to be interpreted (purely) as a sequence of written characters ¶ See Chapters 5.2, 5.4 and 11.3.
this
- this (in Scala and other languages:) a special parameter variable that all methods implicitly have and that refers to the object whose method has been called ¶ See Chapter 2.2.
toString
- toString
(in Scala:) a method whose purpose is to return a description of an object as a
String
¶ See Chapter 2.5. All Scala objects have some sort oftoString
method, which is used by other functions; for instance, the commandprintln(myObject)
prints out a string representation of the object, which it obtains by calling the object’stoString
method (as if we had writtenprintln(myObject.toString)
).toString
methods are helpful in the REPL and when debugging and have other uses as well. - trait
- piirreluokka, piirre
a type-defining construct similar to a class that 1) may have (also) abstract methods
and variables; 2) can be “mixed in” to a class that
defines a subtype of the trait (or to a singleton object); 3) cannot be instantiated directly
but only through its subtypes; and 4) does not take any constructor parameters ¶ See Chapters 7.2
and 7.3 and cf. abstract class and superclass. Trait definitions resemble class definitions but
begin (in Scala) with the
trait
keyword rather thanclass
. Apart from the differences listed above and in Chapter 7.3, what this ebook says about classes usually applies to traits, too. - truth value
- totuusarvo
a value that concerns the truthfulness of a proposition; especially: a value that indicates
whether a proposition is true or false ¶ In programming, it’s common to use Boolean logic, in
which any proposition is unambiguously either true or untrue; see Chapter 3.3 and
Boolean
. try
- try (in Scala:) a reserved word used in exception handling to start a block whose execution may fail due to a runtime error
- tuple
- monikko a combination of a fixed number of values in a specific order ¶ See Chapter 8.4. A tuple with two members is known as a pair. In O1’s terminology, tuples aren’t collections even though there are some similarities between the concepts. Each member of a tuple has its own static type, unlike the elements of a collection, which share a type. You cannot iterate over the contents of a tuple as simply as you can iterate over a collection’s elements. In Scala, tuples are immutable.
- type
- tyyppi (in a programming context usually:) data type
- type annotation
- tyyppimäärittely/-annotaatio an indication of a static type written explicitly into source code ¶ Type annotations may make a program text easier to read; sometimes they also indirectly boost a program’s efficiency. On the other hand, some type annotations are unnecessary and can make it inconvenient to write and read code. In many statically typed programming languages (e.g., Java), the types of each variable and return value must be expressly written in the source code. In contrast, in dynamically typed languages (e.g., Python), type annotations aren’t (normally) written at all. In Scala, you may always add an explicit type annotation but many annotations may be omitted because of type inference; see Chapter 1.8. There are contexts where Scala requires an explicit type; these commonly involve parameter variables; empty collections (see Chapter 1.5); overloaded methods; or recursive functions. In some cases, type annotations can help the Scala compiler produce clearer error messages. It’s often a good idea to annotate the public members of Scala classes.
- type compatible
- tyyppiyhteensopiva
(of data types:) compatible in such a way that a value of one type can be used where a value
of the other type is expected ¶ Example: if the Scala class
Student
is a subclass of classHuman
, theStudent
type that it defines is type compatible with typeHuman
and it’s valid to assign a reference that points to aStudent
instance in a variable of typeHuman
. All types in Scala are type compatible with theAny
type. See also Liskov substitution principle. - type inference
- tyyppipäättely the automatic and static detection of the types of expressions and variables in a program ¶ Type inference is an integral part of the Scala language. See Chapter 1.8. Chapters 3.5 and 7.2 also touch on the topic.
- type parameter
- tyyppiparametri a piece of type information that is needed by some classes and some methods and that further specifies a data type ¶ For instance, many Scala collections take a type parameter that specifies the type of a collection’s elements; see, e.g., Chapters 1.5, 4.3, and 7.4. In Scala, type parameters, like many static types, can be automatically inferred.
- type safety
- tyyppiturvallisuus the extent to which a programming language enforces the constraints of each data type on what one may do with values of that type ¶ See Chapter 1.8. A type-safe language only lets the programmer use a value for operations that are expressly allowed for the value’s type. Scala is a particularly type-safe language, and Scala tools alert the programmer to most type errors with compile-time error messages. See also static typing.
- type system
- tyyppijärjestelmä a set of rules that governs the use of data types in a particular programming language ¶ See static and dynamic typing and type safety.
- Unicode
- Unicode a character set and an associated set of standards ¶ See Chapters 5.4 and 5.6. The Unicode standard defines, among other things, a unique number for each different character in a vast character set. Unicode is widely used in many contexts, including Scala programs.
- uniform access principle
- yhtenäisen osoituksen periaate a design principle for programming-language syntax that states that a programmer who uses a particular program component should be able to use the same notation for accessing all of that component’s functionality irrespective of how that functionality has been implemented ¶ In particular: the user of an object should be able use the same notation for calling a parameterless method that they use for accessing the value of a member variable. See Chapters 2.6 and 7.3.
Unit
- Unit
1) the name of the unit type in some languages, Scala included; 2) a Scala literal
whose value is the unit type’s one and only value ¶ See Chapters 1.6 and 4.3. A common
use for
Unit
is to signal the fact that a function has no meaningful return value. Scala’sUnit
literal can also be written as a pair of empty brackets:()
. - unit type
- yksikkötyyppi
a data type that permits only a single value and that therefore cannot represent information ¶
See Chapter 1.6. There is exactly one value of the unit type. In some languages, Scala included,
that value is named
Unit
. - user interface
- käyttöliittymä the part of a program or device that users interact with ¶ An application’s user interface may be textual and run in a text console, for instance, or it may be graphical. See also view and cf. model.
val
(variable)- val-muuttuja
(in Scala:) a variable whose value cannot be replaced by another ¶ See Chapter 1.4 and cf.
var
variable. In Scala, mostval
variables are defined using theval
keyword, but there are some exceptions: parameter variables and the most-recent holders defined as part of afor
loop areval
s, too. One use forval
s is to define constants, but not allval
s are constants. - value
- arvo
1) a single “granule of data” that cannot be simplified further; the result of evaluating
an expression completely; 2) the second member of a key–value pair in a map ¶ For instance, the
value of the arithmetic expression
1 + 1
is the integer two (Chapter 1.3), the value of the function callmin(10, 5)
is five (Chapter 1.6), and the value of the expressionBuffer(10, 2, 3)
is a reference to a buffer (Chapter 1.5). In O1, we use the term “value” in a subtly different sense than some other sources that refer to any (Scala) object as a value. var
(variable)- var-muuttuja
(in Scala:) a variable that is defined using the
var
keyword and whose value may be modified by assigning a new value that replaces the earlier one ¶ See Chapter 1.4 and cf.val
variable. - variable
- muuttuja a named storage for a single value in the computer’s memory ¶ See Chapters 1.4 and 2.6.
- vector
- vektori an immutable collection that keeps its elements in order by their numerical index ¶ See Chapter 4.2. Cf., e.g., array and buffer.
- view
- näkymä 1) the part of an application that is visible to the user; user interface; 2) (especially:) the part of a user interface that presents a domain model to the user ¶ The second, narrower meaning distinguishes the view not only from the model but also from those parts of the user interface that react to the user’s actions and update the model; see Model–View–Controller on Wikipedia. O1Library contains a a class of the same name.
View
(class)- View
a class for creating graphical user interfaces, defined in O1Library ¶ A
View
object provides a view to same object that serves a domain model. Various event handlers can be defined on aView
. See Chapters 2.7, 3.1, and 3.6 and the class’s documentation; there’s an example on O1’s Scala Reference page, too. - virtual
- virtuaalinen artificial, simulated, mimicked; real (only) in appearance; akin to something despite not actually or officially being that thing ¶ See also virtual machine.
- virtual machine
- virtuaalikone a virtual computer; a program that behaves like a computer and that can execute (a specific sort of) other program ¶ See Chapters 5.4 and 11.2. A virtual machine takes programs in a particular language as input; that language is effectively the virtual machine’s machine language. A virtual machine contains an interpreter (or is an interpreter, depending how one defines that term) that it uses to translate the given programs into actual machine code.
- visibility
- näkyvyys 1) scope; 2) (more specifically:) the part of an identifier’s scope where it is not “hidden” by another identifier of the same name (that is defined in an inner block)
- visibility modifier
- another term for access modifier
- warning
- varoitus a notification from a programming environment or tool that alerts the programmer to a suspected problem in their program that may or may not be an actual error ¶ See Chapter 3.5.
- weak AI
- heikko tekoäly artificial intelligence applied to a narrow speciality ¶ This term means almost the same as narrow AI. It’s often used when contrasting specialized applications with strong AI that has a human-like consciousness.
- WETWET
- WETWET a violation of the DRY principle ¶ Short for “write everything twice write everything twice”.
while
loop- while-silmukka
a loop that has been formed using the
while
keyword at the top and that repeats an operation zero or more times ¶ See Chapter 8.3 and cf.do
loop. - whitespace
- whitespace, tyhje “invisible” characters that create horizontal or vertical space in a text ¶ Examples include space, tabulator, and newline characters.
- write
- kirjoittaa 1) to output text or binary data from a program to an external destination (as part of I/O); 2) to assign to a variable ¶ See Chapter 11.3; see also print.
Feedback
Credits
Thousands of students have given feedback that has contributed to this ebook’s design. Thank you!
Weeks 1 to 13 of the ebook, including the assignments and weekly bulletins, have been written in Finnish and translated into English by Juha Sorva.
Weeks 14 to 20 are by Otto Seppälä. That part of the ebook isn’t available during the fall term, but we’ll publish it when it’s time.
The appendices (glossary, Scala reference, FAQ, etc.) are by Juha Sorva unless otherwise specified on the page.
The automatic assessment of the assignments has been developed by: (in alphabetical order) Riku Autio, Nikolas Drosdek, Joonatan Honkamaa, Jaakko Kantojärvi, Niklas Kröger, Teemu Lehtinen, Strasdosky Otewa, Timi Seppälä, Teemu Sirkiä, and Aleksi Vartiainen.
The illustrations at the top of each chapter, and the similar drawings elsewhere in the ebook, are the work of Christina Lassheikki.
The animations that detail the execution Scala programs have been designed by Juha Sorva and Teemu Sirkiä. Teemu Sirkiä and Riku Autio have done the technical implementation, relying on Teemu’s Jsvee and Kelmu toolkits.
The other diagrams and interactive presentations in the ebook are by Juha Sorva.
The O1Library software has been developed by Aleksi Lukkarinen and Juha Sorva. Several of its key components are built upon Aleksi’s SMCL library.
The pedagogy behind O1Library’s tools for simple graphical programming (such as Pic
)
is inspired by the textbooks How to Design Programs by Flatt, Felleisen, Findler, and
Krishnamurthi and Picturing Programs by Stephen Bloch.
The course platform A+ has been created by Aalto’s LeTech research group and is largely developed by students. The current lead developer is Jaakko Kantojärvi; many other students of computer science and information networks are also active on the project.
For O1’s current teaching staff, please see Chapter 1.1.
Additional credits appear at the ends of some chapters.