Code That Pushed the Language Envelope? 87
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?"
What about Duff's device? (Score:5, Interesting)
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 [tuxedo.org]
For a more detailed explation see here [lysator.liu.se].
Can't post the code, due to Lameness filter.
Re:What about Duff's device? (Score:2)
But just as he points out in the introduction this is the type of work a compiler should do. And a compiler optimized for a given architecture should be able to maximize the loop unrolling benefit. (W.r.t. caches and such.)
Chess? Pah! (Score:4, Interesting)
I remember being rather more impressed when a friend wrote a Tetris clone in JavaScript. Interactive, real-time processing in JavaScript? Well done.
Not too good (Score:5, Insightful)
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 [enpassant.dk] (a simple demo here [enpassant.dk]).
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...
Re:Not too good (Score:1)
Re:Not too good (Score:2)
Not the brightest AI... (Score:2, Interesting)
It falls to a scholar's mate [chesscorner.com].
Wants to reload the icons every move too on my 56k connection for some odd reason.
Re:Not the brightest AI... (Score:2, Interesting)
Strange uses for C (Score:4, Funny)
I have to ask (slashdot) what drugs are these people taking?
Re:Strange uses for C (Score:1)
.
BaSiX (Score:5, Interesting)
Chess is nifty (Score:4, Interesting)
Re:Chess is nifty (Score:2)
Re:Chess is nifty (Score:1)
Would you like to play a game? (Score:2)
Language facilities and syntax not that foreign. (Score:3, Interesting)
Its kind of cool - but... (Score:4, Insightful)
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
Re:Its kind of cool - but... (Score:1)
Use the language best suited to the task at hand. Don't use a handsaw to put a nail in the wall. It's fun when somebody does, but it's really silly and impractical. It's ok if your writing something for fun to use whatever language you like. But at work you should choose wisely.
Re:Its kind of cool - but... (Score:1)
What's this blasphemy? Take your lies elsewhere!
Re:Its kind of cool - but... (Score:2)
Re:Its kind of cool - but... (Score:2, Funny)
Postscript web server (Score:3, Interesting)
Re:Postscript web server (Score:1)
Re:Postscript web server (Score:2, Informative)
Wow that's cool (Score:1)
Solving the N-Queens problem in XSLT (Score:3, Interesting)
Its not that good (Score:1)
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.
Obfuscated code, 1K competition (Score:4, Interesting)
Re:Obfuscated code, 1K competition (Score:1)
Re:Obfuscated code, 1K competition (Score:3, Funny)
As if one would even have to try to make perl code obfuscated? How about a legable perl contest? I'm sure that would be much more difficult.
Re:Obfuscated code, 1K competition (Score:1)
Re:Obfuscated code, 1K competition (Score:3, Funny)
What about templates? (Score:3, Informative)
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.
Re:What about templates? (Score:1)
Re:What about templates? (Score:2)
No, that's not what I wanted at all. I love the mishmash that is C++. I was talking about templates, which are often referred to as a "generic programming" concept, not OO. I am not a language purist, so C++'s handling of OO is fine by me; I even use (gasp!) public data members sometimes.
I am just really intrigued by the concept of templates as a compile-time bound and evaluated language and how that relates to the layer of the language that is compile-time bound but run-time evaluated, and the layer of the language that is run-time bound and run-time evaluated.
These can be thought of as (non-exclusive) members of a hierarchy of dialects of the language, covering many points on the speed-flexibility envelope. I would be very interested in a language designed to look similar at all levels of the hierarchy but able to bind and evaluate as much as possible early, and yet retain the flexibility of creating classes on the fly from a data stream.
Re:What about templates? (Score:1)
It's interesting that you mention dialects, since Lisp is one of the few languages that is generally recognized as having them. Its flexibility lends itself to specialization, such as implementing new dialects of itself or completely new mini languages. For instance, Scheme was originally implemented in an already existing Lisp.
As far as serialization of objects and manipulation of data and code, few languages can boast the power of Lisp's S-expressions. Their power is in their simplicity and allows all Lisp code and data structures to be expressed in the same simple syntax. Also, the entire language is available all the time, meaning that you don't have to make a design decision about whether to use a compiled or an interpreted language.
As far as performance, there are Common Lisp and Scheme implementations that outperform many other modern high level languages and even get close to C++ in some cases (http://www.bagley.org/~doug/shootout/).
Now I am ashamed for not using Lisp more after giving it such a glowing image. Mainly, it's just momentum. I continue to use the tools I'm comfortable with (mainly Python, Java and some C). I think this is the main reason people continue to use relatively low level languages like C and C++ for application programming. I do intend to try new tools, though. I don't want to stagnate.
Of course the fact that I haven't used Lisp much yet means I haven't experienced its downsides. However, I am confident that Lisp's lack of popularity does not reflect its power.
Re:What about templates? (Score:2)
Perl, while commonly usable by scientific programmers (my area), isn't really compiled either in the traditional sense, but parts of a perl program may be more efficient if they are "compile time" evaluatable. Perl, however, has the feature where you can write a program that produces a text string that is capable of being interpreted and executed as code from within the program that wrote the string (if that make sense). It puts the simple run-time binding of C++ to shame. Flexible as hell, but you pay for that flexibility in speed.
The neat thing about templates is that they let you, the designer, separate features by binding/evaluation time. In a dream world, one could ignore such concerns in one's code and the optimizer would be perfect at factoring out and efficiently compiling all early binding and evaluation, but AFAIK we're not there yet.
Re:What about templates? (Score:1)
You're absolutely right about the power of being able to generate source at runtime and evaluate (run) it. That's one of the things I like about Python as well. In fact, I don't think any language can be considered high-level if it doesn't have that. Guess where this concept originated? In the early implementation (around 1960) of Lisp, a function called "eval" was invented to be the definition of the Lisp interpreter. The details are in "The implementation of LISP" [stanford.edu].
The nice thing about the compiled lisps is that you also have the compiler available at runtime, which means that you can generate source code dynamically, then compile it. You are no longer bound by the traditional code/compile/run cycle.
I don't know of compilers/interpreters that can make such high level decisions about when to bind and evaluate, but I believe that Lisp allows a lot more flexibility in that area than C-like languages. Also, it looks like Self [sun.com] might offer something in that area. Another class of languages I have yet to explore, but may be far superior on these issues is that of pure functional languages, especially the lazily evaluated ones. I plan to learn one of the ML's eventually, like OCaml.
Unfortunately, as you pointed out, the best tools can't always be used because of external requirements like programmer or user familiarity. In fact, that's the main reason I haven't really gotten into using Lisp yet: I'm comfortable with languages I already know. But, I'm determined to try new things, especially when there's evidence that there are better tools available.
Basic interpreter written in TeX (Score:2)
Wolfenstein (Score:5, Interesting)
Wolfenstein in 5kb of JavaScript [innofinity.com]
Re:Wolfenstein (Score:1)
Emacs (Score:2)
M-x hanoi
Re:Emacs (Score:2)
Remember, Emacs is a front-end text editor over a LISP interpreter. Personally, I'd vote more for EMACS itself written in an AI language than solving a recursive logic problem in a text editor shell over an AI engine.
Re::Papz? (Score:1)
Re::Papz? (Score:1)
JavaScript taken to its limits (Score:2)
Recursion in XSL (Score:2)
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.
Page reloads (Score:1)
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.
Best pushing of the envelope I've ever done (Score:2, Interesting)
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?
Re:Best pushing of the envelope I've ever done (Score:1, Funny)
So are most slashdotters. Don't be embarrassed; you'll find a partner eventually, and she'll have hands of her own.
Re:Best pushing of the envelope I've ever done (Score:1)
speechd [speechio.org] implements
Re: speechd (Score:1)
Maybe interested in a HTTP-server in PHP? (Score:4, Interesting)
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
Re:Maybe interested in a HTTP-server in PHP? (Score:2)
Re:Maybe interested in a HTTP-server in PHP? (Score:1)
have fun =)
b4n
Re:Maybe interested in a HTTP-server in PHP? (Score:2)
httpd written in native php - GPL it (Score:2)
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.
So it makes legal moves... (Score:1)
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. :)
Postscript Raytracer (Score:2, Interesting)
Quines and Polyglots, oh my! (Score:2, Interesting)
How about a program that compiles and runs in seven different languages?
http://www.nyx.net/~gthompso/poly/polyglot.txt [nyx.net]
Or a program that prints its own source code?
http://www.nyx.net/~gthompso/quine.htm [nyx.net]
Or just a whole collection of weird programming-related stuff?
http://www.catseye.mb.ca/ [catseye.mb.ca]
(OK, so I'm way too late to the party and nobody's going to read this, but hey :)
Object-oriented K shell (Score:1)
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.
Elaborate batch files (Score:2, Interesting)
Well (Score:1)
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.
Pushing the limits (Score:5, Interesting)
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.
Emulator... (Score:1)
Shouldnt be that hard.
Some crazy stuff I have seen... (Score:2)
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...
Re:Some crazy stuff I have seen... (Score:1)
Lynx and Javascript (Score:2)
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++.
Pac-Man (Score:1, Interesting)
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!