Ruby and Subversion

Feedback on "Ten Things a Java Programmer Should Know About Ruby"

This is a compilation of feedback I received for a list of things Java programmers should be aware of when looking at Ruby. This list is not the final version, nor are all (most) of the ideas in this list mine. This is merely a temporarty holding spot for these ideas while I assemble a talk/article/presentation on the topic.

If you have a problem with anything on this list, please bring it up with the person who made the suggestion (i.e. not me!)

However, if you have further suggestions for this list, feel free to drop me a note at jim@weirichhouse.org.

bulletBoolean methods end in ?. Dangerous methods end in !
bulletyou can fit in your mind and write code without looking at the docs every six minutes
bulletless syntax and less typing
bulletDiscipline. Because of its inherent flexibility, Ruby require more self-discipline
bullet"." (dot) is a method call operator. "::" (colon-colon) is a scope operator.
bulletRuby classes are Objects (therefore String.new, not new String())
bulletEverything is an Object
bulletRuby does not have type casting.
bulletCompared to Java, XML is agile. Compared to Ruby, XML is Heavy.
bulletRuby has O/R mappers, so find your Ruby "hibernate", but drop any preconceptions.
bulletDon't worry about early performance optimization
bulletEnjoy closures and blocks
bulletNo method overloading
bulletDon't worry about interfaces, enjoy Duck Typing.
bulletReflection in Ruby is much easier than in Java, and more deeply into the language than the java.lang.reflect tack-on.
bulletThat you can write Ruby in Java (http://jruby.sourceforge.net)
bulletEverything is an expression.
bulletlocal_variable, @instance_variable, $global_variable, Constants, (and @@class_variables)
bulletJava static methods do not (quite) translate to Ruby class methods.
bulletyou can have variable number of parameters, and multiple return values
bulletRuby is not a Silver Bullet, unlike Java, right? :-)
bulletRuby is a language to be used everywhere. You use it even in templates. No need for "Velocity/JSP."
bulletWeb-development is possible with other languages besides Java.
bulletMany things that you're used to thinking of as syntax are now just
bulletRuby is strongly typed, not statically typed
bulletRuby has extensive reflection capabilities
bulletRuby is dynamic. You can add, remove and modify objects, classes and methods at runtime.
bulletREXML vs. JAXP. I rest my case.
bulletKISS
bulletThink in terms of methods (behaviors) instead of classes.
bulletyou cannot rely on the compiler to catch trivial mistakes
bulletNo explicit types. Probably the most disconcerting thing for a javahead
bulletruby has shortcuts for accessor methods which reduces alot of redundant coding in java
bulletyou can use string interpolation, ex: "x: #{@myvar}" instead of having to say "x:" + myvar'
bulletno semi-colons, optional parenthesis
bulletRuby classes are always "open".
bulletC extensions/wrappers are *much* easier in Ruby than JNI interfaces in Java
bulletRuby has MVC and OO programming and libraries, but drop any preconceptions.
bulletIn Ruby data is strongly typed, but variables are *not*
bulletOnce you start coding Ruby, going back to Java is painful.
bulletCamelCase for class names, names_with_underscores for methods and variables.
bulletstop writing so much code
bulletri is your friend. irb is your other friend.
bulleteval
bulletthe builtin classes are much faster because they're written in C and not Ruby
bulletAvoid external utility classes
bulletUse class methods to define pseudo-compile directives
bulletYou probably don't need Factories
bulletEnumerable is your friend
bulletTyping is the enemy
bulletNo external configuration files
bulletmethod_missing
bulletSingleton methods
bulletRuby packaging vs Java packaging
bulletruby has multiple inheritance through mixins (this is sooo nice to have)
bulletwriting code in ruby, can improve the code you write in java
bulletRuby is agile, perfectly suited for XP
bulletRuby's OO is message based.
bulletFixed what's wrong with Perl
bulletFixes what's wrong with Python
bulletIt's super productive (like Perl, Python and Smalltalk)- maybe 5-10x Java.
bulletIs a lot like Smalltalk, but doesn't look as funny
bulletIs a lot like JavaScript, but more OO and more for ful app development
bulletBlocks and Closures
bulletOpen Classes
bulletDuck Typing
bullet"finally" is called "ensure"
bulletUse blocks for transactional behavior like like File.open does.
bulletHelp at: http://ruby-lang.org/en, http://ruby-doc.org/, news:comp.lang.ruby, irc:ruby-talk
bulletAn instance of a class can be extended to be subtly different, without needing to subclass.
bulletyou can change your mind about whether .foo is a simple property or a complex method call, without affecting the interface to your class.
bulletHEREDOC strings with variable interpolation make large chunks of output really easy to construct.
bulletFor good (but subtle) reasons, you have to leave the '++' and '--' behind.

Top 10 Things I Like About Subversion

I've been using Subversion for over two months as my repository on a project at work and I've recently transitioned all of my personal projects on my Powerbook from CVS to Subversion. I'm really digging Subversion and can't imagine or remember what it was like before I found it.

I wrote this up a few days ago for a meeting at work and thought I'd share it with everyone in blogspace. In no particular order, here are the top 10 things I like about Subversion:

  1. Atomic Commits: It's all or nothing! If even one file out of 100 has troubles, then nothing gets committed. My repository is never in an inconsistent state.
  2. Tools Support: If you don't like the command line (and I do), then you have Tortoise. But since I'm an Eclipse user, I tend to enjoy Subclipse (I've read several people who say that Subclipse has problems, but I've had nothing but success with it for over two months).
  3. Hooks: Automatically kick off a build, fire an e-mail, or update my issue tracking system...just by committing some files.
  4. Web-browsable Repository: Without having to do much additional setup (other than Apache), I get to browse my repository via my favorite web-browser.
  5. Easy branching/tagging/merging: I create a new tag or branch by simply making a logical copy in the repository. Couldn't be smoother.
  6. Efficient handling of binary files: It's my understanding that binary files are stored based on binary diffs to be more efficient.
  7. Everything is versioned: Even directories and meta-data.
  8. Externals: I haven't had the privilege of using externals yet, but they sound darn cool. Check out a project and all other projects that it depends on all at once.
  9. Concurrent versioning: Just like CVS. I don't have to lock something before I can commit changes.
  10. Easy refactoring: I can rename a file or repackage a class and Subversion's smart enough to keep keep the file's history.

And for an eleventh thing that I like: I've got an excellent Subversion book to help me out.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值