JavaRush /Java Blog /Random EN /Coffee break #21. Integration of Python with Java. Meet J...

Coffee break #21. Integration of Python with Java. Meet Jakarta EE and Eclipse MicroProfile

Published in the Random EN group

Python integration with Java? Why not!

Source: Jaxenter Coffee break #21.  Integration of Python with Java.  Getting to know Jakarta EE and Eclipse MicroProfile - 1Actually, combining systems programming and scripting languages ​​is not a strange new concept, it's just rarely used. For programming languages ​​that share a common application binary interface, it is perfectly possible to bundle them into a single library or executable. While this makes things a bit more difficult, there are tools that can help. Python and Java actually complement each other. For example, you can use one for typical subtasks and the other as a scripting language to extend your application's settings. In terms of integrating other languages, for example, JavaScript is not commonly used outside of web browsers, at least compared to other scripting languages ​​such as Perl, Tcl, Visual Basic, and Python. However, all these languages ​​are usually combined with other languages. Python has traditionally been paired with C and C++, while Visual Basic is often the scripting language of choice for C++ on the Windows platform. And Perl, like Tcl, is commonly used in C/Unix. Python is used a little more on Windows as it integrates easily with the Microsoft Scripting Host architecture as well as COM. Plus, it's also great for macOS tools.

Why Java and Python?

Python is an object-oriented scripting language, which makes it a good match for Java. When combined with a Python interpreter written entirely in Java, such as Jython, you can write entire Python applets that can then run in any JDK-compatible browser, with almost as fast code execution as C/CPython. The Jython interpreter translates Python source code directly into Java bytecode, giving it incredible speed. But other Java scripting solutions (Java/TCL, Java/Perl, etc.) attach the JVM to the C implementation in these languages, which not only creates a portability problem, but these solutions themselves are not as easy as we would like.

What is the best way to use Java and JPython together?

There are a number of proven tools that implement Python to Java or vice versa, so you can run commands from one language to another. Here is a short list of some of the best tools for integrating Python with Java:
  • Jython - Python implemented in Java.
  • JPype - allows you to run Java commands using Python.
  • Jepp is Java built into Python.
  • JCC is a C++ code generator for calling Java from C++/Python.
  • Javabridge is a package for running and interacting with the JVM from CPython.
  • Py4j - allows you to run Java commands in Python.
  • Voc is an element of the BeeWare instrument . Converts Python code to Java bytecode.
  • p2j - Converts Python code to Java. No longer being developed.
There are several approaches to using these tools. Each has its own advantages and disadvantages. For example, you can prototype an entire application in Jython, and after several cycles of testing and redesign, rewrite everything in Java. This allows you to take advantage of the increased flexibility and speed of developing scripting languages ​​early in your project. However, your final product should be a little more detailed than if you just started writing only in Java. And if you're worried about UI libraries, then Jython can hook into the same UILs as regular Java, so the Java conversion should go smoothly. However, things are not so simple if you are trying to build a large project. You are likely to run into a lack of various components and layers, having independent development cycles, such as top-level components. Of course, you can rewrite individual components in Java as you get closer to a stable release, or you can simply write some of your components exclusively in Java from the beginning. Another option is to rewrite only those components for which performance is important. This way you can leave high-level components in Jython, which means that only lower-level components need to be rewritten, and in some cases you don't have to rewrite anything at all. Another option is to rewrite only those components for which performance is important. This way you can leave high-level components in Jython, which means that only lower-level components need to be rewritten, and in some cases you don't have to rewrite anything at all. Another option is to rewrite only those components for which performance is important. This way you can leave high-level components in Jython, which means that only lower-level components need to be rewritten, and in some cases you don't have to rewrite anything at all.

Introduction to Jakarta EE and Eclipse MicroProfile

Source: DZone Have you heard about Jakarta EE and Eclipse MicroProfile yet? So, it's time to get acquainted with how the Java Enterprise standard has evolved. Both of these technologies are sure to be of great use to you in the future as they are great for building cloud and modern enterprise applications.

What is Jakarta EE?

Jakarta EE is a set of specifications (JAX-RS, CDI, JPA, JSON-P, etc.) for writing enterprise Java applications. These specifications are documents that define the API and interaction of the technology. Coffee break #21.  Integration of Python with Java.  Meet Jakarta EE and Eclipse MicroProfile - 2Specification documents are like interfaces with formal definitions, and the actual implementation of these interfaces depends on the application server vendor (eg WildFly, Open Liberty, Payara, TomEE). To prevent a vendor from misimplementing a specification, each specification provides a Technology Compatibility Kit (TCT). This is a set of tests to verify that an implementation conforms to a particular specification. After the application server sends the TPC for all specifications, it complies with the entire standard. For years, Java EE has been the standard way to write enterprise applications. Java EE (formerly called J2EE) has been supported by Oracle for a long time. In 2017, Oracle decided to no longer develop the corporate standard under its auspices and handed it over to the Eclipse Foundation. For legal reasons, they had to rebrand and decided to call the product Jakarta EE. You can find all Jakarta EE specifications atofficial website , or you can get more information about how the specification process currently works on the Eclipse Foundation website.

What is Eclipse MicroProfile?

Since the process of releasing and adapting new features for Java EE has been rather slow, a group of vendors and community members decided in 2016 to create MicroProfile. The main goal of this project was to help developers keep up with the times, as well as to optimize the existing platform for microservices architecture. Eclipse MicroProfile currently contains twelve specifications. Four of them are also part of Jakarta EE. This allows you to create standalone applications exclusively with MicroProfile. All specifications are vendor agnostic and the implementation comes with the application server. Jakarta EE specifications can be seen as a solid foundation for building enterprise applications. In addition, Eclipse MicroProfile fills a gap in building distributed systems,Twelve-Factor applications .
Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION