ENTRIES TAGGED "programming"

Dos and don’ts in JavaScript

A few best practices for when you're learning the language

With every programming language, there’s a list of do’s and don’ts and JavaScript is no exception. Some of these best practices are there for your protection (like always always always using semi-colons!); some to make your code more readable and less error-prone; and some to increase the efficiency of your code. Read more…

Comment

I just slipped on a banana peel named “this”

Keeping track of this in your JavaScript code

In JavaScript, the special variable this is used to refer an object. But which object this refers too depends on the code you’re executing and how this is used. So, a common problem for those learning JavaScript is keeping track of the value of this in different situations. You can be happily testing your code, and then – bam! Suddenly, things stop working, and you’re wondering what happened, not realizing that you’re assuming this is set to one value, when in fact, it’s an entirely different value. And, bugs caused by confusion about this are notoriously difficult to track down.
Read more…

Comment: 1
Four short links: 8 May 2014

Four short links: 8 May 2014

OpenStack Critique, Good Teaching, More Good Teaching, and Programming Sucks

  1. OpenStack: A Plea — critical take on OpenStack, also in this presentation. Notes the proliferation of inefficiency, devops bolted onto the side, and the long feedback cycle. You code differently when you have a pager. (via Sam Ramji)
  2. What Could Be More Interesting Than How The Mind Works? (Harvard) — the Steven Pinker story. A third ingredient of good teaching is overcoming “the curse of knowledge”: the inability to know what it’s like not to know something that you do know. (via Atul Gawande)
  3. Some Lecturing HeuristicsRealize further that your mood may be determined by only a few people. A smiling nodder will make you feel good, and you will do better. People reading newspapers will make you feel bad, and you will do worse. Do not permit people to do things that make you feel bad.
  4. Programming Sucks — every word is true.
Comment

What is that upside-down tree doing in my browser?

Start using JavaScript to create dynamic web pages by updating the DOM.

The secret to getting your web pages to do your bidding with code is to use JavaScript to manipulate the Document Object Model, or DOM. The DOM is an upside-down tree-like structure that the browser uses to represent your web page internally, and it’s by getting and setting values in the DOM that you can modify your web page in response to users doing things like clicking a button, moving the mouse, or dragging an element around.

Getting started with the DOM is easy once you understand how the browser translates your HTML into this internal structure made of objects. Once these objects are created, then you can manipulate them using a wide variety of properties and methods, to change the content of an element, to add a style to an element, or even remove an element from the page completely.

Read more…

Comment: 1
Four short links: 7 May 2014

Four short links: 7 May 2014

Internet Broadband, Open Radio, Excel Formulae in JS, and Block Chains

  1. Observations of an Internet MiddlemanFive of those congested peers are in the United States and one is in Europe. There are none in any other part of the world. All six are large Broadband consumer networks with a dominant or exclusive market share in their local market. In countries or markets where consumers have multiple Broadband choices (like the UK) there are no congested peers. Relevant as competition works for gigabit fibre to consumers.
  2. Open TXopen source firmware for RC radio transmitters. The firmware is highly configurable and brings much more features than found in traditional radios.
  3. formula.js — Excel formulae in Javascript. Waiting for someone to write a Apple 1 emulator in them.
  4. Minimum Viable Block ChainThe block chain is agnostic to any “currency”. In fact, it can (and will) be adapted to power many other use cases. As a result, it pays to understand the how and the why behind the “minimum viable block chain”.
Comment
Four short links: 5 May 2014

Four short links: 5 May 2014

After Search, Instrumenting Pompeii, Replaceable Work, and The Coding Adventure

  1. This is What Comes After Search (Quartz) — it’s “context”, aka knowing what you’re doing and thinking to the point where the device can tell you what you need to know before you search for it. Also known as the apotheosis of passive consumption.
  2. Wiretapping the Ruins of Pompeii — Pompeii on its way to being one of the most instrumented cities in the world, a mere two thousand years since it was last inhabited. (via Pete Warden)
  3. Technology is Taking Over English Departmentsbanausic—the kind of labor that can be outsourced to non-specialists. (via Courtney Johnston)
  4. phabricatorOpen software engineering platform and fun adventure game. TAKE AWESOME.
Comment

Wait, where is my variable defined?

Learn JavaScript scope so you always know where your variables are defined

You may have noticed that Head First JavaScript Programming is released! Now that the book is done, we’ve got a few more Head First JavaScript Programming teasers for you. The book is aimed at those of you who are learning JavaScript from the ground up, and our goal with these teasers is to tease out a few characteristics of the language that might surprise you, trip you up, or that you might want to pay special attention to as you learn.

Whether you’re coming to JavaScript from another language, or you’re learning JavaScript as your first language, the way scope works — that is, when and where your variables are defined — might surprise you. Scope in JavaScript isn’t always intuitive, and it’s easy to make some simple mistakes that can cause your code to work in unexpected ways.

Read more…

Comment
Four short links: 29 April 2014

Four short links: 29 April 2014

Robot Legs, CS in Classrooms, Go Robotics, and Game Programming

  1. Bionic Legs Let Patients Walk AgainThe Ekso costs about $100,000 and was purchased with a grant from Baptist Health Foundation. Chara Rodriguez, a physical therapist and neurologic clinical specialist at University Health System, called the machine “the Maserati of the rehab world.” (via Robot Economics)
  2. Roundup of CS in Education Systems (Economist) — Above all, the new subject will require teachers who know what they are doing. Only a few places take this seriously: Israel has about 1,000 trained computer-science teachers, and Bavaria more than 700. Mathematics and computer-science graduates generally choose more lucrative trades; the humanities and social-science graduates who will find themselves teaching coding will need plenty of support.
  3. gobot — Go framework for hardware and robotics comms, with Arduino, Sphero, (and more) backends.
  4. Game Programming Patterns — free online book with programming patterns for game developers.
Comment
Four short links: 22 April 2014

Four short links: 22 April 2014

In-Browser Data Filtering, Alternative to OpenSSL, Game Mechanics, and Selling Private Data

  1. PourOver — NYT open source Javascript for very fast in-browser filtering and sorting of large collections.
  2. LibreSSL — OpenBSD take on OpenSSL. Unclear how sustainable this effort is, or how well adopted it will be. Competing with OpenSSL is obviously an alternative to tackling the OpenSSL sustainability question by funding and supporting the existing OpenSSL team.
  3. Game Mechanic Explorer — helps learners by turning what they see in games into the simple code and math that makes it happen.
  4. HMRC to Sell Taxpayers’ Data (The Guardian) — between this and the UK govt’s plans to sell patient healthcare data, it’s clear that the new government question isn’t whether data have value, but rather whether the collective has the right to retail the individual’s privacy.
Comment
Four short links: 18 April 2014

Four short links: 18 April 2014

Interview Tips, Data of Any Size, Science Writing, and Instrumented Javascript

  1. 16 Interviewing Tips for User Studies — these apply to many situations beyond user interviews, too.
  2. The Backlash Against Big Data contd. (Mike Loukides) — Learn to be a data skeptic. That doesn’t mean becoming skeptical about the value of data; it means asking the hard questions that anyone claiming to be a data scientist should ask. Think carefully about the questions you’re asking, the data you have to work with, and the results that you’re getting. And learn that data is about enabling intelligent discussions, not about turning a crank and having the right answer pop out.
  3. The Science of Science Writing (American Scientist) — also applicable beyond the specific field for which it was written.
  4. earhornEarhorn instruments your JavaScript and shows you a detailed, reversible, line-by-line log of JavaScript execution, sort of like console.log’s crazy uncle.
Comment