為您介紹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
法律聲明:未經許可,任何模仿本站模板、轉載本站內容等行為者,本站保留追究其法律責任的權利! 隱私權政策聲明