CX: The Next Generation Blockchain Programming Language
The Skycoin project consists of several key components with multiple solutions to create a balanced ecosystem. CX is Skycoin’s specification and programming language. Unlike other blockchain projects that boast the usage of smart contracts to enforce digital agreements automatically, Skycoin utilizes CX, a full programming language with the ability to serve as a contractual digital intermediary and house simple & complex functions. Error reporting, control-flow statements such as if/else, for loops, arrays, slices, pointers, and packages are all standard features in the CX programming language. As a general-purpose programming language, CX will be used to create anything from websites, desktop apps, to mobile applications. CX is under continuous development.
As a general-purpose programming language, CX will be used to create anything from websites, desktop apps, to mobile applications.
CX vs. Smart Contracts
If smart contracts are the newest technique for executing blockchain agreements, CX is the complete language for creating expansive use-cases of digital technology, through smart contracts as well as more advanced methodologies. Smart contracts are a revolutionary technique for conducting business without the use of intermediaries. Smart contracts act as the digital equivalent of a physical contract, where software may negotiate the rules of an agreement and will digitally verify that obligations are fulfilled. They have their limitations, however. When deploying smart contracts, a programmer must be sure to maintain precise and accurate code. If errors are found in the smart contract, whether logically or programmatically it is difficult to modify the terms of the contract during its utilization. You can think of smart contracts as a two-way method of executing agreements akin to a call between two cell phone users. CX is the language network that can communicate & create logic with a plethora of applications used in everything from cell phones, wearables, and standard computer systems.
Key Features Of CX
CX has several key features that distinguish its ability to provide a convincing use-case for future blockchain applications. Bitcoin is written in C++ which has the inherent problem of not being memory safe, making it susceptible to coding errors which can lead to attacks. This is why Bitcoin’s code can only be worked on by a few developers at one time. CX for Skycoin utilizes Golang which is resistant to arbitrary code execution, a vulnerability or software bug. This keeps coding errors from leading to broader issues of blockchain application security.
OpenGL and OpenGLFW Libraries
Currently, CX can be used to create command line apps and games using Open Graphics Library (OpenGL) a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics, and GLFW a multi-platform library for OpenGL. CX need only import “gl” and “glfw” to have full access to available functions in both libraries.
Kittycash is the perfect example of an application that will run on CX. Each Kittycash character will represent an in-game character that will be playable by applications built on CX. Previously, building applications & games on the blockchain have proven unfeasible with blockchain state updates happening between 30 seconds upwards of 15 minutes. Imagine trying to play a game where each interaction took a minimum of 30 seconds. The user experience would falter & potential players, even with economic incentives would eventually get bored and move on.
Currently, none of the existing platforms have a tangible solution. Skycoin’s CX will be the first platform that will have 300ms blockchain state updates, allowing for a much more user-friendly experience. Developers will be able to build applications with market incentives, while also providing a desirable user experience.
CX Is A Deterministic Language
Applications of non-deterministic languages in the blockchain space have become questionable; a non-deterministic language does not always produce the same output for every input. An AMD processor may not have the same output as an Intel processor, and 32-bit computers input may not always produce the same output as its 64-bit counterpart. Non-deterministic languages can become troublesome for blockchain applications where an incorrect output due to system specifications can lead to security bugs within a blockchain. Non-deterministic languages can have a direct influence on tangible assets where multiple exploits can lead to the loss of millions of dollars worth of assets. CX solves this issue as a deterministic language, meaning that for every input the algorithm will consistently produce the same output regardless of its underlying machine.
Compiled and Interpreted Language
CX can function as a compiled and interpreted language. This feature gives CX the benefit of having speed and memory efficiency like a compiled language, while also being able to have the flexibility of an interpreted language. Compiled languages take the readable source code and apply conversions to a binary equivalent; compiled languages can send the binary files for any computer to run. Interpreted languages send the source code to any computer, and that machine must use an interpreter to translate the readable code into its binary language during runtime.
Compiled and interpreted code can be thought of as the translation of different languages. In a compiled language you are the translator, able to speak multiple languages, human readable text and the binary language of computers. When executing interpreted languages, the compiler needs a translator to convert the human readable text over to its equivalent machine code. Since CX is both a compiled & interpreted language, it can leverage its advanced features such as affordance, serialization, and program stepping. While also allowing for rapid development, interactivity, and flexible programming.
Affordances For Increased Security
In CX there are sets of claims called Affordances, which state which individual entities can request functions and objects. Affordance operates as a process to isolate computer packages while also providing security measures that limit which functions ‘afford’ specified users access to specific memory locations of the programming language. During the Ethereum DAO hack in 2016, hackers used recursive calls to effectively drain funds from the DAO totaling the USD equivalent of over 70 million USD; this was due to loopholes found in the smart contract. With CX Affordance, function calls are formalized to specific users eliminating the calls from being used by unspecified entities, thus effectively neutralizing the ability of hacks like the DAO from occurring.
Imagine the creation of an object which is a digital key to a factory. Affordance allows you to set the users who have access to that key and when they can use it. While also dictating which users have access to secured areas of the factory. If a programmer wanted to change the key and what areas a user can have access to, Affordance allows the user to restrict or grant access to any given area. If each area of the factory grants access to a different coding environment, Affordance is the possibility of that object to be used in a specified environment.
Affordance can act at the program level creating and modify existing structures in a program. CX uses affordances to dictate how functions are used and by whom, making the language powerful enough to have programs that create programs within itself.
Genetic Programming (GP)
CX uses affordances to conduct genetic programming. Genetic programming is a method of evolving computer programs by utilizing evolutionary algorithms. GP can modify functions until it creates the desired output automatically. As a machine learning tool and automatic problem-solving engine, GP specializes in solving problems where the exact solution structure is not known. Predictive models such as curve fitting, data modeling, and classification are all robust applications of genetic programming.
Strict Typing system
CX has a strict typing system with explicit type casting. Computer languages that do not use explicit type casting can be prone to errors. These errors can be the result of implicit type casting performed by the compiler. In implicit type casting, unlike data types are combined and received automatically as a single data type by the compiler. The use of explicit type casting allows users to have absolute control of what data types are fed to the compiler. A 32-bit number and a 64-bit number each have a specific distinction in CX, so do integers and floating numbers, as well as other data types. Implementation of this typing system makes CX an inherently safer language than other programming languages. Debugging becomes more straightforward as most errors you would encounter are caught at compile time.
CX is a garbage collected language, while other languages use manual memory management which necessitates the programmer to identify and deallocate unused objects. Languages with automatic garbage collection use algorithms to reclaim objects or memory that are no longer in use by the program. CX uses the mark-compact algorithm to iterate and sweep through every pointer in the stack to find which objects are used. The mark-compact algorithm is memory efficient and allows for a methodical programming experience.
In a typical programming language, the user executes a program, and it becomes ambiguous for a user to realize what is happening during the execution. The CX object explorer is an API that can be queried to obtain a list of objects present and alive in the heap. The object explorer will present a graphical view of all objects, how much memory they take, and what they are currently doing in that state. This feature is beneficial for debugging in a standard programming environment and valuable with blockchain applications where a user needs to know how much memory each application is reserving at each state of a program.
A significant benefit to programming in CX is serialization, serialization in conjunction with CX’s stepping feature allows the programmer to step through the execution of a program and stop the program in its state, a programmer can then advance through any number of program steps. In CX every object has a standard method of serialization, this enables the user to stop the program at its current state, create a backup or deliver code to a new system and resume at the execution state it was observed last. Serialization is a valuable tool for productive programming, allowing users to test and debug sections of programs actively through the life of its execution. Serialization is useful for networking and sending data across the web; CX makes this easy by having a standardized serialization protocol. CX can utilize its genetic programming features to automate solutions for debugging while authorizing a debugger to return to a previously backed up state if the solution doesn’t meet output requirements.
As a robust and versatile language, CX offers programmers a way to create usable code on top of the Skycoin platform efficiently. CX is the first of its kind in the blockchain realm, giving users the speed and source code privacy of a compiled language, while also having the benefit of flexibility provided with an interpreted language. The inclusion of Affordances allows CX users to provide secure methods to programming, while also combining predictive modeling such a genetic programming to evolve new solutions to problems. Program structures are changed on the fly in a well-supervised manner. Unlike smart contracts in Ethereum, affordance allows contracts to update through the life of the program dynamically.
CX A Blockchain Application Solution
“When we designed CX, we looked at the problems seen with Ethereum and Bitcoin and fixed them.” -Synth
CX will be simple enough to learn, any programmer with the desire can start building decentralized applications with minimal training, while also resilient enough to tackle some of the more challenging problems associated with embedding applications on the blockchain. From a practical standpoint, it’s important for projects to be able to move and pivot with technology that is continuously changing. Blockchain being the emergence of relatively new technology will continue to grow and transform, Skycoin’s CX has placed itself in the most suitable position to develop and move within this fast-paced technological environment.