Kent,
Your comment about PHP got me thinking about something I briefly passed over in the Nimrod docs. Nimrod translates to more than just C. Here is a translation of the hello.nim to hello.js. The last line of the file is where all the action is at for this script.
/* Generated by the Nimrod Compiler v0.9.3 */
/* (c) 2013 Andreas Rumpf */
var Globals = this;
var framePtr = null;
var excHandler = null;
var NTI830 = {size: 0, kind: 17, base: null, node: null, finalizer: null};
var NTI832 = {size: 0, kind: 17, base: null, node: null, finalizer: null};
var NTI842 = {size: 0, kind: 17, base: null, node: null, finalizer: null};
var NTI103 = {size: 0,kind: 31,base: null,node: null,finalizer: null};
var NTI6452 = {size: 0, kind: 18, base: null, node: null, finalizer: null};
var NTI808 = {size: 0, kind: 17, base: null, node: null, finalizer: null};
var NTI137 = {size: 0,kind: 28,base: null,node: null,finalizer: null};
var NTI139 = {size: 0,kind: 29,base: null,node: null,finalizer: null};
var NTI891 = {size: 0,kind: 22,base: null,node: null,finalizer: null};
var NTI824 = {size: 0, kind: 17, base: null, node: null, finalizer: null};
var NTI828 = {size: 0, kind: 17, base: null, node: null, finalizer: null};
var NTI840 = {size: 0, kind: 17, base: null, node: null, finalizer: null};
var NTI844 = {size: 0, kind: 17, base: null, node: null, finalizer: null};
var NNI844 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []};
NTI844.node = NNI844;
var NNI840 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []};
NTI840.node = NNI840;
var NNI828 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []};
NTI828.node = NNI828;
NTI891.base = NTI824;
var NNI824 = {kind: 2, len: 4, offset: 0, typ: null, name: null, sons: [{kind: 1, offset: "parent", len: 0, typ: NTI891, name: "parent", sons: null},
{kind: 1, offset: "name", len: 0, typ: NTI139, name: "name", sons: null},
{kind: 1, offset: "message", len: 0, typ: NTI137, name: "msg", sons: null},
{kind: 1, offset: "trace", len: 0, typ: NTI137, name: "trace", sons: null}]};
NTI824.node = NNI824;
var NNI808 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []};
NTI808.node = NNI808;
NTI824.base = NTI808;
NTI828.base = NTI824;
NTI840.base = NTI828;
NTI844.base = NTI840;
var NNI6452 = {kind: 2, len: 2, offset: 0, typ: null, name: null, sons: [{kind: 1, offset: "Field0", len: 0, typ: NTI139, name: "Field0", sons: null},
{kind: 1, offset: "Field1", len: 0, typ: NTI103, name: "Field1", sons: null}]};
NTI6452.node = NNI6452;
var NNI842 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []};
NTI842.node = NNI842;
NTI842.base = NTI840;
var NNI832 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []};
NTI832.node = NNI832;
var NNI830 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []};
NTI830.node = NNI830;
NTI830.base = NTI828;
NTI832.base = NTI830;
var nim_program_result = 0;
var globalraisehook_5411 = null;
var localraisehook_5416 = null;
var outofmemhook_5419 = null;
function cstrToNimstr(c_6734) {
var result = [];
for (var i = 0; i < c_6734.length; ++i) {
result[i] = c_6734.charCodeAt(i);
}
result[result.length] = 0; // terminating zero
return result;
}
function ArrayConstr(len_7668, value_7669, typ_7670) {
var result = new Array(len_7668);
for (var i = 0; i < len_7668; ++i) result[i] = NimCopy(value_7669, typ_7670);
return result;
}
function add_5433(x_5436, x_5436_Idx, y_5437) {
var F={procname:"system.add",prev:framePtr,filename:"lib/system.nim",line:0};
framePtr = F;
var len = x_5436[0].length-1;
for (var i = 0; i < y_5437.length; ++i) {
x_5436[0][len] = y_5437.charCodeAt(i);
++len;
}
x_5436[0][len] = 0
framePtr = framePtr.prev;
}
function auxwritestacktrace_6447(f_6449) {
var result_6450 = [null];
var it_6455 = f_6449;
var i_6456 = 0;
var total_6457 = 0;
var tempframes_6461 = ArrayConstr(64, {Field0: null, Field1: 0}, NTI6452);
L1: while (true) {
if (!(!((it_6455 == null)) && (i_6456 <= 63))) break L1;
tempframes_6461[i_6456].Field0 = it_6455.procname;
tempframes_6461[i_6456].Field1 = it_6455.line;
i_6456 += 1;
total_6457 += 1;
it_6455 = it_6455.prev;
}
L2: while (true) {
if (!!((it_6455 == null))) break L2;
total_6457 += 1;
it_6455 = it_6455.prev;
}
result_6450[0] = cstrToNimstr("");
if (!((total_6457 == i_6456))) {
result_6450[0] = (result_6450[0].slice(0,-1)).concat(cstrToNimstr("("));
result_6450[0] = (result_6450[0].slice(0,-1)).concat(cstrToNimstr(((total_6457 - i_6456))+""));
result_6450[0] = (result_6450[0].slice(0,-1)).concat(cstrToNimstr(" calls omitted) ...\x0A"));
}
var j_6535 = 0;
var X3Atmp_6539 = 0;
X3Atmp_6539 = (i_6456 - 1);
var res_6541 = X3Atmp_6539;
L3: while (true) {
if (!(0 <= res_6541)) break L3;
j_6535 = res_6541;
add_5433(result_6450, 0, tempframes_6461[j_6535].Field0);
if ((0 < tempframes_6461[j_6535].Field1)) {
result_6450[0] = (result_6450[0].slice(0,-1)).concat(cstrToNimstr(", line: "));
result_6450[0] = (result_6450[0].slice(0,-1)).concat(cstrToNimstr((tempframes_6461[j_6535].Field1)+""));
}
result_6450[0] = (result_6450[0].slice(0,-1)).concat(cstrToNimstr("\x0A"));
res_6541 -= 1;
}
return result_6450[0];
}
function rawwritestacktrace_6542() {
var result_6544 = null;
if ((framePtr == null)) {
result_6544 = cstrToNimstr("No stack traceback available\x0A");
}
else {
result_6544 = (cstrToNimstr("Traceback (most recent call last)\x0A").slice(0,-1)).concat(auxwritestacktrace_6447(framePtr));
framePtr = null;
}
return result_6544;
}
function eqStrings(a_6790, b_6791) {
if (a_6790 == b_6791) return true;
if ((!a_6790) || (!b_6791)) return false;
var alen = a_6790.length;
if (alen != b_6791.length) return false;
for (var i = 0; i < alen; ++i)
if (a_6790[i] != b_6791[i]) return false;
return true;
}
function toJSStr(s_6738) {
var len = s_6738.length-1;
var result = new Array(len);
var fcc = String.fromCharCode;
for (var i = 0; i < len; ++i) {
result[i] = fcc(s_6738[i]);
}
return result.join("");
}
function raiseException(e_6560, ename_6561) {
var Tmp1;
e_6560.name = ename_6561;
if (!((excHandler == null))) {
excHandler.exc = e_6560;
}
else {
var buf_6601 = [rawwritestacktrace_6542()];
if (!!(eqStrings(e_6560.message, null))) Tmp1 = false; else {Tmp1 = !((e_6560.message[0] == 0)); }if (Tmp1) {
buf_6601[0] = (buf_6601[0].slice(0,-1)).concat(cstrToNimstr("Error: unhandled exception: "));
buf_6601[0] = (buf_6601[0].slice(0,-1)).concat(e_6560.message);
}
else {
buf_6601[0] = (buf_6601[0].slice(0,-1)).concat(cstrToNimstr("Error: unhandled exception"));
}
buf_6601[0] = (buf_6601[0].slice(0,-1)).concat(cstrToNimstr(" ["));
add_5433(buf_6601, 0, ename_6561);
buf_6601[0] = (buf_6601[0].slice(0,-1)).concat(cstrToNimstr("]\x0A"));
alert(toJSStr(buf_6601[0]));
}
throw e_6560;}
function raiseOverflow() {
var e_6638 = null;
e_6638 = {m_type: NTI844, parent: null, name: null, message: null, trace: null};
e_6638.message = cstrToNimstr("over- or underflow");
raiseException(e_6638, "EOverflow");
}
function raiseDivByZero() {
var e_6657 = null;
e_6657 = {m_type: NTI842, parent: null, name: null, message: null, trace: null};
e_6657.message = cstrToNimstr("divison by zero");
raiseException(e_6657, "EDivByZero");
}
function rawEcho() {
var node_7038 = document.getElementsByTagName("body")[0];
if ((node_7038 == null)) {
var e_7053 = null;
e_7053 = {m_type: NTI832, parent: null, name: null, message: null, trace: null};
e_7053.message = cstrToNimstr("<body> element does not exist yet!");
raiseException(e_7053, "EIO");
}
for (var i = 0; i < arguments.length; ++i) {
var x = toJSStr(arguments[i]);
node_7038.appendChild(document.createTextNode(x))
}
node_7038.appendChild(document.createElement("br"));
}
rawEcho(cstrToNimstr("Hello World!"));