Programming Languages are Only the Beginning

Programming languages are tools to express programmer intentions. Why, then, do we suffer the indignities of inelegant notation when we might, instead, bend the language to capture our meaning better?

If you’ve written code, you’ve likely accessed the first and last elements of an array:

var grades = [80, 90, 85];
grades[0]; // 80
grades[grades.length - 1]; // 85

How many times have you written [0]? [arr.length – 1]? Or worse, [arr.length], resulting in an off-by-1 error?

What we mean here is “the first element” and “the last element”. Unfortunately, JavaScript doesn’t provide a method on Array objects to extract the first or last elements.

> grades.first()
< TypeError: grades.first is not a function. (In 'grades.first()', 'grades.first' is undefined)

So let’s update the language to clarify that meaning. JavaScript is a prototypal language: There is an Array prototype which all instances of arrays are based on. By adding methods to the Array prototype, we immediately add those methods to every instance of an array.

Array.prototype.first = function() { return(this[0]); }
Array.prototype.last = function() { return(this[ this.length - 1 ]); }

Now, we can easily and without fear of off-by-1 errors access the first and last elements:

> grades.first()
< 80
> grades.last()
< 85

But let’s not stop there… what other functions might it be useful to have? How would you enhance the language to provide those functions?

Any function you write provides an opportunity to make your intentions clearer and to create a domain specific language that allows you to express solutions to problems that interest you more naturally. Use it to your advantage.

FizzBuzz in JavaScript

Functions are first class objects. Functions establish closures.

Problem: Given a range of positive, non-zero integers, output “Fizz” if the number is evenly divisible by 3, output “Buzz” is the number is evenly divisible by 5, and output “FizzBuzz” if the number is evenly divisible by both 3 and 5; otherwise, output the number.

divisor = function(number, string) {
  return(function(d) {
    if (d % number === 0) {return(string)} else {return("")};

mod3er = divisor(3, "Fizz");
mod5er = divisor(5, "Buzz");

for(i = 1; i <= 100; i = i + 1) {
    res = mod3er(i) + mod5er(i);
    console.log(res === "" ? i : res);

FizzBuzz in R

Functions are first class objects. Functions establish closures.

Problem: Given a range of positive, non-zero integers, output “Fizz” if the number is evenly divisible by 3, output “Buzz” is the number is evenly divisible by 5, and output “FizzBuzz” if the number is evenly divisible by both 3 and 5; otherwise, output the number.

divisor <-
  function(number, string) {
    function(d) {
      if (d %% number == 0) string else ""

mod3er <- divisor(3, "Fizz")
mod5er <- divisor(5, "Buzz")

fizzbuzz <- 
  function(i) {
    res <- paste0(mod3er(i), mod5er(i))
    ifelse(res == "", i, res)

sapply(1:100, fizzbuzz)

What Students Say

A note to myself

I believe that I can be a better educator through reflection and active engagement. I believe that I can better serve my students and colleagues by being honest with them. I believe that reflection, engagement, and honesty can help other educators improve their praxis, should they feel so inclined.

It has always been about the students

A note to students

Continue reading

Mike Monteiro @ WebStock ’13: How Designers Destroyed the World

Mike offers some blunt and intense advice about maintaining absolute integrity in one’s work. While he’s addressing his concerns to designers, I take his advice to apply equally well to computer programmers, UX, UI, teachers… any profession where you’re creating… and really, shouldn’t that be all professions?

Visons of Science

I’m supporting a friend with a great idea that’s a little less than 12 hours old….

My friend and fellow computer science education researcher, Brian Danielak, has worked hard today to create what we hope will be the first of many video podcasts to promote high quality visualizations in science.

He and his team would like feedback ASAP on their initial effort.

If you have ~25 minutes tonight (or as soon as you can) watch his ‘cast and provide feedback via the form underneath the video…

Why are Teachers Leaving Teaching?

The Washington Post– and many other outlets– recently reported on the resignation letter of Gerald J. Conti, a social studies teacher at Westhill High School, Syracuse, New York. Mr. Conti has 40 years of teaching experience, but feels that teaching has been marginalized in the increasingly aggressive drive for standardization of curricula, instruction, and assessment.

With regard to my profession, I have truly attempted to live John Dewey’s famous quotation (now likely cliché with me, I’ve used it so very often) that “Education is not preparation for life, education is life itself.” This type of total immersion is what I have always referred to as teaching “heavy,” working hard, spending time, researching, attending to details and never feeling satisfied that I knew enough on any topic. I now find that this approach to my profession is not only devalued, but denigrated and perhaps, in some quarters despised. STEM rules the day and “data driven” education seeks only conformity, standardization, testing and a zombie-like adherence to the shallow and generic Common Core, along with a lockstep of oversimplified so-called Essential Learnings.
Gerald J. Conti

Making Space for Others

Whatever your personal level of achievement, it’s vital that you remember to make space for others to stand up and stand out. Here are three examples of celebrities rising to that challenge.

Michael Bublè and Sam Hollyman in 2010

Billy Joel and Michael Pollack– a Vanderbilt University student in 2013

Bono of U2 and Adam Bevell– a self-taught, blind guitarist– in 2011

Thank you to Christie Veitch of Modular Robotics and Brian Danielak of the University of Maryland for reminding me.

Oppa Adjunct Style: How Schools are Cheating Teachers and Students

“Adjuncts are not regular members of the faculty; we are paid an hourly rate for time spent in the classroom. We are not paid to advise students, grade papers, or prepare materials or lectures for class. . . . To ensure that we remain conscious of the adjunctification of CUNY, we ask that you do not call us ‘Professor.'”

To learn more about the source and context, be sure to read The Village Voice’s article on the outsourcing of education.

Lawrence Lessig: We the People, and the Republic we must reclaim

My sense is that we all often throw up our hands and imagine that there’s nothing we can do, whether it be about our country or our organizations or ourselves.

We should fear failure: the failure to try and the failure to behave in a moral, principled way; everything else is ego.

CSC 111 Introduction to Computer Science

Location: College of Saint Rose
Term(s): Fall 2012, Spring 2013
Class size: ~20

In this course, students develop their computational thinking skills through guided inquiry discussions. Topics such as the nature of computation, binary, boolean logic, computer architecture, networking, and programming are introduced. Students are challenged to reverse engineer programming solutions in order to explore functional decomposition and other computational concepts.

Prerequisite: None
Credits: 3

EPSY 687 Assessment and Evaluation for STEM educators

Location: University at Albany, School of Education, Department of Educational & Counseling Psychology
Term(s): Spring 2013
Class size: TBD
Co-taught with Paul Zachos

Backward design, formative assessment and action research will be applied to practical problems chosen by participants to develop critical assessment and evaluation concepts and skills for STEM-related education. The course will support participants in creating innovative lessons or productively addressing classroom, school, and state challenges such as high-stakes testing and professional performance reviews.

Prerequisite: Participants must be actively teaching during the course. Participants are expected to build and refine a learning module related to their own teaching, to conduct and share the results of assessments of student learning on a monthly basis and to work in consultation with fellow participants and course instructors to produce and evaluate a completed module. This work will be in lieu of extensive readings and a formal paper.
Credits: 3
Format: Online with regular synchronous chat sessions