Coffeescript: the Good Parts

Total Page:16

File Type:pdf, Size:1020Kb

Coffeescript: the Good Parts webapplog.com CoffeeScript: The Good Parts The good and not so good parts of CoffeeScript in comparison to JavaScript @azat_co 1 webapplog.com About The Presenter Azat Mardan • Worked in the US government, startups and corporations • Wrote six books on JavaScript and Node.js (the latest is Practical Node.js by Apress) • Certified yoga teacher and paleo lifestyle enthusiast @azat_co 2 webapplog.com Fun story: “CoffeeScript is a solution without a problem” I used to make fun of CoffeeScript, before falling in love with it. @azat_co 3 webapplog.com Who likes /uses CoffeeScript already? @azat_co 4 webapplog.com Please be open-minded @azat_co 5 webapplog.com Blub Paradox ! Blub paradox: devs are satisfied with whatever language they happen to use, because it dictates the way they think about programs. http://en.wikipedia.org/wiki/ Paul_Graham_(computer_programmer)#Blub @azat_co 6 webapplog.com CoffeeScript’s Bad Rep Most of the people who say bad things about CoffeeScript have never built with it anything relatively large-scale and production-ready. @azat_co 7 webapplog.com CoffeeScript at DocuSign DocuSign stack: CoffeeScript+Node.js+Backbone.js+Grunt Observation: front-end developers, after only a few weeks of CoffeeScript, didn’t want to go back to regular JavaScript! @azat_co 8 webapplog.com “CoffeeScript is a little language that compiles into JavaScript.” — coffeescript.org @azat_co 9 webapplog.com TOC for v1.7.1 Maybe CoffeeScript is not so small anymore? @azat_co 10 webapplog.com JavaScript @azat_co 11 webapplog.com Native JavaScript Issues • == vs === • Functional inheritance vs pseudo-classical • Global variable leakage (missing var) • Many others @azat_co 12 webapplog.com CoffeeScript: The Good Parts (some of them) • Syntax: curly braces, parentheses and semicolons • Function declaration: -> and => • Scoping: automatic var • Iterators / comprehensions: replacement of for loops • Class declaration: class operand @azat_co 13 webapplog.com Syntax • No semicolons, i.e., they are banned • Logical blocks can omit curly braces • Function calls can omit parentheses @azat_co 14 webapplog.com Why Semicolons are Bad? (*IMHO) • Extra time&work to put them • If missed, inconsistent but working code • Redundant/not-needed (expect in two cases) • Semicolon Insertion (ASI) @azat_co 15 webapplog.com Logical Blocks (optional curly braces) kids = brother: name: "Max" age: 11 sister: name: "Ida" age: 9 @azat_co 16 webapplog.com Function calls console.log object.class ! $('.account').attr class: ‘active’ ! $(‘button’).css color: red “font-size”: “16px” @azat_co 17 webapplog.com Function Declaration • Skinny arrow (->) saves time typing “function” over and over again • Fat arrow (=>), i.e., no need to use “var that = this” or “var self = this” @azat_co 18 webapplog.com Function Declaration Elegance CoffeeScript: JavaScript: a = (x,y) -> console.log x+y var a; ! a = function(x, y) { return console.log(x + y); }; ! a(10, -5); @azat_co 19 webapplog.com Function Declaration: Skinny Arrow CoffeeScript: JavaScript: console.log @ $('div').click ()-> console.log @ console.log(this); $('div').click(function() { return console.log(this); }); Prints “window” and DOM elements i.e., “this” changes and @ changes too @azat_co 20 webapplog.com Function Declaration: Fat Arrow CoffeeScript: JavaScript: console.log @ var _this = this; $('div').click ()=> console.log @ ! console.log(this); ! $('div').click(function() { return console.log(_this); }); Prints “window” both times (i.e., the outer scope) @azat_co 21 webapplog.com Scoping • Manual “var” is banned • Variables declared in the scope in which they are encountered first (i.e., the order in which variables used determines their scope). @azat_co 22 webapplog.com Why auto vars are good? Missed “var” Example. CoffeeScript: JavaScript: var a = function (c) { var a = function(c) { b = 10; var b = 10; return b + c; return b + c; } }; console.log(a(0)); console.log(a(0)); ! ! b is window.b — bad! b is a private attribute — what we wanted! @azat_co 23 webapplog.com Scoping: Example I CoffeeScript: JavaScript: b = 1 var a, b; a = -> b = 1; b = -1 a = function() { ! return b = -1; a() }; console.log b a(); console.log(b); @azat_co 24 webapplog.com Scoping: Example II CoffeeScript: JavaScript: a = -> b = -1 b = 1 var a, b; a() a = function() { console.log b var b; return b = -1; }; b = 1; a(); console.log(b); @azat_co 25 webapplog.com Iterators / Comprehensions (for loops) Awesome time savers! Good for arrays and objects: ! for item, index in arrayObject iterator(item) ! for key, value of object iterator(item) ! ! ! ! ! @azat_co 26 webapplog.com Iterating over an Array CoffeeScript: JavaScript: var index, item, _i, _len; ! for item, index in arrayObject for (index = _i = 0, iterator(item) _len = arrayObject.length; _i < _len; index = ++_i) { item = arrayObject[index]; iterator(item); } @azat_co 27 webapplog.com Iterating over an Object CoffeeScript: JavaScript: var key, value; for key, value of object iterator(value) ! for (key in object) { value = object[key]; iterator(value); } @azat_co 28 webapplog.com Iterators / Comprehensions (for loops) II Many options: ! iterator (item) for item in arrayObject ! iterator item for item in arrayObject ! iterator item for item in arrayObject when item > 0 ! ! ! ! ! ! @azat_co 29 webapplog.com Class Declaration • In JavaScript classes are absent at all! • CoffeeScript eloquently implements Pseudo-classical inheritance pattern: “new” and capitalized name (“new Animal”, “new Vehicle”, etc.) • Pseudo-classical is hard and cumbersome without CS • CoffeeScript “constructor” method and “super” call @azat_co 30 webapplog.com Class Example CoffeeScript: class Vehicle constructor: (@name) -> move: (meters) -> console.log @name + " moved #{meters} miles.” ! camry = new Vehicle "Camry" camry.move(50) Output: Camry moved 50 miles. @azat_co 31 webapplog.com Class Example JavaScript: var Vehicle, camry; ! Vehicle = (function() { function Vehicle(name) { this.name = name; } ! Vehicle.prototype.move = function(meters) { return console.log(this.name + (" moved " + meters + " miles.")); }; ! return Vehicle; ! })(); ! camry = new Vehicle("Camry"); ! camry.move(50); 2x: 6 vs 12 lines of code! @azat_co 32 webapplog.com Other CoffeeScript Goodies • Splats (e.g., “options…”) • Conditions (if, isnt, not, and, or, unless) • Arrays and their slicing (arr = [1..10], slicedArr = arr[2..4]) @azat_co 33 webapplog.com CoffeeScript: The Good Parts Summary • Syntax: curly braces, parentheses and semicolons • Function Declaration: -> and => • Scoping: automatic var • Iterators / Comprehensions: replacement of for loops • Class Declaration: class operand @azat_co 34 webapplog.com CoffeeScript: Not So Good Parts • Learning: 1-2 day, free online ebooks • Compilation: extra build step (use Grunt or similar) • Parentheses: optional and cause misinterpretation • Debugging: use source-maps @azat_co 35 webapplog.com CoffeeScript of My Dreams https://github.com/michaelficarra/coffee-of-my- dreams @azat_co webapplog.com How to Get Started $ npm install -g coffee-script $ coffee >… @azat_co 37 webapplog.com Companies that use CoffeeScript • GitHub • Airbnb (mobile) • Dropbox • HotelTonight • DocuSign • Basecamp (mobile) @azat_co 38 webapplog.com Further Reading CoffeeScript FUNdamentals: The Better JavaScript http://bit.ly/1nD4dE3 @azat_co 39 webapplog.com CoffeeScript Ebooks • The Little Book on CoffeeScript (free onine) • CoffeeScript Cookbook (free online) • Smooth CoffeeScript (free online) • CoffeeScript Ristretto (free online) @azat_co 40 webapplog.com Future / Alternatives • Dart (early stage) • TypeScript: MicroSoft project • ECMAScript 6: be careful with old browsers, use shims, fully available after June 2015 • Sweet.js: macros! @azat_co 41 webapplog.com Conclusions • Good for enterprise and large team, because it’s easer to have common style, e.g., https://github.com/styleguide/ javascript • Good for developers new to JavaScript and those coming from OOP languages (Java, Ruby) • Cross-browser / old browser support • More productive and happier developers (after learning) • Tested, robust, and available now • Awesome with Backbone.js and Underscore.js @azat_co 42 webapplog.com Session Summary • Native JavaScript Issues • CoffeeScript: The Good Parts • How to Get Started • Future / Alternatives • Conclusions @azat_co 43 webapplog.com Discussion and Q&A Time Questions, thoughts and experiences? @azat_co 44.
Recommended publications
  • Marketing Cloud Published: August 12, 2021
    Marketing Cloud Published: August 12, 2021 The following are notices required by licensors related to distributed components (mobile applications, desktop applications, or other offline components) applicable to the services branded as ExactTarget or Salesforce Marketing Cloud, but excluding those services currently branded as “Radian6,” “Buddy Media,” “Social.com,” “Social Studio,”“iGoDigital,” “Predictive Intelligence,” “Predictive Email,” “Predictive Web,” “Web & Mobile Analytics,” “Web Personalization,” or successor branding, (the “ET Services”), which are provided by salesforce.com, inc. or its affiliate ExactTarget, Inc. (“salesforce.com”): @formatjs/intl-pluralrules Copyright (c) 2019 FormatJS Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    [Show full text]
  • Coffeescript Accelerated Javascript Development.Pdf
    Download from Wow! eBook <www.wowebook.com> What readers are saying about CoffeeScript: Accelerated JavaScript Development It’s hard to imagine a new web application today that doesn’t make heavy use of JavaScript, but if you’re used to something like Ruby, it feels like a significant step down to deal with JavaScript, more of a chore than a joy. Enter CoffeeScript: a pre-compiler that removes all the unnecessary verbosity of JavaScript and simply makes it a pleasure to write and read. Go, go, Coffee! This book is a great introduction to the world of CoffeeScript. ➤ David Heinemeier Hansson Creator, Rails Just like CoffeeScript itself, Trevor gets straight to the point and shows you the benefits of CoffeeScript and how to write concise, clear CoffeeScript code. ➤ Scott Leberknight Chief Architect, Near Infinity Though CoffeeScript is a new language, you can already find it almost everywhere. This book will show you just how powerful and fun CoffeeScript can be. ➤ Stan Angeloff Managing Director, PSP WebTech Bulgaria Download from Wow! eBook <www.wowebook.com> This book helps readers become better JavaScripters in the process of learning CoffeeScript. What’s more, it’s a blast to read, especially if you are new to Coffee- Script and ready to learn. ➤ Brendan Eich Creator, JavaScript CoffeeScript may turn out to be one of the great innovations in web application development; since I first discovered it, I’ve never had to write a line of pure JavaScript. I hope the readers of this wonderful book will be able to say the same. ➤ Dr. Nic Williams CEO/Founder, Mocra CoffeeScript: Accelerated JavaScript Development is an excellent guide to Coffee- Script from one of the community’s most esteemed members.
    [Show full text]
  • Chapter 1: Introduction to the Pencil Code Environment
    Chapter 1: Introduction to the Pencil Code Environment In this manual we will show how to use Pencil Code to explore programming. Pencil Code is a free programming tool available at pencilcode.net. Pencil Code was developed by Google engineer David Bau together with his son Anthony Bau, with open-source contributions from many others. Two Ways of Looking at a Program There are two ways of viewing a program. A computer user sees a program by looking at its output. A programmer works with a program’s source code. In Pencil Code, the screen is split into two halves, with the source code on the left and the output on the right. You run programs by by pressing the “play” button in the middle. The Pencil Code interface splits the screen, showing source code on the left and output on the right. The play button in the center runs the code and produces output. Languages and Libraries in Pencil Code Pencil Code supports code in both blocks and text using mainstream web programming languages and useful libraries including: • HTML, the standard HyperText Markup Language for the web. • JavaScript, the standard programming language of web browsers. • CSS, the standard Cascading Style Sheet language for visual styles on the web. • jQuery, a popular library that simplifies programming interactive websites. • CoffeeScript, a language that lets you do more with less typing than JavaScript. • jQuery-turtle, which extends jQuery to simplify graphics and animation for novices. With Pencil Code, students can use these technologies to create web applications with global visibility and impact while exploring fundamental concepts in computational thinking.
    [Show full text]
  • Coffeescript Accelerated Javascript Development, Second Edition
    Extracted from: CoffeeScript Accelerated JavaScript Development, Second Edition This PDF file contains pages extracted from CoffeeScript, published by the Prag- matic Bookshelf. For more information or to purchase a paperback or PDF copy, please visit http://www.pragprog.com. Note: This extract contains some colored text (particularly in code listing). This is available only in online versions of the books. The printed versions are black and white. Pagination might vary between the online and printed versions; the content is otherwise identical. Copyright © 2015 The Pragmatic Programmers, LLC. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form, or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior consent of the publisher. The Pragmatic Bookshelf Dallas, Texas • Raleigh, North Carolina CoffeeScript Accelerated JavaScript Development, Second Edition Trevor Burnham The Pragmatic Bookshelf Dallas, Texas • Raleigh, North Carolina Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and The Pragmatic Programmers, LLC was aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf, PragProg and the linking g device are trade- marks of The Pragmatic Programmers, LLC. Every precaution was taken in the preparation of this book. However, the publisher assumes no responsibility for errors or omissions, or for damages that may result from the use of information (including program listings) contained herein. Our Pragmatic courses, workshops, and other products can help you and your team create better software and have more fun.
    [Show full text]
  • Webinar - Kick Start Your Widget Development
    Webinar - Kick start your widget development Kickstart your widget development Jelte Lagendijk | Feb 5 2016 Thank you for joining the Expert webinar "Kickstart your widget development". My name is Jelte Lagendijk, I am a JavaScript developer for the Community team at Mendix. At the Community team we want to enable our Community to create content. In this particular case, we want to enable you as a JavaScript developer to develop your own widgets. For this webinar we expect you to know how a widget works, have technical knowledge about JavaScript and have a basic understanding what Node.js is. Agenda Agenda Scaffolding a widget in a minute Speeding up development using Grunt Updating existing widgets Deprecations (Bonus) Demo time! This webinar will demonstrate new tooling: the use of the Yeoman widget generator and Grunt. We’ll not go in-depth on how a widget works. We have a tutorial on how to create your first widget: https://world.mendix.com/display/howto6/Creating+a+Basic+Hello+World+Custom+Widget Scaffolding (1) Scaffolding (1) Previously Brackets + Mendix widget plugin . Visual and easy to use . Has a few bugs that are hard to fix . Less support – smaller community Introducing a new tool: Yeoman generator . Editor independent . Faster . Better maintainable The Developing a widget using Brackets how-to can be found here: https://world.mendix.com/display/howto6/Getting+started+with+the+Widget+Development +Plugin+for+Adobe+Brackets Scaffolding 2 Scaffolding (2) Yeoman is a scaffolding tool running on top of Node.js + Client uses generators as templates to scaffold various web applications or frameworks .
    [Show full text]
  • Learning HTML5 Game Programming Addison-Wesley Learning Series
    Learning HTML5 Game Programming Addison-Wesley Learning Series Visit informit.com/learningseries for a complete list of available publications. The Addison-Wesley Learning Series is a collection of hands-on programming guides that help you quickly learn a new technology or language so you can apply what you’ve learned right away. Each title comes with sample code for the application or applications built in the text. This code is fully annotated and can be reused in your own projects with no strings attached. Many chapters end with a series of exercises to encourage you to reexamine what you have just learned, and to tweak or adjust the code as a way of learning. Titles in this series take a simple approach: they get you going right away and leave you with the ability to walk off and build your own application and apply the language or technology to whatever you are working on. Learning HTML5 Game Programming A Hands-on Guide to Building Online Games Using Canvas, SVG, and WebGL James L. Williams Upper Saddle River, NJ • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London • Munich • Paris • Madrid Cape Town • Sydney • Tokyo • Singapore • Mexico City Many of the designations used by manufacturers and sellers to distinguish their products Associate are claimed as trademarks. Where those designations appear in this book, and the publish- Publisher er was aware of a trademark claim, the designations have been printed with initial capital Mark Taub letters or in all capitals. Senior Acquisitions The author and publisher have taken care in the preparation of this book, but make no Editor expressed or implied warranty of any kind and assume no responsibility for errors or omis- Trina MacDonald sions.
    [Show full text]
  • Jquery Cloudflare Your Company Via Grunt-Contrib-Uglify Used to Build That Jquery
    JavaScript & Security get married Yan Zhu NCC Group SF Open Forum 9/17/15 F YEAH RUSTIC PENNSYLVANIA WEDDING THEME!! About me: ● Security Engineer at Yahoo! by day ● EFF Technology Fellow (Let’s Encrypt, HTTPS Everywhere) ● That’s a real photo of me -> Our story 09.??.1995 08.19.15 JavaScript released! Started investigating JS optimizer security as a side project. ??.??.1991 01.05.11 08.23.15 I was born! Wrote my first line of Got bored and mostly JavaScript. stopped working on this project. This talk is about JavaScript. (sorry not sorry) JAVASCRIPT What runs JS? ● Browsers ● Servers (node/io.js) ● Soon: everything Inspiration GET YOUR COPY TODAY PoC||GTFO 0x08 https://www.alchemistowl.org/pocorgtfo/ “No amount of source-level verification or scrutiny will protect you from using untrusted code. In demonstrating the possibility of this kind of attack, I picked on the C compiler. I could have picked on any program-handling program such as an assembler, a loader, or even hardware microcode. As the level of program gets lower, these bugs will be harder and harder to detect.” Ken Thompson, Reflections on Trusting Trust (1984) seen in the wild! JS isn’t “compiled,” but ... ● Transpilers to JS exist for every major language ● JS sugar (CoffeeScript, Coco, LiveScript, Sibilant) ● Optimizers (Closure, Uglify) ● Static typing (Closure, Flow, TypeScript, asm.js) ● Language extensions (React’s JSX) ● ES6 -> ES5 converter (Babel) more at https://github.com/jashkenas/coffeescript/wiki/list-of-languages-that- compile-to-js Let’s get hackin’ Step 1: Pick a JS library Who uses UglifyJS2? INSERT OVERCROPPED LOGO gruntjs jquery cloudflare your company via grunt-contrib-uglify used to build that jquery.
    [Show full text]
  • Open Source on IBM I Webinar Series Day 2 ERWIN EARLEY ([email protected]), SR
    Open Source on IBM i Webinar Series Day 2 ERWIN EARLEY ([email protected]), SR. SOLUTIONS CONSULTANT, PERFORCE, NOVEMBER 2019 2 | COMMON Webinar Series: Open Source on IBM i | November 2019 zend.com Day 1 Review • Introduction to Open Source on IBM i • Why is Open Source on IBM i Important • Understanding the PASE environment as the enabler of Open Source on IBM i • Getting Familiar with the PASE environment 2 | Zend by Perforce © 2019 Perforce Software, Inc. zend.com 3 | COMMON Webinar Series: Open Source on IBM i | November 2019 zend.com Day 2 Agenda • Setting up OSS EcoSystem on IBM i – ACS version • Exploring Containers on IBM i • Managing Open Source on IBM i • Exploring Open Source Programming Languages ▪ Integration with Db2 and ILE • After-Hours Lab: Containers & Setting up Development Environment • After-Hours Lab: Open Source Programming Languages 3 | Zend by Perforce © 2019 Perforce Software, Inc. zend.com IBM Systems Technical University © 3 4 | COMMON Webinar Series: Open Source on IBM i | November 2019 zend.com Setting up OSS Ecosystem on IBM i – ACS Version 4 | Zend by Perforce © 2019 Perforce Software, Inc. zend.com 5 | COMMON Webinar Series: Open Source on IBM i | November 2019 zend.com The directory structure Before installing the Open Source ecosystem / dev home lib sbin tmp usr var Directory Contents bin Commands dev Device Files etc Configuration files home User Home Directories lib Libraries pkgs Package files / commands sbin Privileged commands tmp Temporary files usr Utilities & Applications var Variable files
    [Show full text]
  • Webassembly: High Speed at Low Cost for Everyone
    WebAssembly: high speed at low cost for everyone Andreas Rossberg Google [email protected] Abstract instructions that are widely available on modern CPUs. They map WebAssembly is a new language- and platform-independent bi- to machine code in a predictable manner and with predictable nary code format bringing native-code performance to the web. We performance on all relevant platforms. present its design and report our experience with specifying its se- High-level Data Flow. WebAssembly is an expression language: mantics via a reference interpreter written in OCaml, that currently it is defined as an AST in which machine operators return values serves as a proxy for a future formal specification. and can be used as operands to other operators. The binary format is a post-order serialisation of this AST. This design provides for 1. Introduction more compact binaries than 3-address code or SSA form would. Like it or not, the Web has become one of the most important Low-level Control Flow. Control flow is available mainly in the platforms for application development. Yet there is only one pro- form of sequential blocks and branch instructions, plus a structured gramming language that the Web understands: JavaScript. Liter- conditional. However, branches are still structured: they can only ally hundreds of compilers have been written that translate almost break out of an expression, not jump into one. This prevents ir- every imaginable language into JavaScript in order to run on the reducible control flow and associated complications (it’s the pro- Web [1]. Unfortunately, JavaScript is not the most delightful com- ducers’ responsibility to transform irreducible control flow into pilation target: it’s brittle and often slow in unpredictable ways, all structured form [6]).
    [Show full text]
  • How to Pick Your Build Tool
    How to Pick your Build Tool By Nico Bevacqua, author of JavaScript Application Design Committing to a build technology is hard. It's an important choice and you should treat it as such. In this article, based on the Appendix from JavaScript Application Design, you'll learn about three build tools used most often in front-end development workflows. The tools covered are Grunt, the configuration-driven build tool; npm, a package manager that can also double as a build tool; and Gulp, a code-driven build tool that's somewhere in between Grunt and npm. Deciding on a technology is always hard. You don't want to make commitments you won't be able to back out of, but eventually you'll have to make a choice and go for something that does what you need it to do. Committing to a build technology is no different in this regard: it's an important choice and you should treat it as such. There are three build tools I use most often in front-end development workflows. These are: Grunt, the configuration-driven build tool; npm, a package manager that can also double as a build tool; and Gulp, a code-driven build tool that's somewhere in between Grunt and npm. In this article, I'll lay out the situations in which a particular tool might be better than the others. Grunt: The good parts The single best aspect of Grunt is its ease of use. It enables programmers to develop build flows using JavaScript almost effortlessly. All that's required is searching for the appropriate plugin, reading its documentation, and then installing and configuring it.
    [Show full text]
  • Automated Large-Scale Multi-Language Dynamic Program
    Automated Large-Scale Multi-Language Dynamic Program Analysis in the Wild Alex Villazón Universidad Privada Boliviana, Bolivia [email protected] Haiyang Sun Università della Svizzera italiana, Switzerland [email protected] Andrea Rosà Università della Svizzera italiana, Switzerland [email protected] Eduardo Rosales Università della Svizzera italiana, Switzerland [email protected] Daniele Bonetta Oracle Labs, United States [email protected] Isabella Defilippis Universidad Privada Boliviana, Bolivia isabelladefi[email protected] Sergio Oporto Universidad Privada Boliviana, Bolivia [email protected] Walter Binder Università della Svizzera italiana, Switzerland [email protected] Abstract Today’s availability of open-source software is overwhelming, and the number of free, ready-to-use software components in package repositories such as NPM, Maven, or SBT is growing exponentially. In this paper we address two straightforward yet important research questions: would it be possible to develop a tool to automate dynamic program analysis on public open-source software at a large scale? Moreover, and perhaps more importantly, would such a tool be useful? We answer the first question by introducing NAB, a tool to execute large-scale dynamic program analysis of open-source software in the wild. NAB is fully-automatic, language-agnostic, and can scale dynamic program analyses on open-source software up to thousands of projects hosted in code repositories. Using NAB, we analyzed more than 56K Node.js, Java, and Scala projects. Using the data collected by NAB we were able to (1) study the adoption of new language constructs such as JavaScript Promises, (2) collect statistics about bad coding practices in JavaScript, and (3) identify Java and Scala task-parallel workloads suitable for inclusion in a domain-specific benchmark suite.
    [Show full text]
  • Spring Semester 2020 - Week 13
    Comp 324/424 - Client-side Web Design Spring Semester 2020 - Week 13 Dr Nick Hayward Systems Management - Build Tools & Project Development Extra notes Systems Environments & Distributions Build first - overview and usage Grunt basics integrate with project outline and development integrate with project release Webpack setup for local project basic usage assets for local project … JavaScript - Prototype intro along with the following traits of JS (ES6 …), functions as first-class objects versatile and useful structure of functions with closures combine generator functions with promises to help manage async code async & await… prototype object may be used to delegate the search for a particular property a prototype is a useful and convenient option for defining properties and functionality accessible to other objects a prototype is a useful option for replicating many concepts in traditional object oriented programming JavaScript - Prototype understanding prototypes in JS, we may create objects, e.g. using object-literal notation a simple value for the first property a function assigned to the second property another object assigned to the third object let testObject = { property1: 1, prooerty2: function() {}, property3: {} } as a dynamic language, JS will also allow us to modify these properties delete any not required or simply add a new one as necessary this dynamic nature may also completely change the properties in a given object this issue is often solved in traditional object-oriented languages using inheritance in JS, we can use prototype to implement inheritance JavaScript - Prototype basic idea of prototypes every object can have a reference to its prototype a delegate object with properties - default for child objects JS will initially search the onject for a property then, search the prototype i.e.
    [Show full text]