REB IsL漫谈
Programming Fun Again

      支付宝 蔡学镛
REBOL的劣势
完美主义导致发展进度缓慢
对僵化的脑袋来说,这语言有点别扭
远远超出他们的理解
加上核心代码没有开源
好文档相当欠缺
用户与市场需求相当小



       0.0000001%
REBOL的优势
不需要一堆文件与配置
体积超级小…
能做的事却不少
而且很容易就可做到(嗯…上手以后啦)
是当今DSL能力最强的语言
很适合开发抛弃式程序
或者快速打造原型系统
跨越多个主流平台
不可思议的简短代码示例
REBOL[]
View Layout [
    Title "Hello"
    Btn "OK" [
        Quit
    ]
]




    视窗程序居然这么简短
print read http://www.rebol.com




    下载并打印某网页内容
开启视窗、读取网页、邮寄出去

view layout [
    u: field "user@rebol.com"
    h: field "http://"
    btn "Send" [
        send to-email u/text
             read to-url h/text
        alert "Sent“
    ]
]
foreach file load %./ [
    if not dir? file [
        write/binary join
            ftp://user:pass@example.com/
            file
        read/binary file
    ]
]


        FTP上传所有文件
TCP端口扫描
repeat n 100 [
    if not error? try [
        close open probe
            join tcp://localhost: n
    ] [
        print [n "is open"]
    ]
]
remove-each tag page:
    load/markup http://www.rebol.com
    [ tag? Tag ]
write %page.txt page




        将网页存成文件
数字钟
view layout [
    origin 0
    t: h1 red black (to string! now/time)
        rate 1
        feel [
             engage: [
                 t/text: now/time
                 show t
             ]
        ]
]
view l: layout [
    origin 0x0
    b: box "Load" [
        error? try [
            b/image: i:
                load first request-file
            b/text: ""
            l/size: b/size:
            i/size show l
        ]
    ]
]
            图片浏览器
REBOL把事情变简单!
1. 下载、更新,简单!

2. 安装,简单!

3. 不用依赖一堆文件,简单!

4. 编写代码,简单!

4. 移植到其他平台,简单!

5. 维护,简单!
When It Comes
to Programming,
Are You A
   REBEL?                   [`rebl]



Stand up for   Simplicity
and Flexibility, Against Software

Complexity and Software
Obesity             , and Want to

Program with   Fun.

Hay! You Got to Try Java

                      !!!
R   E   B O     L   S   T   A N D   S
F   O R   E   X   A   B   A
          L   P   S   J   N
          A   R   E   E   G
          T   E   D   C U
          I   S       T   A
          V   S           G
          E   I           E
              O
              N
As A Java Programmer,
You Know Objects Already.
But Relative Expression?
Relative-Expression
=>
Context-Sensitive Code


can
• 助动词 / 能
• 名词 / 罐
• 动词 / 装罐
Carl Sassenrath,
The REBOL Creator
3 Ways to Run REBOL Scripts

                                   REBOL
  REBOL          REBOL             Script
  Script         Script


  REBOL                            REBOL
                 REBOL           Interpreter
interactive
               Interpreter
Interpreter

              Operating System
Portable Scripts



                    REBOL Script


REBOL Interpreter                  REBOL Interpreter


Operating System                   Operating System
All In One, One For All

Windowing

Drawing

Networking

Database Accessing

Web Browser Plug-In

External Lib Interface
Data Types You Can Imagine

datatype       value   >> ? 1
                       1 is an integer
Int!       1
                       >> ? 3.1416
Decimal!   3.1416      3.1416 is a decimal
Char!      #"A"        >> ? #"A"
Logic!     True        #"A" is a char
                       >> ? True
String!    "ABC"       TRUE is a logic of value: true
                       >> Type? "ABC"
                       == string!
Data Types You Cannot Imagine

   datatypeURL                  value
Email!             jerry@abc.com
Percent!           32%
Tag!               <IMG>
Date!              2009-7-21
Time!              18:00
File!              %gdi32.dll
Tuple!             127.0.0.1
URL!               http://www.abc.com/
. . . More . . .
REBOL Data Types (& Type Sets)
                                    Char!



                     Scalar

 Any-String
                    Number


   Series      Any-Type          Any-Word



 Any-Block        Any-Function
// Pseudo-Code                          REBOL[]
// Include This and That                View Layout [
// Declare This and That                    Title "Hello"
                                            Btn "OK" [
// ...                                          Quit
Class MyApp {                               ]
  MyApp () {                            ]
    // …
  }
  void action() {
       System.quit();
  }
  void layout() {
     Label title = new Label("Hello")
     Button btn = new Button("OK");
     btn.Click = action;
     Window win = new Window();
     win.add(btn);
     win.add(btn);
     win.show();
  }
Parsing


                           Functions
           Maintain



Literals   Readable    Abstraction               Dialecting



           Writeable                    GUI


           Succinct                    Finance


                                     Database
           Bug-Free

                                         ...
REBOL Plug-ins
                 • Extends REBOL

                 • Are DLLs

                 • Can Be in C or REBOL

                 • Only in REBOL 3.0
REBOL in Web Server



• CGI (Common Gateway Interface)

• Fast-CGI

• Cheyenne Web Server (300 KB Only)

• REBOL Server Pages (RSP)
REBOL 3.0 Supports
• String is in Unicode.             Unicode

• Both In Core and In View

• Will Support Multi CharSets
REBOL/Services (SOA Lite)




        XML? Nah!
        Dialects are Better.
REBOL/Code

• Talk to REBOL VM Directly

• With Great Performance

• REBOL Dialecting Technology
When to Use REBOL




Spider           Dialect          Text
                               Processing




  Mobile          Instance       Artificial
  Agent          Messenger     Intelligence
蔡学镛   Rebol漫谈

蔡学镛 Rebol漫谈