Programming Languages Flashcards
Adding a feature to a programming language to make it easier to do something that was already doable is called adding ANSWER.
syntactic sugar
Matz, the creator of Ruby thinks that it is less important to optimize the execution (efficiency) of a programming language and more important to optimize the efficiency of ANSWER
the programmers
A programming language is called ANSWER if it is executed by an interpreter rather than by first being compiled with a compiler.
interpreted
If the types of a programming language are bound at execution time rather than compile time, then the types are called ANSWER.
dynamically typed
In describing the properties of an object oriented language, encapsulation means ANSWER.
Data and behaviour are packaged together
In discussing object oriented languages objects are organized into a class tree to support the property of ANSWER.
inheritance
In discussing object oriented languages being able to handle objects of related type is called ANSWER.
Polymorphism
(Polymorphism has a different usage in the object oriented programming community than in the functional programming community)
The application that caused a significant increase in the popularity of Ruby was a web framework called ANSWER.
Rails
The concurrency approach used in Ruby is ANSWER.
threads
The command name for the ruby interpreter is ANSWER.
irb
In ruby true.class returns ANSWER
TrueClass
Ruby supports two common ways that boolean expressions are handled in programming languages. In one approach both subexpressions of a boolean operator are evaluated before the boolean operator is evaluated. In the other approach called ANSWER the first subexpression in a boolean expression is evaluated and if that is enough to know the result of the boolean expression, then the second subexpression is not evaluated.
short-circuit evaluation
In Ruby, normally when you try to add a String to a Fixnum, you get an error message saying that a String cannot be coerced to a Fixnum. This is because Ruby is ANSWER typed.
strongly
One way of checking types is to see what constructor was used to create an object that is a parameter. Another way of checking types is to wait until a method is sent to an object and see if it supports the methods. This second way is called ANSWER.
duck typing
A major claim in object oriented design philosophy is that you should code to ANSWER rather than code to implementation.
interface
The & notation in the line of Ruby def gerorge(&sam) is used to indicate that sam is ANSWER.
a code block
The : notation in the Ruby expressions :hi is used to indicate that hi is ANSWER.
a symbol
With respect to the value returned by the Ruby expression:
‘hi’ .object_id == ‘hi’ .object_id
You can say it ANSWER.
could be either true or false
With respect to the value returned by the ruby expression:
:hi.object_id== :hi.object_id
You can say it ANSWER.
will always be true
To execute a code block in Ruby that is passed to a method but does not appear on its parameter list, you use the keyword ANSWER.
yield
To execute a codeblock in Ruby that is passed to a method on its parameter list, you send that parameter the method ANSWER.
call
A code block is some lines of code surrounded by either curly braces or ANSWER.
do end
In Ruby the expression Fixnum.class returns ANSWER.
Class
The root of the inheritance hierarchy in Ruby is the class ANSWER.
Object (According to textbook in 2010)
BasicObject (Updated answer for Ruby 2.3)
In Ruby, the name of the method in the class Me that is automatically invoked when a new object of type Me is created with Me.new is ANSWER.
initialize
In Ruby, the @ is used to indicated that the variable @me is ANSWER.
an instance variable
In Ruby, the @@ is used to indicate that the variable @@me is ANSWER.
a class variable
In Ruby, by convention the ? in the method me? is used to indicate that me is ANSWER.
boolean
In Ruby, the mixin is used to solve the object-oriented programming problem of ANSWER.
multiple inheritance
The feature of programs being able to ‘write programs’ (creating application specific language features) is called ANSWER.
metaprogramming
In Ruby, if you declare a class with a class name that is already in use and put in it the definition of a new method, you have changed the functionality of the existing class (even if it is a predefined class like Fixnum). The property of Ruby that allows this is ANSWER.
open classes
When you send a message to a Ruby object, Ruby first looks at the methods that object supports, and then starts working the inheritance chain. If it still cant find the appropriate method, the message and its parameters get passed as a message to the object looking for a method called ANSWER.
method_missing
In the Ruby community, the acronym DSL is an abbreviation for ANSWER.
domain specific language
In Ruby, if a line starts with a method name, that method is being sent to the object named ANSWER.
self
When you define a method in a class, normally it is meant to be invoked on an object of that class (an instance method). Sometimes it is meant to be invoked on the class name itself (a class method), like Date.parse( ‘3rd Feb 2001’). In Ruby, to define a class method we put ANSWER at the beginning of the method name in its definition.
self
Scala was designed to connect two programming paradigms, which were ANSWER.
object-oriented and functional
Another design goal for Scala was to have its programs easily interoperate with those written in ANSWER.
Java
Scala is ANSWER typed.
statically
Scala uses few type declarations because its compiler does ANSWER.
type inferencing
The main concurrency method used in Scala is ANSWER.
actors
In Scala, to indicate that a variable is immutable, you introduce it with the ANSWER keyword.
val
In Scala, to indicate that a variable is mutable, you introduce it with the ANSWER keyword.
var
In Scala, if I want to redefine a method that is defined in my parent class, I indicate this by using the keyword ANSWER.
override
The Scala feature closest to a Ruby mixin is the ANSWER.
trait
In Scala, the type that every type is a subtype of is called ANSWER.
Any
In Scala, the type that is a subtype of every type is called ANSWER.
Nothing
Many programming languages represent internal constants for types like strings, floats, and integers. Scala has the unusual distinction of having an internal constant representation for the type ANSWER, which is normally viewed as a format external to a program.
XML
The ! in Scala is used to ANSWER.
Send a message to an actor
In the chapter on Scala, we get the following interesting quote: ANSWER is the most important thing you can do to improve code design for concurrency.
Immutability
Instead of the + symbol, Haskell uses the symbol ANSWER for a string concatenation operator
.
++
The type of a string constant in Haskell by default is written ANSWER.
[Char]
In Haskell, you use the keyword ANSWER to collect related code into a similar scope.
module
In Haskell, if I define a function double x = x + x its type signature would be ANSWER.
(Num a ) => a -> a
In Haskell, instead of writing something like if x ==0 then 1 else fact (x-1)*x, you can write a series of lines starting with factorial 0 = 1. This second style is called ANSWER.
pattern matching
In Haskell, instead of writing something like if x==0 then 1 else fact (x-1) x, you can write a series of lines starting with | x > 1 = x factorial (x-a). This second style is called ANSWER.
using guards
In Haskell, instead of writing something like second x = head(tail(x)), you can write this without introducing the parameter x by using function composition. Doing that, you would define second by ANSWER.
second = head . tail
In Haskell, if I write (h:t) = [3 , 5 ,7], ANSWER is the value of h.
3
In Haskell, if I write (h:t) = [3, 5, 7], ANSWER is the value of t.
[5,7]
In Haskell, ANSWER is the output of zip [17…20] [10 , 8 ….4].
[(17,10),(18,8),(19,6), (20,4)]
In Haskell, ANSWER is the output of zip [20….17] [10,8…4]
[]
Default increment is 1 and zip only goes as far as shortest argument list
In Haskell, the anonymous function ANSWER causes the expression ‘map ANSWER [1,2,3]’ to produce [-4, -5, -6].
(\x-> - (x+3))
In Haskell, if we want to define a local named function inside a function definition, we use the keyword ANSWER.
where
In Haskell, the type signature of the function sum x y = x + y is ANSWER.
(Num a ) => a -> a -> a
In Haskell, given the definition sum x y = x + y, ANSWER is the value of that is produced by the expression (sum 3).
(\x -> 3 + x)
The way Haskell handles functions with more than one parameter is called ANSWER.
currying
In most languages, a function definition like f a b = a : (f (a + b) b) would result in an infinite recursion. However, in Haskell we can partially evaluate functions like this because Haskell is based on ANSWER.
lazy evaluation
Although Haskell is a statically typed language, we usually don’t need to write type declarations because Haskell uses ANSWER to handle the matter.
type inference
In Haskell, we can declare the type of a parameter to a function to be something specific like Num. However, we can also declare the type of a parameter to be something that could include many types like ListLike that supports the functions head and tail. We do this with a definition of ListLike that begins with the keyword ANSWER.
class
One of the three most significant parts of a monad is called ANSWER, which wraps up a function and puts it in the container.
return
One of the three most significant parts of a Haskell monad is called ANSWER, which unwraps up a function.
> > =
a bind function
In Haskell’s do notation for working with monads, assignment uses the ANSWER operator.
(left arrow)
Since Haskell doesn’t have traditional error handling mechanisms, by convention, people use the ANSWER monad to distinguish a valid return from an error return.
Maybe
This is similar to NaN’s usage in IEEE standard floating point arithmetic
Haskell, defining lists using a notation like [x*2 | x (left arrow) [3,4,5]] is called using ANSWER.
list comprehesions
In Haskell, [x*2 | x (left arrow) [3,4,5]] evaluates to ANSWER.
[6, 8, 10]
In Prolog, the most natural way to express the fact that a lion is a cat is ANSWER.
cat(lion)
In Prolog, the most natural way to express the query “what animals are cats?” is ANSWER.
animal(What), cat(What)
In Prolog, the most natural way to express the rule that “I am an ancestor of you if I am a parent of you” is ANSWER.
ancestor(I, You) :- parent(I, You)
In Prolog, the most natural way to express the rule that “I am an ancestor of you if I am a parent of an ancestor of you” is ANSWER.
ancestor(I, You) :- parent(I, Ancestor), ancestor(Ancestor, You)
(Both lines are one answer)
In Prolog, the expression hi(X, 4) = hi(3, Y) causes X to have the value ANSWER.
3
In Prolog, the expression hi(X, 4) = hi(3, Y) causes Y to have the value ANSWER.
4
In Prolog, the expression hi(X, 4) = hi(3, X) causes X to have the value ANSWER
X will not be bound
In Prolog, the expression [1, 2, 3] = [X | Y] causes X to have the value ANSWER.
1
In Prolog, the expression [1, 2, 3] = [X | Y] causes Y to have the value ANSWER.
[2, 3]
In Prolog, the expression X = [[1,2] | [3,4]] causes X to have the value ANSWER.
[[1, 2], 3, 4]
In Prolog, the expression X = 1 + 2 causes X to have the value ANSWER.
1+2
In Prolog, the expression 2 = 1 + X causes X to have the value ANSWER.
X remains unbound
In Prolog, the expression that would cause an unbound variable X to take on the sum of the values of a bound variable Y and a bound variable Z is ANSWER.
X is Y + Z
In Erlang, the main approach to concurrency is ANSWER.
actors
In the Erlang community, ANSWER code refers to replacing pieces of your application without stopping your application.
hot-swapping
An unusual built-in constant construct in Erlang lets us write «4:3,1:3» to represent the value ANSWER.
!
octal 41
decimal 33
hexidecimal 21
Many syntax features of Erlang, such as ending statements with a period, reflect the influence of the programming language ANSWER.
Prolog
In Erlang, you can link two processes together. Then when one dies, it sends ANSWER to its twin.
an exit signal
The main programming paradigm in Erlang is ANSWER programming.
functional
In Ruby, you would group methods into a class. In Erlang, you group functions into ANSWER.
a module
The idea that when a process has an error, it is up to a monitoring process to determine what to do about the problem is referred to by the motto ANSWER in Erlang.
Let it crash
Unlike most Lisp systems, Clojure doesn’t use its own custom virtual machine. It was originally designed to compile to code that would run on the ANSWER.
JVM
Java Virtual Machine
The main programming paradigm for Clojure is ANSWER programming.
functional
The loop and recur constructs are in Clojure to guide ANSWER.
tail recursion optimization
tail recursion elimination
In Clojure, the value of (repeat 1) is ANSWER.
an infinite sequence of 1s
a lazy infinite sequence of 1s
In Clojure, (take 3 (iterate (fn [x] (* 2 x)) 2)) produces ANSWER.
(4 8 16)
The main Clojure approach to concurrency is called ANSWER.
Software Transactional Memory
STM
In Clojure, ANSWER is a concurrency construct that allows an asynchronous return before computation is complete.
a future
In Clojure, you cannot change a reference outside of ANSWER,
a transaction
Three concepts related to concurrency were discussed with regards to the language Io. ANSWER was presented as a way to manage two execution streams that pass control back and forth between themselves.
coroutines
Three concepts related to concurrency were discussed with regards to the language Io. ANSWER was presented as a general mechanism for sending a message to an object that would cause that object to respond to the message as a separate process running asynchronously.
Actors
Three concepts related to concurrency were discussed with regards to the language Io. ANSWER was presented as a way to request that something be computed and then be able to continue computing until the result was needed. If the result was available then things would proceed as expected. If the result was not available, then a wait would be initiated until the result became available.
Futures
Io is known for taking a ANSWER-based approach to object oriented programming.
prototype
In Io, the basic method for creating a new object is ANSWER.
clone
In Io, the type of an object is generally the nearest ancestor that ANSWER.
has a name that starts with a capital letter
has a slot for the method type
In Io, we create a singleton by redefining the method ANSWER.
clone
In Ruby, the evaluation of arguments to a message are handled by the object sending the message. In Haskell, the runtime environment decides when and how much to evaluate an argument to a function. In Io, the evaluation of the arguments to a message is made by ANSWER.
the receiver of the message
In Io, a message has three aspects that can be interrogated by the call method. They are: the sender, the reciever, and ANSWER
the argument list
Io allows programmers to play with its syntax, doing things like introducing a colon operator and redefining how curly braces are processed. This makes it easy to use Io to create ANSWER.
Domain Specific Languages
DSLs
As one would expect in an object oriented language, when a message is sent to an object, the first thing the system does is to look for a corresponding method in that object. However, Io lets you change what happens next by redefining the method named ANSWER.
forward