蔡学镛 rebol漫谈
TRANSCRIPT
REB L漫谈Programming Is 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 "[email protected]"
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:[email protected]/
file
read/binary file
]
]
FTP上传所有文件
repeat n 100 [
if not error? try [
close open probe
join tcp://localhost: n
] [
print [n "is open"]
]
]
TCP端口扫描
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
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
!!!
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
As A Java Programmer, You Know Objects Already.
But Relative Expression?
can • 助动词 / 能
• 名词 / 罐
• 动词 / 装罐
Relative-Expression=>Context-Sensitive Code
Carl Sassenrath, The REBOL Creator
3 Ways to Run REBOL Scripts
Operating System
REBOLInterpreter
REBOLScript
REBOLInterpreter
REBOLScript
REBOLinteractive Interpreter
REBOLScript
Portable Scripts
Operating System
REBOL Interpreter
REBOL Script
Operating System
REBOL Interpreter
Windowing
Drawing
Networking
Database Accessing
Web Browser Plug-In
External Lib Interface
All In One, One For All
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!
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 . . .
Any-TypeSeries
Scalar
Number
Any-Word
Any-String
Any-FunctionAny-Block
REBOL Data Types (& Type Sets)Char!
// 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
]
]
Maintain
Writeable
Succinct
Literals Dialecting
Parsing
Abstraction
Bug-Free
Readable
GUI
Finance
Database
. . .
Functions
• Extends REBOL
• Are DLLs
• Can Be in C or REBOL
• Only in REBOL 3.0
REBOL Plug-ins
REBOL in Web Server
• CGI (Common Gateway Interface)
• Fast-CGI
• Cheyenne Web Server (300 KB Only)
• REBOL Server Pages (RSP)
REBOL 3.0 SupportsUnicode• String is in 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
MobileAgent
InstanceMessenger
Dialect
ArtificialIntelligence
TextProcessing