Disclosure of Invention
In view of the foregoing, the present application provides a method, apparatus and computer device for supporting multiple programming languages and multiple programming libraries, so that the device can integrate multiple programming languages or multiple programming libraries or multiple programming languages, thereby meeting application requirements.
A first aspect of the present application provides a method of supporting multiple programming libraries in multiple programming languages, the method comprising:
setting a calling mode of a plurality of program codes referencing a programming library as a command line calling mode; wherein all programming libraries referenced by the plurality of program codes comprise at least two programming libraries, and/or the plurality of programming languages adopted by the plurality of program codes comprise at least two programming languages;
and calling the program code by adopting the command line calling mode, and returning an operation result of the program code.
In a second aspect, the present application provides an apparatus for supporting multiple programming libraries in multiple programming languages, the apparatus comprising a processing module and an execution module, wherein,
the processing module is used for setting the calling mode of the program codes as a command line calling mode aiming at a plurality of program codes referencing a programming library; wherein all programming libraries referenced by the plurality of program codes comprise at least two programming libraries, and/or the plurality of programming languages adopted by the plurality of program codes comprise at least two programming languages;
and the execution module is used for calling the program code in the command line calling mode and returning the running result of the program code.
A third aspect of the application provides a computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of any one of the methods provided in the first aspect of the application when the program is executed.
A fourth aspect of the present application provides a system for supporting multiple programming libraries in multiple programming languages, the system comprising a computer device and a server, wherein,
the computer equipment is used for setting the calling mode of the program codes as a command line calling mode aiming at a plurality of program codes referencing a programming library; wherein all programming libraries referenced by the plurality of program codes comprise at least two programming libraries, and/or the plurality of programming languages adopted by the plurality of program codes comprise at least two programming languages;
and the server is used for calling the program code in the command line calling mode and returning the running result of the program code.
The method, the device and the computer equipment for supporting the multi-programming language multi-programming library provided by the application aim at a plurality of program codes referencing the programming library, and the calling mode of the program codes is set as a command line calling mode, so that the program codes are called by adopting the command line calling mode, and the running result of the program codes is returned. Wherein all programming libraries referenced by the plurality of program code include at least two programming libraries, and/or the plurality of programming languages employed by the plurality of program code include at least two programming languages. Therefore, as the programming libraries referenced by the program codes support named-row calling, when the calling mode of each program code is set as command-row calling, multiple programming languages or multiple programming libraries exclusive or multiple programming libraries which are multiple programming languages can be integrated on the equipment so as to meet application requirements.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples do not represent all implementations consistent with the application. Rather, they are merely examples of apparatus and methods consistent with aspects of the application as detailed in the accompanying claims.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any or all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used herein to describe various information, these information should not be limited by these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of the application. The word "if" as used herein may be interpreted as "at … …" or "at … …" or "responsive to a determination", depending on the context.
The application provides a method, a device and computer equipment for supporting multiple programming languages and multiple programming libraries, so that the equipment can integrate multiple programming languages or multiple programming libraries with multiple programming languages, and the application requirements are met.
Several specific examples are given below to describe the technical solution of the present application in detail. The following embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
FIG. 1 is a flowchart of a method for supporting multiple programming libraries in multiple programming languages according to an embodiment of the present application.
Referring to fig. 1, the method provided in this embodiment may include:
s101, setting a calling mode of a plurality of program codes referencing a programming library as a command line calling mode; wherein all the programming libraries referred to by the plurality of program codes comprise at least two programming libraries, and/or the plurality of programming languages adopted by the plurality of program codes comprise at least two programming languages.
For example, in one embodiment, 4 program codes (for convenience of description, program code 1, program code 2, program code 3, and program code 4, respectively) referring to a programming library are included, wherein program code 1 refers to programming TensorFlow and Scikitlearn, and the programming language adopted by the program code is Python; the program code 2 refers to a programming library SparkMLlib, and the programming language adopted by the program code is Scala; the program code 3 refers to a programming library DL4J, and the programming language adopted by the program code is Java; the program code 4 refers to a programming library CNTK, which uses a programming language c++. The four program codes reference 5 program libraries, and the 5 program libraries are different, i.e., all program libraries referenced by the 4 program codes include 5 program libraries. In addition, the programming languages used by each program code are different, and the 4 programming languages used by the 4 program codes include 4 programming languages.
In this step, the calling mode of each program code is set as a command line calling mode. Thus, as each programming library supports named-row calling, when the calling mode of each program code is set as command-row calling, a plurality of programming libraries of a plurality of programming languages can be integrated on the device.
S102, calling the program codes by adopting the command line calling mode, and returning the running results of the program codes.
In the step, different functions can be realized by calling each program code in a command line calling mode, and the application requirements are met. In combination with the above example, in the above example, by setting the calling mode of the program code to the command line calling mode, 5 programming libraries of 4 programming languages can be integrated on the device.
According to the method for supporting the multi-programming language multi-programming library, aiming at a plurality of program codes referencing the programming library, the calling mode of the program codes is set to be a command line calling mode, the program codes are further called by the command line calling mode, and the running result of the program codes is returned. Wherein all programming libraries referenced by the plurality of program code include at least two programming libraries, and/or the plurality of programming languages employed by the plurality of program code include at least two programming languages. Therefore, as the programming libraries referenced by the program codes support named-row calling, when the calling mode of each program code is set as command-row calling, multiple programming languages or multiple programming libraries exclusive or multiple programming libraries which are multiple programming languages can be integrated on the equipment so as to meet application requirements.
FIG. 2 is a flowchart illustrating a method for supporting multiple programming libraries in multiple programming languages according to a second embodiment of the present application. Referring to fig. 2, the method provided in this embodiment, based on the above embodiment, step S101 may include:
s201, judging whether the program codes need to be compiled or not according to the programming language adopted by each program code.
Specifically, the programming languages are divided into two types according to whether the compiler is required to compile, one type is a programming language which is required to compile by using the compiler, and the other type is a programming language which is not required to compile by using the compiler. For example, interpreted languages do not need to be compiled using a compiler (Python, javaScript, perl, shell, etc.), and non-interpreted languages do need to be compiled using a compiler (c++, C language, java, scala, etc.). In this step, it can be determined whether the program code needs to be compiled according to whether the program language adopted by each program code is an interpreted language.
S202, if the program code needs to be compiled, compiling the program code to generate an executable file, otherwise, determining the program code as the executable file.
Specifically, the program codes to be compiled are divided into two types according to the different programming languages, and when the programming languages are the first type programming languages, the program codes are compiled into the first type executable files. For example, when the program language employed is C, C ++, the program code is compiled into an executable file with a suffix of. Exe or. Dll. Further, when the adopted programming language is the second type programming language, compiling the program code into a target file, and combining a plurality of target files to generate a second type executable file. For example, when the adopted programming language is Java or Scala, the programming code is compiled into a target file with a suffix of class, and then a plurality of target files are combined together and packaged into an executable file with a suffix of jar.
S203, storing the executable file, and assembling an execution command for instructing to execute the executable file.
Specifically, in an embodiment, the implementation process of this step may include: the executable file is stored locally.
Further, in another embodiment, the specific implementation procedure of this step may include: and sending the executable file to the target server.
In this embodiment, after the executable file is sent to the target server and the execution command for instructing to execute the executable file is assembled, the method may further include:
and sending the execution command to the target server.
In particular, the target server may be a server on which the program code executes. In addition, the process of sending the executable file and executing the command may be explicit or implicit, which is not limited by the present embodiment.
Further, the program code is called by adopting the command line calling mode, and the running result of the program code is returned, which comprises the following steps:
and calling the program code according to the execution command, and returning an operation result of the program code.
The method provided by the embodiment provides a specific implementation method for setting the calling mode of the program code as the command line calling mode, and by the method, the calling mode of the program code can be set as the command line calling mode. Thus, as each programming library referenced by the program code supports named-row calling, when the calling mode of each program code is set as command-row calling, multiple programming libraries or multiple programming libraries of multiple programming languages or multiple programming languages can be integrated on the device.
Corresponding to the foregoing embodiments of the method for supporting multiple programming libraries in multiple programming languages, the present application also provides embodiments of an apparatus for supporting multiple programming libraries in multiple programming languages.
Embodiments of the apparatus for supporting multiple programming libraries in multiple programming languages of the present application may be implemented on a computer device. The apparatus embodiments may be implemented by software, or may be implemented by hardware or a combination of hardware and software. Taking software implementation as an example, the device in a logic sense is formed by reading corresponding computer program instructions in a memory into a memory by a processor of a computer body where the device is located. In terms of hardware, as shown in fig. 3, a hardware structure diagram of a computer device where an apparatus for supporting multiple programming libraries in multiple programming languages according to an exemplary embodiment of the present application is located is shown, and in addition to the memory 310, the processor 320, the memory 330 and the network interface 340 shown in fig. 3, the computer device where the apparatus in an embodiment is located may further include other hardware according to the actual functions of the apparatus for supporting multiple programming libraries in multiple programming languages, which will not be described herein.
FIG. 4 is a schematic diagram of a device supporting multiple programming libraries in multiple programming languages according to an embodiment of the present application. Referring to fig. 4, the apparatus provided in this embodiment may include a processing module 410 and an executing module 420; wherein,,
the processing module 410 is configured to set, for a plurality of program codes referencing a programming library, a calling manner of the program codes to be a command line calling manner; wherein all programming libraries referenced by the plurality of program codes comprise at least two programming libraries, and/or the plurality of programming languages adopted by the plurality of program codes comprise at least two programming languages; the execution module 420 is configured to call the program code in the command line call manner, and return an operation result of the program code.
Specifically, the device of the present embodiment may be used to implement the technical solution of the method embodiment shown in fig. 1, and its implementation principle and technical effects are similar, and are not described herein again.
Further, the processing module 410 is specifically configured to:
judging whether the program codes need to be compiled or not according to the programming language adopted by each program code;
if the program code needs to be compiled, compiling the program code to generate an executable file, otherwise, determining the program code as the executable file;
storing the executable file, and assembling an execution command for indicating the execution of the executable file.
Further, the execution module 420 is specifically configured to call the program code according to the execution command, and return an operation result of the program code.
Further, the processing module 410 is further specifically configured to:
when the programming language adopted by the program code is a first type programming language, compiling the program code into a first type executable file;
when the programming language adopted by the program code is the second type programming language, compiling the program code into target files, and combining a plurality of target files to generate a second type executable file.
Further, the storing the executable file includes:
storing the executable file locally;
or alternatively, the method can be used for processing,
transmitting the executable file to a target server;
when the storing the executable file includes sending the executable file to a target server, the assembling is used for indicating to execute the executable file after the executing command, the method further includes:
and sending the execution command to the target server.
Further, fig. 5 is a schematic diagram of a system supporting multiple programming libraries in multiple programming languages according to the present application. Referring to fig. 5, the system for supporting multiple programming libraries in multiple programming languages provided in the present embodiment may include a computer device 1 and a server 2, wherein,
the computer device 1 is configured to set, for a plurality of program codes referencing a programming library, a calling manner of the program codes as a command line calling manner; wherein each program code references at least one programming library, and a plurality of programming languages adopted by the plurality of program codes at least comprise two programming languages;
and the server 2 is used for calling the program code in the command line calling mode and returning the running result of the program code.
Further, the computer device 1 is specifically configured to:
judging whether the program codes need to be compiled or not according to the programming language adopted by each program code;
if the program code needs to be compiled, compiling the program code to generate an executable file, otherwise, determining the program code as the executable file;
and assembling an execution command for indicating to execute the executable file, and sending the executable file and the execution command to a server.
Further, the server is configured to call the program code according to the execution command, and return an operation result of the program code.
The foregoing description of the preferred embodiments of the application is not intended to be limiting, but rather to enable any modification, equivalent replacement, improvement or the like to be made within the spirit and principles of the application.