1.2.4 Types of programming language
No description yet. This curated deck is ready for daily study.
Card preview (24)
What is a programming paradigm?
Programming paradigms are established conventions and practices that dictate how computer programs are structured and developed.
Define a low-level language
A low-level language is a type of computer language that is closely aligned with the basic instructions that a computer’s hardware understands.
What are the features of low-level languages?
• They allow programmers to have direct control over hardware to access machine specific functionality • They can be more complex • Less flexible than high-level languages. • They’re quicker to translate • They make more efficient use of the memory where a system may have limited resources • They are likely to be specific to the processor type used, and therefore not portable • Doesn’t require a compiler/interpreter (does require assembler though)
Define a high-level language
A high-level programming language is a programming language that uses English-like words, making it easier for humans to read, write and understand.
What are the features of high-level languages?
• They are portable because they are independent of specific hardware • They must be translated into machine code using a compiler or interpreter • They provide abstraction from hardware details, as they include built-in libraries and advanced features
Describe procedural programming languages
Languages that carry out a sequence of instructions step-by-step and organise code into reusable blocks (procedures) which perform specific tasks.
What are the advantages of procedural programming languages?
• Calling subroutines reduces the amount of repeated code • Large programs can be worked on by a team of programmers who develop individual subroutines concurrently • Simple to implement • Suited to problems that can easily be expressed as a series of instructions using the sequence, selection, iteration and recursion constructs • Can be applied to a wide range of problems • Relatively easy to write and interpret
What are the disadvantages of procedural programming languages?
• Not possible to solve all problems with these languages and can be inefficient to do so • It struggles when attempted to be used to reuse classes or make them inherit from one another.
How are procedural languages used?
They are commonly used for software development, data processing and teaching programming fundamentals as they emphasise logical structure and modular design.
Describe object oriented programming languages
They organise code around objects, which are instances of classes that combine data (attributes) and behaviour (methods) into reusable units.
Describe how classes are used in Object Oriented programming Languages
Classes are templates from which objects are created. They define both attributes and methods.
How do you define a class in Python?
e.g. class Dog: def __init__(self, name, breed, height, weight): self.__name = name self.__breed = breed self.__height = height self.__weight = weight self.__variable is used to indicate that the variable is private, self. can be used if it’s public
How do you write a method in python?
You just write it as a function. E.g. def getLevel(): return level
What is the difference between private and public attributes and methods?
If an attribute/method is public it can be called by any class. If it’s private it can only be called by the current class.
What is a getter?
A method which retrieves the value of a given attribute
What is a setter?
A method that sets the value of a given attribute
Describe how Encapsulation is used in Object Oriented Programming Languages
Classes can be encapsulated by making attributes private and providing public access methods. This allows for an attribute to only be accessed by a method (method function). This allows data to be protected.
Describe how get and set methods are used to regulate access to private attributes
Getters and setters are used to make sure attributes can’t be directly accessed and edited by users by restricting access to only those using the getter and/or setter.
What is a constructor?
It allows for the instantiation of an object
Describe inheritance in Object Oriented programming
It enables a child class to be created which can reuse or extend the classes of the parent class. This promotes the reuse of code.
Describe polymorphism in Object Oriented Programming
It means that objects can behave differently depending on their class. This can result in the same methods producing different outputs.
Describe overriding as a form of polymorphism
A method is redefined within a subclass, altering the code so that it functions differently and produces a different output.
Describe overloading as a form of polymorphism
Passing different parameters into a method.
What are the advantages of Object Oriented Programming?
• It has an advantage in security as encapsulation protects attributes from being directly accessed. • It is efficient as classes can be reused and inherit from one another. • The separation of components into classes make programs easy to update and maintain • It is flexible due to polymorphism