Slide 1

Slide 1 text

Learning New Programming Languages Manish Pandit Cohackathon - 02/20/2021

Slide 2

Slide 2 text

About me Engineering Manager, Facebook First Computer : BBC Micro First Programming Language : BBC BASIC

Slide 3

Slide 3 text

About this session We will talk about... ..what complexity is solved by programming languages ..basic constructs of a programming language ..how to recognize patterns so it’s easier to pick up new languages

Slide 4

Slide 4 text

Guess the language! org 0x100 mov dx, msg mov ah, 9 int 0x21 mov ah, 0x4c int 0x21 msg db 'Hello, World!', 0x0d, 0x0a, '$'

Slide 5

Slide 5 text

Guess the language! program Hello; begin writeln ('Hello, World!'); end.

Slide 6

Slide 6 text

Guess the language! program hello print *, "Hello World!" end program

Slide 7

Slide 7 text

Guess the language! print("Hello, World!")

Slide 8

Slide 8 text

Guess the language! fun main(args : Array) { println("Hello, World!") }

Slide 9

Slide 9 text

Guess the language! mysql> select "Hello World";

Slide 10

Slide 10 text

Why do we need Programming Languages Programming Languages help us write human readable programs - making it easier to interact with the underlying complexity in a computer. All programs end up being translated in a format that the computer understands.

Slide 11

Slide 11 text

“Underlying Complexity”

Slide 12

Slide 12 text

Microprocessors Microprocessors are the lowest level programmable units in a computer. Each processor defines an “architecture”, laying out it’s internal components and a programming manual. Intel 8086 from 1979 AMD64 from 2020

Slide 13

Slide 13 text

Operating Systems Operating Systems are programs that allow other programs to run, and handle basic and primitive operations like memory management, I/O, storage management, etc. Often times Operating Systems are called “System Software”. Can you think of some examples of Operating Systems?

Slide 14

Slide 14 text

Compilers Compilers convert Higher Level Programming Languages (think human readable) to Machine Code (Operating System or processor readable), which can run natively on the Operating System.

Slide 15

Slide 15 text

Runtime Compilers Runtimes, or “cross-platform-runtimes” host an environment for the compiled code to run. Think of it as an another layer between the operating system and the machine code, called bytecode. This allows code to be compiled once, regardless of the operating system, as long as that operating system supports the target runtime. Can you think of some examples of runtimes?

Slide 16

Slide 16 text

Interpreters Interpreters run program instructions one step at a time, by converting them into machine code (or runtime bytecode). You cannot run programs written in an interpreted language without the interpreter being present. You can run code compiled by a compiler without that compiler being present.

Slide 17

Slide 17 text

Syntax A programming language syntax is a set of rules (called grammar) to form statements and expressions. A statement is an instruction to carry a task, like assigning values, or calling other parts of the program. An expression needs to be evaluated to determine the value - like 1+2. Think of the English Language Grammar - the words, their order, and how we start and finish the sentences matters (and makes a huge difference!). All programming language differ in their syntax in varying degrees.

Slide 18

Slide 18 text

Variables and Types Variables are references to data. Type of a Variable indicates the structure of the data the variable references to. Examples - Characters, Integers, Booleans, Floats, Strings..

Slide 19

Slide 19 text

Keywords Keywords are reserved words in any programming language that carry a special meaning to the compiler or interpreter. These cannot be used as variable names. Examples - if, else, while, for..

Slide 20

Slide 20 text

Conditionals Conditionals are statements that control the flow of the code. Usually they’re if-then-else, and each language has a different syntax. Some languages support multiple conditionals - like switch. Recall expressions vs. statements - An if-then-else or if-else is a statement that uses an expression to evaluate the code to execute. if {..} else {..} if {..} else if {..} .. else {..}

Slide 21

Slide 21 text

Loops Loops allow us to do the same set of instructions repeatedly. All modern languages support for-loops, while-loops. Let’s talk about statements and expressions again. A loop is a statement that evaluates an expression to know when to stop looping, among other things. for {..} while {..} do {..} while

Slide 22

Slide 22 text

Methods or Functions Methods, or functions are blocks of code grouped together to process input and provide output. They help with readability and code structure. Functions can call other functions, and can be called from other functions. Most languages have built-in functions for common tasks. Can you tell which function did we see being used in the “Hello, World!” examples?

Slide 23

Slide 23 text

Code Structure Also referred to as “packaging”. Most languages have a way to distribute code so it can be re-used. Packaging also helps manage large codebases by organizing the code in a standard way. You’ll hear terms like modules, libraries, and packages being used to represent this.

Slide 24

Slide 24 text

Program Flow ● Functions ● Errors ● Structure and Organization

Slide 25

Slide 25 text

Data Structures A data structure is a way to organize data so it can be used and managed efficiently. A data structure has a fixed set of functions that can be run on the data contained in it. Can you think of some examples of data structures?

Slide 26

Slide 26 text

Data Structures Maps - put(K,V), get(K), get_keys() Linked Lists - next(), previous(), add(), delete() Queues - enqueue(), dequeue(), peek(), is_empty() Stacks - push(), pop(), peek(), is_empty() Other Data Structures are Arrays, Sets, Lists, Trees, Graphs, etc.

Slide 27

Slide 27 text

Algorithms Algorithms are a set of ordered instructions that operate on input to produce an output. Think of them as recipes - which operate on a set of ingredients to produce a dish.

Slide 28

Slide 28 text

Algorithms There are standard algorithms to perform common operations in computing. Searching Sorting Encrypting Random Number Generation ..

Slide 29

Slide 29 text

Complexity While there are multiple ways (algorithms) to perform an operation (search), the efficiency of the algorithms is measured using complexity. Not all algorithms are created equal. Space complexity - How much memory does the algorithm use Time complexity - How much time does the algorithm take Balancing these 2 complexities is what programmers strive for. These are not numbers (like 2GB or 10s) but are expressed in the relation of the input size of N. A 2N space complexity algorithm would use 2 times the input space, while a log(N) time complexity algorithm would use log(N) time to perform the operation.

Slide 30

Slide 30 text

Advanced Built in libraries - Data Structures and Algorithms Concurrent Programming - Threads, Promises, Futures Advanced I/O - native IO, polling, push

Slide 31

Slide 31 text

Implementation ● Read the implementation of the built-in data structures after your implementation.

Slide 32

Slide 32 text

Summary Best tool for the job Familiarize yourself with the syntax Look for patterns for conditionals, loops, functions Pick a few algorithms to implement consistently

Slide 33

Slide 33 text

Practice Hackerrank Leetcode Project Euler Harvard’s CS50

Slide 34

Slide 34 text

Questions