News for hackers. Stuff that matters.
Re:Conway's Game Of Life in one line of APL by jacquesm on Saturday January 09, 2010 @11:45AM (#1041612)
I don't know the origin of the quote but 'if you need more than one line of APL you do not fully understand your problem'.
Re:Conway's Game Of Life in one line of APL by profquail on Saturday January 09, 2010 @01:47PM (#1041778)
Also:

  "There are three things a man must do
   before his life is done;
   Write two lines in APL,
   And make the buggers run."
   -- Stan Kelly-Bootle, 'The Devil's DP Dictionary'
And:

  "APL is a mistake, carried through to perfection.
   It is the language of the future, for the programming
   techniques of the past: it creates a new generation
   of coding bums."
   -- Edsger Dijkstra
Re:Conway's Game Of Life in one line of APL by moe on Saturday January 09, 2010 @11:05AM (#1041574)
Impressed. Not just by the syntax (first time I see APL) but also by how easily he juggles and shapes what is mostly hieroglyphs to me.

I know he was probably following a script to spare us the trial & error. I also know the hieroglyphs could be replaced with ascii-keywords to make it look more down to earth. But still; if I was to come up with a game of life in any language then the process wouldn't look anywhere near this elegant...

Re:Conway's Game Of Life in one line of APL by gvb on Saturday January 09, 2010 @01:51PM (#1041790)
"I also know the hieroglyphs could be replaced with ascii-keywords to make it look more down to earth."

Not really, that is APL. The keywords in the APL language are mathematical symbols (Greek letters plus a lot more). http://aplwiki.com/AplCharacters#What_exactly_is_.22APL385_U... The result is readable (I assume) to a mathematician, but is hard for mere mortals to read and hard to type without a special keyboard.

Re:Conway's Game Of Life in one line of APL by iamwil on Saturday January 09, 2010 @10:37AM (#1041548)
That was my first time seeing APL code. All I knew about it was that it had its very own keyboard for its own funky symbols.
Re:Conway's Game Of Life in one line of APL by profquail on Saturday January 09, 2010 @10:56AM (#1041566)
I've been reading a bit about APL, and I can't find anywhere to buy one of the old APL keyboards. However, you can remap your existing keyboard to output APL symbols for certain key combinations, which is how I think most people are using it these days.

EDIT: Picture of the keyboard layout: http://www.users.on.net/~farnik/upload/APL2union.gif

Re:Conway's Game Of Life in one line of APL by shaunxcode on Saturday January 09, 2010 @01:24PM (#1041740)
Actually you can purchase one here: http://pckeyboards.stores.yahoo.net/adcolkey.html they even provide different colors and special keys (windows key into a meta key etc.) - I have the dark grey one and I love it.

You can also get APL stickers that fit onto any keyboard (I put them onto an hp 1000 laptop even) from here: http://hooleon.com/miva/merchant.mvc?Screen=PROD&Product... for about 15 dollars. They actually work really well - I would advise using a pair of tweezers to get them positioned exactly how you want because one they are on they are pretty permanent!

Re:Conway's Game Of Life in one line of APL by sunkencity on Saturday January 09, 2010 @02:15PM (#1041824)
Wow! Now that looks like a keyboard map for some serious dark programming magic! Now I really want to put on my pointy hat and enter the astral planes of APL!
Re:Conway's Game Of Life in one line of APL by coliveira on Saturday January 09, 2010 @11:08AM (#1041577)
You can also use J (http://www.jsoftware.com/), which follows the same philosophy but uses only normal characters (all of them, in fact).
Re:Conway's Game Of Life in one line of APL by michael_dorfman on Saturday January 09, 2010 @11:09AM (#1041578)
Most people are using virtual keyboards, but Dyalog (in the warning on their website) mention that they sell APL keyboards.
Re:Conway's Game Of Life in one line of APL by afshin on Saturday January 09, 2010 @08:32PM (#1042407)
J and K both came out of APL ... except they use the normal ASCII character set for their built-in functions. It still seems like magic to me when I saw one line of K execute really quickly and return what takes me dozens of lines of code in another language. Look at the APL/J/K solutions on some of the Project Euler problems. The longest ones are maybe two lines long.
Re:Conway's Game Of Life in one line of APL by michael_dorfman on Saturday January 09, 2010 @10:48AM (#1041557)
That's a great video for giving a taste of APL. It's too bad that the barriers to entry for learning APL seem to be so high; it's a great language.

The link mentioned in the video, which gives a fuller explanation, is here: http://www.dyalog.com/dfnsdws/n_life.htm

Re:Conway's Game Of Life in one line of APL by julio_the_squid on Saturday January 09, 2010 @02:49PM (#1041879)
J is essentially the new version of APL using ascii rather than the odd symbols, if I'm not mistaken? I'd love to see a version in J.
Re:Conway's Game Of Life in one line of APL by tobych on Saturday January 09, 2010 @03:38PM (#1041954)
I'd love to be able to understand some complicated bit of code by watching an Etherpad-style timeline, with audio commentary of the whole (test-first?) process.

I love all those special characters, too. So much easier and quicker to read (chunk) than method names and so on.

And I expect the audio track to be sampled on a forthcoming relaxation tape.

Re:Conway's Game Of Life in one line of APL by agazso on Saturday January 09, 2010 @01:03PM (#1041713)
It reminded me the old saying that "every C program can be written in one line". Think about it, it's true.

For me it was similar to obfuscated C code, when one line of code packed with funny symbolic names produces a program that shows a bouncing ball or something unexpected like that.

Re:Conway's Game Of Life in one line of APL by dazmax on Saturday January 09, 2010 @04:03PM (#1041981)
It would be better to say it is done in one expression.
Re:Conway's Game Of Life in one line of APL by plaes on Saturday January 09, 2010 @04:14PM (#1041996)
I also found another one-line solution for the same problem: http://catpad.net/michael/apl/
Re:Conway's Game Of Life in one line of APL by tvon on Saturday January 09, 2010 @12:35PM (#1041681)
"one line of APL"? He was coding for 7 minutes, on many lines...

edit: also my first time seeing APL, very neat stuff.

Re:Conway's Game Of Life in one line of APL by smanek on Saturday January 09, 2010 @01:13PM (#1041726)
Most of it was just messing with APL's REPL to build up the less than 3 lines that actually mattered.

That's why I like languages with REPL-like functionality (Lisp, Python, Haskell, etc) so much. It makes for much faster debugging/development loop.

Whenever I code Java/C, I always end up using a tiny 'Testing' file (on the side of my real project) with lots of print statements that serves as a poor man's REPL. But it's still much slower.

Re:Conway's Game Of Life in one line of APL by tvon on Saturday January 09, 2010 @01:48PM (#1041779)
> Most of it was just messing with APL's REPL to build up the less than 3 lines that actually mattered.

Fair enough, and good to know. It was a very cool demo, I just don't care for the "in one line" or "in fifteen minutes" nonsense.

Re:Conway's Game Of Life in one line of APL by gvb on Saturday January 09, 2010 @01:27PM (#1041743)
Work is constant, effort varies (defining effort to be work (useful stuff) plus time wasted to get the work done). By this definition, work will take constant time. He just did a lot of work in one line, so it took quite a while to write that one line.

With different programming languages and different skill levels, you have a different amounts of "wasted time" to do the (constant) useful work.

The person doing the YouTube video wasted almost no time (a couple of typos). If I were to do it, I would have a lot of wasted effort since I never was very good at APL and time has not improved that.

Re:Conway's Game Of Life in one line of APL by tvon on Saturday January 09, 2010 @01:49PM (#1041783)
Yeah, I'm not denigrating the video itself, just the title used here on HN (which does not appear on the youtube page).
Re:Conway's Game Of Life in one line of APL by gvb on Saturday January 09, 2010 @01:57PM (#1041798)
Understood. My comment was an insight that occurred to me as a result of your comment. The insight is that programming "work" is very much like physics "work"

work = effort * distance

In physics, if you don't move something, you have done no work (even though you are sweating and out of breath). In programming, if all you do is write boilerplate stuff, you have not done any work because you have not advanced toward your goal.

Re:Conway's Game Of Life in one line of APL by blaiset on Saturday January 09, 2010 @02:24PM (#1041836)
I wish I fully understood half of what happened in that video. (First time seeing APL, very cool)
Re:Conway's Game Of Life in one line of APL by tibbon on Saturday January 09, 2010 @01:04PM (#1041714)
Can someone put that one line here? I don't feel like watching a video on my mobile.
Re:Conway's Game Of Life in one line of APL by gvb on Saturday January 09, 2010 @01:39PM (#1041763)
life ← {⊃ 1 ω ∨ . ∧ 3 4 = +/ +⌿ 1 0 ~ 1 ∘ . Θ 1 - ~1 Φ" ⊂ ω}

(all typos are mine, not the author's)

Re:Conway's Game Of Life in one line of APL by spc476 on Saturday January 09, 2010 @11:59PM (#1042681)
It took a few minutes (and looking closely at the video) but I think this is what he typed:

life ← { ⊃ 1 ω ∨ . ∧ 3 4 = +/ +⌿ 1 0 ‾1 ∘.θ 1 - ‾1 Φ″ ⊂ ω }

Re:Conway's Game Of Life in one line of APL by gvb on Sunday January 10, 2010 @01:12PM (#1043385)
The actual source can be found at http://www.dyalog.com/dfnsdws/c_life.htm
Re:Conway's Game Of Life in one line of APL by elblanco on Saturday January 09, 2010 @06:38PM (#1042197)
I don't think I have most of those keys on my keyboard...anybody else?
Re:Conway's Game Of Life in one line of APL by mosheg101 on Saturday January 09, 2010 @12:38PM (#1041686)
I fell asleep during the video. Twice.

Thanks for a great solution for insomnia!!

Re:Conway's Game Of Life in one line of APL by houseabsolute on Sunday January 10, 2010 @01:36AM (#1042759)
The guy's voice does have a soporific quality, and I also found myself nodding off (because I am jetlagged). But this is perhaps not the most constructive thing to comment about.