over budget
Scalus – Scala to Plutus compiler
Current Project Status
Unfunded
Amount
Received
$0
Amount
Requested
$84,000
Percentage
Received
0.00%
Solution

Scala compiler plugin to compile Scala to Untyped Plutus Core, similar to PlutusTx.

Benefits:

  • more devs
  • huge JVM ecosystem
  • compiles to JavaScript via Scala.js
  • better DX: debugger, great IDE support
Problem

Writing DApps in Haskell has some drawbacks: 

  • hard to hire talent
  • slow compilation
  • no debugger
  • poor IDE support
  • can’t compile to JavaScript, because GHCJS barely ever works, producing huge JS sources
Impact / Alignment
Feasibility
Auditability

Team

1 member

Scalus – Scala to Plutus compiler

Please describe your proposed solution.

Market

Developers building out the Cardano ecosystem who would prefer to write smart contracts, off-chain server code, and in-browser front-end code using a single widely adopted JVM programming language.

Problem Space

I will second and expand the MLabs description of The Plutus Compilation Pipeline and Plutus Tx Pain Points from their Plutarch proposal:

The Plutus Tx compilation library has several shortcomings. Notably, it:

  • Extensively relies on the INLINEABLE pragma making the majority of existing Haskell libraries unusable
  • Produces extremely complicated error messages
  • Makes it difficult to use abstractions due to overhead added to the resulting code
  • Silently changes the semantics of Haskell code turning function applications strict
  • Does not allow for fine-tuned control of Plutus Core
  • Does not erase type abstractions (they get turned into a “delay”)
  • Almost impossible to debug the UPLC scripts

Solution

Essentially, it was an original goal of using Haskell and PlutusTx – to reuse existing libraries, infrastructure, and tooling.

I propose an even better solution. Scala being a JVM targeted language, benefits from an enormous amount of libraries, has a great industry-grade tooling, excellent IDE support, and broader community.

Scala has a well designed and mature compiler plugins infrastructure we can leverage, similarly to how PlutusTx uses Haskell compiler.

Scala compiles to an intermediate representation, called TASTY, giving access to other code ASTs, allowing reuse of existing code. It’s like having INLINEABLE pragma everywhere.

Please describe how your proposed solution will address the Challenge that you have submitted it in.

Adding Scala support will have a large impact on the Cardano Developer Ecosystem:

  • open a large pool of talent for hire
  • simplify adoption by the financial sector companies that heavily invested in Java and Scala ecosystems
  • greatly improve developers experience with working debugger, good IDE support, faster ‘change-compile-test’ turnaround

What are the main risks that could prevent you from delivering the project successfully and please explain how you will mitigate each risk?

The main risks are unknown unknowns that may arise during the development.

I think I'll be able to solve the potential issues by consulting with either my former colleagues from IOG and/or Scala Compiler developers. I know the guys, we met on conferences, etc.

Please provide a detailed plan, including timeline and key milestones for delivering your proposal.

Main tasks and development milestones are:

  • Scala UPLC CEK machine implementation
  • Scala TASTY to UPLC converter (limited to functions, constants, builtins, and expressions)
  • Scala Compiler Plugin MVP
  • Execution cost for CEK machine
  • Flat serialization
  • Plutus v2 builtins implementation
  • Generic Data serialization/deserialization for Scala datatypes
  • Optimization
  • Test Suit satisfying "plutus-conformance" test vectors
  • Documentation, examples, tutorialsDevOps Effort (CI, Maven Central release, AWS)

Please provide a detailed budget breakdown.

Scala UPLC CEK machine implementation – 80 hours

Scala TASTY to UPLC converter (limited to functions, constants, builtins, and expressions) – 80 hours

Scala Compiler Plugin MVP – 80 hours

Execution cost for CEK machine – 80 hours

Flat serialization – 80 hours

Plutus v2 builtins implementation – 160 hours

Generic Data serialization/deserialization for Scala datatypes – 80 hours

Optimization – 80

Test Suit satisfying "plutus-conformance" test vectors – 80 hours

Documentation, examples, tutorials – 80 hours

DevOps Effort (CI, Maven Central release, AWS) – 40 hours

Contingency Budget – 200 hours

Total engineering hours – 1120 hours

Budget – $84,000

Please provide details of the people who will work on the project.

Alexander Nemish

<https://github.com/nau/>

Scala and Haskell engineer.

Former IOG employee, worked on Marlowe.

If you are funded, will you return to Catalyst in a later round for further funding? Please explain why / why not.

Yes. I'd like to extend the Scala support with further development of libraries/frameworks for writing on-chain and off-chain code on Cardano.

Please describe what you will measure to track your project's progress, and how will you measure these?

It's an open source project, so the progress will be seen on Github: https://github.com/nau/scalus

KPIs (Key Performance Indicators):

  • plutus-conformance test suit passes
  • can evaluate Plutus scripts using Scala CEK machine
  • can compile a subset of Scala to UPLC
  • can serialize/deserialize scripts to/from 'flat' encoding
  • can use all Plutus v2 builtins

What does success for this project look like?

Developers will be able to write Plutus Scripts in Scala.

Developers will benefit from the excellent IDE support, debugger, build tools, and faster compilation-testing turnaround whilst not sacrificing type safety.

More developers could write smart contracts for Cardano.

Developers will be able to reuse their Scala code in browser by compiling it to JavaScript using Scala.js.

Please provide information on whether this proposal is a continuation of a previously funded project in Catalyst or an entirely new one.

This is a new proposal.

close

Playlist

  • EP2: epoch_length

    Authored by: Darlington Kofa

    3m 24s
    Darlington Kofa
  • EP1: 'd' parameter

    Authored by: Darlington Kofa

    4m 3s
    Darlington Kofa
  • EP3: key_deposit

    Authored by: Darlington Kofa

    3m 48s
    Darlington Kofa
  • EP4: epoch_no

    Authored by: Darlington Kofa

    2m 16s
    Darlington Kofa
  • EP5: max_block_size

    Authored by: Darlington Kofa

    3m 14s
    Darlington Kofa
  • EP6: pool_deposit

    Authored by: Darlington Kofa

    3m 19s
    Darlington Kofa
  • EP7: max_tx_size

    Authored by: Darlington Kofa

    4m 59s
    Darlington Kofa
0:00
/
~0:00