METHODS AND SYSTEMS FOR SOFTWARE CODE GENERATION

Embodiments of the disclosure provide systems and methods for automated generation of computer source code across multiple programming languages. According to one embodiment, a method for automated generation of computer source code can comprise receiving information defining a coding node. The coding node can comprise a definition of an object within an object tree for the computer source code. The coding node can be created based on the received information defining the coding node and the coding node can be transformed into an intermediate, transformed coding node. The intermediate, transformed coding node can then be transpiled into software source code in a target programming language of a plurality of programming languages.

FIELD OF THE DISCLOSURE

Embodiments of the present disclosure relate generally to methods and systems for computer programming and more particularly to automated generation of computer source code across multiple programming languages.

BACKGROUND

The tech industry has long grappled with the inefficiencies associated with developing software for multiple platforms. By necessitating manual reimplementation across diverse programming languages, companies face inflated costs and risks of inconsistency. Hence, there is a need for improved methods and systems for automated and uniform code generation, reducing the maintenance burden.

BRIEF SUMMARY

Embodiments of the disclosure provide systems and methods for automated generation of computer source code across multiple programming languages. According to one embodiment, a method for automated generation of computer source code can comprise receiving information defining a coding node. The coding node can comprise a definition of an object within an object tree for the computer source code. According to one embodiment, the information defining the coding node can comprise Javascript Syntax extension (JSX) code. Additionally, or alternatively, the information defining the coding node can comprise user defined information. The languages composed with the coding node types is Turing-complete. Hence, it can be used to expressed any algorithm.

The coding node can be created based on the received information defining the coding node and the coding node can be transformed into an intermediate, transformed coding node. Creating the coding node can comprise generating one or more of: a node type; one or more node attributes; or one or more child nodes for the coding node based on the received information defining the coding node. In some cases, creating the coding node can further comprise performing a preliminary validation on the coding node. Transforming the coding node into the intermediate, transformed coding node can comprise gathering additional information defining a context for the coding node, validating the coding node for unresolved references and anomalies, modifying the coding node based on the information defining the coding node and the object tree, and propagating one or more code characteristics from the modified coding node to the intermediate, transformed coding node.

The intermediate, transformed coding node can then be transpiled into software source code in a target programming language of a plurality of programming languages. Transpiling the intermediate, transformed coding node into the source code in the target programming language can comprise selecting a transpiler from a plurality of available transpilers based on the target programming language.

According to another embodiment, a system can comprise a processor and a memory coupled with and readable by the processor. The memory can store therein a set of instructions which, when executed by the processor, causes the processor to receive information defining a coding node. The coding node can comprise a definition of an object within an object tree for the computer source code. According to one embodiment, the information defining the coding node can comprise Javascript Syntax extension (JSX) code. Additionally, or alternatively, the information defining the coding node can comprise user defined information.

The instructions can further cause the processor to create the coding node based on the received information defining the coding node and transform the coding node into an intermediate, transformed coding node. Creating the coding node can comprise generating one or more of: a node type; one or more node attributes; or one or more child nodes for the coding node based on the received information defining the coding node. In some cases, creating the coding node can further comprise performing a preliminary validation on the coding node. Transforming the coding node into the intermediate, transformed coding node can comprise gathering additional information defining a context for the coding node, validating the coding node for unresolved references and anomalies, modifying the coding node based on the information defining the coding node and the object tree, and propagating one or more code characteristics from the modified coding node to the intermediate, transformed coding node.

The instructions can further cause the processor to transpile the intermediate, transformed coding node into software source code in a target programming language of a plurality of programming languages. Transpiling the intermediate, transformed coding node into the source code in the target programming language can comprise selecting a transpiler from a plurality of available transpilers based on the target programming language.

According to yet another embodiment, a non-transitory, computer-readable medium can comprise a set of instructions stored therein which, when executed by a processor, causes the processor to receive information defining a coding node. The coding node can comprise a definition of an object within an object tree for the computer source code. According to one embodiment, the information defining the coding node can comprise Javascript Syntax extension (JSX) code. Additionally, or alternatively, the information defining the coding node can comprise user defined information.

The instructions can further cause the processor to create the coding node based on the received information defining the coding node and transform the coding node into an intermediate, transformed coding node. Creating the coding node can comprise generating one or more of: a node type; one or more node attributes; or one or more child nodes for the coding node based on the received information defining the coding node. In some cases, creating the coding node can further comprise performing a preliminary validation on the coding node. Transforming the coding node into the intermediate, transformed coding node can comprise gathering additional information defining a context for the coding node, validating the coding node for unresolved references and anomalies, modifying the coding node based on the information defining the coding node and the object tree, and propagating one or more code characteristics from the modified coding node to the intermediate, transformed coding node.

The instructions can further cause the processor to transpile the intermediate, transformed coding node into software source code in a target programming language of a plurality of programming languages.

DETAILED DESCRIPTION

In the following description, for the purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of various embodiments disclosed herein. It will be apparent, however, to one skilled in the art that various embodiments of the present disclosure may be practiced without some of these specific details. The ensuing description provides exemplary embodiments only and is not intended to limit the scope or applicability of the disclosure. Furthermore, to avoid unnecessarily obscuring the present disclosure, the preceding description omits a number of known structures and devices. This omission is not to be construed as a limitation of the scopes of the claims. Rather, the ensuing description of the exemplary embodiments will provide those skilled in the art with an enabling description for implementing an exemplary embodiment. It should however be appreciated that the present disclosure may be practiced in a variety of ways beyond the specific detail set forth herein.

While the exemplary aspects, embodiments, and/or configurations illustrated herein show the various components of the system collocated, certain components of the system can be located remotely, at distant portions of a distributed network, such as a Local-Area Network (LAN) and/or Wide-Area Network (WAN) such as the Internet, or within a dedicated system. Thus, it should be appreciated, that the components of the system can be combined in to one or more devices or collocated on a particular node of a distributed network, such as an analog and/or digital telecommunications network, a packet-switch network, or a circuit-switched network. It will be appreciated from the following description, and for reasons of computational efficiency, that the components of the system can be arranged at any location within a distributed network of components without affecting the operation of the system.

The term “computer-readable medium” as used herein refers to any tangible storage and/or transmission medium that participate in providing instructions to a processor for execution. Such a medium may take many forms, including but not limited to, non-volatile media, volatile media, and transmission media. Non-volatile media includes, for example, Non-Volatile Random-Access Memory (NVRAM), or magnetic or optical disks. Volatile media includes dynamic memory, such as main memory. Common forms of computer-readable media include, for example, a floppy disk, a flexible disk, hard disk, magnetic tape, or any other magnetic medium, magneto-optical medium, a Compact Disk Read-Only Memory (CD-ROM), any other optical medium, punch cards, paper tape, any other physical medium with patterns of holes, a Random-Access Memory (RAM), a Programmable Read-Only Memory (PROM), and Erasable Programable Read-Only Memory (EPROM), a Flash-EPROM, a solid state medium like a memory card, any other memory chip or cartridge, a carrier wave as described hereinafter, or any other medium from which a computer can read. A digital file attachment to e-mail or other self-contained information archive or set of archives is considered a distribution medium equivalent to a tangible storage medium. When the computer-readable media is configured as a database, it is to be understood that the database may be any type of database, such as relational, hierarchical, object-oriented, and/or the like. Accordingly, the disclosure is considered to include a tangible storage medium or distribution medium and prior art-recognized equivalents and successor media, in which the software implementations of the present disclosure are stored.

Various additional details of embodiments of the present disclosure will be described below with reference to the figures. While the flowcharts will be discussed and illustrated in relation to a particular sequence of events, it should be appreciated that changes, additions, and omissions to this sequence can occur without materially affecting the operation of the disclosed embodiments, configuration, and aspects.

FIG. 1 is a block diagram illustrating elements of an exemplary computing environment in which embodiments of the present disclosure may be implemented. More specifically, this example illustrates a computing environment 100 that may function as the servers, user computers, or other systems provided and described herein. The environment 100 includes one or more user computers, or computing devices, such as a computing device 104, a communication device 108, and/or more 112. The computing devices 104, 108, 112 may include general purpose personal computers (including, merely by way of example, personal computers, and/or laptop computers running various versions of Microsoft Corp.'s Windows® and/or Apple Corp.'s Macintosh® operating systems) and/or workstation computers running any of a variety of commercially-available UNIX® or UNIX-like operating systems. These computing devices 104, 108, 112 may also have any of a variety of applications, including for example, database client and/or server applications, and web browser applications. Alternatively, the computing devices 104, 108, 112 may be any other electronic device, such as a thin-client computer, Internet-enabled mobile telephone, and/or personal digital assistant, capable of communicating via a network 110 and/or displaying and navigating web pages or other types of electronic documents. Although the exemplary computer environment 100 is shown with two computing devices, any number of user computers or computing devices may be supported.

The system may also include one or more servers 114, 116. In this example, server 114 is shown as a web server and server 116 is shown as an application server. The web server 114, which may be used to process requests for web pages or other electronic documents from computing devices 104, 108, 112. The web server 114 can be running an operating system including any of those discussed above, as well as any commercially-available server operating systems. The web server 114 can also run a variety of server applications, including SIP servers, HyperText Transfer Protocol (secure) (HTTP(s)) servers, FTP servers, CGI servers, database servers, Java servers, and the like. In some instances, the web server 114 may publish operations available operations as one or more web services.

The environment 100 may also include one or more file and or/application servers 116, which can, in addition to an operating system, include one or more applications accessible by a client running on one or more of the computing devices 104, 108, 112. The server(s) 116 and/or 114 may be one or more general purpose computers capable of executing programs or scripts in response to the computing devices 104, 108, 112. As one example, the server 116, 114 may execute one or more web applications. The web application may be implemented as one or more scripts or programs written in any programming language, such as Java™ , C, C#®, or C++, and/or any scripting language, such as Perl, Python, or Tool Command Language (TCL), as well as combinations of any programming/scripting languages. The application server(s) 116 may also include database servers, including without limitation those commercially available from Oracle®, Microsoft®, Sybase®, IBM® and the like, which can process requests from database clients running on a computing device 104, 108, 112.

The web pages created by the server 114 and/or 116 may be forwarded to a computing device 104, 108, 112 via a web (file) server 114, 116. Similarly, the web server 114 may be able to receive web page requests, web services invocations, and/or input data from a computing device 104, 108, 112 (e.g., a user computer, etc.) and can forward the web page requests and/or input data to the web (application) server 116. In further embodiments, the server 116 may function as a file server. Although for ease of description, FIG. 1 illustrates a separate web server 114 and file/application server 116, those skilled in the art will recognize that the functions described with respect to servers 114, 116 may be performed by a single server and/or a plurality of specialized servers, depending on implementation-specific needs and parameters. The computer systems 104, 108, 112, web (file) server 114 and/or web (application) server 116 may function as the system, devices, or components described herein.

The environment 100 may also include a database 118. The database 118 may reside in a variety of locations. By way of example, database 118 may reside on a storage medium local to (and/or resident in) one or more of the computers 104, 108, 112, 114, 116. Alternatively, it may be remote from any or all of the computers 104, 108, 112, 114, 116, and in communication (e.g., via the network 110) with one or more of these. The database 118 may reside in a Storage-Area Network (SAN) familiar to those skilled in the art. Similarly, any necessary files for performing the functions attributed to the computers 104, 108, 112, 114, 116 may be stored locally on the respective computer and/or remotely, as appropriate. The database 118 may be a relational database, such as Oracle 20i®, that is adapted to store, update, and retrieve data in response to Structured Query Language (SQL) formatted commands.

FIG. 2 is a block diagram illustrating elements of an exemplary computing device in which embodiments of the present disclosure may be implemented. More specifically, this example illustrates one embodiment of a computer system 200 upon which the servers, user computers, computing devices, or other systems or components described above may be deployed or executed. The computer system 200 is shown comprising hardware elements that may be electrically coupled via a bus 204. The hardware elements may include one or more Central Processing Units (CPUs) 208; one or more input devices 212 (e.g., a mouse, a keyboard, etc.); and one or more output devices 216 (e.g., a display device, a printer, etc.). The computer system 200 may also include one or more storage devices 220. By way of example, storage device(s) 220 may be disk drives, optical storage devices, solid-state storage devices such as a Random-Access Memory (RAM) and/or a Read-Only Memory (ROM), which can be programmable, flash-updateable and/or the like.

The computer system 200 may additionally include a computer-readable storage media reader 224; a communications system 228 (e.g., a modem, a network card (wireless or wired), an infra-red communication device, etc.); and working memory 236, which may include RAM and ROM devices as described above. The computer system 200 may also include a processing acceleration unit 232, which can include a Digital Signal Processor (DSP), a special-purpose processor, and/or the like.

The computer-readable storage media reader 224 can further be connected to a computer-readable storage medium, together (and, optionally, in combination with storage device(s) 220) comprehensively representing remote, local, fixed, and/or removable storage devices plus storage media for temporarily and/or more permanently containing computer-readable information. The communications system 228 may permit data to be exchanged with a network and/or any other computer described above with respect to the computer environments described herein. Moreover, as disclosed herein, the term “storage medium” may represent one or more devices for storing data, including ROM, RAM, magnetic RAM, core memory, magnetic disk storage mediums, optical storage mediums, flash memory devices and/or other machine-readable mediums for storing information.

The computer system 200 may also comprise software elements, shown as being currently located within a working memory 236, including an operating system 240 and/or other code 244. It should be appreciated that alternate embodiments of a computer system 200 may have numerous variations from that described above. For example, customized hardware might also be used and/or particular elements might be implemented in hardware, software (including portable software, such as applets), or both. Further, connection to other computing devices such as network input/output devices may be employed.

FIG. 3 is a block diagram illustrating an exemplary environment in which automated code generation can be performed according to one embodiment of the present disclosure. As illustrated in this example, the environment 300 can comprise a cloud-based storage system 305 coupled with a communications network 310. The cloud-based storage system 305 can comprise any one or more servers and/or other computing devices as described above. Similarly, the communications network 310 can comprise any one or more wired and/or wireless, local-area and/or wide-area networks as described including, but not limited to, the Internet. Also coupled with the communications network 310 can be any one or more client devices 315A and 315B and/or one or more partner systems 320. The one or more client devices 315A and 315B and/or one or more partner systems 320 can each comprise any one or more of the computing devices as described above.

Generally speaking, the cloud-based storage system 305 can provide any number of services 325A and 325B accessible by the one or more client devices 315A and 315B and/or one or more partner systems 320 via the communications network 310 and an Application Program Interface (API) 330. Such service 325A and 325B can include, but are not limited to, services related to online storage and backup, an online collaboration environment, etc. In some cases, the one or more partner systems 320 can provide additional services to the client systems 315A and 315B based on and/or utilizing the services 325A and 325B provided by the cloud-based storage system.

According to one embodiment, the cloud-based storage system 305 can provide a code generator module 335. As will be described below, the code generator module 335 can allow users of the partner systems 320 to easily and automatically generate code utilizing the one or more client devices 315A and 315B and/or one or more partner systems 320 regardless of the code languages utilized by the partner system 320. For example, users of a partner system 320 can utilize the code generator module 335 to generate code to access and use the services 325A and 325B and the API 330 of the cloud-based storage system 305. In other cases, the code generator module 335 can be used to generate code to accomplish any software purpose based on the input provided. For example, there can be a pricing computation algorithm of one partner company that takes a number of arguments and computes a relevant price. By representing the algorithm in JSX and the code generator module 335, the partner company can assure that the algorithm works to consistently yield the same results on all target platforms.

FIG. 4 is a block diagram conceptually illustrating automated code generation according to one embodiment of the present disclosure. As illustrated in this example, automated generation of computer source code can comprise receiving or reading a JSX syntax code definition 405. This code definition can define one or more coding nodes as will be described in further detail below with reference to FIG. 5. Generally speaking, a code generator 335 can then transform and transpile this code definition 405 into any number, depending upon the number of programming languages supported, of computer application files 415A-415C, e.g., source code and/or working code files in different programming languages. Additional details of generating computer source code as may be performed by the code generator 410 will be described in greater detail below with reference to FIG. 6.

FIG. 5 is a block diagram illustrating content of a coding node according to one embodiment of the present disclosure. As illustrated in this example, a program 5050 can comprise one or more coding nodes 510. The coding node, expressed in JSX syntax, for example, can comprise a type 515 for the node 510. As illustrated in this example, the type 515 for the node 510 is “String” which is a subtype of “Literals” type. Other subtypes of Literals type in the reference implementation can be Boolean, Number, or Empty. The node 510 can further comprise a data type 520 for each of one or more attributes 525 and values 530 for the attributes 525. Using the example illustrated here, the corresponding JSX syntax expression can be: <Program><String value=“Hello world”/></Program>.

FIG. 6 is a flowchart illustrating an exemplary process for code generation according to one embodiment of the present disclosure. As illustrated in this example, automated generation of computer source code can comprise receiving 605 information defining a coding node. The coding node can comprise a definition of an object within an object tree for the computer source code. According to one embodiment, the information defining the coding node can comprise JSX code.

The coding node can be created 610 based on the received information defining the coding node. Creating 610 the coding node can comprise generating one or more of: a node type; one or more node attributes; or one or more child nodes for the coding node based on the received information defining the coding node. In some cases, creating 610 the coding node can further comprise performing a preliminary validation on the coding node.

The coding node can then be transformed 615 into an intermediate, transformed coding node. Generally speaking, intermediate, transformed coding nodes can act as a bridges between JSX constructs of the coding nodes and the final transpiled code. To do so, one or more transformers can deduct additional context, further validate, and adapt the coding nodes, with a focus on top-down, pre-order traversal. In some cases, a transformation accumulator can aid in complex transformations. Additional details of an exemplary transformation process will be described below with reference to FIG. 7.

The intermediate, transformed coding node can then be transpiled 620 into software source code in a target programming language of a plurality of programming languages. Transpiling 620 the intermediate, transformed coding node into the source code in the target programming language can comprise selecting a transpiler from a plurality of available transpilers based on the target programming language.

In some cases, the information defining the coding node can further comprise manual code. Therefore, the processes can further comprise optionally adding 625 user defined, i.e., manually defined, information supplementing the JSX code. That is the code generator output is not limited to what can be expressed by the abstract JSX. It can also include platform specific code written in the target programming language to compose any software solution, i.e., partly generated, partly manual. In this way, users are not limited in any way. They can generate as much of the solution as practical and provide the rest as manual code together with the manual code definitions, e.g., for validation of coding nodes that depend on the manual code.

FIG. 7 is a flowchart illustrating an exemplary process for coding node transformation according to one embodiment of the present disclosure. As illustrated in this example, transforming the coding node into the intermediate, transformed coding node can comprise gathering 705 additional information defining a context for the coding node. The information provided here can come from the JSX syntax. It can include the type of the coding node, e.g., Program, If, Function, Literal, etc., its properties depending of the type of the node, e.g., name and arguments for a function, and children, i.e., the nested code nodes. Some properties can have default values assigned during creation in case they weren't included in the original JSX.

The coding node can then be validated 710 for unresolved references and anomalies. The validation of the node can depend on its type and can be performed to assure the node is used correctly. For example, a Program node cannot be used as a child of Function-it can only be used as a top-level node. Additional, or alternatively, validations can include checking if the values of properties are legal. For example, if use calls a function using Call node, a check can be made to determine if the number of provided arguments is correct.

The coding node can be modified 715 based on the information defining the coding node and the object tree. Based on the context of how a node is used and its contents, the transformation process may include modifying them. For example, if a Function accepts some complex data structure in its arguments, e.g., like a record of records, the transformer can extract it into its separate definitions so that the target programming language can define the structure first and then reference it. Some languages do not support declaring complex structures in function definitions so they can be extracted first. Other, simpler kinds of modification may include changing the casing of identifier to adhere to target language coding standards, e.g., camelCase in JavaScript vs snake_case in Python3.

One or more code characteristics can then be propagated 720 from the modified coding node to the intermediate, transformed coding node. The two primary examples for propagation of node characteristic include asynchronous processing and exception handling. Many modern programming languages distinct synchronous and asynchronous modes of processing with a special syntax. If a user calls a asynchronous function they need to do it in a special way. If this happens in another function it makes it an asynchronous function by propagation. The JSX itself does not have the notion of async/sync calls. It uses propagation to figure out which Function and Call nodes should be transpiled to asynchronous syntax in the target programming language. The same applies to exception handling. Some languages explicitly specify which function can throw errors and this characteristic also propagates across function calls.