Older blog entries for sness (starting at number 4851)

JavaScript (ES6) Has Tail Call Optimization - A Passion for Breaking Things - Brandon Benvie does JavaScript

JavaScript (ES6) Has Tail Call Optimization - A Passion for Breaking Things - Brandon Benvie does JavaScript: "What is a Tail Call and Why Should I Care About Optimizing It?

A tail call is a function call who's return value is used as the caller's return value. Example:

function factorial(remaining, accumulator){
if (remaining === 0) {
return accumulator;
}
return factorial(remaining - 1, remaining * accumulator); // <--- tail call
}
Without tail call optimization, every recursive call will add another frame to the call stack, eventually leading to memory exhaustion. JavaScript engines typically will fail at 10,000 - 30,000 levels of recursion with a RangeError."

'via Blog this'

Syndicated 2013-01-09 18:23:00 from sness

harmony:proper_tail_calls [ES Wiki]

harmony:proper_tail_calls [ES Wiki]: "We need to define when a call is in possible tail position for safety purposes, and proper tail position for liveness purposes. An implementation MAY implement a call in possible tail position as a proper tail call (PTC) and MUST implement a call in proper tail position as a PTC. (Loosely speaking, implementing a call as a PTC is also known as tail call optimization.) The old ES4 proposal for proper tail calls should be adapted to provide these definitions for ES-Harmony."

'via Blog this'

Syndicated 2013-01-09 18:23:00 from sness

When EC2 Hardware Changes Underneath You… | PiCloud Blog

When EC2 Hardware Changes Underneath You… | PiCloud Blog: "Amazon seems to have disabled the OSXSAVE feature at the hypervisor layer on their new Xeon E5-2665 based m2.* series of instances. This may just be because their version of the Xen hypervisor that manages these instances lacks support for handling AVX registers in context switching. But even if support does exist in the hypervisor, it makes sense to disable AVX for the m2.* family as long as there are Xeon X5550 based instances. Imagine compiling a program on an m2.xlarge EBS instance, thinking you had AVX support, and then upon stopping/starting the instance, finding that the program crashes, because your instance now runs on older hardware that doesn’t have AVX support! A downside of VM migration is that all your hardware must advertise the least common denominator of capabilities."

'via Blog this'

Syndicated 2013-01-09 17:59:00 from sness

Decorators and Functional Python

Decorators and Functional Python: "Decorators are one of Python's great features. In addition to their intrinsic usefulness in the language, they also help us to think in an interesting way — a functional way.

I intend to explain how decorators work from the ground up. We'll start by covering a few topics you'll need in order to understand decorators. After that, we'll dive in and explore a few simple decorators and how they work. Finally, we'll talk about some more advanced ways to use decorators, such as passing them optional arguments or chaining them together."

'via Blog this'

Syndicated 2013-01-09 17:41:00 from sness

Two star programming

Two star programming: "I wrote up a benchmark where I remove every other element from a ten million list of integers. My results (clang, MacBook Pro 2012):

vector      :      10 ms
list        :     422 ms
forward_list:    1327 ms
C list      :     419 ms

So std::vector about 40x quicker than any linked list. std::forward_list was surprisingly slow.

"

'via Blog this'

Syndicated 2013-01-09 17:40:00 from sness

The Story of the PING Program

The Story of the PING Program: "I named it after the sound that a sonar makes, inspired by the whole principle of echo-location. In college I'd done a lot of modeling of sonar and radar systems, so the "Cyberspace" analogy seemed very apt. It's exactly the same paradigm applied to a new problem domain: ping uses timed IP/ICMP ECHO_REQUEST and ECHO_REPLY packets to probe the "distance" to the target machine."

'via Blog this'

Syndicated 2013-01-09 17:37:00 from sness

Don't worry, it's just ESD! (Electrostatic Discharge) - YouTube

Don't worry, it's just ESD! (Electrostatic Discharge) - YouTube: "