intro to f# and daxif#files.meetup.com/10193032/ramones_f#_and_daxif#_mf#k2013.pdf · concurrency:...
TRANSCRIPT
Intro to F# and
DAXIF#Talk by Ramón Soto Mathiesen
@ Mødegruppe for F#unktionelle Københavnere 2013
Contents
• About me
• What is F# and why use it?
• F# on a daily basis: DAXIF#
• Live demo (DAXIF#)
• How to get started with F#
• Summary
About me
• MSc. Computer Science from DIKU
• CRM Architect @ Delegate A/S
‣ ER-modeling, WSDL, OData (REST API)
• F# / C# / JavaScript / C++
F# - What is it?
• Is an open-source, strongly typed, multi-paradigm programming language encompassing functional, imperative and object-oriented designed by Don Syme (MS Research Cambridge UK) and maintained by Microsoft, F# Software Foundation and open contributors
• F# derived from OCaml: http://caml.inria.fr/ocaml/
• It’s a mature language that is part of Visual Studio and the .NET Framework (+Mono)
F# - Why use it?
• Conciseness
• Convenience
• Correctness
• Concurrency
• Completeness
F# - Why use it?
• Conciseness:
‣ F# is not cluttered up with coding noise such as curly brackets, semicolons and so on
‣ You almost never have to specify the type of an object, thanks to a powerful type inference system.
‣ And, compared with C#, it generally takes fewer lines of code to solve the same problem
F# - Why use it?
• Convenience:
‣ Many common programming tasks are much simpler in F#. This includes things like creating and using complex type definitions, doing list processing, comparison and equality, state machines, and much more
‣ And because functions are first class objects, it is very easy to create powerful and reusable code by creating functions that have other functions as parameters, or that combine existing functions to create new functionality
F# - Why use it?
• Correctness:
‣ F# has a powerful type system which prevents many common errors such as null reference exceptions.
‣ Values are immutable by default, which prevents a large class of errors
‣ In addition, you can often encode business logic using the type system itself in such a way that it is actually impossible to write incorrect code or mix up units of measure, greatly reducing the need for unit tests
F# - Why use it?
• Concurrency:
‣ F# has a number of built-in libraries to help when more than one thing at a time is happening. Asynchronous programming is very easy, as is parallelism. F# also has a built-in actor model, and excellent support for event handling and functional reactive programming
‣ And of course, because data structures are immutable by default, sharing state and avoiding locks is much easier
F# - Why use it?
• Completeness:
‣ Although it is a functional language at heart, F# does support other styles which are not 100% pure, which makes it much easier to interact with the non-pure web sites, databases, other applications, and so on. In particular, F# is designed as a hybrid functional/OO language, so it can do virtually everything that C# can do
‣ Of course, F# is part of the .NET ecosystem, which gives you seamless access to all the third party .NET libraries and tools.
‣ Finally, it is well integrated with Visual Studio, which means you get a great IDE with IntelliSense support, a debugger, and many plug-ins for unit tests, source control, and other development tasks
C# vs. F#
‣ no coding noise
‣ fewer lines of code
‣ no type specification
‣ Immutable (threadsafe)
‣ Records don’t have identity
F# on a daily basis:DAXIF#
• DAXIF#: Delegate Automated Xrm Installation Framework
‣ One-click-deployment
‣ TFS commit DEV DEV-BUILD TEST PROD
‣ Web resources synchronization
‣ Data management (Import/Export with Parallelism)
‣ Data migration: 1:1 between source and target Created by/on + Modified by/on (only for On-premise)
‣ Only one programming language (to rule them all)
‣ Type Strong script files
‣ Unit tests executed before building assembly
F# on a daily basis:DAXIF#
• Why F#? less code, error-free projects,
only one code base, big data, parallelism,
concurrency, asynchronous (buzzwords)
• Delegate A/S is the new kid on the block
small teams, less time to spend on
side projects
F# on a daily basis:DAXIF#
• DAXIF# started out as DAXIF (C#, .BAT files, almost no time for unit test, …, you know the drill)
• Now, all modules are less than 100 lines of code. Easy to read again, and again, and again …
F# on a daily basis:DAXIF#
• Unit test are executed before building the final assembly file. F# interactive for add-hoc testing (is able to interact with C# assemblies)
• Documentation is generated on the Markdown headers of the functions (HTML/Latex)
Live demo:DAXIF#
Live demo:C# vs. F# (CRM Parallelism)
How to get started
with F#• Tryfsharp http://www.tryfsharp.org
How to get started
with F#• Project Euler and Emacs http://projecteuler.net/problems
Summary
• The language is mature and you can do awesome stuff in less
time that you would spend on other languages
• Jump into it, the only way to master something is by try/error
on a daily basis
• Be pragmatic about it. If you can use a Dictionary (mutable
data structure) don’t use a sequence/list for the sake of purity
Remark: Pragmatic ≠ sloppy
• A lot of the cool stuff is licensed under a very lightweight
Open Source license (Apache License). Try, as much as
possible, to give back to the community in small
modules/libraries that are also open source
Questions?