advertisement

Declarative JavaScript concepts and implemetation

50 %
50 %
advertisement
Information about Declarative JavaScript concepts and implemetation
Technology

Published on March 3, 2014

Author: om-shankar

Source: slideshare.net

Description

Declarative style JavaScripting and the curious case of underscore.js.
- Presented at BangaloreJS Eleventh meetup: http://bangalorejs.org/eleventh.html
advertisement

{ Functional programming in JavaScript … and the curious case of _.js Om Shankar JavaScripter @ InMobi bit.ly/omshankar

Functional programming is the use of functions that transform values into units of abstraction, subsequently used to build software systems.

Do Something ! – by doing this, and then that, – and don’t forget to do this at the end of all that. Get Something Done ! – I don’t care how you do it, – also, when I want it done again, it should be as easy as it was the first time. Declarative programming: stackoverflow.com/a/8357604/1249219

Closures Flow and Chaining Recursion { Functions constructing Functions The building blocks of Functional JavaScript Mutation policies Functions passed as parameters Class-less JavaScript

• Should travel in First Class • Should be Pure, hence, should be re-usable • Should be Applicative - function A supplied to B should perform actions in B’s context.

Strings are first class in JS, - so are functions with all possible operations // Both can be stored var string = "BangaloreJS"; var stringFn = function() { return "BangaloreJS"; } // can be used on the fly, as an expression: // string "BangaloreJS"; "BangaloreJS".slice(3); // function "BangaloreJS" + (function(){ return " Rocks !!"; }());

A pure function • • • • takes argument(s) returns value(s) returns same value(s) for same argument(s) does nothing else ! Arguments Return value

An impure function • takes argument(s) • returns value(s) • reads/writes external states, for eg., modifies global DOM, objects, arrays. Read State Arguments Return value tightly coupled with read state Change State

_. map reduce / reduceRight find / detect / where filter / reject every / some ...

_.bind(scopeObject, normalFn); _.bindAll(obj, fn1, [fn2, fn3, ...]); • Creating a complement function • Creating a repeater function

Functions taking functions as parameters function repeat(times, fn) { return _.map(_.range(times), fn); }

Functions returning functions as value var numData = [1,2,null,4,5]; _.reduce(numData, function(tot, curr) { return tot * curr; }); // Problem? // Solution: function returning modified safe function // and not imperatively modified data // though what we actually do is modify data on the fly

RxJS - Reactive extensions for JS by Microsoft { Declarative JavaScript Libraries Bilby.js - bilby.brianmckenna.org Allong.es - github.com/fogus/lemonad

CoffeScript - coffeescript.org { Declarative JavaScript Compilers ClojureScript - github.com/clojure/clojurescript ROY - bilby.brianmckenna.org

@om_invincible { geekyogi.com End of Part - 1 Happy JavaScript-ing github.com/OmShiv bit.ly/omshankar

Add a comment

Related presentations

Presentación que realice en el Evento Nacional de Gobierno Abierto, realizado los ...

In this presentation we will describe our experience developing with a highly dyna...

Presentation to the LITA Forum 7th November 2014 Albuquerque, NM

Un recorrido por los cambios que nos generará el wearabletech en el futuro

Um paralelo entre as novidades & mercado em Wearable Computing e Tecnologias Assis...

Microsoft finally joins the smartwatch and fitness tracker game by introducing the...

Related pages

Formalization and Declarative Implementation of an ...

Formalization and Declarative Implementation of an ... Implementation of an Executable Concept ... Formalization and Declarative Implementation ...
Read more

Putting Declarative Programming into the Web: Translating ...

Putting Declarative Programming into the Web: ... implementation of this concept in the declarative multi ... Structure of the WUI/JavaScript implementation
Read more

Imperative programming - Wikipedia, the free encyclopedia

The hardware implementation of almost all ... Robert W. Concepts of ... Originally based on the article 'Imperative programming' by Stan ...
Read more

Three D's of Web Development #1: Declarative vs ...

Three D’s of Web Development #1: ... In JavaScript with jQuery, ... The concepts of declarative markup and imperative code are important to understand ...
Read more

Integrating JavaScript | Qt 4.8

Integrating JavaScript. QML encourages building UIs declaratively, ... Proof of Concept; Design & Implementation; Productization; Qt Cloud Services; Download.
Read more

Use functional programming techniques to write elegant ...

Use functional programming techniques to write elegant JavaScript. ... also called declarative. ... concepts in JavaScript to accomplish day ...
Read more

Learning and Declarative Knowledge - Colocation ...

Learning and Declarative Knowledge. Home; Site Map; About; Leadership; Training; ... Concepts (simple): The representation of a class of objects
Read more

Declarative programming - Wikipedia, the free encyclopedia

Declarative (contrast: Imperative) ... Concept; In computer science ... The specifics of how these queries are answered is up to the implementation and its ...
Read more

Putting Declarative Programming into the Web: Translating ...

Putting Declarative Programming ... the tedious details to interact with JavaScript, ... We demonstrate an implementation of this concept in the ...
Read more