In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces what is the Jython language, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
The Jython language combines the flexibility and efficiency of Python with the power of Java. Jython is a combination of two widely popular languages, Java and Python. Java has been widely accepted, as evidenced by the fact that many companies have deployed Java-based applications.
In addition, Java has a large number of available class libraries and detailed documentation. On the other hand, Python has good flexibility, rapid development and easy to use. It's hard to choose between two languages, but with Jython, you don't have to make that choice anymore. Jython can implement any class, algorithm, and pattern implemented in Java or Python, regardless of other languages, and it can operate almost seamlessly between the two languages.
Extending other languages like Perl or Python requires a dedicated API or cumbersome wrapper. Without modification, no C code can be used in Perl or Python, while any Java code can run in Jython. Thanks to the seamless integration with Java, you can introduce and use any Java class in Jython and create derived classes. Includes not only those classes written for a particular API or packaged with a particular tool, but also any Java classes. In addition, you can compile Jython into Java bytecode to run within the framework of Java. You can even introduce and use any Python class in Java and create derived classes.
There are also some small differences between Jython and Java, and a correct understanding of these differences is helpful to understand Jython. Java is a type-rich language, while Jython uses dynamic typing without obvious type definition. Java has packages that contain classes, while Jython has packages, modules, classes, and functions. Java must be compiled, while Jython can run interactively, interpret an uncompiled script or compile to bytecode. The Java class has accessors like private and Protected, while Jython has minimal access restrictions and no obvious modifiers like Private.
The most interesting thing is that the difference between Jython and Java does not cause much trouble, but can complement each other. Jython's interaction mode provides a quick way to test and study Java classes, while Java's interfaces and abstract classes provide Jython derived classes with a good way to specify protocols. The dynamic typing of Jython is of great help to rapid prototyping and flexibility, while the static typing of Java increases runtime efficiency and type security. These complementarities are good because of their seamlessness. Increasing the cost of the program to balance these features will have side effects on the functionality of the program. Fortunately, Jython makes them simple, easy to understand, and at no extra cost.
What is Jython?
To understand Jython, you must first understand Python. Python is a high-level, object-oriented, open source programming language written in C. Cuido vanRossum is the original creator of Python, and then a large group of high-level designers and programmers have been produced in the rapid development of Python. The number of developers using Python is growing rapidly and continues to grow. However, Sun's Java programming language is also popular. As the number of projects implemented in Java approaches the number of projects implemented in Candlestick +, the Java implementation of Python becomes necessary. Jython, originally called JPython, is the Java implementation of the Python language. In order to avoid confusion
Jython is a complete language, not a Java translator or just a Python compiler, it is a complete implementation of the Python language in Java. Jython also has many module libraries that inherit from CPython. The most interesting thing is that unlike CPython or any other high-level language, Jython provides all access to its implementation language. So Jython not only provides you with the library of Python, but also provides all the Java classes. This gives it a huge repository of resources.
Jython and Python emphasize the simplicity, convenience, and readability of the code. Jython uses indentation to demarcate blocks of code to avoid using curly braces in Java. Jython uses a new line to indicate the beginning of a new statement with several important differences, such as allowing the semicolon to be omitted after each statement. Jython does not have public, private, and protected accessors like those in Java, which gives programmers the flexibility they need for rapid development and focuses on program logic. As mentioned earlier, Jython does not need obvious static type definitions, so programmers do not need to move from program logic to type definitions.
Jython's history can be traced back to JimHugunin, a colleague of Guidovan Rossum at the National Center for Research Dynamics (CNRI). JimHugunin recognized the importance of implementing the Python programming language in Java and implemented a language originally called JPython. Due to the development of aspectj (http://aspectj.org/), JimHugunin can no longer work on JPython. So when the developers of Python were ready to leave CNRI, Barry Warsaw, who was also in CNRI at the time, continued to lead the development.
After Python and the Jython project team left CNRI, they were transformed into a more open language model on Sourceforge. During this period, FinnBock, a person who made a major contribution to Jython (JPython), led the Jython project team. It is because of FinnBock's outstanding contribution that Jython is now such a valuable tool. Open source projects like Jython are as outstanding as the people who develop and maintain them, and in this sense Jython is lucky to have FinnBack's contribution and guidance. Another person who made a valuable contribution to Jython is SamuelePedroni. Samuele's contribution is mainly in Jython's class loading, import mechanism, and so on. Finn and Samuele are currently the two main developers of Jython.
Why do I need Jython?
Jython is unique because it inherits the characteristics of both Java and Python. This section describes these features and their significance.
Seamless access to Java classes
Implementing Python in Java can see the interesting role of Java reflecting API. Reflection enables Jython to use any Java class seamlessly. Jython inherits many advantages from CPython, but unlike other things written specifically for Python, there are some problems between C and Python that limit the use of C library functions. This problem is really solved in Jython, and its programming efficiency and productivity have been greatly improved.
Thanks to its seamless integration with Java, Jython can benefit any company that deploys Java applications and frameworks without additional work. Accepting any departmental programming language is not easy for any company and requires careful consideration because it involves the overall structure, servers, and peripheral tools. As a seamless integrated language of Java, Jython can seamlessly increase existing Java applications without major choices. Many companies spend a lot of money on building Java applications, which reduces the efficiency and attractiveness of using CPython, Perl, Ruby, PHP and other high-level languages that cannot transparently integrate existing Java implementations. Jython has the ability to complement the existing Java framework, and the two can be seamlessly combined.
Efficiency
Computing the efficiency of programming languages is a wide range of topics, which takes into account the programmer's time, overall complexity, lines of code, availability, maintainability and running efficiency. Of course, many people do not agree with the weight given to these variables, and the emphasis is often different in different situations. The speed of Jython is comparable to that of other high-level languages, but speed is not the goal and feature of high-level languages. The difference is that it is more efficient to translate Jython code into Java when accelerating a needed application, due to the seamless integration of Jython and Java. In addition, direct access to all valid Jaya classes increases the possibility of improving existing classes.
Dynamic type
You don't have to declare types in Jython as you do in Java, because types are determined at run time. The list and mapping types of Jython are instances of advanced polymorphic Java classes. Polymorphism means that objects can work on different data types. For example, the list type of Jython can be a sequence of numbers, a sequence of strings, a sequence of characters, or a combination of them. Dynamic and polymorphic columns are a great contribution to programming. From many high-level languages that have abandoned explicit static type definitions, it can be seen that it reduces the number of lines of code, reduces complexity, and improves program efficiency.
Introspection and dynamic execution
Jython has some internal functions that allow convenient object introspection and dynamic execution of code. Introspection is the ability to discover information about an object, while dynamic execution is the ability to execute code generated at run time. This function greatly reduces the number of lines of code and increases the reliability of the program, making it more convenient to maintain. This also enables better integration of data and program structure or logic without affecting reusability, because everything is determined at run time.
* * Class functions and function programming
Jython has the same class functions as Python. A class function is a callable object that can be called like a variable. * Class functions make sense for event handling and other situations, which results in an increase in the functionality of Java inner classes. Although the inner class of Java is similar to the * class function, it has great shortcomings in terms of convenience and flexibility, because the * class function in Jython reduces the syntax overhead in Jython.
Jython also includes all the tools needed for functional programming. This means that mandatory object-oriented functional programming is supported in Jython. This obviously makes a lot of sense in teaching, enabling Jython programmers to choose the programming language that is best suited to a particular problem rather than being imposed by the language. Functional tools such as list inclusion, lambda forms, map, filter, and reduce also play a big role in reducing the number of lines of code, complexity, and the number of name rebindings (name rebinding has a lot of side effects).
Short learning cycle
Any Java programmer can become familiar with Jython in a matter of days. Because there is a lot of content, the key is to learn the details, but it is really valuable to have the rapid development capabilities of Jython in just a few days. Groups engaged in testing and technical support usually do not have much time to learn complex Java code, but learning Jython can quickly improve the technical level and efficiency of the company with little overhead.
Write once, available everywhere
Because Jython is written in Java and can be compiled into Java bytecode, Jython also has the "write once, available everywhere" feature of Java. Jython can run on any compatible Java1.1' or higher Java virtual machine (JVM) version of the platform. In addition, you can compile the Jython application into self-contained bytecode, which can run on any compatible JVM. Applications compiled on Linux can run on any other platform that is compatible with JVM.
Java security
The security of Java is special and increasingly important. From sandboxing to signaling, Jython has the ability to use Java's special security framework.
Code clarity
The clarity of the code is the advantage of Python***, and of course, the advantage of Jython***. Unnecessary punctuation and lines are avoided. Jython code is similar to natural language in terms of readability and clarity. This stems from Python's commitment to a simple description of code blocks and statements. Indentation marks the code block, and newline characters mark the new statement.
Thank you for reading this article carefully. I hope the article "what is Jython language" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.