Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Programming

1K JavaScript Madness 131

An anonymous reader writes "JS1k has a simple goal: to get programmers producing demos written in JavaScript that are 1k in size or less. That's just 1024 bytes to play with. There's even additional bonus points on offer if a demo's code can fit inside a single tweet. Now that the contest is finished and there is a top-ten, I'm wondering what they can do if given some extra bytes." I like the Tetris clone. The pulsing wires demo is neat too but kinda stuttery on my machine.
This discussion has been archived. No new comments can be posted.

1K JavaScript Madness

Comments Filter:
  • by space_jake ( 687452 ) on Tuesday September 28, 2010 @02:47PM (#33727260)
    About javascript in their tweets...
  • js1337 (Score:4, Funny)

    by user24 ( 854467 ) on Tuesday September 28, 2010 @02:47PM (#33727266)

    >I'm wondering what they can do if given some extra bytes.

    In a few weeks you'll find out at js1337.com ;0)

  • And BOOM (Score:4, Funny)

    by Anonymusing ( 1450747 ) on Tuesday September 28, 2010 @02:48PM (#33727306)
    Is there a Javascript app for "This site has been Slashdotted"?
  • "Hey slashdot kids. It's 4pm east coast. Here's 10 games you can play, hosted on this site here. See you all at the coffee machine in 180 seconds."

    • by harrkev ( 623093 )

      HUH? I do not see what the big deal is. Each script is only one single friggin kilobyte! Even though each page includes the source and some comments, and the usual HTML wrappers, I cannot imagine each page being more than about 5K to 10K each. Evan an old Pentium should be able to keep up with that kind of load.

  • ...you can't castle queen side.
  • Asteroids (Score:4, Interesting)

    by Hatta ( 162192 ) on Tuesday September 28, 2010 @02:56PM (#33727428) Journal

    I'm wondering what they can do if given some extra bytes."

    If they use bankswitching, maybe they can pull off Asteroids [atariage.com]

    • by mcgrew ( 92797 ) *

      I wish I was a better JS programmer, I'd have entered the contest (I've only done a little JS programming, and it's been a few years since I have). I made a fully functional battle tanks game back in 1982 that you could play single-player or two players playing against each other at the same time. It was under 4k as that's all the computer had without an expansion pack; I don't remember how big the actual code was, probably less than 1k. However, it was in hand-assembled Z-80 machine code for the Sinclair 1

      • by Hatta ( 162192 )

        I wouldn't think Asteroids would be too hard.

        You're right. In Racing the Beam they say that Asteroids on the 2600 could have been done in 4k with some extra time for optimization but Atari decided that time was money and sprung for the extra ROM chips.

        I wonder if this kind of thing is easier to do in Javascript. Given the size of the javascript language themselves, they have a lot more to actually work with. But then javascript is a lot more verbose than 6502 machine language.

  • can they produce a 1k jQuery?
    • by blair1q ( 305137 )

      Nope. Slashdotted those, too. Someone needs to put these on some embiggener iron.

    • Not that it matters at all, but the "Tiny Chess" cannot castle with the king rook (at least).

      Other than that, it looks pretty nice!

      • I beat it first try, and it just sits there. Apparently, 1023 bytes isn't big enough to say "You win". (And it can't be that good - I haven't played chess in decades).
  • Genetic approach (Score:3, Interesting)

    by Iamthecheese ( 1264298 ) on Tuesday September 28, 2010 @03:04PM (#33727536)
    Would it be feasible to take a current simple game like Pacman, write a driver to check it for proper functionality on an x86 CPU, spawn thousands of them in minor variations, and use a genetic algorithm to keep the smallest?
    • by blair1q ( 305137 )

      Sure. But how do you define "minor variations" such that more than a handful out of "thousands" function at all?

      • You don't: a handful must be enough. Then you spawn thousands of children from that handful.
        • Re: (Score:2, Offtopic)

          by blair1q ( 305137 )

          I think if you can devise a few variation methods that work at all, you could make a good guess at which lead to the smallest code.

          What you need are thousands of methods of varying the code, and millions of iterations looking for working results, and then a cost function (in this case merely size) to choose the optimal result.

    • by TelavianX ( 1888030 ) on Tuesday September 28, 2010 @03:18PM (#33727740)
      This is possible, but how many valid javascript programs are 1024 characters or less? A very large amount!

      Checking each if it followed the predefined rules would be time consuming. For instance, in Pacman, you might have to have the computer play a full game to check if the rules are met.

      Almost all the programs would be utter nonsense.
    • Re: (Score:2, Informative)

      by Anonymous Coward

      Sorry to spoil your party, but you will be dealing with issues in automatic software verification which themselves are infeasible.
      This is one problem you can't just throw a bunch of computing power (yet) and it will magically find it a small solution in a reasonable amount of time.

      Just fyi, assuming each character has 256 different possibilities in a 1000 byte program in js, there are 256^1000 possibilities, or 2^8000 possible programs to choose from.
      To put that into perspective, current estimates on the nu

    • Would it be feasible to take a current simple game like Pacman, write a driver to check it for proper functionality on an x86 CPU, spawn thousands of them in minor variations, and use a genetic algorithm to keep the smallest?

      Your problem then lies in making a PERFECT "driver". If it's not perfect, you'll end up with code highly effective at tricking it, and doing NOTHING ELSE. This is what viruses are for.

      Your suggestion is just like using a random number generator to write books... First, spell-check.

  • http://www.the5k.org/ [the5k.org] Does anyone remember this site? It was a contest back in 2000-2002 to create the coolest website with only 5KB. Looks like it had a spiritual successor too: http://10k.aneventapart.com/ [aneventapart.com]
    • by pjt33 ( 739471 )

      I remember that, and I still have the Mandlebrot applet I wrote for it. I've also had good fun with the Java 4k [java4k.com] contest.

  • by Anonymous Coward

    Chess in 1024 bytes and I can't win it. What a shame.

  • by psbrogna ( 611644 ) on Tuesday September 28, 2010 @03:33PM (#33727928)
    Interesting idea. Thirty years ago many people were introduced to programming by printed (ink on mashed up trees) anthologies of programs that were generally around a page long (8.5 x 11). Don't know how pervasive the term was, but in my personal circles these programs were called "K-Byters" because they were ~1 K long (or less).
    • Re: (Score:3, Informative)

      by mcgrew ( 92797 ) *

      I remember them, there were lots of 'em. All computer magazines back then had programs you could type in. IIRC most of them were BASIC, although a few were assembly. Heck, the original Wolfenstein came on a 540k floppy and shareware DOOM was two of them IIRC.

      • COMPUTE!'s Gazette including listings each month. If I remember, maybe a third of the magazine was devoted to pages upon pages of hex listings. You'd use their machine language entry program "MLX" (BASIC code for which was included verbatim in every single issue -- you'd have to type THAT in first) and sit there for hours typing in the code. It had a simple checksum scheme, so each line was 9 bytes with the last byte being a checksum. If you made a mistake, you found out at the end of the line when the thin

        • by mcgrew ( 92797 ) *

          Alas, mine got left behind after my divorce when I moved from the big two story house to a small apartment. My then-teenaged daughter, seeing what I'd rented for us, wailed "My ROOM was bigger than this apartment!"

          I miss the old IBM XT even more, though. It would probably be worth some money now.

  • Got beaten by the feckin' 1K chess game in about a dozen moves. Feck!

  • wtf (Score:1, Insightful)

    by Anonymous Coward

    >>Now that the contest is finished and there is a top-...

    WTF tell me I can win shit then say it's over >:/

  • I'm wondering what they can do if given some extra bytes

    Get them all to work in Internet Explorer. Most demos give errors in IE8x64.

    • window.onerror=function(){this.onerror=void(alert('Get a better browser!'))}

      Done.

    • Re: (Score:2, Flamebait)

      by Unending ( 1164935 )

      Part of the competition was to use Canvas tags in interesting ways, and considering IE9 doesn't even support Canvas I think you're out of luck unless you get a standards compliant browser.

      • by weicco ( 645927 )

        What standard you are talking about? Wikipedia: HTML5 is currently under development.

  • Readability... (Score:2, Interesting)

    by deepu_s ( 530426 )
    It'd be truly impressive if it were *human-readable* source code that fit under 1k.
  • Chess (Score:3, Interesting)

    by Dthief ( 1700318 ) on Tuesday September 28, 2010 @04:09PM (#33728392)
    impressed that they fit in a reasonable A.I. into the thing!
  • "There's even additional bonus points on offer if a demo's code can fit inside a single tweet."

    So that kid that made the self-posting Twitter worm the other day wins by default?
  • My first computer was Tandy 16K color computer, one of the contest in the old Rainbow Magazine was how much you could put in one line of basic code. Still great to see people be creative within a limited space of memory.
  • What about Perl? (Score:3, Interesting)

    by slapout ( 93640 ) on Tuesday September 28, 2010 @04:39PM (#33728678)

    It just hit me--think of all the stuff you could do in a Perl program that would fit into one tweet?

    • by SQLGuru ( 980662 )

      Think of all of the things you COULDN'T do in Lisp if you could only use 1k parens...... :D

    • It just hit me--think of all the stuff you could do in a Perl program that would fit into one tweet?

      I hope it hits you unconscious next time. Because I'd hate to see that piece of Perl, my day job already exposes me to an indecent amount of vulgar Perl :-)

  • I can't believe this story's been up for nearly two hours and no one's rushed in to explain that these are one kibibyte demos, thus depriving us of our right to make fun of them and their dumb-sounding pet units.

  • Really? Only 1k? (Score:1, Redundant)

    by tyrione ( 134248 )
    It must be nice to not include the entire infrastructure of code that is actually doing the heavy lifting as this fantasy that in only 1K you too can do x,y and z.
  • by Anonymous Coward

    Here's the making of of WOLF1K and the rainbow characters [p01.org] the Wolfenstein 3D-ish game sans violence in 1k that game #4

  • Hardly any on those work in IE9.

  • Raymarching using Distance Fields in 1K Fast on Chrome and Opera http://js1k.com/demo/704 [js1k.com]
  • madness...?? this... is... javascript!!!!

You know you've landed gear-up when it takes full power to taxi.

Working...