📜 ⬆️ ⬇️

Java developers should learn Ruby

Well, it may not be Ruby. Choose some other language. Choose Erlang or even Javascript.
It does not matter - the main thing is that it is different from Java, and its study would require some effort.
This will help you to be ready to learn new things.

What for? Because learning other languages ​​will make you better as a Java developer. Seriously.

Learning another language will make you plunge into another community.
You will see other ideas and approaches to many common tasks. Ideas and approaches do not have to be better, they are just different . In other communities, you can often find a fresh look at similar tasks. And sometimes even you can appreciate what we have in the Java community (for example, a huge number of really useful libraries).

Learning another language can teach you new idioms.
Some you will use in Java, some not. Ruby blocks, for example, are a widely used form of closures in most Ruby programs. They are very useful for executing code that delegates to a block with a specific behavior. Here is a simple example of iterating an array and performing a specific action (printing an item):
animals = ['lion','tiger', 'bear']
animals.each {|animal| puts animal }


Unfortunately, there are no closures in Java. But not really. Most of all closures in Java 6 (and in previous versions - note. Lane) resembles an anonymous nested class, which, in fact, is used in GUI applications when we add a Listener. All that is needed is a specific interface and method in the class providing the implementation, and this will iterate (like the each method in Ruby). Imagine that in java.util.List there is a method each, which takes an OnEach as input:
public interface OnEach {
void run(T obj);
}
public interface List ... {
void each( OnEach action );
}

:
List animals = Arrays.asList( new String[]{"lion", "tiger", "bear"} );
animals.each( new OnEach() {
public void run( String animal ) {
System.out.println(animal);
}
});

, ? , , , . Java 7, , Ruby Javascript-. Alex- Java 7.

.
Ruby RSpec, (Behaviour Driven Development - BDD), .
BDD - , .

: autotest - ZenTest, . ( ) , . , . , , . JUnit TestNG Eclipse, , .

, , Java . Java , . Java 13 Java. , , , Java .

Java ?

---
: jbossdna.blogspot.com/2008/06/java-developers-should-learn-ruby.html

')

Source: https://habr.com/ru/post/31611/


All Articles