C Extensions with Ruby

Angelegt von suung Thu, 24 Mar 2011 19:47:00 GMT

This article

Javascript fuer Einsteiger

Angelegt von suung Sat, 18 Dec 2010 05:58:00 GMT

Preprocessing JavaScript

Angelegt von niklas Thu, 07 Oct 2010 10:16:00 GMT

Just found this page and thought I'd give it a try. What I wanted to have was a less verbose way to define classes.

So here's a macro to conveniently define classes:

#define class(klass, ...) var klass = function(__VA_ARGS__)
Use it like this:
// class definition
class (Foo, bar) { // Foo: name of the class ; bar: first argument of initializer. can take arbitrary args.
  this.bar = bar;
};
// instantiation
var x = new Foo("xyz");
x.bar; //=> "xyz";
When processing that code with CPP (give it all the above code incl. macro as input) ...
/usr/bin/cpp -P -undef -Wundef -std=c99 -nostdinc -Wtrigraphs -fdollars-in-identifiers -C 
... this is what comes out (comments stripped):
var Foo = function(bar) {
  this.bar = bar;
}

var x = new Foo("xyz");
x.bar;

Now this is pretty convenient, but not the whole story. Here's how I'd like to define a method:

class(Foo) {
  def(bar, arg) {
    alert(arg);
  }
}

var x = new Foo();
x.bar("xyz"); // alerts "xyz"
Definitely possible:
#define def(method, ...) this. method = function(__VA_ARGS__)
Almost the same thing as the class. Here's the output:
var Foo = function() {
  this.bar = function(arg) {
    alert(arg);
  }
}

var x = new Foo();
x.bar("xyz");
Pretty rubyish, isn't it?

Well, this is not the end of the story of course, but it's a start. Anyway, I hope this will cause people to take a deeper look at the GNU cpp, which really doesn't deserve it's bad reputation as being dusty and old, and imho should get more attention outside the scope of C in general. Whatever. Use it or ignore it.

Populiarity of programming languages

Angelegt von suung Mon, 04 Oct 2010 13:35:00 GMT

Reading niklas' article , i did a research, because i was pretty sure to have seen a chart, that shows PHP far before the next language (i guess C).


Now i give you some links:


1) Wikipedia explains, how populiarity of languages is calculated:

  • It is difficult to determine which programming languages are most widely used, and what usage means varies by context. One language may occupy the greater number of programmer hours, a different one have more lines of code, and a third utilize the most CPU time. Some languages are very popular for particular kinds of applications. For example, COBOL is still strong in the corporate data center, often on large mainframes; FORTRAN in engineering applications; C in embedded applications and operating systems; and other languages are regularly used to write many different kinds of applications.
    
    Various methods of measuring language popularity, each subject to a different bias over what is measured, have been proposed:
    
    counting the number of job advertisements that mention the language[1]
  • the number of books sold that teach or describe the language[2]
  • estimates of the number of existing lines of code written in the language—which may underestimate languages not often found in public searches[3]
  • counts of language references (i.e., to the name of the language) found using a web search engine.
  • counting the number of projects in that language on SourceForge and FreshMeat.[4]

    2) Langpop.com gives you a lot of different graphs, interesting!
    3) The technical university Wien has a table