//No Comment - JavaScript Classes, Checking APIs & Deep Learning
//No Comment - JavaScript Classes, Checking APIs & Deep Learning
Written by Ian Elliot   
Thursday, 09 March 2017

• Refactoring Legacy JavaScript Code to Use Classes: The Good, The Bad and The Ugly 

• Statically Checking Web API Requests in JavaScript

• Development of JavaScript-based deep learning platform and application to distributed training

 

nocomment

Sometimes the news is reported well enough elsewhere and we have little to add other than to bring it to your attention.

No Comment is a format where we present original source information, lightly edited, so that you can decide if you want to follow it up. 

 

Refactoring Legacy JavaScript Code to Use Classes: The Good, The Bad and The Ugly

JavaScript is the language we all love to hate, except of course for those few rare programmers who have caught on to is rare qualities and embrace its difference. However, what will it take to make JavaScipt beautiful to the conventional eye. Will classes hack it? What about refactoring code to use classes?

JavaScript systems are becoming increasingly complex and large. To tackle the challenges involved in implementing these systems, the language is evolving to include several constructions for programming- in-the-large.

For example, although the language is prototype-based, the latest JavaScript standard, named ECMAScript 6 (ES6), provides native support for implementing classes. Even though most modern web browsers support ES6, only a very few applications use the class syntax.

In this paper, we analyze the process of migrating structures that emulate classes in legacy JavaScript code to adopt the new syntax for classes introduced by ES6. We apply a set of migration rules on eight legacy JavaScript systems. In our study, we document:

(a) cases that are straightforward to migrate (the good parts);

(b) cases that require manual and ad-hoc migration (the bad parts);

and

(c) cases that cannot be migrated due to limitations and restrictions of ES6 (the ugly parts).

Six out of eight systems (75%) contain instances of bad and/or ugly cases. We also collect the perceptions of JavaScript developers about migrating their code to use the new syntax for classes.

From the comments we have just one pro-prototype JavaScript:

“IMHO the class syntax is misleading, as JS “classes” are not actually classes. Using prototypal patterns seems like a simpler way to do inheritance.” (Developer of system isomer)

It is good to remember that not everyone thinks that class based. object oriented. lanuages are the only solution. 

 nocomment

 

Statically Checking Web API Requests in JavaScript

This seems like a really good idea, but why isn' t this the way it is always done? It seems that HTTP based APIs don't really count and we don't consider them real enough to develop tools for. 

Many JavaScript applications perform HTTP requests to web APIs, relying on the request URL, HTTP method, and request data to be constructed correctly by string operations. Traditional compile-time error checking, such as calling a non-existent method in Java, are not available for checking whether such requests comply with the requirements of a web API.

In this paper, we propose an approach to statically check web API requests in JavaScript. Our approach first extracts a request's URL string, HTTP method, and the corresponding request data using an inter-procedural string analysis, and then checks whether the request conforms to given web API specifications.

We evaluated our approach by checking whether web API requests in JavaScript files mined from GitHub are consistent or inconsistent with publicly available API specifications. From the 6575 requests in scope, our approach determined whether the request's URL and HTTP method was consistent or inconsistent with web API specifications with a precision of 96.0%.

Our approach also correctly determined whether extracted request data was consistent or inconsistent with the data requirements with a precision of 87.9% for payload data and 99.9% for query data. In a systematic analysis of the inconsistent cases, we found that many of them were due to errors in the client code. The here proposed checker can be integrated with code editors or with continuous integration tools to warn programmers about code containing potentially erroneous requests.

nocomment

Development of JavaScript-based deep learning platform and application to distributed training

Forget TensorFlow. you can do AI in JavaScript. It is important to note that this is not a toy system or a demonstrator. It makes use of GPU hardware to get a reasonable training speed. 

Deep learning is increasingly attracting attention for processing big data. Existing frameworks for deep learning must be set up to specialized computer systems. Gaining sufficient computing resources therefore entails high costs of deployment and maintenance.

In this work, we implement a matrix library and deep learning framework that uses JavaScript. It can run on web browsers operating on ordinary personal computers and smartphones.

Using JavaScript, deep learning can be accomplished in widely diverse environments without the necessity for software installation. Using GPGPU from WebCL framework, our framework can train large scale convolutional neural networks such as VGGNet and ResNet. In the experiments, we demonstrate their practicality by training VGGNet in a distributed manner using web browsers as the client.

You can download the code from: https://github.com/mil-tokyo where you will also find a fast matrix library

Our contributions are the following:

• We implemented the fastest matrix library and deep learning library that can run on web browsers using GPGPU. The source code is provided as open-source software.

• Even where GPGPU cannot be used, native JavaScript implementation is provided, which allows high-level multi-dimensional matrix operation.

• We describe the possibility of training large scale CNN in a distributed manner without installing software in computation nodes, except for a generic plugin.

• JavaScript aficionado Ian Elliot is the author of  Just jQuery: The Core UI

Related Articles

Angular Jumps To Version 4

WebAssemby Another Milestone

Synaptic - Advanced Neural Nets In JavaScript

Deobfuscated JavaScript Through Machine Learning

 

nocomment

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter,subscribe to the RSS feed and follow us on, Twitter, FacebookGoogle+ or Linkedin.

 

Banner

 nocommentJavaScript


New Kotlin Style Guides Unveiled
03/11/2017

The Android team has produced two new style guides for using Kotlin on Android and provided some updates on how Kotlin uptake is going. 



Prepare to Run a Code Club with Future Learn
21/11/2017

The Raspberry Pi Foundation has just opened the doors on a new free, short online course on the Future Learn platform. The aim of 'Prepare to Run a Code Club' is to assist new volunteers who want [ ... ]


More News

 
 

 

blog comments powered by Disqus

 

Last Updated ( Thursday, 09 March 2017 )
 
 

   
Banner
RSS feed of news items only
I Programmer News
Copyright © 2017 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.