Code That Pushed the Language Envelope?
Lil Fritz asks: "Following on from the cool Flash Adventure game last week, this geezer Neil Pearce has written a full client side JavaScript CPU chess player (which drew with me, but then I'm papz at Chess). Now this sort of thing always amazes me. Doing stuff for which it was never intended. Do we have other warped (ie 'they wrote it in what?!?') uses of languages and tools?"
When I first saw it, I was amazed that it worked, but I would say it pushed the limits
Code example and discussion in the Jargon File
For a more detailed explation see here.
Can't post the code, due to Lameness filter.
If we think about it, Chess is only requiring a lot of processing on the client side. It's a waste of CPU power but nothing more.
I remember being rather more impressed when a friend wrote a Tetris clone in JavaScript. Interactive, real-time processing in JavaScript? Well done.
Greg
(Inside a nuclear plant)
Aaaarrrggh! Run! The canary has mutated!
The site says it looks 2 moves deep, but I don't see how it can play like this then:
1.e4 Nc6 2.d4 Nf6 3.e5 Ne4 4.Bd3 Nxd4?? 5.Bxe4 Nxc2?? 6.Qxc2
Leaving two knights hanging to immediate capture threats, that doesn't suggest any lookahead to me.
But of course, it's neat that it works. People have made utilities for playing through chess games before, like PalView (a simple demo here).
Adapting that to take user input and a very simple lookahead is work, but not stunning in my opinion. Unless there's some reason why this is very hard in JS, I don't really do that language...
I believe posters are recognized by their sig. So I made one.
It falls to a scholar's mate.
Wants to reload the icons every move too on my 56k connection for some odd reason.
Some people use the C programming language to actually attempt to write qulaity programs.
I have to ask (slashdot) what drugs are these people taking?
I think BaSiX ought to qualify - a BASIC interpreter written in TeX, no less.
My opinion? See above.
Anything in "good old FORTRAN-77" that tries to use high-level data structures and things that would be better solved using dynamic memory and structures (or objects, even) definitely push the language past its limits. I suppose that's why languages evolve.
Along the same vein, a couple weeks ago I coded Tic-Tac-Toe in JavaScript complete with an alpha-beta search such that the when it is in expert mode, you cannot beat your web browser. Solving the whole game on my computer takes about 5 seconds, so I added an opening book to compute the first move. With that response time is pretty much instantaneous even in expert mode.
JavaScript's syntax and language facilities are pretty similar to C, it's not that far fetched that he was able to do this, and considering that a lot of Mozilla is controlled via JavaScript, it doesn't suprise me that this is possible.
I know, I know - its just a little game to see if they could do it. But geesh - I see this stuff in the OFFICE all the time. Some of the devs do stuff in java, some in VB, some in perl etc... What I hate to see is when someone is so wrapped up in VB, or java, or any language that they WILL NOT write anything in any other code.
A few of the VB guys, they push it to the extreme, and are zelots about it. Sometimes I actually think they believe they are making the world a better place because they write in VB....
This is cool, but man, it happens all the time and not always for the right reasons.
Duke
FreeBSD: Nothing runs like a daemon with a pitch fork.
I seem to remember a web server writen in postscript being mentioned on /. some years back. It seems like a pretty big stretch to me having a language designed for displaying text and graphics serve out web pages.
In Republican America phones tap you.
Once upon a time there was an argument whether XSLT was turing-complete (this was when the spec was being worked out), so I posted an XSLT "stylesheet" that places N queens on an NxN chessboard so that none threatens the other. You can see the post here: http://www.biglist.com/lists/xsl-list/archives/199 906/msg00289.html and the stylesheet here: http://www.biglist.com/lists/xsl-list/archives/199 906/bin00003.bin. That's a pretty twisted piece of code if I do say so myself :-) Strangely enough it has been actually "used" - to benchmark XSLT processors etc. (e.g., here: http://www.machi.pe.kr/xml/document/xslt/xslt_benc hmark.htm.
I beat it with ease.
That is really cool. Excellent work in javascript. I guess now I have to stop laughing at my boss who thinks its actually useful to use javascript. Bummer.
Norris/Palin 2012
Fact: We deserve leaders who can kick your ass and field dress your carcass.
Lots of "barrier pushing" code can be found in obfuscation contests. Check out the Obfuscated C contest or the Obfuscated Perl contest. For similar feats on the web, check out The 5k (which recently featured a lightweight chess entry).
Every day, my appreciation for templates grows deeper. I've even thought that there ought to be another language built from the ground up around templates, one that shows more parallelism in the syntax of compile-time templates and "regular" code.
taken! (by Davidleeroth) Thanks Bingo Foo!
Basix
Searching this page didn't show it up, so here's the link:
Wolfenstein in 5kb of JavaScript
M-x hanoi
#exclude <ms/windows.h>
So what heck does "I'm papz at chess" mean? the word doesn't show up in online dictionaries... a real quick google on 'papz chess' and just 'papz' doesn't seem to be very revealing.
"It's tough to be bilingual when you get hit in the head."
We had a guy speak to our users group about their Open Source product called TIBET that takes JavaScript to its limits. They've implemented language constructs that the JavaScript designers were surprised by. Things like closures, a type system, multiple inheritence, and meta-classes. The whole system (about 1MB) is downloaded to the client system, and everything runs on the client system without having to pull down anything but data from the server. Very impressive.
Software sucks. Open Source sucks less.
Another example of: "Not how did they do it, but why?"
r y/ x-xslrecur/
http://www-106.ibm.com/developerworks/xml/libra
The only application I can think of is to build a drop down with Fibonacci numbers in it. Of course, recursion has efficiency on the order of 2^N, which means 100 fibonacci numbers would take 10^30 operations to generate.
How to make your webpages load slower: use recursion in XSL.
"All I ever wanted was to see Larry Wall give Bill Gates a Perl necklace."
http://www.eisenschmidt.org/jweisen
we all know about all languages being essential equal in what you can do if you have enough time. However, this topic is still quite interesting. Here's some stuff I take my hat off to;
A Pascal compiler in LOGO (Brian Harvey), compiles Pascal into LOGO then evaluates the code so in the end you just type the name of the pascal program which had been turned into a LOGO word. V. cool.
IIRC the first Smalltalk was written in BASIC. Mind you this was back in the 70s and BASIC wasn't the sort of BASIC you had on your well cool 8-bit machine. Still, would like to see the code.
The Frenchies once wrote a very early PROLOG interpreter in FORTRAN (back when it was even more disabled than it is now) and this was their first reasonably sized piece of programming.
This is probably UK urban myth but when I was a kid there were stories going around about using a paint programme on the BBC model B to "paint" code into the vide RAM, he then did a JSR to the code. I can see how it would work.
That Javascript chess game would certainly be a lot cooler if it didn't refresh the whole damn page each time you even click on the board.
Not to say that it's not impressive but it gets a little annoying having those graphics reload each time. I don't think it would've been that hard to make it work without reloads. Ah well.
Shouldn't reload everytime, what browser are you using?
Not coincidentally, one on my pet projects that I want to spend time on is to make (or find if it already exists) a generic plug-in module in Mozilla that can do the same thing with no external hardware outside a vanilla PC sound card (or on board chip). Links anyone?
...Open Source isn't the only answer -- but it's almost always a better value than the alternatives...
The other day I played around with PHP's socket-extension. After some reading I thought about a normal server-service I could try. A webserver came to my mind. So I made up a HTTP-server/daemon in PHP. PHP should be an extension to a webserver not a webserver itself, that's why it might fit into this topic.
...
I played around with it and tested it with apache benchmark. As I'm able to handle multiple request it got pretty fast and stable - even faster then pure apache (no wonder - it has more features).
The advantage of this webserver is, you don't need any php-optimizer as everything in your application gets includes in the webserver and loaded with it. If anyone wants the code just tell me
b4n
1. e2 e4 b8 c6
2. g1 f3 d7 d5
3. e4 d5 d8 d5
4. b1 c3 d5 f3
5. d1 f3 g8 f6
6. f1 c4 e7 e5
7. c3 d5 f6 d5
8. c4 d5 f8 d6
9. f3 f7 e8 d8
10. d2 d4 c6 d4
11. c1 g5 d6 e7
12. f7 e7#
If it is "Looking two moves into the future," it isn't looking very carefully. Still, kind of a fun project...at least I have a computer opponent that I can frequently beat. :)
There's no place I can be, since I found Serenity.
here
How about a program that compiles and runs in seven different languages?
http://www.nyx.net/~gthompso/poly/polyglot.txt
Or a program that prints its own source code?
http://www.nyx.net/~gthompso/quine.htm
Or just a whole collection of weird programming-related stuff?
http://www.catseye.mb.ca/
(OK, so I'm way too late to the party and nobody's going to read this, but hey :)
The strangest one I ever saw was the application written in object-oriented K shell! It was a complex run-script for a Verilog simulation environment. To protect the guilty, I won't identify where I saw it. (NO, I wasn't the guilty party, even though I am the worlds worst programmer!) The person who showed it to me was the current maintainer, who had inherrited it from a former collegue, since departed from the company. He wasn't too thrilled with being responsible for its maintenence, but admitted that it worked "remarkably well". The program has since been retired.
I forget the details, but the basic idea was something like...
Object instances were represented by directories. Methods were represented by shell scripts named for the methods. Derived objects were represented by subdirectories. Overlaid methods would be scripts in the subdirecrory, and inherited methods (from the parent directory) would be used if the script wasn't present. Instance variables were data files in the corresponding object directory. I think class and global variables were stored in environment variables, but I'm a little hazy on that. The whole scheme relied heavily on scripts that walk directory trees, programs that exec each other, inherited environment variables, and scripts inheriting settings from other scripts by sourcing them.
I'm also hazy on how fullly it really implemented the concept of classes independent of class instances (i.e. objects).
As for the big question: Why??? I was never able to find an answer.
At a company where I worked in the early '90s, I used to write batch files that really pushed the limits. I tried to avoid using third-party utilities such as 4DOS so they'd run about anywhere but I sure used the standard DOS utilities. Some of my batch files used pipes and redirects to script EDLIN to search and replace data in text files. Some used ASCII control codes to send color data to the ANSI.SYS driver. They called me ".bat man". I still have a Batman coffee mug at work. It was a joke then, but nobody gets it anymore. :) These days, I'd just use Perl.
assert(birth_date<time-86400)
I'll going to remember that for the next PostScript class I teach.
Islam. Terror. Death. Muslim Assasins.
You are the deathbringer, you are demon seed you are antichrist, you are the minion of evil, you kill babbies, you kill women, you rape boys, you make women put towels on the head to shame them, you chop off the clitoris of your women, you dream of sucking the balls of King Fahd, you imagine his desert sweaty nuts, slurp, slurp.
YOU are going to suffer!
I recently wrote an BrainFuck interpreter in INTERCAL. I keep it here and it's an evil evil beast. :D
:/
Several years back I also wrote a relatively full-featured BBS, complete with message boards, file areas and dropfile support for door games, in QBASIC, as well as a DataPac network scanner in same.
I know a guy who wrote a program to calculate Pi to an arbitrary number of digits in
You ready for this?
DOS
He wrote the entire progeram as a series of .BAT files that recursively called each other.
No external programs, no tricks. Nothing but the native capabilities of COMMAND.COM. Local variables were stored in the environment, and globals were stored in files.
It ran really slow.
The Web is like Usenet, but
the elephants are untrained.
I was thinking of doing an Amiga emulator in Flash.
Shouldnt be that hard.
-- Senior Software Engineer, Attorney appearance services, locallawyerapp.com.
I remember seeing a version of "California Racin'" or such done completely in Javascript - took forever to load the graphics (there was a lot of graphics to load for all the sprite 3D scaling effects). Also, who could forget Frag Island, a Quake-like game written in Java?
I once pushed VB hard and made a perspective-correct texture mapped 3D spinning cube - no DirectX used, either.
Then there was the time in highschool I wrote a mandelbrot display engine in Applesoft Basic, and displayed it via an assembler hi-color display hack (allowed you to get 16 colors at a good resolution if you had an 80x24 display card). Then I repeated it using PICK Basic, and a Wyse 370 set to emulate a Tectronix (sp?) graphics plotter terminal (eeeek!!!).
I think my favorite, though, has to be a game I remember coded by some Japanese guy in QBasic - it was in the ABC Archive - anyhow, this game was a 640x480 monochrome side-scrolling shooter with an UNBELIEVABLE amount of sprites on-screen, complete with end-level bosses - all in QBasic.
Then there is the code a friend of mine gave me that he never released that used QuickBasic 4.5, some custom assembler routines, etc - to make a side-scrolling platformer robo-anime style game, with full sound-blaster effects - but it isn't as relevant because the graphics scrolling/sprite routines were coded in x86 Assembler - of course, he wrote this back in 1992 or so...
Reason is the Path to God - Anon
Someone once wrote javascript support for lynx, can't
find the URL for it, but googling does find several references to it.
Ok, so its not as amazing as a chess engine, or Tetris playing javascript code, but still, its pretty wierd.
The other thing that stretches the imagination as to why is when C coders start implementing Templates in C, rather than using C++. I'm a C coder, but even I know when to use C++.
I use to have a funny sig, but slash cut it off, and I forgot what the punchline was.
I used to have Pac-Man written entirely within MS Excel.
a n. zip
Should be able to grab it from
http://www.winsite.com/info/pc/win3/excel/pac-m
May not have pushed the limit, but it was pretty cool nonetheless. Boss key? We don't need no shtinkin boss key!
Uh, tic-tac-toe? Thats a pretty simple game. The mainframe in the movie War Games was able to figure it out. And that was some pretty old technology. (Of course, it was also able to figure out that global thermo-nuclear war is also always a draw if both players know how to play well.) Doesn't seem like it'd be that difficult to do in JavaScript. Hell, I've figured out the algorithm with pencil and paper.
Software sucks. Open Source sucks less.
Interesting -- yes. Thanks for the link.
...Open Source isn't the only answer -- but it's almost always a better value than the alternatives...
this is what sourceforge is for
just throw it up and somebody else will emerge to help you maintain it.
GPL it, dude!
at least put up a website and release it under some sort of OSS license.
Use my userscript to add story images to Slashdot. There's no going back.