`
fireflyjava
  • 浏览: 186277 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

To Ruby From Java

阅读更多
Java is mature. It’s tested. And it’s fast (contrary to what the anti-Java crowd may still claim). It’s also quite verbose. Going from Java to Ruby, expect your code size to shrink down considerably. You can also expect it to take less time to knock together quick prototypes.
Similarities
As with Java, in Ruby,...

    * Memory is managed for you via a garbage collector.
    * Objects are strongly typed.
    * There are public, private, and protected methods.
    * There are embedded doc tools (Ruby’s is called RDoc). The docs generated by rdoc look very similar to those generated by javadoc.

Differences
Unlike Java, in Ruby,...

    * You don’t need to compile your code. You just run it directly.
    * There are different GUI toolkits. Ruby users can try WxRuby, FXRuby, Ruby-GNOME2, or the bundled-in Ruby Tk for example.
    * You use the end keyword after defining things like classes, instead of having to put braces around blocks of code.
    * You have require instead of import.
    * All member variables are private. From the outside, you access everything via methods.
    * Parentheses in method calls are usually optional and often omitted.
    * Everything is an object, including numbers like 2 and 3.14159.
    * There’s no static type checking.
    * Variable names are just labels. They don’t have a type associated with them.
    * There are no type declarations. You just assign to new variable names as-needed and they just “spring up” (i.e. a = [1,2,3] rather than int[] a = {1,2,3};).
    * There’s no casting. Just call the methods. Your unit tests should tell you before you even run the code if you’re going to see an exception.
    * It’s foo = Foo.new( "hi") instead of Foo foo = new Foo( "hi" ).
    * The constructor is always named “initialize” instead of the name of the class.
    * You have “mixin’s” instead of interfaces.
    * YAML tends to be favored over XML.
    * It’s nil instead of null.
    * == and equals() are handled differently in Ruby. Use == when you want to test equivalence in Ruby (equals() is Java). Use equal?() when you want to know if two objects are the same (== in Java).
分享到:
评论

相关推荐

    From Java to Ruby

    《From Java to Ruby》这本书是Java开发者转向Ruby语言的一份宝贵资源。它引导读者了解从传统的Java编程环境过渡到Ruby的动态世界时所遇到的概念差异和技术挑战。Ruby是一种灵活、简洁且富有表现力的编程语言,它...

    From java to Ruby

    ### 从 Java 到 Ruby:理解两种编程语言的转变 #### 概述 《从 Java 到 Ruby》这本书由 Bruce Tate 所著,旨在帮助 Java 开发者了解并过渡到 Ruby 这一更为灵活和高效的编程语言。本书不仅对 Ruby 的核心概念和...

    from java to ruby -things every manager should know

    ### 从 Java 到 Ruby:每位管理者应知之事 #### 引言 随着技术的不断发展,编程语言也在不断地演进。对于很多企业来说,选择合适的技术栈是至关重要的一步。《从 Java 到 Ruby:每位管理者应知之事》这本书正是为了...

    Beginning.Ruby.From.Novice.to.Professional.3rd.Edition.1484212797

    Based on the bestselling first and second editions, Beginning Ruby, Third Edition is a leading guide to learn Ruby from the ground up. The new edition of this book provides the same excellent ...

    从 Java 到 Ruby_ 每一个管理者应该知道的事情

    压缩包中的文件列表暗示了这可能是一本电子书的资源,例如 "Pragmatic.Bookshelf.From.Java.to.Ruby.Jun.2006.pdf",这可能来自 Pragmatic Bookshelf 出版社,一家知名的程序员图书出版商。"intro.txt" 可能是书籍的...

    Beginning Ruby - From Novice to Professional (2007)

    - **特性与优势**:详细阐述Ruby语言的主要特点,如简洁性、面向对象、动态类型等,并对比其他编程语言如Java、Python等,突出其独特之处。 ##### 2. Ruby基础语法 - **数据类型**:讲解Ruby中的基本数据类型,包括...

    Programming Ruby

    Like Smalltalk, it is dynamically typed (as opposed to Java or C++), but unlike Smalltalk, Ruby features the same conveniences found in modern scripting languages such as Perl and Python. The ...

    ruby初学者教程(对初学者很有帮助)

    ### Ruby语言介绍与基础知识 #### 一、Ruby语言概述 **1.1 Ruby的历史** Ruby是一种面向对象的脚本语言,由日本人松本行弘(Matsumoto Yukihiro)于1993年开始开发。起初,Ruby是作为一种兴趣项目而诞生的,但...

    Ruby.Pocket.Reference

    This section likely covers the basic command-line usage of the `ruby` command and how to run scripts directly from the terminal. - **Using a Shebang Line on Unix/Linux:** Discusses the use of the ...

    ruby的惯用法的使用

    - **循环控制**: Java中的循环控制语句相对固定,而Ruby提供了更多的灵活性。 ```java // Java for (int i = 1; i ; i++) { System.out.println(i); } ``` ```ruby # Ruby (1..10).each { |i| puts i } ``...

    FromJavaToRubyFreePdfBook.pdf 英文原版

    From Java To Ruby – Free Pdf Book

    JAVA 脚本应用数据

    在Java中,你可以利用内置的ScriptEngine接口和相关的脚本引擎实现对不同脚本语言(如JavaScript、Groovy、Ruby等)的支持,从而在应用程序中进行动态计算、数据处理或者扩展功能。JavaMail则是Java中用于处理电子...

    《Numeric Computation and Statistical Data Analysis on the Java Platform》高清完整英文PDF版

    The author focuses on practical programming aspects and covers a broad range of topics, from basic introduction to the Python language on the Java platform (Jython), to descriptive statistics, ...

    Pro Couchbase Development(Apress,2015)

    The target audience is largely Java developers but the book also supports PHP and Ruby developers who want to learn about Couchbase. The author supplies examples in Java, PHP, Ruby, and JavaScript.

    Pro MongoDB Development [2016]

    What You'll Learn:* How to use a Java client and MongoDB shell * How to use MongoDB with PHP, Ruby, and Node.js as well* How to migrate Apache Cassandra tables to MongoDB documents; Couchbase to ...

Global site tag (gtag.js) - Google Analytics