Text

JK navigation

The pretty cool thing for each of developers is using effective using of keyboard.

JK is classical keyboard approach for navigation (Are you using vi-clone?)

All of modern websites and applications should support it, like:

Text

JavaScript anonymous recursion and Y combinator

Today i was faced with necessity of implementation recursion of anonymous delegate in C#. As i find there is the kind of combinators, called Y combinator (fixed point combinator) that can enter recursion into languages, whose don’t support it.

There is interesting article how to implement Y combinator for C# http://blogs.msdn.com/b/wesdyer/archive/2007/02/02/anonymous-recursion-in-c.aspx

And one interesting thing - ECMAScript supports it out-of-box:

function makeFactorialFunc() {
   alert('making a factorial function!');
   return function(x) {
      if (x <= 1)
         return 1;
      return x * arguments.callee(x - 1);
   };
}

var result = makeFactorialFunc()(5); // returns 120 (5 * 4 * 3 * 2 * 1)

arguments.callee - it’s the key for anonymous recursion

Text

How to extend existing JavaScript function

I have some issues with extensibility of one javascript framework.

One of the issues was how to extend the existing javascript function:

var result = openDialog(parameters);
result.close 
//this function calls by external framework code

For the first I was trying something like that:

var close = result.close;

result.close = function(param) { 
    alert('test'); 
    close(param); 
}

But this code wasn’t working well, caused by incorrect context for the function in this case.

After a little thinking about I found the solution:

var close = result.close;

result.close = function(param) { 
    alert('test'); 
    result.close = close; 
    result.close(param); 
}

But it was a little strange. After a little more time of research I was suggested to implement it just like:

var close = result.close;

result.close = function(param) { 
    alert('test'); 
    close.call(result); 
}

The internal javascript function call calls function and set the context this by the given parameter.

Text

Create TextMate Bundle for Node.js

Recently i was playing with node.js. It’s wonderful and perspective technology. Today i want to describe my environment for tests.

For the first - it’s TextMate, this editor allows you to write code with more comfortable way with nice templates engine.

While playing you need to change your focus all time from one window to another (editor, console and browser) and it’s make its process less nice.

TextMate makes it possible to write custom bundles for several types. And we will automate running node.js environment and browser by hotkey into TextMate.

For this you need to do the follow steps:

  1. TextMate - Bundles - Bundle Editor - Show Bundle Editor - New Bundle
  2. After that you will create new command “Run” (command + R)
  3. Play with references for autosaving and text output
  4. Insert into commands window the follow text:
#!/usr/bin/env ruby

require ENV['TM_SUPPORT_PATH'] + '/lib/escape.rb'

def terminal_script_filepath
  %|tell application "Terminal"
      activate
      do script "open 'http://localhost:8000'"
      do script "node #{e_as(e_sh(ENV['TM_FILEPATH']))}"
    end tell|
end

open("|osascript", "w") { |io| io << terminal_script_filepath }

Be careful with localhost:8000 with this configuration - it’s my favorite port.

After that steps - your environment ready for comfortable playing.

References:

Text

Server-Side JavaScript

Several years ago when I talked with my colleagues about a feature perspectives of web-development there was a dispute about polyglot-style. Typical web developer needs to know a stack of languages: server-side language (Python, Java), JavaScript and SQL, sequence goes on. We have 2 different positions in our dispute.

Situation will never be changed.

And may be thats right position. Last years there are absolutely no changes into job requirements for web developers. You use specific languages for specific types of work. SQL for work with data, Python for domain logic and infrastructure, JavaScript for client interactivity. That’s all on their places. 

Stack become mono language.

Client side. There are some technologies that came in the middle of 00s: GWT, Script#. That possibilities eliminated needs of using javascript and introduced more possibilities for closed integration into day-by-day development process (I mean one environmental unit-testing and similar things).

SQL. The most outstanding step that I see was introduction of LINQ into .NET. But now all web frameworks have their own data query language: Active Record, Django data models, etc.

But in our dispute we didn’t touch nice idea: each web developer know javascript, and it will became single language for web development.

And that we see today:

  • All NoSQL engines use REST for data queries
  • Server-side JavaScript libraries and engines increase more and more popularity. For example node.js - right concept in right time.
  • jQuery - industrial standart

Welcome to the new era, era of JavaScript!

Text

yep, I’m soft(ware developer)

You are not your programming language. You are not the web stack you’ve learned. You are not your text editor you write your code in. You are the all crafting, multilingual developer of the world! (C)

http://whatupdave.tumblr.com/post/1170718843/leaving-net