Author Topic: A movie about A Turing -- Factor programming language  (Read 12428 times)

0 Members and 2 Guests are viewing this topic.

RobbeK

  • Guest
A movie about A Turing -- Factor programming language
« on: October 17, 2014, 01:41:52 AM »
Hi all,

http://www.imdb.com/video/imdb/vi3398414105/?ref_=tt_ov_vi

... at least : a movie should have been made earlier, but :  "In the United Kingdom, computer scientist Alan Turing, famous for his contributions to mathematics and computer science, was a homosexual who chose to undergo chemical castration in order to avoid imprisonment in 1952.[23] At the time, homosexual acts between males were still illegal and homosexuality was widely considered to be a mental illness that could be treated with chemical castration.[23] Turing experienced side effects such as breast enlargement[24] and bloating of the physique.[23] He died two years later, with the inquest returning a verdict of suicide,[25] although recent research has cast doubt on this result.[26] In 2009, the then British Prime Minister Gordon Brown issued a public apology for the "appalling" treatment of Turing after an online petition seeking the same gained 30,000 signatures and international recognition.[27] He was given a posthumous Royal Pardon in December 2013."

 >:(   ---   the reward for saving 1000s of people

-------------------  and a most interesting programming language :
http://www.youtube.com/watch?v=f_0QlhYlS8g

it feels great :  it's a stack oriented language, avoiding the lisp parenses by doing everything via same --  it has the full numeric tower , OpenGL , streams and lazy lists , mapping , lambdas etc ...
2 compilers : a naive and an optimizing ..  high speed compiled code benchmarks ....


best, Rob
« Last Edit: October 17, 2014, 01:49:56 AM by RobbeK »

JRS

  • Guest
Re: A movie about A Turing -- Factor programming language
« Reply #1 on: October 17, 2014, 12:30:16 PM »
Rob,

In a strange way I can relate to Alan Turing story. My beliefs in a simple to use, cross platform BASIC solution is viewed as a sick way of thinking.  :-[  I may be wrong and the reason folks don't use SB because what they have seen looks too good to be true. (all screen shots are Photoshop'ed and none of the code really works) Who knows what goes on in the minds of those not willing to put one foot in front of another.


Charles Pegge

  • Guest
Re: A movie about A Turing -- Factor programming language
« Reply #2 on: October 17, 2014, 01:19:35 PM »

Short demo of an interactive concatenative system.

"Brief" Concatenative Programming Language Demo
2011


http://www.youtube.com/watch?v=R3MNcA2dpts

JRS

  • Guest
Re: A movie about A Turing -- Factor programming language
« Reply #3 on: October 17, 2014, 10:49:57 PM »
Brief has a Lisp philosophy. Should be doable in a web interface.

 

Charles Pegge

  • Guest
Re: A movie about A Turing -- Factor programming language
« Reply #4 on: October 18, 2014, 12:36:23 AM »
I think it would be very easy to reconfigure Lisp into a Cat language.

1 Place all operators on the right, before each closing bracket.

2 remove closing brackets

3 remove opening brackets and offer an optional fence marker.

Disposing of all those brackets would be a blessed relief :)

RobbeK

  • Guest
Re: A movie about A Turing -- Factor programming language
« Reply #5 on: October 18, 2014, 02:02:15 AM »
Hi Charles, John ,

.... My beliefs in a simple to use, cross platform BASIC solution is viewed as a sick way ...
oh, but most people love complexities ( .. and gadgets, it gives a (false) feeling of importance  :-\

Yep, coding in (somthing like) Factor , gives a "Lisp Erlebnis / déjà-vu"   8) , and the stack a nice mechanism removing the parens --  do you remember the (iirc) Jupiter Ace home computer from the early 1980's ????  it was equipped with a Forth interpreter/compiler and outperformed in speed everything else on the market.

that Euler #1 is also a one-liner in Lisp (a quicky) :

(apply + (filter (lambda (x) (or (zero? (mod x 3)) (zero? (mod  x 5)))) (sequence 1 999)))


-------------- REPL

newLISP v.10.6.0 32-bit on Win32 IPv4/6 libffi, options: newlisp -h

>
(3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60
 63 65 66 69 70 72 75 78 80 81 84 85 87 90 93 95 96 99 100 102 105 108 110 111 114
 115 117 120 123 125 126 129 130 132 135 138 140 141 144 145 147 150 153 155 156
 159 160 162 165 168 170 171 174 175 177 180 183 185 186 189 190 192 195 198 200
 201 204 205 207 210 213 215 216 219 220 222 225 228 230 231 234 235 237 240 243
 245 246 249 250 252 255 258 260 261 264 265 267 270 273 275 276 279 280 282 285
 288 290 291 294 295 297 300 303 305 306 309 310 312 315 318 320 321 324 325 327
 330 333 335 336 339 340 342 345 348 350 351 354 355 357 360 363 365 366 369 370
 372 375 378 380 381 384 385 387 390 393 395 396 399 400 402 405 408 410 411 414
 415 417 420 423 425 426 429 430 432 435 438 440 441 444 445 447 450 453 455 456
 459 460 462 465 468 470 471 474 475 477 480 483 485 486 489 490 492 495 498 500
 501 504 505 507 510 513 515 516 519 520 522 525 528 530 531 534 535 537 540 543
 545 546 549 550 552 555 558 560 561 564 565 567 570 573 575 576 579 580 582 585
 588 590 591 594 595 597 600 603 605 606 609 610 612 615 618 620 621 624 625 627
 630 633 635 636 639 640 642 645 648 650 651 654 655 657 660 663 665 666 669 670
 672 675 678 680 681 684 685 687 690 693 695 696 699 700 702 705 708 710 711 714
 715 717 720 723 725 726 729 730 732 735 738 740 741 744 745 747 750 753 755 756
 759 760 762 765 768 770 771 774 775 777 780 783 785 786 789 790 792 795 798 800
 801 804 805 807 810 813 815 816 819 820 822 825 828 830 831 834 835 837 840 843
 845 846 849 850 852 855 858 860 861 864 865 867 870 873 875 876 879 880 882 885
 888 890 891 894 895 897 900 903 905 906 909 910 912 915 918 920 921 924 925 927
 930 933 935 936 939 940 942 945 948 950 951 954 955 957 960 963 965 966 969 970
 972 975 978 980 981 984 985 987 990 993 995 996 999)
>
233168
>

yesterday I coded a complete triangulation network wit 5-6 lines of Lisp code   (unique branches - no overlaps )   -- it's not special , just easy in languages like Lisp etc ...

Factor :  sadly my comp's hardware is out of date :
http://factorcode.org/factor-windows7.png

if you install  Factor , it should run in the listener just with     "spheres" run


best Rob

 

Charles Pegge

  • Guest
Re: A movie about A Turing -- Factor programming language
« Reply #6 on: October 18, 2014, 02:58:28 AM »
Yes, I remember the Jupiter, but they were on the market for such a brief period, I never got round to buying one.

http://en.wikipedia.org/wiki/Jupiter_Ace

Notional Cat code:

N factorial

  inc 1 ( dec2 one? exit  dup2 mul repeat ) swap pop

JRS

  • Guest
Re: A movie about A Turing -- Factor programming language
« Reply #7 on: October 18, 2014, 05:32:20 AM »
Quote
oh, but most people love complexities ( .. and gadgets, it gives a (false) feeling of importance

I have come to the conclusion no one programs in BASIC any longer.  The only interest in BASIC is creating another interpreter because the 100+ variations that exist in one form or another aren't good enough.

JRS

  • Guest
Re: A movie about A Turing -- Factor programming language
« Reply #8 on: October 18, 2014, 05:40:50 AM »
Quote from: Rob
sadly my comp's hardware is out of date

Did you ever give Koding.com a try? (64 bit Ubuntu 14.04 LTS) FREE

Charles Pegge

  • Guest
Re: A movie about A Turing -- Factor programming language
« Reply #9 on: October 19, 2014, 02:41:00 AM »
The Pentium's FPU (floating point processor) is an almost perfect cat machine.

a+(b*c)+d

fxch  st1   ' b   a   c   d
fmulp st2   ' a (b*c)   d
faddp st1   ' a+(b*c)  d
faddp st1   ' a+(b*c)+d




the FPU instructions are deployed here in a deff macro. Such macros handle all Oxygen's core floating point functions.

Code: [Select]
include "$/inc/console.inc"
indexbase 0

deff TestFormula

'a+(b*c)+d

'naive

'fxch st1 '
'fmul st2
'fadd st1
'fadd st3
'fxch st3
'fstp st0 ' drop
'fstp st0 ' drop
'fstp st0 ' drop


'appending 'p' puts the result in the specified FPU stack register (st0..st7),
'then drops st0 after the instruction,
'moving all operands up 1 position.

'compacted:   st0 st1 st2 st3

fxch  st1   ' b   a   c   d
fmulp st2   ' a (b*c)   d
faddp st1   ' a+(b*c)  d
faddp st1   ' a+(b*c)+d

end deff

float a
#show a=TestFormula(1,2,3,4)
print a
waitkey
« Last Edit: October 19, 2014, 05:38:43 AM by Charles Pegge »

Charles Pegge

  • Guest
Re: A movie about A Turing -- Factor programming language
« Reply #10 on: October 19, 2014, 04:03:38 AM »
An earlier film on Turing:

Breaking the Code: Biography of Alan Turing (Derek Jacobi, BBC, 1996)
http://www.youtube.com/watch?v=S23yie-779k


Alan Turing: Inquest's suicide verdict 'not supportable' -2012
http://www.bbc.co.uk/news/science-environment-18561092
« Last Edit: October 19, 2014, 04:23:41 AM by Charles Pegge »

Charles Pegge

  • Guest
Re: A movie about A Turing -- Factor programming language
« Reply #11 on: October 19, 2014, 07:22:52 PM »
Fibonacci series using the FPU stack

This is built around two instructions:

fadd
fxch


The CPU manages iteration and storage of the values into array f[]

Code: [Select]
include "$/inc/console.inc"
indexbase 0

deff FiboSeries
===============
fld1
fldz
(
 dec   ecx
 jl    exit
 fadd  'st1
 fxch  'st1
 fld   st0
 fistp qword [edx]
 add   edx, 8
 repeat
)
fstp st0
fstp st0
end deff

sys n=90
quad f[100]
ecx=n+1 : edx=@f : =FiboSeries()
print f[n-1] "/" f[n] cr f[n]/f[n-1]
waitkey

RobbeK

  • Guest
Re: A movie about A Turing -- Factor programming language
« Reply #12 on: October 20, 2014, 01:53:35 AM »
Hi ,    thanks John -- forgot, but tried it now, works great !

Great Charles,  :)

It could also be written in Lisp without much problems imho.

-------------------------

;; CatSimul

(define stack nil)

(define (pop*) (pop stack))
(define (push* x) (push x stack))
(define (dup*) (push (first stack) stack))

(define (swap*)
  (let ((a (pop stack))
        (b (pop stack)))
   (push a stack)
   (push b stack)))

(define (clr*) (setq stack nil))

(define (+*) (push* (+ (pop*) (pop*))))

(define (print*) (print (pop*)))

(define (rot*)
  (let ((a (pop*))
        (b (pop*))
        (c (pop*)))
   (push* b) (push* a) (push* c)))

(define-macro (do* i f)
  (dotimes (void (eval i) )
    (dolist (j (eval f)) (eval j) )))

(define (fibo x)
  (clr*)
  (do* 2 '((push* 1L)))
  (do* x '((dup*) (rot*) (+*) ))
  (swap*) (print*) (print "  OK  ")
   )

----------------------------REPL

> (time (fibo 4000))
6457488449094817353137694901536959564441390064015134270840757759817721035903408891444947780728724174
3760741523783818897499227009742183152482019062763550798743704275106856470216307593623057388506776767
2020696704775060888952943005092911660239478668417638539538139822817039366653699227090953080068213995
2478072104995582919140702994362208777929645917401261014865952038117045259114133194933608057714170864
5783606636081941915217355115810993973945783493983844592749672661361548061615756595818944317619922097
3699176769740582063418920881445493379744229521401326215683407010162734227278277627261530663030930529
8205175744474242803310752241946621965578041310175950523161722257829248608100239121878518929967575776
6920269402348733644662725774717740924068828300186439425921761082545463164628807702653752619616157324
434040342057336683279284098590801501L  OK  78.125
-----------------
that's less than 0.1 sec (with an interpreter)

the stack is typeless here  8)   can contain strings, lambda's, numbers ...  other stacks  ???   etc...

maybe an own stack for the iterations and maybe one for the formulae (lambda's)  ...
Syntax can be completely changed by writing some syntax-macro's   ... numbers already evaluate to themselves, but function could be changed into symbols (here it are still functions)  then the parens can go, the sequence can be changed and numbers will be automatically placed on the stack     ... but as mixing data and code is no problem .....

just a simulation of course ;..   ,,   thanks for the links .. appreciated !!

best Rob

the code does

A
B
-------------------->  DUP ROT +
A+B
B   
(on the stack)

mmm, an idea -- a numeric stack processed with Oxygen - and a (slower) typeless controled by Lisp -- that should be something

-----    better syntax :


(define stack nil)
(define lambda-stack nil)
(define $cat 0)

(define (clr-lambda-stack) (setq lambda-stack nil))
 

(define-macro (cat#)
 (doargs (i)
   (if (number? i)
       (push i stack)
   (if (list? i) (push i lambda-stack)
   (let ((s (string i)))
       (cond ((= s "dup") (push (stack 0) stack))
             ((= s ".") (println (pop stack) "  ok" ))
             ((= s "drop") (pop stack))
             ((= s "+" ) (push (+ (pop stack) (pop stack)) stack ))
             ((= s "swap") (let ((a (pop stack))
                                 (b (pop stack))) (push a stack) (push b stack)))
             ((= s "do")
                 (dotimes (void (pop stack)) (eval (cons 'cat# (first lambda-stack))))
                 (clr-lambda-stack))
             ((= s "rot") (let (( a (pop stack))
                                (b (pop stack)) (c (pop stack)))
                    (push b stack) (push a stack) (push c stack)))
             ((= s "$cat") (push $cat stack))     
  )))))  )


now the only parens used are to put composed parts on a "lambda-stack" for iteration etc...
it is called recursively, but only one level / parens ...  they can be nested ....


> (cat# 1L 1L (dup rot +) 4000 do swap .)    -- all that's needed for a fibonacci


6457488449094817353137694901536959564441390064015134270840757759817721035903408891444947780728724174
3760741523783818897499227009742183152482019062763550798743704275106856470216307593623057388506776767
2020696704775060888952943005092911660239478668417638539538139822817039366653699227090953080068213995
2478072104995582919140702994362208777929645917401261014865952038117045259114133194933608057714170864
5783606636081941915217355115810993973945783493983844592749672661361548061615756595818944317619922097
3699176769740582063418920881445493379744229521401326215683407010162734227278277627261530663030930529
8205175744474242803310752241946621965578041310175950523161722257829248608100239121878518929967575776
6920269402348733644662725774717740924068828300186439425921761082545463164628807702653752619616157324
434040342057336683279284098590801501L  ok
171.875


« Last Edit: October 20, 2014, 06:27:07 AM by RobbeK »

Charles Pegge

  • Guest
Re: A movie about A Turing -- Factor programming language
« Reply #13 on: October 20, 2014, 08:03:56 AM »
Hi Rob,

It seems there was no evidence  that Turing was feeling depressed and persecuted leading to suicide. He had a laboratory next to his bedroom, and he was performing experiments with gold plating, which involves electrolysis with potassium cyanide solution. It looks like an unfortunate accident. However, he might have been suicided by the security services as a perceived risk, having all those boyfriends...



I am making one minor change to the assembler, to make deff macros able to invoke other simple macros. This will greatly facilitate building stack languages around FPU instructions.

This is an experimental coding for the inner loop of a Mandelbrot plot. It saturates the FPU stack, but it does the iteration entirely in registers.

Code: [Select]
deff MandelbrotLimit
====================
  push 0
  fistp dword[esp]
  pop ecx
  fldz 'y0
  fldz 'x0
  inc  ecx
  (
   dec   ecx
   jle exit             'always exit after 'count' iterations
   fld   st0 : fmul st0 'sqx0
   fld   st2 : fmul st0 'sqy0
   fsubp st1            'sqx0-sqy0
   fadd  st3            '+x
   fld   st1            'x0
   fmul  st3            'x0*y0
   fadd  st0            '2*x0*y0
   fadd  st5            '+y
   fstp  st3            'new y0
   fst   st1            'new x0
   ; TEST LIMIT
   fmul  st0            'sq x0
   fld st2 : fmul st0   'sq y0
   faddp st1            'sqx0+sqy0
   fld st5              '4.0
   fcomip               'compare 4.0 - result ( drop 4.0 )
   fstp st0             'drop result
   ja repeat            'continue if 4.0 was greater than result
  )
  fstp st0 : fstp st0
  fstp st0 : fstp st0
  fstp st0
  push ecx
  fild dword [esp]
  pop ecx
end deff

Used in conjunction with one of Peter's GDI windows examples:
Code: [Select]
include "window.inc"
Window "MANDEL AFRICAN",620,500,4

single x,y,cx,cy,f=.004, four=4.0
sys    count=32

ClsColor 105,168,100
  For x=0 To 620
    cx=x*f-1.5
    For y=0 To 250 
      cy=1-y*f
      i=MandelbrotLimit(four, cy, cx, count)
      if i
        i=count-i
        Pixel x, y,ColorRGB(i*.4,y,i*.6)
        Pixel x, 500-y, ColorRGB(i*.4,y,i*.6)
      end if
    Next
  Next
Pause
« Last Edit: October 20, 2014, 08:50:21 AM by Charles Pegge »

Mike Lobanovsky

  • Guest
Re: A movie about A Turing -- Factor programming language
« Reply #14 on: October 20, 2014, 08:19:13 AM »
Hi Charles,

Given

Code: [Select]
edx=@f-8
and

Code: [Select]
(
 add   edx, 8
 dec   ecx
 jl    exit
 fadd  'st1
 fxch  'st1
 fld   st0
 fistp qword [edx]
 repeat
)

the integer instruction flow will run at least 2 times faster thanks to UV pairability of successive add edx and dec ecx instructions which are otherwise separated by a jump back at repeat. :)