Ruby on Rails
DEFINITION: Ruby on Rails is a software development environment that is built with and uses the object-oriented programming language Ruby, with the overall aim of making programmers’ jobs both more fun and more productive.
The programming language Ruby has been around since 1993. Initially popular in Japan, its use has been growing and widening. Ruby got a big boost in 2004 with the release of a new programming environment called Rails that was built around Ruby. Before discussing Rails, let’s first examine Ruby and see what makes it different from other languages.
Ruby is a pure object-oriented, open-source programming language with a very clean syntax that one writer has said “combines Smalltalk’s elegance, Python’s ease of use and Perl’s pragmatism.” An interpreted scripting language, Ruby is as useful for creating small ad hoc scripts as it is for full-scale applications. Using a direct-execution model and dynamic typing, Ruby lets you develop code incrementally; in most cases, you can add a feature and then try it immediately. Ruby programs are usually shorter than their Perl, Python or C++ counterparts.
Ruby’s creator, Yukihiro Matsumoto, has said he wanted a language that would make him more productive and at the same time be fun to use. In fact, this desire for fun in programming is probably Ruby’s biggest single point of differentiation from any other language. When one first starts reading the Ruby literature, it’s easy to think that it’s a boutique language with a cultlike following of near-fanatic users. But remember that Perl, PGP and Python started out in much the same way.
Every language is designed with specific purposes: ease of coding; compactness of code; readability; speed of execution; orientation for specialized situations such as text processing, database handling or numerical computation. Even so, with most languages that are Turing-complete, you can pretty much do anything you need; the practical differences from one to another will be in the areas of form, style, size, ease of use or maintainability. For example, Python and Ruby provide almost the same power to the programmer.
Ruby’s syntax is such that once you’re familiar with its vocabulary and style, you can read many lines of code in something like natural language, making programs much easier to understand and maintain. Ruby eliminates the need to start out each program with long statements declaring structures and variables.
Like Perl, Ruby has features that make it easily adaptable to processing text files and to systems management tasks. You can add methods to a class, or even to an instance during runtime, so that you can have an instance of one class behave differently from other instances of the same class. Also like Perl, but quite different from Python, Ruby lets you code things in many ways, thus it can appeal to programmers with very different styles and personalities.
Rails is a full-stack, open-source programming framework implemented in Ruby and designed for writing database-oriented real-world Web applications quickly and easily. It was created by David Heinemeier Hansson, a Danish college student, based on a project management tool he’d written called Basecamp. Ruby on Rails was released to the public in July 2004.
By full-stack framework, Hansson means that all layers are built to work together so that you don’t repeat yourself (DRY) and you can use a single language from top to bottom. Everything in Rails is written in Ruby. To achieve DRY, Rails relies on a couple of guiding principles.
The first is less software, meaning you write fewer lines of code. Keeping code small speeds development and makes for fewer bugs, and it makes code easier to understand, maintain and enhance. One feature of Ruby that contributes to writing less code is that it assumes that the framework itself can and should handle metadata.
The second is the principle of convention over configuration, meaning that Rails doesn’t use configuration files, relying instead on some simple programming conventions that let it figure out what it needs to know by using information already contained in the application code and the database that’s running.
Ruby on Rails
定義:Ruby on Rails是一種軟件開(kāi)發(fā)環(huán)境,它是利用面向?qū)ο缶幊陶Z(yǔ)言Ruby構(gòu)建起來(lái)的,其總的目標(biāo)就是要使程序員的工作比較有趣、生產(chǎn)率也較高。
編程語(yǔ)言Ruby自1993年起就已存在。最初,它在日本很流行,其應(yīng)用在擴(kuò)大。在2004年,隨著一個(gè)叫Rails、圍繞Ruby構(gòu)建起來(lái)的新穎編程環(huán)境的問(wèn)世,Ruby獲得了一次大發(fā)展。在討論Rails之前,先讓我們看看Ruby,它是如何使其有別于其他的語(yǔ)言。
Ruby是一種純粹的面向?qū)ο蟮拈_(kāi)放源碼的編程語(yǔ)言,它有非常清晰的語(yǔ)法,有位作者稱,它將Smalltalk的精致、Python的易用和Perl的實(shí)用結(jié)合一身。作為一種解釋型的腳本語(yǔ)言,Ruby對(duì)生成短小的特定腳本與編寫(xiě)完整的應(yīng)用程序一樣有用。利用直接執(zhí)行模型和動(dòng)態(tài)鍵入,Ruby讓你用逐步增加的方式開(kāi)發(fā)程序,在多數(shù)情況下,你能增加一個(gè)功能,并能馬上進(jìn)行試驗(yàn)。Ruby程序通常比同類的Perl、Python、或C++程序都要短。
Ruby的發(fā)明人Yukihiro Matsumoto說(shuō)過(guò),他需要一種既能使他有較高的生產(chǎn)率,同時(shí)又能樂(lè)意使用的語(yǔ)言。事實(shí)上,讓編程好玩的想法可能是Ruby與其他任何一種語(yǔ)言的不同之處。當(dāng)一個(gè)人首次閱讀Ruby文獻(xiàn)時(shí),很容易就認(rèn)為它是一種熱門(mén)的語(yǔ)言,有著一群近乎狂熱的用戶崇拜它追隨它。但請(qǐng)記住,Perl、PGP和Python開(kāi)始時(shí)也有類似的情況。
每一種語(yǔ)言都是為特定目的設(shè)計(jì)的:易于編程、程序緊湊、可讀性、執(zhí)行速度、面向特定情形(如文本處理)、數(shù)據(jù)庫(kù)處理或數(shù)值計(jì)算。即便這樣,對(duì)于大多數(shù)具有完整圖靈原理的語(yǔ)言來(lái)說(shuō),你能用它們做你需要做的任何事,它們之間實(shí)際上的差異在于形式、風(fēng)格、大小、易用性和可管理性。例如,Python和Ruby給程序員提供了幾乎是相同的功能。
Ruby的語(yǔ)法就是這樣的:一旦你熟悉它的詞匯和風(fēng)格,你就能像讀自然語(yǔ)言那樣一目幾行,使得程序更容易理解和維護(hù)。Ruby不需要在開(kāi)始每個(gè)程序時(shí)先寫(xiě)很長(zhǎng)的注釋語(yǔ)句,說(shuō)明結(jié)構(gòu)和變量。
Ruby像Perl那樣具有不少功能,使之很容易適應(yīng)處理文本文件和系統(tǒng)管理等任務(wù)。你能給類增加方法,甚至在運(yùn)行中給實(shí)例增加方法,從而你就能擁有不同于同一類的其他實(shí)例的類行為實(shí)例。Ruby還能像Perl那樣、但不同于Python,讓你用多種方法對(duì)事情編程,因而它能以不同的風(fēng)格和個(gè)性吸引程序員。
Rails是用Ruby實(shí)現(xiàn)的全堆棧、開(kāi)放源碼的編程架構(gòu),旨在快速、簡(jiǎn)易地編寫(xiě)面向數(shù)據(jù)庫(kù)的、真實(shí)世界的Web應(yīng)用程序。它是由一名丹麥的大學(xué)生David Heinemeier Hansson發(fā)明的,它基于一個(gè)由他編寫(xiě)的稱作Basecampde的項(xiàng)目管理工具。Ruby on Rails是在2004年7月公開(kāi)的。
所謂全堆棧架構(gòu),Hansson是要構(gòu)建所有層面,以便一起工作,從而你不必重復(fù)你自己的工作(DRY),從頂?shù)降锥寄苡猛徽Z(yǔ)言。Rails中所有東西都是用Ruby寫(xiě)的。為了獲得DRY,Rail有兩條指導(dǎo)原則。
第一條是較小的軟件,這意味著你編寫(xiě)較少的程序行。程序小就能加速開(kāi)發(fā),錯(cuò)誤也較少,使得程序較容易理解、維護(hù)和增強(qiáng)。對(duì)編寫(xiě)較小程序做出貢獻(xiàn)的Ruby的一個(gè)特性就是它假設(shè)該架構(gòu)本身能夠并應(yīng)該處理元數(shù)據(jù)。
第二條是對(duì)配置的協(xié)定原理,這意味著Rails不用配置文件,而是依靠一些簡(jiǎn)單的編程協(xié)定,讓它通過(guò)利用應(yīng)用程序已有的信息和在運(yùn)行的數(shù)據(jù)庫(kù),解決它需要知道什么這個(gè)問(wèn)題。
DEFINITION: Ruby on Rails is a software development environment that is built with and uses the object-oriented programming language Ruby, with the overall aim of making programmers’ jobs both more fun and more productive.
The programming language Ruby has been around since 1993. Initially popular in Japan, its use has been growing and widening. Ruby got a big boost in 2004 with the release of a new programming environment called Rails that was built around Ruby. Before discussing Rails, let’s first examine Ruby and see what makes it different from other languages.
Ruby is a pure object-oriented, open-source programming language with a very clean syntax that one writer has said “combines Smalltalk’s elegance, Python’s ease of use and Perl’s pragmatism.” An interpreted scripting language, Ruby is as useful for creating small ad hoc scripts as it is for full-scale applications. Using a direct-execution model and dynamic typing, Ruby lets you develop code incrementally; in most cases, you can add a feature and then try it immediately. Ruby programs are usually shorter than their Perl, Python or C++ counterparts.
Ruby’s creator, Yukihiro Matsumoto, has said he wanted a language that would make him more productive and at the same time be fun to use. In fact, this desire for fun in programming is probably Ruby’s biggest single point of differentiation from any other language. When one first starts reading the Ruby literature, it’s easy to think that it’s a boutique language with a cultlike following of near-fanatic users. But remember that Perl, PGP and Python started out in much the same way.
Every language is designed with specific purposes: ease of coding; compactness of code; readability; speed of execution; orientation for specialized situations such as text processing, database handling or numerical computation. Even so, with most languages that are Turing-complete, you can pretty much do anything you need; the practical differences from one to another will be in the areas of form, style, size, ease of use or maintainability. For example, Python and Ruby provide almost the same power to the programmer.
Ruby’s syntax is such that once you’re familiar with its vocabulary and style, you can read many lines of code in something like natural language, making programs much easier to understand and maintain. Ruby eliminates the need to start out each program with long statements declaring structures and variables.
Like Perl, Ruby has features that make it easily adaptable to processing text files and to systems management tasks. You can add methods to a class, or even to an instance during runtime, so that you can have an instance of one class behave differently from other instances of the same class. Also like Perl, but quite different from Python, Ruby lets you code things in many ways, thus it can appeal to programmers with very different styles and personalities.
Rails is a full-stack, open-source programming framework implemented in Ruby and designed for writing database-oriented real-world Web applications quickly and easily. It was created by David Heinemeier Hansson, a Danish college student, based on a project management tool he’d written called Basecamp. Ruby on Rails was released to the public in July 2004.
By full-stack framework, Hansson means that all layers are built to work together so that you don’t repeat yourself (DRY) and you can use a single language from top to bottom. Everything in Rails is written in Ruby. To achieve DRY, Rails relies on a couple of guiding principles.
The first is less software, meaning you write fewer lines of code. Keeping code small speeds development and makes for fewer bugs, and it makes code easier to understand, maintain and enhance. One feature of Ruby that contributes to writing less code is that it assumes that the framework itself can and should handle metadata.
The second is the principle of convention over configuration, meaning that Rails doesn’t use configuration files, relying instead on some simple programming conventions that let it figure out what it needs to know by using information already contained in the application code and the database that’s running.
Ruby on Rails
定義:Ruby on Rails是一種軟件開(kāi)發(fā)環(huán)境,它是利用面向?qū)ο缶幊陶Z(yǔ)言Ruby構(gòu)建起來(lái)的,其總的目標(biāo)就是要使程序員的工作比較有趣、生產(chǎn)率也較高。
編程語(yǔ)言Ruby自1993年起就已存在。最初,它在日本很流行,其應(yīng)用在擴(kuò)大。在2004年,隨著一個(gè)叫Rails、圍繞Ruby構(gòu)建起來(lái)的新穎編程環(huán)境的問(wèn)世,Ruby獲得了一次大發(fā)展。在討論Rails之前,先讓我們看看Ruby,它是如何使其有別于其他的語(yǔ)言。
Ruby是一種純粹的面向?qū)ο蟮拈_(kāi)放源碼的編程語(yǔ)言,它有非常清晰的語(yǔ)法,有位作者稱,它將Smalltalk的精致、Python的易用和Perl的實(shí)用結(jié)合一身。作為一種解釋型的腳本語(yǔ)言,Ruby對(duì)生成短小的特定腳本與編寫(xiě)完整的應(yīng)用程序一樣有用。利用直接執(zhí)行模型和動(dòng)態(tài)鍵入,Ruby讓你用逐步增加的方式開(kāi)發(fā)程序,在多數(shù)情況下,你能增加一個(gè)功能,并能馬上進(jìn)行試驗(yàn)。Ruby程序通常比同類的Perl、Python、或C++程序都要短。
Ruby的發(fā)明人Yukihiro Matsumoto說(shuō)過(guò),他需要一種既能使他有較高的生產(chǎn)率,同時(shí)又能樂(lè)意使用的語(yǔ)言。事實(shí)上,讓編程好玩的想法可能是Ruby與其他任何一種語(yǔ)言的不同之處。當(dāng)一個(gè)人首次閱讀Ruby文獻(xiàn)時(shí),很容易就認(rèn)為它是一種熱門(mén)的語(yǔ)言,有著一群近乎狂熱的用戶崇拜它追隨它。但請(qǐng)記住,Perl、PGP和Python開(kāi)始時(shí)也有類似的情況。
每一種語(yǔ)言都是為特定目的設(shè)計(jì)的:易于編程、程序緊湊、可讀性、執(zhí)行速度、面向特定情形(如文本處理)、數(shù)據(jù)庫(kù)處理或數(shù)值計(jì)算。即便這樣,對(duì)于大多數(shù)具有完整圖靈原理的語(yǔ)言來(lái)說(shuō),你能用它們做你需要做的任何事,它們之間實(shí)際上的差異在于形式、風(fēng)格、大小、易用性和可管理性。例如,Python和Ruby給程序員提供了幾乎是相同的功能。
Ruby的語(yǔ)法就是這樣的:一旦你熟悉它的詞匯和風(fēng)格,你就能像讀自然語(yǔ)言那樣一目幾行,使得程序更容易理解和維護(hù)。Ruby不需要在開(kāi)始每個(gè)程序時(shí)先寫(xiě)很長(zhǎng)的注釋語(yǔ)句,說(shuō)明結(jié)構(gòu)和變量。
Ruby像Perl那樣具有不少功能,使之很容易適應(yīng)處理文本文件和系統(tǒng)管理等任務(wù)。你能給類增加方法,甚至在運(yùn)行中給實(shí)例增加方法,從而你就能擁有不同于同一類的其他實(shí)例的類行為實(shí)例。Ruby還能像Perl那樣、但不同于Python,讓你用多種方法對(duì)事情編程,因而它能以不同的風(fēng)格和個(gè)性吸引程序員。
Rails是用Ruby實(shí)現(xiàn)的全堆棧、開(kāi)放源碼的編程架構(gòu),旨在快速、簡(jiǎn)易地編寫(xiě)面向數(shù)據(jù)庫(kù)的、真實(shí)世界的Web應(yīng)用程序。它是由一名丹麥的大學(xué)生David Heinemeier Hansson發(fā)明的,它基于一個(gè)由他編寫(xiě)的稱作Basecampde的項(xiàng)目管理工具。Ruby on Rails是在2004年7月公開(kāi)的。
所謂全堆棧架構(gòu),Hansson是要構(gòu)建所有層面,以便一起工作,從而你不必重復(fù)你自己的工作(DRY),從頂?shù)降锥寄苡猛徽Z(yǔ)言。Rails中所有東西都是用Ruby寫(xiě)的。為了獲得DRY,Rail有兩條指導(dǎo)原則。
第一條是較小的軟件,這意味著你編寫(xiě)較少的程序行。程序小就能加速開(kāi)發(fā),錯(cuò)誤也較少,使得程序較容易理解、維護(hù)和增強(qiáng)。對(duì)編寫(xiě)較小程序做出貢獻(xiàn)的Ruby的一個(gè)特性就是它假設(shè)該架構(gòu)本身能夠并應(yīng)該處理元數(shù)據(jù)。
第二條是對(duì)配置的協(xié)定原理,這意味著Rails不用配置文件,而是依靠一些簡(jiǎn)單的編程協(xié)定,讓它通過(guò)利用應(yīng)用程序已有的信息和在運(yùn)行的數(shù)據(jù)庫(kù),解決它需要知道什么這個(gè)問(wèn)題。