##I'm Excited About JavaScript, ##and You Should be Too! (JavaScript Now)
#Who? ##Christohper Smith * Website [cmsmith.co](http://cmsmith.co/) * Blog [theresapatternforthat.com](http://theresapatternforthat.com/) * Twitter [@cmsmithco](https://twitter.com/cmsmithco) * Git Hub [Queuehammer](https://github.com/QueueHammer)
##What * Developer for 8 years * Worked for large and small companies * Programmed in C++, C#, Ruby, JavaScript * Now working in the front end * Espousing Angular.js and JavaScript
##Why * With a diverse background why program JavaScript? * Why work on the front end? * I am here intentionally
##Interesting Times, With Interesting Problems * Concurrency * Big Data * Distributed Systems
##Developers Love Solving Problems * It’s a part of our profession, and we are taught it in college * You solve a problem by breaking it into smaller pieces till it can be solved
##The Power of Simplicity * Looking at enough simple problems, abstractions are formed. * Preferably with as few dependencies as possible (e.g. Loosely Coupled)
##It's the Abstractions that Matter * A good abstraction will find it's self everywhere
##Big Data - A Problem to Look Into * Hadoop is a framework for working with and big data. * At it’s core it is build around the concepts of parallelism * The data is distributed across the nodes in the cluster * It then schedules tasks to process that data to run at each node * The request is mapped across the nodes in the cluster * The results are reduced into the final result
##At It’s Core * Hadoop is Map and Reduce; Basic abstractions scaled. * "Map" a task over a collection * In this case its each node in the cluster gets a task * "Reduce" aggregates a collection into a single output * This could also be a new collection * Every tutorial I took on Hadoop had me learning Map and Reduce * I had already been doing this in JavaScript with Underscore or Lo-Dash * This got me thinking of the other patterns I used in JavaScript
##Lists and Collections - Great Abstractions * We instinctually think in sets; Them / Us. * Do Y to every X * Sort N into M groups * Idle, working and disabled processes
##Lambdas - List Essentials * When thinking in lists it's easy to map, reduce, filter or find with a function over a collection * Lambdas are functions that you create in line, and can be passed as arguments to functions like map * Lambdas are also powerful because they bring along closures * Local variables that are in scope are closed inside the function and accessible to it * All modern languages have Lambdas * JavaScript (1996), C# (2007), C++ (2011), Java (2014)
##Chaining * The natural conclusion of sets, objects, and lambdas * A collection is represented by an object * The same wrapper is returned after each method call * The method is passed a lmabda to be run on the collection
###Linq (2007) aCollection .where(x => x.mass > 70) .select(x => x.id) .toList();
###Rx.js (2013) source .filter(function (quote) { return quote.price > 30; }) .map(function (quote) { return quote.price; }) .forEach(function (price) { console.log('Prices higher than $30: $' + price); });
###jQuery (2006) $('.target') .find('.taged') .children() .hide();
##The Patterns Persist * I keept seeing that when my favorite features of C# were things I could do in JavaScript. e.g. Chaining in Linq, Lambdas, Object / Collection initializers. * Also the struggles I had, along with most others, with JavaScript were around Internet Explorer and not the language itself. * Furthermore it was thriving despite this * So I took a look at what they community has been up to
##Node.js * It uses the same V8 that runs in chrome but it's free from the browser * It was developed as a server using a single thread, like the standard intrepreters for Python and Ruby. * The difference in Node.js was that all IO was async, and event driven. * Given it’s targeted application was inherently latent, async was critical for performance.
##Async Patterns Grow Up * With async request and callbacks, pattern like Thread.Join is needed. * There had been lots of frustration with callbacks and code structure * The solution to this was the promise Q(performAsyncRequest()) .then(a) .then(b) .catch(x) .done(); * A async task immediatly returns a promise and when it finishes it is "fufilled" * Any functions you passed to `then()` are run * `done()` returns the final value * Code can be written procedurally, yet still use callbacks.
##Let's Not Forget Hadoop * With existing and developed patterns in JavaScript. What would something logicly simular look like?
##Mock Q(_.map(nodes, function(node) { return node.doWork(x); }) .then(function(results) { return _.reduce(results, function (memo, value, index) { //... }, {}); }) .error(function(err) { //... });
##[Timothy](https://www.npmjs.org/package/timothy) require('timothy') .map(function(line){ var words = line.split(" "); for(var i=0; i<words.length; i++) this.emit(words[i], 1); }) .reduce(function(word,counts){ this.emit(word, counts.length); }) // runLocal can be used instead of run to simulate the job execution // from the command line .runLocal("~/Desktop/test_input.txt");
##What Other Problems Could Be Solved? * Think outside the browser * The patterns of JavaScript excel in any application where: * The app is event driven * Incoming server requests * Inputs from a UI * Interrupts from hardware * Collections can be leveraged though chaining
##[Gulp](http://gulpjs.com/) * Builds are IO intensive, and working with files are streams/collections * So with chaining, lambdas, and async; Gulp, was the next setp in build systems realised though JavaScript/Node. // task gulp.task('minify-js', function () { gulp.src('./JavaScript/*.js') // path to your files .pipe(uglify()) .pipe(gulp.dest('path/to/destination')); });
##Embedded * Hardware interrupts, tasks running on co-modules, and other system events are exactly the application for Node.js and JavaScript * Companies like [Tessel.io](https://tessel.io/) are creating embedded hardware that will allow you to write your code in javascript (@technicalhumans) * Libraries like [Jonny-Five](https://github.com/rwaldron/johnny-five) allow remote task execution through node on Arduino * Program flying drones at a [Node Copter](http://nodecopter.com/) event * JavaScript has offically invaded the Makers Space
##Critical Mass * Windows 8 apps can be built with JavaScript * The online store for MS Office requires apps to be written in JavaScript * C++, Fortran, etc, can be complied though LLVM and then to JavaScript with [Emscripten](https://github.com/kripken/emscripten) * Mobile app development is shifting to JavaScript for cross platform “nearly native” apps * Even these slides were made though JavaScript
##But can it teach a generation to program? * We see an shortage of CS majors and Programmers * There are alternatives to loading students on the struggle bus of C++ compiling and debugging * Or teaching the Java development tool chain through Eclipse before the first line of code. * Python and Ruby require less upfront commitment and provide a REPL for exploration and learning * Or you open any web browser and press F12. You have a REPL to explore and the entire debugging tool chain installed. * Even more pleasing UIs exist in the form of JSBin, Plunker, and Codio * All for free!
##Teach a Person to Fish * Teach a person to program and they don’t just have a hobby, they have a career. * One that pays well and is secure
##Closing * I am here intentionally * I’m here because of what is being done in JavaScript * I’m here for what we can still do