蔡学镛 Rebol漫谈

49
REB L漫谈 Programming Is Fun Again 支付宝 蔡学镛

Transcript of 蔡学镛 Rebol漫谈

Page 1: 蔡学镛   Rebol漫谈

REB L漫谈Programming Is Fun Again

支付宝 蔡学镛

Page 2: 蔡学镛   Rebol漫谈

REBOL的劣势

Page 3: 蔡学镛   Rebol漫谈

完美主义导致发展进度缓慢

Page 4: 蔡学镛   Rebol漫谈

对僵化的脑袋来说,这语言有点别扭

Page 5: 蔡学镛   Rebol漫谈

远远超出他们的理解

Page 6: 蔡学镛   Rebol漫谈

加上核心代码没有开源

Page 7: 蔡学镛   Rebol漫谈

好文档相当欠缺

Page 8: 蔡学镛   Rebol漫谈

用户与市场需求相当小

0.0000001%

Page 9: 蔡学镛   Rebol漫谈

REBOL的优势

Page 10: 蔡学镛   Rebol漫谈

不需要一堆文件与配置

Page 11: 蔡学镛   Rebol漫谈

体积超级小…

Page 12: 蔡学镛   Rebol漫谈

能做的事却不少

Page 13: 蔡学镛   Rebol漫谈

而且很容易就可做到(嗯…上手以后啦)

Page 14: 蔡学镛   Rebol漫谈

是当今DSL能力最强的语言

Page 15: 蔡学镛   Rebol漫谈

很适合开发抛弃式程序

Page 16: 蔡学镛   Rebol漫谈

或者快速打造原型系统

Page 17: 蔡学镛   Rebol漫谈

跨越多个主流平台

Page 18: 蔡学镛   Rebol漫谈

不可思议的简短代码示例

Page 19: 蔡学镛   Rebol漫谈

REBOL[]

View Layout [

Title "Hello"

Btn "OK" [

Quit

]

]

视窗程序居然这么简短

Page 20: 蔡学镛   Rebol漫谈

print read http://www.rebol.com

下载并打印某网页内容

Page 21: 蔡学镛   Rebol漫谈

view layout [

u: field "[email protected]"

h: field "http://"

btn "Send" [

send to-email u/text

read to-url h/text

alert "Sent“

]

]

开启视窗、读取网页、邮寄出去

Page 22: 蔡学镛   Rebol漫谈

foreach file load %./ [

if not dir? file [

write/binary join

ftp://user:[email protected]/

file

read/binary file

]

]

FTP上传所有文件

Page 23: 蔡学镛   Rebol漫谈

repeat n 100 [

if not error? try [

close open probe

join tcp://localhost: n

] [

print [n "is open"]

]

]

TCP端口扫描

Page 24: 蔡学镛   Rebol漫谈

remove-each tag page:

load/markup http://www.rebol.com

[ tag? Tag ]

write %page.txt page

将网页存成文件

Page 25: 蔡学镛   Rebol漫谈

view layout [

origin 0

t: h1 red black (to string! now/time)

rate 1

feel [

engage: [

t/text: now/time

show t

]

]

]

数字钟

Page 26: 蔡学镛   Rebol漫谈

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

]

]

]

图片浏览器

Page 27: 蔡学镛   Rebol漫谈

REBOL把事情变简单!

1. 下载、更新,简单!

2. 安装,简单!

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

4. 编写代码,简单!

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

5. 维护,简单!

Page 28: 蔡学镛   Rebol漫谈

When It Comes to Programming, Are You A

R E B E L ?[`rebl]

Stand up for Simplicityand Flexibility, Against Software

Complexity and Software

Obesity, and Want to

Program with Fun.

Hay! You Got to Try Java

!!!

Page 29: 蔡学镛   Rebol漫谈

R E B O L

E

L

A

T

I

V

E

X

P

R

E

S

S

I

O

N

A

S

E

D

B

J

E

C

T

A

N

G

U

A

G

E

S T A N D S

F O R

Page 30: 蔡学镛   Rebol漫谈

As A Java Programmer, You Know Objects Already.

Page 31: 蔡学镛   Rebol漫谈

But Relative Expression?

Page 32: 蔡学镛   Rebol漫谈

can • 助动词 / 能

• 名词 / 罐

• 动词 / 装罐

Relative-Expression=>Context-Sensitive Code

Page 33: 蔡学镛   Rebol漫谈

Carl Sassenrath, The REBOL Creator

Page 34: 蔡学镛   Rebol漫谈

3 Ways to Run REBOL Scripts

Operating System

REBOLInterpreter

REBOLScript

REBOLInterpreter

REBOLScript

REBOLinteractive Interpreter

REBOLScript

Page 35: 蔡学镛   Rebol漫谈

Portable Scripts

Operating System

REBOL Interpreter

REBOL Script

Operating System

REBOL Interpreter

Page 36: 蔡学镛   Rebol漫谈

Windowing

Drawing

Networking

Database Accessing

Web Browser Plug-In

External Lib Interface

All In One, One For All

Page 37: 蔡学镛   Rebol漫谈

Data Types You Can Imagine

datatype value

Int! 1

Decimal! 3.1416

Char! #"A"

Logic! True

String! "ABC"

>> ? 1

1 is an integer

>> ? 3.1416

3.1416 is a decimal

>> ? #"A"

#"A" is a char

>> ? True

TRUE is a logic of value: true

>> Type? "ABC"

== string!

Page 38: 蔡学镛   Rebol漫谈

Data Types You Cannot Imagine

datatypeURL value

Email! [email protected]

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 . . .

Page 39: 蔡学镛   Rebol漫谈

Any-TypeSeries

Scalar

Number

Any-Word

Any-String

Any-FunctionAny-Block

REBOL Data Types (& Type Sets)Char!

Page 40: 蔡学镛   Rebol漫谈

// Pseudo-Code

// Include This and That

// Declare This and That

// ...

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();

}

}

REBOL[]

View Layout [

Title "Hello"

Btn "OK" [

Quit

]

]

Page 41: 蔡学镛   Rebol漫谈

Maintain

Writeable

Succinct

Literals Dialecting

Parsing

Abstraction

Bug-Free

Readable

GUI

Finance

Database

. . .

Functions

Page 42: 蔡学镛   Rebol漫谈
Page 43: 蔡学镛   Rebol漫谈

• Extends REBOL

• Are DLLs

• Can Be in C or REBOL

• Only in REBOL 3.0

REBOL Plug-ins

Page 44: 蔡学镛   Rebol漫谈

REBOL in Web Server

• CGI (Common Gateway Interface)

• Fast-CGI

• Cheyenne Web Server (300 KB Only)

• REBOL Server Pages (RSP)

Page 45: 蔡学镛   Rebol漫谈

REBOL 3.0 SupportsUnicode• String is in Unicode.

• Both In Core and In View

• Will Support Multi CharSets

Page 46: 蔡学镛   Rebol漫谈

REBOL/Services (SOA Lite)

XML? Nah! Dialects are Better.

Page 47: 蔡学镛   Rebol漫谈

REBOL/Code

• Talk to REBOL VM Directly

• With Great Performance

• REBOL Dialecting Technology

Page 48: 蔡学镛   Rebol漫谈

When to Use REBOL

Spider

MobileAgent

InstanceMessenger

Dialect

ArtificialIntelligence

TextProcessing

Page 49: 蔡学镛   Rebol漫谈