Quantum Computing on Arduino
As someone noticed from the previous post, last weeks I started to write a new programming language for Tezos smart contracts. This project was initially intended as a personal exercise for studying parsers, ast and other compiler’s things, but the code just go out of hand very quickly. The joke compiler is now becoming a “real language” that I’ll continue as an hobby project github.com/dakk/yallo-lang.
Yallo (which stands for yet another language lo?) is essentially a functional language which integrates (a sort of) object oriented paradigm. Instead of classes, interfaces and objects, in yallo we have contracts, contract interfaces and contract instances. Here it is an exemple to show how it works.
Let’s suppose we want to create a contract that defines a new token; we first define its interface (which is not mandatory for the Token contract, but useful for other contract calling a Token contract instance):
interface IToken {
entry transfer(from: address, to: address, val: nat);
view getBalance(ad: address): nat;
}
As you can see, our interface has two entrypoints: transfer allows to send tokens from an address to another, and getBalance is used by another contract to retrieve the token balance of the given address. Note that we defined getBalance as a “view”, which is a syntactic sugar for entrypoints which callback to an ‘a contract passed as argument.
Interfaces can also be extended, so we can create an interface IMintableToken which also has a mint entrypoint.
And now let’s see an implementation for this interface, the contract (something like a class); first we declare our storage, which is composed of typed fields. Then we declare a parametrized constructor which is useful for contract deploy (we will investigate this later). And finally we declare our two entrypoints.
contract Token implements IToken {
field balances: (address, nat) big_map;
field totalSupply: nat;
field symbol: string;
constructor (owner: address, supply: nat, symbol: string) {
this.balances = [ { owner: supply } ];
this.totalSupply = supply;
this.symbol = symbol;
}
entry transfer(from: address, to: address, val: nat) {
let a: nat = this.balances.get(from, 0n);
let b: nat = this.balances.get(to, 0n);
assert (a >= val);
this.balances.update(from, a - val);
this.balances.update(to, b + val);
[]
}
view getBalance(ad: address): nat {
this.balances.get(ad, 0n)
}
}
After compiling and deploying our amazing Token contract, other yallo contracts can easily interact with it. Inside our new contract entrypoint, we call the Token getBalance using the IToken.of(address) which returns a typed contract instance of IToken; then we call getBalance passing an address and our callback.
import "IToken.yallo";
const tokenContractAddress: address = @KT1ThEdxfUcWUwqsdergy3QnbCWGHSUHeHJq;
contract usingAToken {
field bal: nat;
entry checkBalance(a: address) {
[IToken.of(tokenContractAddress).getBalance(a, this.checkBalanceCallback)]
}
entry checkBalanceCallback(b: nat) {
this.bal = b;
[]
}
}
Another powerful feature that I introduced is the ability to deploy a contract from another contract, as follows. We call the createContract passing the result of Token(…), which creates a pair composed with the code of Token, and the initial storage generated by its constructor.
import "Token.yallo";
contract deployAToken {
field tokenAddress: address;
entry deployToken() {
let (a: address, op: operation) = Tezos.createContract (Token(Tezos.selfAddress(), 100, "ourToken"), None, 0);
this.tokenAddress = a;
[op]
}
}
At the moment, the compiler will feature cameligo as the only target language, but I’ll work also on a Coq compilation backend. The code and the language itself is in active development and it is not yet ready to use, but any ideas and comments are welcome.
If you liked yallo, please put a star on github.com/dakk/yallo-lang
During my Quantum Computing journey, I often needed to simulate some quantum circuits; sometimes they are small, but some other times they are bigger enough ...
Despite it is sold as a non-cartographic handled GPS device, with limited storage capacity of 10 MB and the inability to expand it, the eTrex 10 GPS, like al...
Since the latest v0.1.18 version, the Qlasskit library offers two useful tool for circuit analysis and optimization.
In the last release of Qlasskit, I introduced a new feature able to export a qlassf function to a binary quadratic model (as bqm, qubo or ising model). This...
In early 2023, I embarked on a journey to explore the field of probabilistic computing. This endeavor culminated in the construction of a hardware prototype,...
Today, I’m going to show you how to use Qlasskit to create a quantum circuit able to search for Sudoku puzzle solutions.
In a recent article I wrote, “Quantum Computing on a Commodore 64 in 200 Lines of BASIC”, published both on Medium and Hackaday.com, shows a two-qubit quantu...
Traditionally, creating quantum circuits requires specialized knowledge in quantum programming. This requirement holds true when encoding a classical algorit...
In an age where companies are selling two-qubit quantum computers for a sum of money that would make your wallet recoil in horror, here we are, stepping off ...
This June I emerged as one of the top participants with 9 bounties collected (alongside another exceptional contributor) in the #UnitaryHack Hackathon, hoste...
A few days ago I came across a yt video discussing the ESA Copernicus program, a European initiative for monitoring earth via a satellite constellation. This...
Qiskit is a python SDK developed by IBM and allows everyone to create quantum circuits, simulate them locally and also run the quantum circuit on a real quan...
As someone noticed from the previous post, last weeks I started to write a new programming language for Tezos smart contracts. This project was initially int...
While writing a new programming language, it is often useful to write some real use-cases to test the syntax, the language expressiveness and the code cleann...
Documentation is like sex: when it is good, it is very, very good; and when it is bad, it is better than nothing
This is my new blog, based on jekyll. I’ll soon import old posts from my old blog.
Contractvm is a general-purpose decentralized framework based on blockchain. The framework allows to implement arbitrary decentralized applications in an eas...
Most of bitcoin dice software use a system to prove the fair play of the server for each bet. Most of them implement this mechanism using two seed (server se...
In the aim to merge two of my server on digitalocean, today I tried to write a mod_rewrite rule to redirect a secondary domain to a subfolder. After one hour...
MineML is a multithread CPU based bitcoin miner written in F#. At the moment it’s a slow implementation, but the class structure offers the possibility to im...