March of the scripting languages

 

Connecting state and local government leaders

Sun opens up Java for faster Web development, and programmers get right in line.

During this year's JavaOne conference, it seemed as if Sun Microsystems executives finally understood the popularity of scripting languages ' a popularity company officials had acknowledged only grudgingly in the past. In fact, during the show, the company introduced a scripting language of its own, a multimedia authoring tool called JavaFX.'Why another scripting language? The world has so many,' asked Java creator James Gosling, prefacing the JavaFX announcement. Indeed, there are many languages. Thanks to the proliferation of Web applications, the past decade has seen an explosion in scripting languages, such as Perl, Python, Ruby on Rails and PHP.Such scripting languages do not have the formal restrictions of regular languages, allowing programmers to get up to speed more quickly. Although mostly relegated to smaller tasks, they have been taking on more complex duties that previously would have been relegated to enterprise Java platforms.Now, the folks who develop the Java platform, called the Java Virtual Machine, have engineered it so it can run some of these scripting languages. They are also working on ways to allow non-Java programs to use functions originally written in Java. Industry observers say it represents a long-term shift in thinking.Initially, the developers behind Java 'were very cold to the idea of [outside] languages running over the JVM,' said Frank Cohen, head of service-oriented architecture test automation company PushToTest. 'Over the last two years, [Sun] has accepted scripting languages and has even encouraged people to write scripting languages to go on top of the JVM.''We unfortunately created a strong association between the Java language and the Java platform,' said Sun Microsystems technical evangelist Raghavan Srinivas in his presentation at Sun Tech Days recently in Washington. 'But there is no need to have this association be very close. You should be able to run non-Java programs on the Java Virtual Machine.'By giving Java programmers more options about what language to use, they can gain more flexibility within their preferred development environment. And by opening the JVM to other languages, non-Java developers can use the rich set of Java functions.Historically, Sun has positioned Java as a cross-platform language. The idea was that a programmer only had to write one set of code, which then could run on a variety of platforms such as Unix or Microsoft Windows. The JVM made this possible, as Sun itself built a unique JVM for each operating system. So all the programmer had to do was write for the one JVM, rather than for multiple OSes, which simplified a lot of work.As Srinivas noted, the JVM doesn't necessarily have to run Java alone ' a fact that the developers around the JVM are starting to acknowledge. The Java community has been working to accommodate scripting languages of late. Sun established the Java Community Process to allow vendor input to updating Java specifications, so development of the language and platform is done by a mix of Sun employees and outside contributors. JCP has written a number of specifications that will allow Java to interoperate with other languages.Java Specification Request 223, which is now undergoing final release, details how scripting languages such as PHP can call Java objects, or small pieces of Java programs that execute certain tasks. This will allow developers to make use of features previously only available to other Java programs.JSR 223 also details how scripting languages can be used within Java applications run from within a Java-based application server. This lets Java Web application developers harness non-Java scripts.Another specification request, JSR 282, which is not as far along as 223, details how to support dynamically typed languages on the JVM.Features within this specification are slated to be included in the upcoming Version 7 of the Java Standard Edition.In this case, the Standard Edition will let developers add support for languages by simply dropping the Java Archive files on the computer in a location that can be found by the JVM. When the Java program runs, it looks for the scripting engine and then uses that to run the script itself. The programmer can modify existing languages or even write one entirely from scratch.Since Java is a fairly mature language ' with supporting libraries and a solid runtime platform ' why should hard-core Java programmers look to scripting languages? 'It's just easy to program in scripting,' Srinivas said. 'It is really good for rapid prototyping. [Scripting languages] are really good if you are doing small projects.'Perhaps the feature that best eases a programmer's duties ' one that most scripting languages possess ' is something called dynamic typing. This means programmers do not have to specify the formats of the information entered into their programs ahead of time.It is the opposite of static typing, which requires that inputs be in a certain format defined by a programmer. They have to specify if an input has to be, say, a string of characters of a certain length, or a number with so many decimal points. Then, if the input ' perhaps entered by a person or another program ' is not in that format, the program will send out an alert or even halt.Most programming languages such as Java are statically typed. Although this ensures the program runs more smoothly and has fewer security vulnerabilities, defining each variable at development time can be time-consuming.Another advantage of scripting languages, Cohen said, is that they allow organizations to very easily create domain-specific languages, or languages customized to answer one specific set of needs. These languages can have very narrow uses, such as for installing new programs across a set of servers. Since the administrators don't have to learn an entire regular programming language to use these tools with dexterity, they can work more easily in a very tightly defined subset. Plus, it is easier to maintain that language over time, Cohen said.'One of the things that is charming about scripting languages is that they tend to be focused on specific things,' Gosling said during his presentation.By enabling JVM to support scripting languages, the Java team can ensure that Java programmers can make use of these flexible features without having to learn entirely new languages. In addition, they can still use the vast array of Java libraries to take care of routine tasks instead of writing the functions by hand.Opening up the JVM to outside languages also could result in a potentially wider audience. 'There are more non-Java programmers out there than Java programmers,' Cohen said.Support for new features such as dynamic typing was hard for the JVM development team to incorporate, said Bob Brewin, Sun's chief technology officer for software, in a conference during JavaOne. 'Interpreting a dynamic language is difficult.There's a certain amount of bookkeeping that the [program] requires to dispatch a method call.' But JCP seems determined to carry out the duties.Although the Java environment has only recently been laid open for interaction with scripting language, an amazing number of new dynamic languages have already sprouted up, including Groovy, JRuby, Beanshell, Jackl, Jaskell, Jawk, Jelly and Jexl.Many of these new languages are very similar to existing languages, but they are written in the Java environment. Jython, for instance, is a version of Python written in Java, which lets developers easily import Java classes (GCN.com/786).And Sun itself even got into the game with JavaFX.In a way, JavaFX is a domain-specific language, one designed for building multimedia-heavy Web sites more easily than by using Java alone, said Rich Green, Sun vice president of software, in a presentation on the language. That market is now dominated by Adobe Flash.Although the company has long offered this capability through Java Applets, Green said Sun had heard many complaints about the complexity of deploying Java, noting that while the language is flexible it is also burdensome for the Web.'We can do it with Java, it just takes a long time,' he said, summing up the concerns the company received from developers.JavaFX is intended to offer a simple set of interfaces allowing Web developers to harness the wide range of Java libraries, particularly Java Swing and Java 2D, said Chris Oliver, one of the Sun developers behind JavaFX, in a follow-on presentation. In doing so, developers could create interactive buttons, sliders and special effects in far fewer number of lines than they could using Java alone.JavaFX scripts can run on any machine with the Java Standard Edition, which is deployed on most user desktops today. It can also be used on portable devices, allowing developers to create one Web application for multiple platforms.Although Sun Microsystems is branching out from Java, this doesn't mean its support for the language will diminish, company executives say. 'We still believe that Java is the best language for robust, maintainable applications,' Brewin said. It just means that Java will have some help from its kin.And that can only be good news for developers.

Less code, more danger!

In his presentation at Sun Tech Days recently in Washington, Sun Microsystems technical evangelist Raghavan Srinivas illustrated the advantage of writing some preliminary code in a scripting language. He presented a small program that adds three names to a list and then identifies all the names on the list that are have more than three letters.

Written in Java, such a program would require about 12 lines of meaningful code:




To write the same function in Ruby, you'd need to write only this:




'You can see that instead of a page of code, you end up with two or three lines of code,' said Srinivas. He did note, though, that there is a trade-off. Because Ruby 'is very expressive,' it might be difficult for the Java programmer to understand what is going on in a set of code. 'If you don't follow what is going on, it might be doing something it is not supposed to,' he said. ' Joab Jackson

NEW HORIZONS: Sun's Bob Brewin says Java still is best for robust applications.













Write once, run everywhere





















The dynamic type















Easy action



















X
This website uses cookies to enhance user experience and to analyze performance and traffic on our website. We also share information about your use of our site with our social media, advertising and analytics partners. Learn More / Do Not Sell My Personal Information
Accept Cookies
X
Cookie Preferences Cookie List

Do Not Sell My Personal Information

When you visit our website, we store cookies on your browser to collect information. The information collected might relate to you, your preferences or your device, and is mostly used to make the site work as you expect it to and to provide a more personalized web experience. However, you can choose not to allow certain types of cookies, which may impact your experience of the site and the services we are able to offer. Click on the different category headings to find out more and change our default settings according to your preference. You cannot opt-out of our First Party Strictly Necessary Cookies as they are deployed in order to ensure the proper functioning of our website (such as prompting the cookie banner and remembering your settings, to log into your account, to redirect you when you log out, etc.). For more information about the First and Third Party Cookies used please follow this link.

Allow All Cookies

Manage Consent Preferences

Strictly Necessary Cookies - Always Active

We do not allow you to opt-out of our certain cookies, as they are necessary to ensure the proper functioning of our website (such as prompting our cookie banner and remembering your privacy choices) and/or to monitor site performance. These cookies are not used in a way that constitutes a “sale” of your data under the CCPA. You can set your browser to block or alert you about these cookies, but some parts of the site will not work as intended if you do so. You can usually find these settings in the Options or Preferences menu of your browser. Visit www.allaboutcookies.org to learn more.

Sale of Personal Data, Targeting & Social Media Cookies

Under the California Consumer Privacy Act, you have the right to opt-out of the sale of your personal information to third parties. These cookies collect information for analytics and to personalize your experience with targeted ads. You may exercise your right to opt out of the sale of personal information by using this toggle switch. If you opt out we will not be able to offer you personalised ads and will not hand over your personal information to any third parties. Additionally, you may contact our legal department for further clarification about your rights as a California consumer by using this Exercise My Rights link

If you have enabled privacy controls on your browser (such as a plugin), we have to take that as a valid request to opt-out. Therefore we would not be able to track your activity through the web. This may affect our ability to personalize ads according to your preferences.

Targeting cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites. They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising.

Social media cookies are set by a range of social media services that we have added to the site to enable you to share our content with your friends and networks. They are capable of tracking your browser across other sites and building up a profile of your interests. This may impact the content and messages you see on other websites you visit. If you do not allow these cookies you may not be able to use or see these sharing tools.

If you want to opt out of all of our lead reports and lists, please submit a privacy request at our Do Not Sell page.

Save Settings
Cookie Preferences Cookie List

Cookie List

A cookie is a small piece of data (text file) that a website – when visited by a user – asks your browser to store on your device in order to remember information about you, such as your language preference or login information. Those cookies are set by us and called first-party cookies. We also use third-party cookies – which are cookies from a domain different than the domain of the website you are visiting – for our advertising and marketing efforts. More specifically, we use cookies and other tracking technologies for the following purposes:

Strictly Necessary Cookies

We do not allow you to opt-out of our certain cookies, as they are necessary to ensure the proper functioning of our website (such as prompting our cookie banner and remembering your privacy choices) and/or to monitor site performance. These cookies are not used in a way that constitutes a “sale” of your data under the CCPA. You can set your browser to block or alert you about these cookies, but some parts of the site will not work as intended if you do so. You can usually find these settings in the Options or Preferences menu of your browser. Visit www.allaboutcookies.org to learn more.

Functional Cookies

We do not allow you to opt-out of our certain cookies, as they are necessary to ensure the proper functioning of our website (such as prompting our cookie banner and remembering your privacy choices) and/or to monitor site performance. These cookies are not used in a way that constitutes a “sale” of your data under the CCPA. You can set your browser to block or alert you about these cookies, but some parts of the site will not work as intended if you do so. You can usually find these settings in the Options or Preferences menu of your browser. Visit www.allaboutcookies.org to learn more.

Performance Cookies

We do not allow you to opt-out of our certain cookies, as they are necessary to ensure the proper functioning of our website (such as prompting our cookie banner and remembering your privacy choices) and/or to monitor site performance. These cookies are not used in a way that constitutes a “sale” of your data under the CCPA. You can set your browser to block or alert you about these cookies, but some parts of the site will not work as intended if you do so. You can usually find these settings in the Options or Preferences menu of your browser. Visit www.allaboutcookies.org to learn more.

Sale of Personal Data

We also use cookies to personalize your experience on our websites, including by determining the most relevant content and advertisements to show you, and to monitor site traffic and performance, so that we may improve our websites and your experience. You may opt out of our use of such cookies (and the associated “sale” of your Personal Information) by using this toggle switch. You will still see some advertising, regardless of your selection. Because we do not track you across different devices, browsers and GEMG properties, your selection will take effect only on this browser, this device and this website.

Social Media Cookies

We also use cookies to personalize your experience on our websites, including by determining the most relevant content and advertisements to show you, and to monitor site traffic and performance, so that we may improve our websites and your experience. You may opt out of our use of such cookies (and the associated “sale” of your Personal Information) by using this toggle switch. You will still see some advertising, regardless of your selection. Because we do not track you across different devices, browsers and GEMG properties, your selection will take effect only on this browser, this device and this website.

Targeting Cookies

We also use cookies to personalize your experience on our websites, including by determining the most relevant content and advertisements to show you, and to monitor site traffic and performance, so that we may improve our websites and your experience. You may opt out of our use of such cookies (and the associated “sale” of your Personal Information) by using this toggle switch. You will still see some advertising, regardless of your selection. Because we do not track you across different devices, browsers and GEMG properties, your selection will take effect only on this browser, this device and this website.