為您介紹ActiveShell:一個(gè)為Web而設計的Shell
過(guò)去的幾周我都在為一個(gè)名為ActiveShell的項目忙碌著(zhù),這個(gè)Shell是為Web而設計的。就像Unix的Shell,ActiveShell能夠讓你用文本命令來(lái)操作。而和Unix的Shell不同的地方在于,ActiveShell的會(huì )話(huà)存在于瀏覽器中。Web正支持越來(lái)越多強大的應用,相比較于硬件文本終端當道的年代,我們在界面設計上可以做得更好。我們可以通過(guò)存儲更多的輸出結果和歷史命令來(lái)提高效率,并且通過(guò)增加基于內容的易讀性以便于用戶(hù)學(xué)習。我們不是僅僅支持本地機器或僅僅支持遠程SSH服務(wù)器,而是通過(guò)一致的接口來(lái)支持網(wǎng)絡(luò )中任何可用的服務(wù),例如社交網(wǎng)絡(luò )API,電子郵件,FTP,或數據庫服務(wù)器。
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.
藉此良機,我們應該為今后的開(kāi)發(fā)環(huán)境設計一個(gè)更好的Shell,我認為這個(gè)Shell將成為Web本身。消費電腦設備正變得不如以前常規和開(kāi)放,這些設備更多的是被設計用來(lái)消費而不是創(chuàng )造。出生的那些人可能在成長(cháng)過(guò)程中缺乏靈活的工具,而這些工具在桌面電腦時(shí)代曾經(jīng)點(diǎn)燃了許多年輕人對于編程的熱情。
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目前還處在原型階段。我正致力于為確切的實(shí)際用例擴展原型,解決擴展點(diǎn)上的設計問(wèn)題,這些問(wèn)題在以后可能很難改變。一旦這部分完成,新的接口特性、動(dòng)詞(譯者注:在計算機語(yǔ)言中用來(lái)執行動(dòng)作的關(guān)鍵字,比如AND,READ,DO等)、以及端口都可由用戶(hù)社區創(chuàng )造和分享。系統管理員可以用ActiveShell部署多臺服務(wù)器;學(xué)生可以用它來(lái)學(xué)習互動(dòng)編程教程;程序員可以用它來(lái)修復bug并將補丁提交回版本控制系統;研究人員可以用它來(lái)裝載樣本數據集,運行一些研究命令,最終將工作排成隊列,以此來(lái)對整個(gè)數據集進(jìn)行同樣的分析,并將結果發(fā)布到網(wǎng)絡(luò )服務(wù)器上。這些用例需要不同的功能和連接不同的遠程系統,這就是為什么動(dòng)詞(用來(lái)處理數據)和端口(用來(lái)讓輸入/輸出與其他網(wǎng)絡(luò )通信)是擴展點(diǎn)。保持不變的是有序互動(dòng)模型、基于文本的命令和一致的接口,以供任何數據通過(guò),并被發(fā)現和操作。
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.
類(lèi)似于Unix的統一接口在小的、組合型的程序中有很多好處。但不幸的是,在Unix中,使用純文本流每次都需要進(jìn)行不方便的語(yǔ)法分析和轉碼。我們用一套類(lèi)似于JSON的小型的簡(jiǎn)單數據類(lèi)型和數據集合來(lái)傳遞結構化數據,該集合包含字符串、數字、布爾值、列表和映射。字符串參數總是被引用的,使用類(lèi)似于C語(yǔ)言的字符串語(yǔ)法。命令語(yǔ)法是最基本的,并且允許動(dòng)詞出現在參數之前、之后或之中,這能給自動(dòng)完成和語(yǔ)法提示更大的空間。大部分Unix Shell命令語(yǔ)法的模糊性和不優(yōu)雅都能輕易地消除。
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(無(wú)線(xiàn)自組網(wǎng))對之前命令輸出結果的重用。在Unix中,命令的輸出結果寫(xiě)在終端上,但其他的卻丟失了,除非它被明確的重定向到另一個(gè)命令或文件。相比于現在,這在上世紀70年代更加有意義的多。對之前命令輸出結果的簡(jiǎn)單重用能夠鼓勵人們對編程的探索和對數據的分析。這個(gè)ad-hoc路由在命令的輸入與輸出之間創(chuàng )造出一種聯(lián)系,從而開(kāi)始消除使用Shell和編寫(xiě)Shell腳本之間的區別。在ad-hoc序列命令計算完數值之后,對數值的整個(gè)運算過(guò)程以及該數值的依賴(lài)關(guān)系樹(shù)都可以顯示在Shell上,并且可以用來(lái)讓本該簡(jiǎn)單的事情變得簡(jiǎn)單,例如重新將該復雜的運算應用到新的輸入數據上。針對一個(gè)數值的運算過(guò)程無(wú)需重新配置就能夠應用到一系列其他數值上。你可以要求Shell“存儲根據輸入A,B,C得到輸出X的一系列步驟”,然后,一段ad-hoc腳本讀取三個(gè)參數——這三個(gè)參數可以存儲為一個(gè)新的動(dòng)詞甚至導出為一個(gè)庫函數以供在Shell之外使用——就能有效的獲得結果。這樣的腳本,以及命令歷史本身,都被存儲在解析過(guò)的表示中,所以命令語(yǔ)法能夠自由地改變而無(wú)需破壞與當前會(huì )話(huà)或存儲腳本的向后兼容性(這一點(diǎn)跟Unix Shell的語(yǔ)法差別很大)。
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.
本系統提供一個(gè)安全的環(huán)境,像意外的擦除文件系統這樣的副作用基本上是不可能發(fā)生的,這能鼓勵用戶(hù)進(jìn)行舒適的探索式編程。一個(gè)能使用"rm -rf *"的環(huán)境必須謹慎使用,這就阻礙了用戶(hù)的探索和學(xué)習。ActiveShell的基礎就是安全和可逆操作。該安全環(huán)境外的任何副作用都必須通過(guò)端口,端口是與Shell外部世界通訊的方法。一個(gè)打開(kāi)的端口就代表了一個(gè)外部系統或服務(wù),如IMAP電郵賬戶(hù),博客的公開(kāi)API,社交網(wǎng)絡(luò )賬戶(hù),版本控制系統,或遠程服務(wù)器的文件系統。數據只能通過(guò)端口進(jìn)入Shell的會(huì )話(huà)或從Shell中出來(lái)。端口必須明確由用戶(hù)打開(kāi),如果沒(méi)有危險的端口被打開(kāi),那么也不會(huì )有危險的副作用發(fā)生。網(wǎng)絡(luò )上任何可用的服務(wù)都可以通過(guò)編寫(xiě)一個(gè)新的端口實(shí)現來(lái)在Shell中使用,該實(shí)現可能完全在客戶(hù)端運行或擁有一個(gè)服務(wù)器端組件。
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.
希望這段簡(jiǎn)單的介紹能讓你了解到ActiveShell項目的內容,以及我為什么對這個(gè)工作感動(dòng)興奮。在我的下一篇帖子里,我會(huì )通過(guò)一系列截屏說(shuō)明一項簡(jiǎn)單的任務(wù),以此來(lái)介紹一下原型。
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上關(guān)注我。歡迎在此或在“黑客新聞”上留言。如果一個(gè)基于Web的Shell能實(shí)現你所有的需求,你會(huì )用它來(lái)做什么?
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對早期草稿提供的意見(jiàn)。
Copyright@ 2011-2016 版權所有:大連千億科技有限公司 遼ICP備11013762-3號 google網(wǎng)站地圖 百度網(wǎng)站地圖 網(wǎng)站地圖
公司地址:大連市沙河口區中山路692號辰熙星海國際2317 客服電話(huà):0411-39943997 QQ:2088827823 37482752
法律聲明:未經(jīng)許可,任何模仿本站模板、轉載本站內容等行為者,本站保留追究其法律責任的權利! 隱私權政策聲明