Posts

Showing posts from July, 2014

Summer Reading--This Is the Story of a Happy Marriage

Image
“The tricky thing about being a writer,” Ann Patchett writes in her memoir This Is the Story of a Happy Marriage (HarperCollins, 2013), “is that in addition to making art you also have to make a living.”   She had my attention with that first line in the first essay.   Her work here is a compendium of pieces published in a variety of magazines and journals over the years, and includes what I later discovered to be her most famous essay on the writing life:   “The Getaway Car:   A Practical Memoir about Writing and Life, ” which first appeared in an online publication called Byliner . Patchett began her life in letters at Seventeen magazine where she published several short fictional stories.   She asked her editor for a nonfiction assignment, figuring that at most she could publish one or two pieces of fiction in the magazine’s pages each year.   However, “A writer of nonfiction, on the other hand, could publish an article every issue, sometimes multiple ...

Dispatched and direct method calls in ECMAScript 5 and 6

There are two ways to call methods in JavaScript: via dispatch, e.g. obj.someMethod(arg0, arg1) directly, e.g. someFunc.call(thisValue, arg0, arg1) This blog post explains how these two work and why you will rarely call methods directly in ECMAScript 6. Dispatched method calls versus direct method calls Background: prototype chains Remember that each object in JavaScript is actually a chain of one or more objects ( [1] is a quick refresher of JavaScript OOP). The first object inherits properties from the later objects. For example, the prototype chain of an array ['a', 'b'] looks as follows: The instance, holding the elements 'a' and 'b' Array.prototype , the properties provided by the Array constructor Object.prototype , the properties provided by the Object constructor null (the end of the chain, so not really a member of it) You can examine the chain via Object.getPrototypeOf() : > var arr = ['a', 'b']; > var p = Ob...

Wait, What?--Short Attention Span Theater

Image
I’ve been noticing something in class the last few years and it disturbs me. When I started teaching years ago, I was told by my mentor teacher to change activities every twenty minutes within a lesson.   So, about halfway through the class hour, I would move from discussion to worksheet, from lecture to group work.   Occasionally, if the lesson allowed, I’d change three times an hour, moving from a quick explanation to group work to presentations.   When I did ignore my mentor’s advice and lectured the entire hour, or assigned individual work for the duration, the students became antsy around—you guessed it—the twenty minute mark. Now what I have noticed is that I must change activities three to four times an hour.   It is short attention span theater.   Often, things move so fast that I feel like we’ve all be inhaling helium or been caught up in a Charlie Chaplin flick.   No more than five complete sentences and we’re off to the races—seat work, group wo...

The roles of AngularJS and Polymer

A key feature of AngularJS 2.0 is its support for Web Components [1] . Google’s Polymer is a Web Component polyfill (enabling them on all current browsers) and a framework on top of Web Components. This blog post describes how the Angular team sees the roles of AngularJS and Polymer. The roles, according to the AngularJS team AngularJS 2.0 team member Rob Eisenberg recently explained the relationship between AngularJS and Polymer: “Angular is really designed around optimizing application development (including DI, routing, templating and decorator directives, more advanced databinding)” “while Polymer is really optimized around custom element development. So, it has basic templating and binding and a strong component model.” Therefore, Eisenberg expects people to implement cross-framework UI components either as pure Web Components or via Polymer. He thinks apps and app-specific components are more likely to be built in Angular. Are Polymer and AngularJS competing? Yes and no At Goo...

A JavaScript survival guide

Are you a programmer who is considering learning JavaScript, but unsure whether it is worth the pain? Then this blog post is for you: I argue that it is worth it and give tips for surviving the language. Why learn JavaScript? The present The main reason for choosing JavaScript is the breadth of its ecosystem: the web platform, Node.js, JSON, NoSQL databases, Cordova/PhoneGap, automating PhotoShop and many other apps, etc. Compared to Java, I like the interactivity of JavaScript and the web platform. It is easy to quickly try out things and to inspect what is currently going on. I also like the flexibility of the language. It means that where you have deep inheritance hierarchies and other relatively complex patterns in more static languages, you can often get by with more lightweight solutions in JavaScript. The future ECMAScript 6 [1] , the upcoming version of JavaScript fixes many of JavaScript’s problems: not enough data structures, limited built-in support for inheritance, no buil...

The five stages of coming to terms with JavaScript

The five stages of coming to terms with JavaScript are: Denial: “I won’t need this language.” Anger: “Why does the web have to be so popular?” Bargaining: “OK, at least let me compile a reasonable language to JavaScript.” Depression: “Programming is not for me, I’ll pursue a career in masonry, like I always wanted.” Acceptance: “I can’t fight it, I may as well prepare for it.”

React JSX via ECMAScript 6 template strings

Facebook’s React has an optional language extension that enables you to embed HTML inside JavaScript. This extension can make your code more concise, but it also breaks compatibility with the rest of the JavaScript ecosystem. ECMAScript 6 will have template strings [1] , which enable you to implement JSX (or something close to it) inside the language. Jonathan Raphaelson has done so and the result looks as follows. define(function(require) { ... var EchoComponent = React.createClass({ ... render: function() { return jsx` <div> <input ref='input' onChange='${this.handleChange}' defaultValue='${this.state.value}' /> ${this.state.value} </div> `; } }); return function() { ...

Writing In The Sciences

Image
This summer for the third year in a row I’m teaching a writing workshop for college students called Writing In The Sciences .   My students are all freshmen biological sciences majors who have recently graduated from high school or are transferring to a four-year institution from a junior college.   The program is part of a STEM grant, an acronym for science, technology, engineering, and mathematics. In previous years, I focused on writing practice.   Since the students come from a variety of educational programs from Advanced Placement and honors to mainstream college preparatory courses, from public high schools to charters, magnets, and private institutions, I wanted just to get them writing every day with drafts submitted at the end of the week for my review.   That way I could respond individually to each student’s writing, and formulate lessons to address specific areas needing attention involving the whole class.   This worked well for two years, but at ...