为您介绍ActiveShell:一个为Web而设计的Shell
过去的几周我都在为一个名为ActiveShell的项目忙碌着,这个Shell是为Web而设计的。就像Unix的Shell,ActiveShell能够让你用文本命令来操作。而和Unix的Shell不同的地方在于,ActiveShell的会话存在于浏览器中。Web正支持越来越多强大的应用,相比较于硬件文本终端当道的年代,我们在界面设计上可以做得更好。我们可以通过存储更多的输出结果和历史命令来提高效率,并且通过增加基于内容的易读性以便于用户学习。我们不是仅仅支持本地机器或仅仅支持远程SSH服务器,而是通过一致的接口来支持网络中任何可用的服务,例如社交网络API,电子邮件,FTP,或数据库服务器。
This is an opportunity to design a better shell for the development environment of the future, which I believe will be the Web itself.Consumer computing devices are becoming less general and open, designed for consumption more than creation.Those born today may grow up without access to the kinds of flexible tools that sparked so many young people's interest in programming during the era of desktop computing.Bringing developer tools to the Web means bringing the full power of general-purpose computing to a new generation.
藉此良机,我们应该为今后的开发环境设计一个更好的Shell,我认为这个Shell将成为Web本身。消费电脑设备正变得不如以前常规和开放,这些设备更多的是被设计用来消费而不是创造。出生的那些人可能在成长过程中缺乏灵活的工具,而这些工具在桌面电脑时代曾经点燃了许多年轻人对于编程的热情。
ActiveShell is currently at the prototype stage.I am focused on extending the prototype for specific practical use cases, while resolving any design issues around extension points that would be difficult to change later.Once this is done, new interface features, verbs, and ports can be created and shared by the community of users.A sysadmin might use ActiveShell to deploy to multiple servers; a student to follow an interactive programming tutorial; a programmer to fix a bug and commit the fix back to the revision control system; a researcher to load a sample data set, run some exploratory commands, and eventually queue a job on a cluster to run that same analysis over the full data set and publish the output to a Web server.These use cases require different capabilities and access to different kinds of remote systems, which is why verbs (which process data) and ports (which mediate I/O with the rest of the Web) are extension points.What remains constant is the interaction model of sequential, text-based commands, and the consistent interface through which data of any kind can be explored and manipulated.
ActiveShell目前还处在原型阶段。我正致力于为确切的实际用例扩展原型,解决扩展点上的设计问题,这些问题在以后可能很难改变。一旦这部分完成,新的接口特性、动词(译者注:在计算机语言中用来执行动作的关键字,比如AND,READ,DO等)、以及端口都可由用户社区创造和分享。系统管理员可以用ActiveShell部署多台服务器;学生可以用它来学习互动编程教程;程序员可以用它来修复bug并将补丁提交回版本控制系统;研究人员可以用它来装载样本数据集,运行一些研究命令,最终将工作排成队列,以此来对整个数据集进行同样的分析,并将结果发布到网络服务器上。这些用例需要不同的功能和连接不同的远程系统,这就是为什么动词(用来处理数据)和端口(用来让输入/输出与其他网络通信)是扩展点。保持不变的是有序互动模型、基于文本的命令和一致的接口,以供任何数据通过,并被发现和操作。
There are many benefits to a Unix-like uniform interface between small, composable programs.In Unix, unfortunately, the use of plain text streams requires inconvenient parsing and escaping at every turn.We can do better by passing structured data, with a JSON-like small set of primitive data types and collections over them: strings, numbers, Boolean values, and lists and maps.String arguments are always quoted, using C-like string literal syntax.Command syntax is minimalist and allows verbs to appear before, after, or among arguments, which gives greater scope to autocompletion and hinting.Most of the ambiguity and ugliness of Unix shell command syntax is easily eliminated.
类似于Unix的统一接口在小的、组合型的程序中有很多好处。但不幸的是,在Unix中,使用纯文本流每次都需要进行不方便的语法分析和转码。我们用一套类似于JSON的小型的简单数据类型和数据集合来传递结构化数据,该集合包含字符串、数字、布尔值、列表和映射。字符串参数总是被引用的,使用类似于C语言的字符串语法。命令语法是最基本的,并且允许动词出现在参数之前、之后或之中,这能给自动完成和语法提示更大的空间。大部分Unix Shell命令语法的模糊性和不优雅都能轻易地消除。
ActiveShell supports the ad-hoc re-use of the output of any earlier command.In Unix, command output is written to the terminal but otherwise lost, unless it was explicitly redirected to another command or to a file.This made more sense in the 1970s than it does now.Easy re-use of the output of previous commands encourages exploratory programming and data analysis.This ad-hoc routing creates a relationship between command inputs and outputs, which begins to erase the difference between using a shell and writing a shell script.After calculating a value by an ad-hoc sequence of commands, the entire calculation of that value and its dependency tree is known to the shell and can be used to make things simple that should be simple, such as re-applying the same complex calculation to new input data.A process that was performed on one value can be applied to a set of values without specifying the process again.The shell can be asked to "save the sequence of steps which took inputs A, B, C and gave the output X", and the result is then effectively an ad-hoc shell script taking three arguments, which can be saved as a new verb or even exported as a library function for use outside of the shell.Such scripts, and the command history itself, are stored in a parsed representation, so the command syntax can be freely changed without breaking backward compatibility with existing sessions or stored scripts (this has held back Unix shell syntax considerably).
ActiveShell支持ad-hoc(无线自组网)对之前命令输出结果的重用。在Unix中,命令的输出结果写在终端上,但其他的却丢失了,除非它被明确的重定向到另一个命令或文件。相比于现在,这在上世纪70年代更加有意义的多。对之前命令输出结果的简单重用能够鼓励人们对编程的探索和对数据的分析。这个ad-hoc路由在命令的输入与输出之间创造出一种联系,从而开始消除使用Shell和编写Shell脚本之间的区别。在ad-hoc序列命令计算完数值之后,对数值的整个运算过程以及该数值的依赖关系树都可以显示在Shell上,并且可以用来让本该简单的事情变得简单,例如重新将该复杂的运算应用到新的输入数据上。针对一个数值的运算过程无需重新配置就能够应用到一系列其他数值上。你可以要求Shell“存储根据输入A,B,C得到输出X的一系列步骤”,然后,一段ad-hoc脚本读取三个参数——这三个参数可以存储为一个新的动词甚至导出为一个库函数以供在Shell之外使用——就能有效的获得结果。这样的脚本,以及命令历史本身,都被存储在解析过的表示中,所以命令语法能够自由地改变而无需破坏与当前会话或存储脚本的向后兼容性(这一点跟Unix Shell的语法差别很大)。
Comfortable exploratory programming is also encouraged by providing a safe environment where such side-effects as accidentally erasing a filesystem are simply not possible.An environment where "rm -rf *" is even possible must be approached with caution, which hinders exploration and learning.ActiveShell begins with safe, reversible operations.Any side-effects outside of this safe environment must occur through ports, which are the means of communication with the world outside of the shell.An open port represents any external system or service, such as an IMAP email account, blog publication API, social networking account, version control system, or the filesystem of a remote server.Data comes into the shell session or goes out into the world only through a port.A port must be explicitly opened by the user, and if no dangerous ports are open, no dangerous side-effects are possible.Any service available over the network is made available to the shell by writing a new port implementation, which may run entirely in the client or may have a server-side component.
本系统提供一个安全的环境,像意外的擦除文件系统这样的副作用基本上是不可能发生的,这能鼓励用户进行舒适的探索式编程。一个能使用"rm -rf *"的环境必须谨慎使用,这就阻碍了用户的探索和学习。ActiveShell的基础就是安全和可逆操作。该安全环境外的任何副作用都必须通过端口,端口是与Shell外部世界通讯的方法。一个打开的端口就代表了一个外部系统或服务,如IMAP电邮账户,博客的公开API,社交网络账户,版本控制系统,或远程服务器的文件系统。数据只能通过端口进入Shell的会话或从Shell中出来。端口必须明确由用户打开,如果没有危险的端口被打开,那么也不会有危险的副作用发生。网络上任何可用的服务都可以通过编写一个新的端口实现来在Shell中使用,该实现可能完全在客户端运行或拥有一个服务器端组件。
Hopefully this brief introduction has given you some idea of what the ActiveShell project is all about, and why I'm excited to be working on it.In my next post, I'll introduce the prototype, with a series of screenshots illustrating a simple task.
希望这段简单的介绍能让你了解到ActiveShell项目的内容,以及我为什么对这个工作感动兴奋。在我的下一篇帖子里,我会通过一系列截屏说明一项简单的任务,以此来介绍一下原型。
For further updates, follow me on twitter or github.Comments welcome here or on hacker news.What would you use a Web-based shell for, if it could do anything you would want?
如欲获得后续更新,请在Twitter或GitHub上关注我。欢迎在此或在“黑客新闻”上留言。如果一个基于Web的Shell能实现你所有的需求,你会用它来做什么?
Thanks to Hugh FD Jackson, Gary Katsevman, Devin Samarin, and Connor Lane Smith for their comments on earlier drafts.
感谢Hugh FD Jackson、Gary Katsevman、 Devin Samarin和Connor Lane Smith对早期草稿提供的意见。
Copyright@ 2011-2016 版权所有:大连千亿科技有限公司 辽ICP备11013762-3号 google网站地图 百度网站地图 网站地图
公司地址:大连市沙河口区中山路692号辰熙星海国际2317 客服电话:0411-39943997 QQ:2088827823 37482752
法律声明:未经许可,任何模仿本站模板、转载本站内容等行为者,本站保留追究其法律责任的权利! 隐私权政策声明