# guitarvydas/forthish

**Source:** https://github.com/guitarvydas/forthish

GitHub - guitarvydas/forthish



[Skip to content](#start-of-content)













## Navigation Menu

Toggle navigation

[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fguitarvydas%2Fforthish)

Appearance settings

* Platform

  + AI CODE CREATION
    - [GitHub CopilotWrite better code with AI](https://github.com/features/copilot)
    - [GitHub SparkBuild and deploy intelligent apps](https://github.com/features/spark)
    - [GitHub ModelsManage and compare prompts](https://github.com/features/models)
    - [MCP RegistryNewIntegrate external tools](https://github.com/mcp)
  + DEVELOPER WORKFLOWS
    - [ActionsAutomate any workflow](https://github.com/features/actions)
    - [CodespacesInstant dev environments](https://github.com/features/codespaces)
    - [IssuesPlan and track work](https://github.com/features/issues)
    - [Code ReviewManage code changes](https://github.com/features/code-review)
  + APPLICATION SECURITY
    - [GitHub Advanced SecurityFind and fix vulnerabilities](https://github.com/security/advanced-security)
    - [Code securitySecure your code as you build](https://github.com/security/advanced-security/code-security)
    - [Secret protectionStop leaks before they start](https://github.com/security/advanced-security/secret-protection)
  + EXPLORE
    - [Why GitHub](https://github.com/why-github)
    - [Documentation](https://docs.github.com)
    - [Blog](https://github.blog)
    - [Changelog](https://github.blog/changelog)
    - [Marketplace](https://github.com/marketplace)

  [View all features](https://github.com/features)
* Solutions

  + BY COMPANY SIZE
    - [Enterprises](https://github.com/enterprise)
    - [Small and medium teams](https://github.com/team)
    - [Startups](https://github.com/enterprise/startups)
    - [Nonprofits](https://github.com/solutions/industry/nonprofits)
  + BY USE CASE
    - [App Modernization](https://github.com/solutions/use-case/app-modernization)
    - [DevSecOps](https://github.com/solutions/use-case/devsecops)
    - [DevOps](https://github.com/solutions/use-case/devops)
    - [CI/CD](https://github.com/solutions/use-case/ci-cd)
    - [View all use cases](https://github.com/solutions/use-case)
  + BY INDUSTRY
    - [Healthcare](https://github.com/solutions/industry/healthcare)
    - [Financial services](https://github.com/solutions/industry/financial-services)
    - [Manufacturing](https://github.com/solutions/industry/manufacturing)
    - [Government](https://github.com/solutions/industry/government)
    - [View all industries](https://github.com/solutions/industry)

  [View all solutions](https://github.com/solutions)
* Resources

  + EXPLORE BY TOPIC
    - [AI](https://github.com/resources/articles?topic=ai)
    - [Software Development](https://github.com/resources/articles?topic=software-development)
    - [DevOps](https://github.com/resources/articles?topic=devops)
    - [Security](https://github.com/resources/articles?topic=security)
    - [View all topics](https://github.com/resources/articles)
  + EXPLORE BY TYPE
    - [Customer stories](https://github.com/customer-stories)
    - [Events & webinars](https://github.com/resources/events)
    - [Ebooks & reports](https://github.com/resources/whitepapers)
    - [Business insights](https://github.com/solutions/executive-insights)
    - [GitHub Skills](https://skills.github.com)
  + SUPPORT & SERVICES
    - [Documentation](https://docs.github.com)
    - [Customer support](https://support.github.com)
    - [Community forum](https://github.com/orgs/community/discussions)
    - [Trust center](https://github.com/trust-center)
    - [Partners](https://github.com/partners)
* Open Source

  + COMMUNITY
    - [GitHub SponsorsFund open source developers](https://github.com/sponsors)
  + PROGRAMS
    - [Security Lab](https://securitylab.github.com)
    - [Maintainer Community](https://maintainers.github.com)
    - [Accelerator](https://github.com/accelerator)
    - [Archive Program](https://archiveprogram.github.com)
  + REPOSITORIES
    - [Topics](https://github.com/topics)
    - [Trending](https://github.com/trending)
    - [Collections](https://github.com/collections)
* Enterprise

  + ENTERPRISE SOLUTIONS
    - [Enterprise platformAI-powered developer platform](https://github.com/enterprise)
  + AVAILABLE ADD-ONS
    - [GitHub Advanced SecurityEnterprise-grade security features](https://github.com/security/advanced-security)
    - [Copilot for BusinessEnterprise-grade AI features](https://github.com/features/copilot/copilot-business)
    - [Premium SupportEnterprise-grade 24/7 support](https://github.com/premium-support)
* [Pricing](https://github.com/pricing)

Search or jump to...


# Search code, repositories, users, issues, pull requests...

Search

Clear

[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)

# Provide feedback

We read every piece of feedback, and take your input very seriously.


Include my email address so I can be contacted

Cancel
 Submit feedback





# Saved searches

## Use saved searches to filter your results more quickly

Name

Query

To see all available qualifiers, see our [documentation](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax).

Cancel
 Create saved search

[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fguitarvydas%2Fforthish)

[Sign up](/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&source=header-repo&source_repo=guitarvydas%2Fforthish)

Appearance settings

Resetting focus

You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
 


Dismiss alert

{{ message }}

[guitarvydas](/guitarvydas) 
/
**[forthish](/guitarvydas/forthish)**
Public

* [Notifications](/login?return_to=%2Fguitarvydas%2Fforthish) You must be signed in to change notification settings
* [Fork
  0](/login?return_to=%2Fguitarvydas%2Fforthish)
* [Star
   1](/login?return_to=%2Fguitarvydas%2Fforthish)

[1
star](/guitarvydas/forthish/stargazers) [0
forks](/guitarvydas/forthish/forks) [Branches](/guitarvydas/forthish/branches) [Tags](/guitarvydas/forthish/tags) [Activity](/guitarvydas/forthish/activity)

[Star](/login?return_to=%2Fguitarvydas%2Fforthish)

[Notifications](/login?return_to=%2Fguitarvydas%2Fforthish) You must be signed in to change notification settings

* [Code](/guitarvydas/forthish)
* [Issues
  0](/guitarvydas/forthish/issues)
* [Pull requests
  0](/guitarvydas/forthish/pulls)
* [Actions](/guitarvydas/forthish/actions)
* [Projects
  0](/guitarvydas/forthish/projects)
* [Security
  0](/guitarvydas/forthish/security)
* [Insights](/guitarvydas/forthish/pulse)

Additional navigation options


* [Code](/guitarvydas/forthish)
* [Issues](/guitarvydas/forthish/issues)
* [Pull requests](/guitarvydas/forthish/pulls)
* [Actions](/guitarvydas/forthish/actions)
* [Projects](/guitarvydas/forthish/projects)
* [Security](/guitarvydas/forthish/security)
* [Insights](/guitarvydas/forthish/pulse)

# guitarvydas/forthish

main

[Branches](/guitarvydas/forthish/branches)[Tags](/guitarvydas/forthish/tags)

Go to file

Code

Open more actions menu

## Folders and files

| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- | --- |
| Latest commit   History[26 Commits](/guitarvydas/forthish/commits/main/)   26 Commits | | |
| [.hg](/guitarvydas/forthish/tree/main/.hg ".hg") | | [.hg](/guitarvydas/forthish/tree/main/.hg ".hg") |  |  |
| [.obsidian](/guitarvydas/forthish/tree/main/.obsidian ".obsidian") | | [.obsidian](/guitarvydas/forthish/tree/main/.obsidian ".obsidian") |  |  |
| [assets](/guitarvydas/forthish/tree/main/assets "assets") | | [assets](/guitarvydas/forthish/tree/main/assets "assets") |  |  |
| [basic](/guitarvydas/forthish/tree/main/basic "basic") | | [basic](/guitarvydas/forthish/tree/main/basic "basic") |  |  |
| [course](/guitarvydas/forthish/tree/main/course "course") | | [course](/guitarvydas/forthish/tree/main/course "course") |  |  |
| [frish](/guitarvydas/forthish/tree/main/frish "frish") | | [frish](/guitarvydas/forthish/tree/main/frish "frish") |  |  |
| [.gitignore](/guitarvydas/forthish/blob/main/.gitignore ".gitignore") | | [.gitignore](/guitarvydas/forthish/blob/main/.gitignore ".gitignore") |  |  |
| [.hgignore](/guitarvydas/forthish/blob/main/.hgignore ".hgignore") | | [.hgignore](/guitarvydas/forthish/blob/main/.hgignore ".hgignore") |  |  |
| [INSTALL-hg.md](/guitarvydas/forthish/blob/main/INSTALL-hg.md "INSTALL-hg.md") | | [INSTALL-hg.md](/guitarvydas/forthish/blob/main/INSTALL-hg.md "INSTALL-hg.md") |  |  |
| [INSTALL.md](/guitarvydas/forthish/blob/main/INSTALL.md "INSTALL.md") | | [INSTALL.md](/guitarvydas/forthish/blob/main/INSTALL.md "INSTALL.md") |  |  |
| [README.md](/guitarvydas/forthish/blob/main/README.md "README.md") | | [README.md](/guitarvydas/forthish/blob/main/README.md "README.md") |  |  |
| View all files | | |

## Repository files navigation

* [README](#)

# Forth in $WHATEVER

This is a collection of Forth (or Forth-like) implementations in various languages. It is intended to provide examples of how you can leverage Forth to simplify and add extensibility to your programs.

## Python Implementations

### [simple.py](/guitarvydas/forthish/blob/main/simple.py?rev=tip)

The simplest thing that could be called a Forth (Mr. Moore will probably disagree with me). However, it provides a useful parser, stack and interface to the host system. Words in this implementation:

* **+** ( a b -- sum) Add two numbers on top of stack.
* **-** ( a b -- difference) Subtracts top number from next on stack.
* **.** ( n --) Pop top of stack and print it.
* **.s** ( --) Print contents of stack (nondestructive).
* **bye** ( --) Exit interpreter.
* **interpret** ( string --) Execute word on top of stack.
* **swap** ( a b -- b a) Swaps top two items on stack.
* **word** ( c -- string) Collect characters in input stream up to character c.

### [fram.py](/guitarvydas/forthish/blob/main/fram.py?rev=tip)

This implements a semi-traditional Forth dictionary in the RAM array. Words are stored with a name field, link field and code field. Instead of finding things directly with a Python dictionary, the `'` word searches for the xt, or "execution token", to be executed.

In real terms, a little slower, but offers some exciting benefits, which I'll explore later.

* **'** ( name -- xt) Finds word's xt in dictionary.
* **execute** ( xt --) Executes the code at xt.
* **negate** ( n -- -n) Makes number negative (or positive, if you use it twice).
* **words** ( --) Prints list of all words in dictionary.

### [fvars.py](/guitarvydas/forthish/blob/main/fvars.py?rev=tip)

Now we're getting into memory manipulations with variables and such. This introduces some new stuff in the code field -- a constant or variable is just like any other Forth word, except the code retrieves the values (or address of the values, for variables).

* **!** ( v a --) Store value at address a.
* **,** ( v --) Store v as next value in dictionary.
* **@** ( a -- v) Fetch value from address a.
* **constant** ( name | v --) Create constant with value v.
* **create** ( name | --) Create word name in dictionary.
* **dump** ( start n --) Dump n values starting from RAM address a.
* **variable** ( name | v --) Create variable name, with initial value v.

### [fcomp.py](/guitarvydas/forthish/blob/main/fcomp.py?rev=tip)

Stuff is getting tricky now... This implements user definitions. Also reworks some previous words.

#### Variables

* **state** Variable for interpreter state -- 0 = interpret, 1 = compile.

#### Special Words for Compilation

These words are used during compilation to handle literal values and control flow. You will generally not need to use them.

* **(literal)** Used when compiling literal values in definitions.
* **branch** Unconditional branch.
* **0branch** Branch on false.

#### Words for Definitions

The colon and semicolon begin and end a Forth definition. The if/else/then triad can only be used inside a definition (in traditional Forth).

* **:** ( name | --) Start compiling new definition.
* **;** ( --) End definition.
* **if** ( f --) Evaluate based on flag f.
* **else** ( --) What to do when if is false.
* **then** ( --) End if/else/then clause, continue with normal execution.

#### Regular Words

This is a grab bag of stuff that I found useful as I went. Notably, the `"` (quote) word is state-smart, meaning it can be used outside and inside a definition. Now that you know that, forget it...

* **find** ( name | -- name 0|xt 1|xt -1) Search for word name.
* **(** ( --) Start inline comment, reads until closing paren.
* **."** ( --) Prints text up to closing quote.
* **"** ( -- s) Reads text up to closing quote as a string, puts on stack.
* **/** ( a b -- div) Divides a by b.
* **\*** ( a b -- product) Multiplies a times b.
* **cr** ( --) Carriage return.
* **emit** ( c --) Prints ascii character c.
* **dup** ( a -- a a) Duplicate TOS.
* **drop** ( a --) Discards TOS.

If you care, this is effectively a DTC (Direct Threaded Code) implementation.

*Explanation of how colon definitions work goes here...*

## References

Some links to more information that will help in understanding why you might do with this and what to do with it once you've got it. If nothing else, please read Walker's essay at the first link.

### Essential

* [ATLAST](https://www.fourmilab.ch/atlast/) -- My first encounter with this concept, written by the legendary John Walker. He explains it better than I can.
* [Starting Forth](https://www.forth.com/starting-forth/) -- Classic Forth tutorial and textbook. Don't be fooled by the illustrations, this book not only teaches you how to use Forth, but actually gives you enough information to write your own as well.
* [Levels of FORTH](https://www.forth.org/literature/forthlev.html) -- Glen Haydon's taxonomy of Forth implementations, slightly outdated, but useful if you're trying to figure out what functionality to implement next.

### Supplemental

* [Forth Standard](https://forth-standard.org/standard/words) Yes, Forth has a language standard. Don't feel like you need to follow it slavishly, though...
* [JONESFORTH](https://github.com/nornagon/jonesforth/blob/master/jonesforth.S) -- A full implementation of Forth, in assembly.
* [Thinking Forth -- A Language and Philosophy for Solving Problems](https://www.forth.com/wp-content/uploads/2018/11/thinking-forth-color.pdf) -- Leo Brodie's masterwork, read this to figure out how to *really* use your new Forth implementation.

### Historical

* [Forth - The Early Years](https://colorforth.github.io/HOPL.html) -- Potted history of Forth, by its creator, Chuck Moore.
* [Programming a Problem Oriented Language](https://archive.org/details/chuck-moore-forth-book/page/10/mode/2up) -- Unpublished book by Chuck Moore describing early Forth.

## About

No description, website, or topics provided.

### Resources

[Readme](#readme-ov-file)

### Uh oh!

There was an error while loading. Please reload this page.

[Activity](/guitarvydas/forthish/activity)

### Stars

[**1**
star](/guitarvydas/forthish/stargazers)

### Watchers

[**0**
watching](/guitarvydas/forthish/watchers)

### Forks

[**0**
forks](/guitarvydas/forthish/forks)

[Report repository](/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2Fguitarvydas%2Fforthish&report=guitarvydas+%28user%29)

## [Releases](/guitarvydas/forthish/releases)

No releases published

## [Packages 0](/users/guitarvydas/packages?repo_name=forthish)

No packages published

## Languages

* [Python
  66.6%](/guitarvydas/forthish/search?l=python)
* [JavaScript
  22.6%](/guitarvydas/forthish/search?l=javascript)
* [HTML
  10.4%](/guitarvydas/forthish/search?l=html)
* Other
  0.4%

## Footer

© 2026 GitHub, Inc.

### Footer navigation

* [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
* [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
* [Security](https://github.com/security)
* [Status](https://www.githubstatus.com/)
* [Community](https://github.community/)
* [Docs](https://docs.github.com/)
* [Contact](https://support.github.com?tags=dotcom-footer)
* Manage cookies
* Do not share my personal information



You can’t perform that action at this time.