0% found this document useful (0 votes)
3 views2 pages

Programming Language Basics With Examples

The document outlines key programming language concepts, including the distinction between static and dynamic typing, aliasing, parameter passing mechanisms, dynamic scope, explicit access control, static scope, and the definitions of environment and states. It provides examples in languages like Python and C/C++ to illustrate these concepts. Understanding these fundamentals is essential for effective programming and memory management.

Uploaded by

sanjanamaroju82
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Programming Language Basics With Examples

The document outlines key programming language concepts, including the distinction between static and dynamic typing, aliasing, parameter passing mechanisms, dynamic scope, explicit access control, static scope, and the definitions of environment and states. It provides examples in languages like Python and C/C++ to illustrate these concepts. Understanding these fundamentals is essential for effective programming and memory management.

Uploaded by

sanjanamaroju82
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Programming Language Basics - With Examples & Diagrams

1. Static/Dynamic Distinction

- Static: Checked at compile-time (e.g., C/C++ typing)

- Dynamic: Checked at runtime (e.g., Python typing)

Example:

Static: int x = 5;

Dynamic: x = 5

x = 'Hello' # Python allows this

2. Aliasing

- When two variables refer to the same memory location

Example:

def modify(lst):

lst.append(10)

a = [1, 2, 3]

b = a # b is an alias of a

modify(b) # a is also modified

3. Parameter Passing Mechanisms

- Call by Value: Copies the value

- Call by Reference: Passes actual memory reference

Example (Python):

def add(x):

x += [4]

lst = [1, 2]; add(lst) # lst becomes [1, 2, 4]

4. Dynamic Scope

- Variable references resolved using the call stack at runtime


- Used in shell scripts and some older languages

5. Explicit Access Control

- Controls visibility: public, private, protected

Example:

class MyClass:

def __init__(self):

self.__private = 42 # double underscore = private

6. Static Scope and Block Structure

- Variables resolved based on code structure

- Most languages like C, Java, Python use static scoping

Example:

def outer():

x = 10

def inner():

print(x)

7. Environment and States

- Environment: Maps variable names to memory locations

- State: Current values of variables

Important for memory management and tracking changes

You might also like