Robert Vitolo CS474.  Branched off of ML (metalanguage)  Developed at Microsoft, available as part of the Visual Studio 2010 software package, integrated.

Slides:



Advertisements
Similar presentations
Module 6: Introduction to C Language ITEI102 Introduction to Programming Structure of C++ Program - Programming Terminologies - Microsoft Visual Studio.
Advertisements

Evis Trandafili Polytechnic University of Tirana Albania Functional Programming Languages 1.
Week 9: Methods 1.  We have written lots of code so far  It has all been inside of the main() method  What about a big program?  The main() method.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
Virtual techdays INDIA │ 9-11 February 2011 Parallelism in.NET 4.0 Parag Paithankar │ Technology Advisor - Web, Microsoft India.
Chapter 15 Other Functional Languages. Copyright © 2007 Addison-Wesley. All rights reserved. Functional Languages Scheme and LISP have a simple syntax.
High-Level Programming Languages
Dr. Muhammed Al-Mulhem ICS An Introduction to Functional Programming.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
CH1 – A 1 st Program Using C#. Program Set of instructions which tell a computer what to do. Machine Language Basic language computers use to control.
Microsoft Visual Basic 2012 CHAPTER ONE Introduction to Visual Basic 2012 Programming.
Microsoft Visual Basic 2005 CHAPTER 1 Introduction to Visual Basic 2005 Programming.
Python quick start guide
SEC(R) 2008 Intel® Concurrent Collections for C++ - a model for parallel programming Nikolay Kurtov Software and Services.
CS 355 – Programming Languages
Chapter 8 High-Level Programming Languages (modified by Erin Chambers)
Chapter 6: User-Defined Functions I Instructor: Mohammad Mojaddam
Computing with C# and the.NET Framework Chapter 1 An Introduction to Computing with C# ©2003, 2011 Art Gittleman.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 6 Value- Returning Functions and Modules.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages.
Copyright © 2007 Addison-Wesley. All rights reserved.1-1 Reasons for Studying Concepts of Programming Languages Increased ability to express ideas Improved.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Summary of what we learned yesterday Basics of C++ Format of a program Syntax of literals, keywords, symbols, variables Simple data types and arithmetic.
About Me Microsoft MVP Intel Blogger TechEd Israel, TechEd Europe Expert C++ Book
Productivity Tools Ken Nguyen Department of Information Technology Clayton State University.
Functions, Procedures, and Abstraction Dr. José M. Reyes Álamo.
Built-in Data Structures in Python An Introduction.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 6: User-Defined Functions I.
Arithmetic Expressions Russell Taylor NC Computing Software Application Development.
Introducing Python CS 4320, SPRING Resources We will be following the Python tutorialPython tutorial These notes will cover the following sections.
Theory of Programming Languages Introduction. What is a Programming Language? John von Neumann (1940’s) –Stored program concept –CPU actions determined.
1 Programming Environment and Tools VS.Net 2012 First project MSDN Library.
School of Computing and Mathematics, University of Huddersfield CHA2545: WEEK 4 LECTURE: DENOTIONAL SEMANTICS OF A SIMPLE LANGUAGE TUTORIAL: Do exercises.
Parallelism Can we make it faster? 25-Apr-17.
CS5205Introduction1 CS5205: Foundation in Programming Languages Lecture 0 : Overview Lecturer : Chin Wei Ngan Office : COM2.
Chapter 8 High-Level Programming Languages. 2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
1-1 An Introduction to Functional Programming Sept
CS-303 Introduction to Programming
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 6: User-Defined Functions I.
Programming and Languages Dept. of Computer and Information Science IUPUI.
Chapter 3: User-Defined Functions I
Functional Programming IN NON-FUNCTIONAL LANGUAGES.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 6: User-Defined Functions I.
An Introduction to F# Sushant aboutdev.com
Algorithms in Programming Computer Science Principles LO
1 Proving Properties of Recursive List Functions CS 270 Math Foundations of CS Jeremy Johnson.
Functional Programming
Functional Programming
Introduction to Algorithms
Chapter 6: User-Defined Functions I
Introduction to Higher Order (Functional Programming) (Python) part 2
PROGRAMMING LANGUAGES
Representation, Syntax, Paradigms, Types
Chapter 1: Introduction to Computers and Programming
Introduction to Computer Programming
Functions, Procedures, and Abstraction
CIS16 Application Development – Programming with Visual Basic
Unit 1: Introduction Lesson 1: PArts of a java program
slides created by Marty Stepp
Representation, Syntax, Paradigms, Types
4. Dividing Computing with Pattern Matching in F#
Representation, Syntax, Paradigms, Types
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
Introduction to Algorithms
Introduction to Value-Returning Functions: Generating Random Numbers
Principles of Programming Languages
Representation, Syntax, Paradigms, Types
Class code for pythonroom.com cchsp2cs
Dictionary.
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

Robert Vitolo CS474

 Branched off of ML (metalanguage)  Developed at Microsoft, available as part of the Visual Studio 2010 software package, integrated into the.NET environment just as C#, Visual C  Allows for three programming paradigms: Imperative, Object-Oriented, or Functional

 Modeled on mathematical functions, rooted in lamda calculus  Relatively simple syntax and semantic structure compared to imperative languages that give it high readability.  Uses ‘functions’ that are conceptually similar to math functions, making it a highly appropriate paradigm for representing equations or performing math operations

 Allows you to quickly evaluate expressions or perform computation on- the-fly

 Data structures make it a fitting language candidate for computation over large sets of data. List (homogeneous data) Tuple (related data) Record (heterogeneous data) Discriminated Unions

 Purely functional languages do not use mutable data or mutable states, and thus are inherently thread safe – the output value of a function depends entirely on its arguments. List, for example, is a data structure that stores an immutable series of ordered elements as a linked list, all of the same type. F# does allow mutable data if you explicitly define it with a ‘mutable’ keyword i.e. let mutable x = 5.  This frees up the programmer from having to manage complex thread synchronization / locks

 Problem: Return the square of a range of numbers. Return the squares of 1 to n: [1 2, 2 2 … n 2 ]  In this example, from integers 1 to 10.  Two approaches: C# approach F# approach

C# CODEOUTPUT

1. Define the function “square” and what it does 2. Define a range of numbers, using a List [brackets] 3. Map the function square to each item in the list -- to each number

 Using the Task Parallel Library you can create parallel programs in F#. You have access to all of the same.NET functions in C#, including Parallel.For, Parallel LINQ (PLINQ) and Parallel CPU Asyncs  In this example we’ll use PLINQ, which is the best one to use if you want to program in a purely functional manner.

 Problem: Find the sum for all squares in a range of values in parallel and return the execution time and the sum.  In this example, from integers 1 to 1500.

F# CODE AND OUTPUT

 Think of the execution of this statement in this manner: Take our list of numbers (1 to 1500) and map the squaring function sqr to each item, and return that set of values. Take the set of values and run the function “sum” on that set, and return the answer to ParallelSumOfSquares.

 Problem: Find the largest value in a list of values in parallel and return that value.  Code:

 Result:

 The burning question: Is F# “faster” or “better” than C# ? How about for parallel programming? Answer:  In terms of Productivity?Yes, for many applications  Parallel Programming?Yes, for ease of setup  Execution Time?No