Pre-assessment notes

Statically typed

I'd say these answers are correct. Note, though, that we're actually interested in all types, not just the types of variables - e.g. expressions have types, too. The implication of types being known at compile time is that if they don't make sense, the programmer can be informed then. Haskell and Java are both statically typed languages; Haskell is a functional languate, Java is an object oriented language. By contrast, Smalltalk is a dynamically typed object oriented language. Lisp is a dynamically typed functional language. And this is true, though not complete:

Types being known at compile time is a different thing from the programmer needing to give types in the code. Types may be inferred, instead, and this can happen at compile time or at run time. If you think about it, we always have some type inference: if you have specified that i and j are integers, you routinely assume that you do not have to specify that i + j is an integer, because you expect the computer to work out - that is, infer - that information. Some languages do a lot of type inference, others much less. Standard ML is an example of a statically typed language with lots of type inference: typically, Haskell programmers write down more types than ML programmers do, but they can often get away with not doing so; Java has relatively little type inference. So these are not right:

- note that the last one of these says the opposite of the others - and this one nicely hedges its bets with "normally" :-) Many people perhaps guessed that "static" should mean "unchanging". In fact, even in dynamically typed languages, where types are not identified and checked until run time, it's rather rare for the type of a variable to change. The only language I know well where a single variable can be treated as having different unrelated types, depending on context, is Perl; even there, the variable doesn't actually change types (so as to be able to store different values, say). OO polymorphism can be seen as a special case of this, though, where the types have to be related in a certain way: see later. Some people were confused with the notion of static method, attribute, inner class etc. in Java - confusingly, indeed, this is not a closely related idea; best to think of it as happening to use the same word. A few answers were idiosyncratically wrong: Several people, naturally, gave answers that were mixtures of right and wrong: hopefully it's clear enough by now which bits are which:
This page is maintained by Perdita Stevens (perdita@inf.ed.ac.uk)


Home : Teaching : Courses : Seoc : 2014_2015 : Preassessment 

Informatics Forum, 10 Crichton Street, Edinburgh, EH8 9AB, Scotland, UK
Tel: +44 131 651 5661, Fax: +44 131 651 1426, E-mail: school-office@inf.ed.ac.uk
Please contact our webadmin with any comments or corrections. Logging and Cookies
Unless explicitly stated otherwise, all material is copyright © The University of Edinburgh