In this post I would like to tell about the highly underrated functional programming pattern named “Currying“. In this article I’ll concentrate on the practical application of this pattern.
Archives for Javascript
Javascript snippet: “asUtfCodes” function
Sometimes I need to include escaped string sequence to my code (mostly for unit tests), because clearcase (VCS I forced to use by my current employer) chokes when it encounters UTF-8 -encoded source code. In order to make my life easier, I wrote a small function that transforms a given input string to it’s escaped [...]
CommonJS: the best is yet to come
CommonJS is an approach to build reliable cross-interpreter library that provides developers with module loaders, package management facility, charset converters, unit-testing framework and much more. Discussions: here and here.
Web Workers
Web Workers is an approach to multitasking in JavaScript. Web Workers is drafted and committed for review for being added to HTML5 standard. Web Workers now used in node.js.
In-browser code editing
In-browser code editing now available for modern browsers. Wow!
Inheritance is evil
Quite an interesting article related to overusing inheritance pattern. Upd: Related problem with JDK’s Properties class. (Ru) Discussion related to composition vs inheritance. (Ru) Discussion “shall we drop inheritance support?”.
Rich HTML editing
Two articles by Olav Junker: Part 1 Part 2
Javascript benchmark in different engines
I’ve tried latest v8 benchmark in the following browsers: Chrome 5.0.391, Firefox 3.6.3, Opera 10.53 and QtWebKit 4.6 (qtsdk 2010.02) The results are as follows (in order of decreasing performance score): Chrome: 5308 Opera: 3243 QtWebKit: 2125 Firefox: 375
Pattern-matching in a functional way
Several days ago I needed an easy to use and easy to extend facility that performs pattern matching. I ended up with the following interface: // matcher function. To prevent situations when no pattern matches the object given, // it might be initialized as follows: // matcher = function() { throw new Error(“no applicable pattern [...]
when typeof string != string
Curious javascript sample. Consider the following code: var s = “asd” var f = function() { return typeof(this) } An expression typeof(s) returns “string” (as it is expected), but f.call(s) returns “object”! To make matters worse consider the following snippet: var s = “asd” var f = function() { return this instanceof String } An [...]
Posts