sharkbrainguy
Joined 18 years ago
Joined 18 years ago
As an earlier example of an Embedded DSL, the book PAIP[1] included prolog embedded in common lisp in 1992.
It could be argued that the loop macro in Common Lisp is a DSL for describing iteration. If not loop, then certainly regular expressions are a common EDSL for describing a regular language, and performing operations with those languages against strings?
I found this snippet from Computers in Crisis [2] which seems to describe domain-specific languages in familiar terms from 1975
Most domain-specific programming languages can be categorized in one
of two ways; either as a "sugared" general ... of programming, in
fact the style of problem solving, embedded in and supported by that
language remains unchanged.
[1] http://www.norvig.com/paip/README.html
[2] http://books.google.co.nz/books?id=QndQAAAAMAAJ&q=%22Embedde...[1] https://www.coca-cola.com.au/ourdrinks [2] http://coke.co.nz/ [3] http://www.coca-cola.co.uk/brands/diet-coke.html [4] http://en.wikipedia.org/wiki/Diet_coke
It can be true that a piece of software is a poor replacement for an existing tool.
It can be true that recommending it as a replacement for that tool is dangerous.
You can make these judgements about a piece of software without an incident like this happening. What's important here, is how you behave once you've made these judgements.
Debating the technical merits of this particular project can't really address that.
> es5-shim.js and es5-shim.min.js monkey-patch a
> JavaScript context to contain all EcmaScript 5
> methods that can be faithfully emulated with a
> legacy JavaScript engine.
It provides Array::map, Array::filter, Array::reduce as defined in Ecmascript 5 along with String::trim and others, as well as replacing buggy implementations.Previous versions of es5-shim included shims for things that cannot be correctly or completely shimmed in ES3 but those have since been separated and I now recommend including es5-shim in basically all web projects to get closer to a modern javascript in most browsers.
function render(tpl,data){
function lookup (obj, keys) {
return (keys.length === 0) ? obj
: lookup(obj[keys[0]], keys.slice(1));
}
var matches = tpl.match(/\{[^\}]+\}/g),
max = matches.length,
i, rep, keys;
for (i = 0; i < max; i++) {
keys = matches[i].slice(1, -1).split('.');
rep = lookup(data, keys);
tpl = tpl.replace(matches[i],rep);
}
return tpl;
}
alert(render("{a} is all that i've {b.a} {b.b} {b.c}", {
a: "this",
b: {
a: "ever",
b: "really",
c: "needed"
}
}));Scheme has:
call-with-current-continuation http://people.csail.mit.edu/jaffer/r4rs_8.html#IDX509
Tail Call Optimisation
A numeric tower http://people.csail.mit.edu/jaffer/r4rs_8.html#SEC50
A Code/Data equivalence and therefore macros
Ports
Javascript has: Prototypal inheritance
Every 'object' is mutable bag of string indexed properties
There's a pile of differences, even just at the semantic level before you get into the syntax or the equivalence semantics.I understand that if you take a specific subset of javascript, you can write code as-though it has some scheme semantics (minus call/cc and TCO), but that's true to a similar extent of any language with lexical scope, closures and anonymous functions.
because I prefer this:
Q: "How much will lunch cost?"
A: "$20"
To this: Q: "How much will lunch cost?"
A: "Either $0 or $200"Pandoc is written in haskell but there's c bindings to it https://github.com/toyvo/libpandoc so you can use it from anywhere.
edit: Invite Received! Email redacted! Thanks alot
function Kitten(width, height, color) {
var img, g, w, h;
w = parseInt(width, 10);
h = parseInt(height, 10);
g = color ? "" : "g/";
img = document.createElement('img');
img.src = "http://placekitten.com/" + g + w + "/" + h;
img.width = w;
img.height = h;
return img;
};
http://www.gerardpaapu.com/
[email protected]