Creative Commons Sharealike Attributions Noncommercial Few Instruction
It's a workshop not a presentation !!!
Parking Lot
Perks
Creative Commons Sharealike Attributions Noncommercial Aim of the session
Introduction to programming concepts and techniques
Differentiate between various programming paradigms
Q: Why there are so many programming paradigms? A: Q: Isn't there 'one language' that would suffice? A: Q: How can we deal with understanding so many paradigms? A:
Creative Commons Sharealike Attributions Noncommercial Flow of the session
Programming Paradigm Definition
Why bother about 'Programming Paradigms'?
Appreciating 'Programming paradigms'
Programming Concepts
An Overview
Eager and Lazy Evaluation
Procedures
Functions
External and Internal State
Concurrency
Static vs Dynamic Typing
Some Real-Life Problems
Search (Java vs Prolog)
Higher Order Functions (Java vs Haskell)
Creative Commons Sharealike Attributions Noncommercial Flow of the session
An example of how a trivial concept can affect/support a computation and hence a particular style of programming...
Int X; Int Y = X; Print( Y );
Execution Flow
?
Creative Commons Sharealike Attributions Noncommercial Flow of the session
Programming Paradigm - Definition
Why bother about 'Programming Paradigms'?
Appreciating 'Programming paradigms'
Programming Concepts
An Overview
Eager and Lazy Evaluation
Procedures
Functions
External and Internal State
Concurrency
Static vs Dynamic Typing
Some Real-Life Problems
Search (Java vs Prolog)
Higher Order Functions (Java vs Haskell)
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – An Overview Set of Programming Concepts Procedures Functions Higher/1 st Order Evaluation Eager/Lazy Variables Single/Multi store Scope Scope of variables Typing State Internal/External Objects Classes Concurrency & on & on & on.....
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – An Overview Subset of Concepts Programming Model Set of Programming Concepts Programming Language(s) Embraced by Followed by Embraced by Followed by
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – An Overview Subset of Concepts OO Programming Model Set of Programming Concepts OO Programming Language(s) Embraced by Followed by
Java
Ruby
Oz
C++
Scala
Etc...
Objects
Classes
Inheritance
Polymorphism
Explicit State
Etc...
Embraced by Followed by
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – An Overview Subset of Concepts Functional Programming Model Set of Programming Concepts Functional Programming Language(s) Embraced by Followed by
Lazy/Eager Evaluation
Functions
Higher Order Func.
Etc...
Haskell
Erlang
ML
Scheme
Etc...
Embraced by Followed by
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – An Overview
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – An Overview
An expression which is evaluated as soon as it gets bound to a variable
Importance
Simple
Commonly found
Easy implementation for languages
Problems
Expressions are always evaluated
Languages supporting easy evaluation
Almost all including java, c#, c, etc.
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Eager Evaluation .... List Gen ( int N ) { ArrayList list = new ArrayList(); list. add ( N ); list. addAll ( Gen (N+1) ); return list; } void myMethod () { List K = Gen (1); System.out. println ( "Elements: " + K. getElementAt ( 3 ) ); } ....
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Lazy Evaluation declare fun lazy { Gen N} N | { Gen N+1} end declare K = { Gen 1} { Browse “Elements: ” + Nth K 3}
One of the most basic building block of any programming language
A means of telling the system how to execute some behavior
May be used as to abstract out functions, objects & classes
Languages that support procedures
C, C++, C#, Oz
proc { Max X Y ?Z} if X>=Y then Z=X else Z=Y end end
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Procedures local Default MaxOrDefault in Default=10 proc { MaxOrDefault Arg ?Result} if Arg >= Default then Result = Arg else Result = Default end end local Result in { MaxOrDefault 5 Result} { Browse Result} end end
Accepts functions as arguments along with other types
Can return a function as result
Ordering means...
1st order :- having no functions as args
2nd order :- can have 1st order functions as args
nth order :- can have n-1th order functions as args
We can build abstraction using Higher Order Functions
map f [] = [] map f (x:xs) = f x : map f xs numbers = [ 7,9,13 ] inc x = x + 1 more_numbers = map inc numbers
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Functions (Higher Order) listsum [] = 0 listsum (x:xs) = x + listsum xs listprod [] = 1 listprod (x:xs) = x * listprod xs fold op init [] = init fold op init (x:xs) = x `op` fold op init xs listsum = fold (+) 0 listprod = fold (*) 1
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – External and Internal State
Explicit State
State remembrance across calls
Importance
One of the base concept for Object Orientation
Implicit state
Defined by the function for its internal calculations.
Importance
Storing temporary results which otherwise might require repetitive calls.
Languages that support external state
Object Oriented languages like Java, Smalltalk, etc
Languages that have global variables
Languages that support internal state
All languages that have variables in procedures / functions
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – External and Internal State fun { Sum Numbers} Result = { NewCell 0} Input = { NewCell Numbers} proc { Sum } case @Input of nil then skip [] X | Y then Result := @Result + X Input := Y { Sum } end end in { Sum } @Result end
reducing expressiveness of the programming language
restrictions for the programmer on the programs he can write
Languages that use static typing
C, C++, C#, Java, ML, Pascal, Haskell
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Static Typing int num, sum; // explicit declaration num = 5; // now use the variables sum = 10; sum = sum + num;
Creative Commons Sharealike Attributions Noncommercial What we expect post this session
Experimentation with other programming languages
Functional language -> Haskell / ML / Scheme
Object Oriented language -> Java, C++, C#, Scala
Aspect Oriented language -> AspectJ, AspectC++
Logic language -> Prolog / Mercury
Mixed languages -> Scala, Oz
Sharing your experiences with us...
A testimonial
“ I want to thank you and DIRECTI for conducting such a marvelous session and I am very much indebted for that. I fell in love with LISP programming language and found that it was very much ideal for signal processing algos. The approach u have suggested was just great and the book you have suggested was really really great.” - Chinni Krishna, Mukt '08 Session Attendee
0 comments
Post a comment