Java.next: The first part--common ground

Source: Internet
Author: User

This article is the first part of the Java.next series. In this part, I will explore the common characteristics of the language as Java.next.

I chose four languages as representatives of "Java.next": Clojure,groovy,jruby, and Scala. At first glance, these languages are very different. Clojure is a Lisp dialect; Groovy is the choice of "class Java"; JRuby, which has the grace of Ruby and the advantages of rails, is Scala, which has the characteristics of a static language.

As you might expect, there are many debates about who is the best in these languages. There is so much debate, largely because these languages have a lot in common. They have a common evolutionary background: the Java language. The advantages and disadvantages of the Java language affect the direction in which these languages are designed.

In this article, I focus on the following two aspects to illustrate the common features of these languages:

In the past 10 years, we have got a lot of information about how to develop readable, maintainable applications in virtual machines and object-oriented language programming. Java.next These results, making these languages more focused on the nature of the problem rather than the form.

☆ The design concept of "essence VS form" makes a great change in the way of programming, which changes much more than the previous transformation from C + + to java.

I have summed up the common advantages of Java.next to the following eight points:

All objects

Concise method of attribute definition

Easy to use collection classes

Functional programming

Operator overloading

Maintainable exception Handling

Add new methods to existing classes

Create a new language structure

All objects

In Java, we face the difference between an object type and a basic type every moment of the day. This difference leads to three practical problems:

1.API must write two copies: one for object type and one for base type. Worse, you need to rewrite multiple copies: one for the object type, and one for each of the basic types.

2. The default numeric type has a range limit, and once the line is crossed, the program is interrupted in a bizarre fashion.

3. For those high precision types (translator Note: Refer to BigInteger and other types), you cannot use intuitive mathematical operators (+,-,etc.) to manipulate them.

In Java.next, everything is an object. You can invoke methods on all types using the same syntax.

; clojure
(. 1 floatValue)
1.0
// groovy
1.floatValue()
===> 1.0
# ruby
1.to_f
=> 1.0
// scala
1.floatValue
res1: Float = 1.0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.