Just contact Ruby, found that Ruby really strong, after so long Java, has been Java's tedious grammar of the entire language, especially Java exception, design out is a failure! Ruby is now up to 2.x, the community is active, and development efficiency is not at a level compared to Java.
First of all, from the perceptual comparison of Ruby and Java coding efficiency, Java is really weak to explode. Take the usual example of reading a file:
First on the Java code, I believe many friends will write this:
1 ImportJava.io.File;2 ImportJava.io.FileInputStream;3 Importjava.io.IOException;4 5 /**6 * 7 * @authorVilleron8 * @time 2014-12-289 * Ten */ One Public classFileRead { A - Private Static FinalString File_path = "FILE.RB"; - the Public Static voidMain (string[] args) { - - //Create a File object -File File =NewFile (file_path); + - //In order to be able to refer to the in variable in finally, it needs to be declared outside the try block and assigned the initial value +FileInputStream in =NULL; A Try { atin =NewFileInputStream (file);//open a file stream - byte[] B =New byte[1024];//declaring a buffer - intLen = 0; - while(len = In.read (b))! =-1) {//reads the contents of the file row by line and displays -System.out.println (NewString (b, 0, Len)); - } in}Catch(Exception e) {//Exception Handling - e.printstacktrace (); to}finally{//Close File Stream + Try { - if(In! =NULL) { the in.close (); * } $}Catch(IOException e) {Panax Notoginseng e.printstacktrace (); - } the } + A } the +}
This is a very coarse code to adjust the format is believed to be around the line, actually useful code on 23~28 Line (6 lines), I believe many Java friends have long been tired of Java cumbersome exception handling and grammar restrictions, There's a whole bunch of over-designed class libraries. Perhaps you would say that Java has been greatly improved in this respect, such as Java7 has try with resource,java8 and lambda expression, but I want to say that not beautiful girl in no more makeup also no original beauty beautiful.
Let's look at Ruby's performance:
1 ' readtextbyline.rb ' 2 file = open (filename)3 text = file.readlines4print Line } 5 File.close
Saying a lot of crap, let's start building a ruby running environment:
Search on the Internet, mostly in Linux under the installation method, the use of manual compilation of source code, for the habit of win development of us, or vulgar point in Windows slowly naked for some time. The installation procedure in Windows environment is relatively simple, next->next->finish is finished, haha ~ ~ ~
Step 1: Download Rubyinstaller
Choose the appropriate version of the download on the line.
This link can be downloaded to: http://rubyinstaller.org/
When installing the note Select Add to environment variable.
STRP 2: Verify that the installation is ready.
If this is the effect, the explanation is OK.
The next is to write code, of course, you can use Notepad, like Sublime Text, notepad++ and so on, of course, if it must be so primitive way, I have nothing to say.
Instead of installing a powerful development environment, why use Notepad so yourself?
Step 3: Install Rubymine7
I'm using the latest version of the official 7.0.2 you might say that the software is charged ... The amount, if in celestial still so have moral integrity really admire!
I also very support the use of genuine!
but the habit of piracy I was really not accustomed to, and I am not used for commercial purposes, for the moment pirated, and so the elder brother developed to provide a jetbrains Company 7.x series of registration code generation tool (including Webstrom6,webstrom7,phpstrom6,pycharm,rubymine), Heart, please poke:http://download.csdn.net/ detail/csulennon/8309235
Look at the effect:
Well, start your ruby journey!
Ruby Environment Building