Entry to the JS1k 2015 coding competition by Philippe Deschaseaux procedurally generates island landscapes using an incredibly small amount of javascript. Running in your browser, the code for it to run looks like this:

for(_=’*(H1,G[p-GxF2,E],Dw/EC0,BCB0DFACy+A-@Math.  abs(S+w> sin(.01H3onkey++q[DL[I]=8|3&t+S||8Hh),c.fillRect(“+o+”,M[2]=1Style=”&&(20 cos( .push(a.widthfunction(),=T[P] random()=tD==a.whickBO5BQ=[eGR=b=N=P=BBB0DX=/EY=a.height/1.5,T=[DsetInterval(){for(m= Rn=Ri=m*k,j=n*k,K=(5- 4*R))/4,l=O/E!bN<0TB(r=8*)* t=44*r*t[4,.1D0(S=!bN%0*T[P])?(P,U,V,M,J):e=#888”o=BY-l,2*X,Y+l)L=[QDI;q=eL[—I];)t=Bpxyshw«p,0==N2==ph>10<.2T240>h?8:3Bx+Gy+G[[G4,55D[4,G100D[8BE90]][0|h/1+(18>DhSf=u=x-U)v=y-Vpf!8]qBBBF+@@Cy-A+Cy-CB0](d= sqrt(u*u+v*v))<SW=(J||+(1- pow(d/S,M[0]))*S*M[1])>h3]=s=?0|+*u/(d+1)/9:16>W?190:80+0|W/304]=W)d=k-(m*x+n*y8]!f)p>2*b+d/900)?(t=x>i^3Hy>jL[I]=8|3&t132]):h>12!Sg=m*y-n*x)<dh-Eo-so=srgb(“+os=X/dX+s*g-(w*=s*KY+s*O-(h=s*-l,w+w+Gh+);e=b},0down=a){b,O+=33-34HO>R+=9-7,k+=40-38},up=){b=0};’;g=/[- @-H]/.exec(_);)with(_.split(g))_=join(shift());eval(_)

Try it out for yourself here

hey roleplayers and developers!

I want to build a web-based messenger service, built specifically to make text-based roleplaying (stuff like this) as streamlined as possible!

Ideally it will be:

  • easy to deploy
  • easy to use
  • open source
  • responsive

nice features might include: (but let’s discuss them!)

  • color highlighting and/or pictures for different character
  • tiny URL’s for each RP, just link your friends to it and get going
  • minimizing OOC text out to the side
  • no registration required, possibly?

if anyone is interested, please talk to me!

Flow In JavaScript

Flow provides a quick way to specify that functions should use each others values in a chain. To demonstrate, here is a normal way of displaying a wrapped word (displaying being simulated by a console.log):

var capitalize = function(word) {
    return word[0].toUpperCase() + word.slice(1);

var wrapWord = function(word) {
    return '<span>' + word + '</span>';

var displayCapitalized = function(word) {
    var capitalized = capitalize(word);
displayCapitalized('word');// '<span>Word</span>'

But with flow the definition for displayCapitalized can be significantly shortened:

displayCapitalized = flow(capitalize, wrapWord, console.log);
displayCapitalized('word');// '<span>Word</span>' 

The flow function just returns a function that keeps on passing evaluated results from a left function into a right function. The passed in value to this function will be the initial value:

var flow = function(/*callbacks*/) {
    var callbacks = Array.prototype.slice.call(arguments);

    return function useCallback(word, index) {
        index = index || 0;
        if (index < callbacks.length) {
            var result = callbacks[index](word);
            return useCallback(result, index + 1);

        return word;;

Flow is available in libraries like Lodash.

Github Location https://github.com/Jacob-Friesen/obscurejs/blob/master/2015/flow.js

thewireboundpony asked:

When you make games, are you one that comments and docs as you go, docs afterwards, or never docs/comments code? Im in the school of half as I go, and half afterwards.

Hey, thewireboundpony, thanks for the question!

My personal coding style is to use comments where needed while I’m coding, but mostly write code clean enough to where I don’t need comments. (I know a lot of people say that and don’t do that, but I like to think I do an okay job of it.)

Since I’m a solo developer most of the time, I just have to make sure I can understand my code when I revisit it later. Now that I think about it, I might start generating documentation from source code comments with docco or explainJS.

Anyway, some general guidelines I follow when I code:

  • Use descriptive variable and function names. This may seem obvious, but its value can’t be understated.
  • Don’t make long, complicated functions; make several small, understandable functions. ”Do one thing and do it well” applies, to a degree.
  • Don’t do things in a fancy or complicated manner just because you can. You have to look and maintain at that code later, so make sure it’s understandable.
  • Convention over Configuration and Don’t Repeat Yourself
  • Liberal use of whitespace. This isn’t Python, so let the code breathe if it needs to. (Obviously, disregard if you’re writing a language with significant whitespace.)

Thanks again for the question!