Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass "implementation file" to Fart compiler #32

Open
EthanThatOneKid opened this issue Oct 27, 2021 · 1 comment
Open

Pass "implementation file" to Fart compiler #32

EthanThatOneKid opened this issue Oct 27, 2021 · 1 comment
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@EthanThatOneKid
Copy link
Collaborator

In order for Fart to properly convert a source Fart into a runnable program, it must be provided an implementation file. This file will hold the code needed to run the Fart generated program.

An "implementation file" is any file that [defaultly] exports an implementation of the source Fart.

Idea

// https://etok.codes/fart/main/ex/guessing_game/guessing_game.fart
type GuessingGame {
  previous_guess: number
  
  guess*: fn % <number, string>
  hint*: fn % <_, string>
  remind*: fn % <_ string>
}
// https://etok/codes/fart/main/ex/guessing_game/ts/guessing_game.impl.ts
import { GuessingGame } from "./guessing_game.ts";
export default new GuessingGame();

Awesome! Now we have a guessing game design and implementation supported in TypeScript. To run the guessing game in the command line via Deno, all the user must do is simply run the following command:

deno run https://fart.tools/deno.cli/EthanThatOneKid/fart/main/ex/guessing_game/guessing_game.ts~EthanThatOneKid/fart/main/ex/guessing_game/ts/guessing_game.impl.ts

The Fart server parses this URL such that the segment after the ~ is the location of the implementation file. Implementation files are used often by Fart cartridges that generate runnable programs out-of-the-box.

The result should be a functioning guessing game running in Deno.

@EthanThatOneKid EthanThatOneKid added the enhancement New feature or request label Oct 27, 2021
@EthanThatOneKid EthanThatOneKid added this to the v1.0 milestone Oct 27, 2021
@EthanThatOneKid EthanThatOneKid self-assigned this Oct 27, 2021
@EthanThatOneKid
Copy link
Collaborator Author

Code Cartridges Requiring Implementation File(s)

  • cli: Command Line Interface
  • http_server: Serves implementation as HTTP server
  • http_edge: Edge compute node that serves HTTP
  • http_client: Library that fetches from server instance

The idea is that each of the code cartridges above would have separate versions for each supported programming language.

Example

Let's say you created a generative art implementation in TypeScript, but you want to use the service in Go. Shoot, you do not have a Go implementation, just a TypeScript implementation. It is okay though because we can just generate the Go http_client targeting the generative art implementation TypeScript http_server or http_edge. This bridges the gap between languages via Internet connection. As long as a language has a standard HTTP library, the language should be able to support all other implementations out-of-the-box.

Purpose

Every time you write a feature or library, it is often dedicated to a single point of access such as a UI or server endpoint. Imagine you could instead standardize your library such that it can be used [and/or implemented] by any programming language. This way, your code can be reused as a module and can be reused and repurposed as a CLI, HTTP server, HTTP client, and more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant