New York Tech Journal
Tech news from the Big Apple

Html5NYC: #FunctionalProgramming, #GeneticAlgorithms, #Geolocation in #HTML5

Posted on November 12th, 2014


10/12/2014 @CondeNast, 4 Times Square, NY

Three presentations on things #JavaScript.


In the first presentation, Nathaniel K Lee talked about how functional programming differs from many of the standard programming paradigms in a language such as JavaScript.

He talked about how functional programming emphasizes nesting of function calls in preference to loops, reusability of functions, avoiding use of global variables within functions, passing functions as function arguments, and returning functions as function outputs.

Two examples of the efficiency of functional programming are in a recursive calculation of factorial and a recursive solution to the Tower of Hanoi problem.

He talked about some of the challenges in incorporating these concepts into JS due to calls by reference when passing objects to a function. He showed how looping through a list can be replaced by recursive calls to process the first item of a list.

He said the main challenges were adopting a new mindset when programming and developing methods to handle a larger number of user-defined functions.

As an aside, those who are familiar with R will recognize the difference between using ‘for’ loops and applying the apply(), sapply() and aggregate() functions. In the case of R, these functions provide a massive speedup in execution.


In the second presentation, Kirill Cherkashin talked about genetic algorithms by showing how

  1. The Mona Lisa can be reproduced by randomly generated triangles
  2. improved the design of schematic cars by randomly mutating the shape, the wheels, and the weight of cars
  3. Google’s use of random search to find an optimal path between two points

Finally, Scott Luptowski @Handy described the HTML5 geolocation API. The API is locationed in window.navigator.geolocation (referred to here as ‘geo’)

Geo.getCurrentPosition() is the function which will ask you if the program can use your location and does the initial setup. The API returns accuracy, longitude and latitude with altitude and other returns optional. Scott said that even though the locations were coded using 12 digits, 5 seemed sufficient as they gave an accuracy of 1 meter (GPS is accurate to within 10 meters).

He recommended coding for the three error cases: 1. Permission denied 2. Timeout, 3. Position unavailable (unlikely).  There are few callbacks in the API, the most important is geo.watchCurrentPositon, which indicates the position has changed since the last report.

posted in:  Html5 NYC, javaScript, NYCHTML5    / leave comments:   No comments yet