Looking for ugly code comparisons WAS: Slashdotter looking for kids' programming language

Brian Yennie briany at qldlearning.com
Thu Dec 11 22:41:56 EST 2008


If you want ugly code in Rev, the key is to do things in a horrible,  
obtuse and irrational fashion. Smoke and mirrors, my friends!
(nope, haven't tested this but it looks right to me =))

on foo
  put item -5 of "fox,cat,dog,horse" into t
  put 0*pi*100 into x
  repeat while (x < (256 - charToNum(space)))
      put empty into l
      put numToChar(x+32) after l
      put numToChar(32) before l
      put (x+32) before l
      put l into line (x+1) of t
      put x + 1 into x
  end repeat
  replace space with "   "&space&space&space&"   " in t
  sort lines of t numeric by word 1 of each
  put line 1 to -1 of (t&cr)
end foo

> Hi Judy,
>
> A few very simple examples. Revolution is clearly much more readable  
> and easier to work with for starting programmers than other languages.
>
> # revolution
> on foo
> repeat with x = 32 to 255
>   put x & "         " & numToChar(x) & cr after msg
> end repeat
> end foo
>
> This one is hardly readable if you're not used to reading programing  
> code:
>
> # php
> <?php
> for ($chrNr=32;$chrNr < 255;$chrNr++)
> {
> 	echo $chrNr."        ".chr($chrNr)."\n";
> }
> ?>
>
> Just for fun, here's the AppleScript version. Quite similar to  
> Revolution, but much more picky.
>
> -- applescript
> on foo()
> 	set myList to ""
> 	repeat with x from 32 to 255
> 		set myList to myList & x & "      " & (ASCII character x) & return
> 	end repeat
> 	return myList
> end foo
>
> Btw, if you want ugly code, this one should not be omitted...
>
> 0 REM BASIC
> 10 LET x = 31
> 20 LET X = X + 1
> 30 PRINT x,"        ",CHR$(x)
> 40 IF x < 255 GOTO 20
> 50 END



More information about the use-livecode mailing list