- What You Can Do
- Overview
- Getting Started
- How It Works
- Language Basics
- Web Frontend (Text β Morse Translator)
- Development
Morse Lang lets you write full Python programs using only dots (.) and dashes (-). Here's what you can build:
Create and store values in variables:
Python:
var x = 10
var y = 20
var name = "morse"Morse:
...- .- .-. -..- -...- .---- -----
...- .- .-. -.-- -...- ..--- -----
...- .- .-. -.. .- -- . -...- .----. -- --- .-. ... . .----.
Perform arithmetic with addition, subtraction, multiplication, and division:
Python:
var result = 5 + 3
var product = 10 * 2
var difference = 100 - 25
var quotient = 20 / 4Morse:
...- .- .-. .-. . ... ..- .-.. - -...- ..... .-.-. ...--
...- .- .-. .--. .-. --- -.. ..- -.-. - -...- .---- ----- -.-.- ..---
...- .- .-. -.. .. ..-. ..-. . .-. . -. -.-. . -...- .---- ----- ----- -....- ..--- .....
...- .- .-. --.- ..- --- - .. . -. - -...- ..--- ----- -..-. ....-
Display output to the console:
Python:
print("Hello, World!")
print(42)
print(x + y)Morse:
.--. .-. .. -. - -.--. .----. .... . .-.. .-.. --- --..-- .-- --- .-. .-.. -.. .----. -.--.-
.--. .-. .. -. - -.--. ....- ..--- -.--.-
.--. .-. .. -. - -.--. -..- .-.-. -.-- -.--.-
Iterate over a range of numbers:
Python:
for i in range(5):
print iMorse:
..-. --- .-. .. .. -. .-. .- -. --. . -.--. ..... -.--.- --- --..--
.--. .-. .. -. - ..
Output:
0
1
2
3
4
Repeat code while a condition is true:
Python:
var count = 0
while count < 3:
print count
var count = count + 1Morse:
...- .- .-. -.-. --- ..- -. - -...- -----
.-- .... .. .-.. . -.-. --- ..- -. - -....- ...--
.--. .-. .. -. - -.-. --- ..- -. -
...- .- .-. -.-. --- ..- -. - -...- -.-. --- ..- -. - .-.-. .----
Output:
0
1
2
Define reusable functions with parameters and return values:
Python:
func greet():
print hello
print world
greet()
func add(a b):
return a + b
var result = add(3 5)
print resultMorse:
..-. ..- -. -.-. --. .-. . . - -.--. -.--.- --- --..--
.--. .-. .. -. - .... . .-.. .-.. ---
.--. .-. .. -. - .-- --- .-. .-.. -..
--. .-. . . - -.--. -.--.-
..-. ..- -. -.-. .- -.. -.. -.--. .- -... -.--.- --- --..--
.-. . - ..- .-. -. .- .-.-. -...
...- .- .-. .-. . ... ..- .-.. - -...- .- -.. -.. -.--. ...-- ..... -.--.-
.--. .-. .. -. - .-. . ... ..- .-.. -
Output:
hello
world
8
Here's a full program that combines all features:
Python:
func calculate_sum(a b):
return a + b
var x = 5
var y = 10
var total = calculate_sum(x y)
print total
for i in range(3):
print iMorse:
..-. ..- -. -.-. -.-. .- .-.. -.-. ..- .-.. .- - . ... ..- -- -.--. .- -... -.--.- --- --..--
.-. . - ..- .-. -. .- .-.-. -...
...- .- .-. -..- -...- .....
...- .- .-. -.-- -...- .---- -----
...- .- .-. - --- - .- .-.. -...- -.-. .- .-.. -.-. ..- .-.. .- - . ... ..- -- -.--. -..- -.-- -.--.-
.--. .-. .. -. - - --- - .- .-..
..-. --- .-. .. .. -. .-. .- -. --. . -.--. ...-- -.--.- --- --..--
.--. .-. .. -. - ..
Output:
15
0
1
2
π‘ Note: Morse Lang supports all these features and more! You can combine variables, math, loops, and functions to build complex programs entirely in Morse code.
Morse Lang is a programming language where your source code is written entirely in Morse code. You write a .mc file using dots (.) and dashes (-), the morse CLI decodes it into Python, and then executes it.
It works the same way on macOS, Windows, and Linux as long as you have Python installed.
Use cases
- Learning / teaching Morse code with a fun programming twist
- Code golf / esolangs and experimentation
- Novel demos where the source file looks like radio traffic but runs like Python
-
Step 1 β Morse source (
.mc):
You create a file filled with Morse symbols (e.g..-,--..--) separated by spaces. -
Step 2 β Decode to Python:
The CLI usesmorse_lang.morse_to_textandMORSE_MAPto translate each Morse token into a character, building a normal Python source file line by line. -
Step 3 β Execute:
The decoded Python string is executed withexec(...)in a fresh namespace, just like running a regular.pyscript.
Because of this, Morse Lang programs can do anything Python can. Only run .mc files you trust, just as you would with untrusted Python code.
- Python: 3.8 or newer (3.10+ recommended)
- Works on:
- macOS (tested on recent versions)
- Windows 10/11
- Linux (any modern distro)
You can check your Python version with:
python --versionOn Windows, you may need:
py --versionThe simplest way is to install the package directly from PyPI.
- macOS / Linux (bash, zsh, etc.):
python -m pip install --upgrade pip
python -m pip install morse-lang- Windows (PowerShell or Command Prompt):
py -m pip install --upgrade pip
py -m pip install morse-langAfter installation, the morse command should be available on your PATH.
If you are working directly with this repository:
git clone https://github.com/sharky-3/morse-programming-language.git
cd morse-programming-language
# (Optional but recommended) create a virtual environment
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
python -m pip install --upgrade pip
python -m pip install -e .This installs morse-lang in editable mode so changes to the source are reflected immediately.
If you cloned this repository, you can immediately run the included example:
-
macOS / Linux:
morse examples/hello.mc
-
Windows:
morse examples\hello.mc
You should see:
hello, world
Create a new file, for example my_program.mc, and add some Morse code:
Example: Simple math program
Create math.mc:
...- .- .-. -..- -...- .---- -----
...- .- .-. -.-- -...- .....
...- .- .-. ... ..- -- -...- -..- .-.-. -.--
.--. .-. .. -. - ... ..- --
Run it:
-
macOS / Linux:
morse math.mc
-
Windows:
morse math.mc
Output:
15
Example: Try loops and functions
You can also run the included example with loops and functions:
-
macOS / Linux:
morse examples/loops_and_functions.mc
-
Windows:
morse examples\loops_and_functions.mc
π‘ Tip: Use the Web Frontend to help translate your Python code to Morse code!
If the morse command is not found after installation:
Windows:
# Try using Python module directly
py -m morse_lang.cli math.mc
# Or with full path
python -m morse_lang.cli math.mcmacOS / Linux:
# Try using Python module directly
python -m morse_lang.cli math.mc
# Or check if morse is in your PATH
which morseIf it's still not working, make sure:
- Python is installed and in your PATH
- You've activated your virtual environment (if using one)
- The package was installed successfully (
pip list | grep morse-lang)
At its core, Morse Lang is "Python in Morse". Each Morse token is mapped to a character using standard Morse code conventions:
- Single space (
" ") between Morse codes β separates letters within a word - Triple space (
" ") between sequences β separates words - Each line in your
.mcfile β one line of decoded Python
The mapping is defined in MORSE_MAP and includes:
.- β a -... β b -.-. β c -.. β d . β e
..-. β f --. β g .... β h .. β i .--- β j
-.- β k .-.. β l -- β m -. β n --- β o
.--. β p --.- β q .-. β r ... β s - β t
..- β u ...- β v .-- β w -..- β x -.-- β y
--.. β z
----- β 0 .---- β 1 ..--- β 2 ...-- β 3 ....- β 4
..... β 5 -.... β 6 --... β 7 ---.. β 8 ----. β 9
.-.-. β + (addition)
-....- β - (subtraction)
-.-.- β * (multiplication)
-..-. β / (division)
-...- β = (assignment/equality)
--..-- β , (comma)
...... β . (period)
.----. β ' (apostrophe)
-.--. β ( (left parenthesis)
-.--.- β ) (right parenthesis)
When writing your .mc files, remember:
- Separate letters with single spaces:
.... . .-.. .-.. ---=hello - Separate words with triple spaces:
.... . .-.. .-.. --- .-- --- .-. .-.. -..=hello world - Each line becomes one Python line: Line breaks in
.mcbecome line breaks in Python
Python:
print("Hello, World!")Morse:
.--. .-. .. -. - -.--. .----. .... . .-.. .-.. --- --..-- .-- --- .-. .-.. -.. .----. -.--.-
Python:
var x = 10
var y = 5
var result = x + y
print resultMorse:
...- .- .-. -..- -...- .---- -----
...- .- .-. -.-- -...- .....
...- .- .-. .-. . ... ..- .-.. - -...- -..- .-.-. -.--
.--. .-. .. -. - .-. . ... ..- .-.. -
Output:
15
Python:
for i in range(5):
print iMorse:
..-. --- .-. .. .. -. .-. .- -. --. . -.--. ..... -.--.- --- --..--
.--. .-. .. -. - ..
Output:
0
1
2
3
4
Python:
var count = 0
while count < 3:
print count
var count = count + 1Morse:
...- .- .-. -.-. --- ..- -. - -...- -----
.-- .... .. .-.. . -.-. --- ..- -. - -....- ...-- --- --..--
.--. .-. .. -. - -.-. --- ..- -. -
...- .- .-. -.-. --- ..- -. - -...- -.-. --- ..- -. - .-.-. .----
Output:
0
1
2
Python:
func add(a b):
return a + b
var result = add(3 5)
print resultMorse:
..-. ..- -. -.-. .- -.. -.. -.--. .- -... -.--.- --- --..--
.-. . - ..- .-. -. .- .-.-. -...
...- .- .-. .-. . ... ..- .-.. - -...- .- -.. -.. -.--. ...-- ..... -.--.-
.--. .-. .. -. - .-. . ... ..- .-.. -
Output:
8
π Pro Tip: Morse Lang supports variables (
var), math operations, print statements, for loops (for i in range(n):), while loops (while condition:), and functions (func name(args):withreturn). Use indentation (spaces) to define code blocks, just like Python!
This repository also includes a small Flask web app that lets you convert between text and Morse interactively.
From the project root:
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python app.pyThen open http://localhost:5000 in your browser.
The page lets you:
- Type text β get Morse code
- Paste Morse β get decoded text
The web app uses the same MORSE_MAP as the CLI, so behavior is consistent.
If you want to hack on Morse Lang itself:
- Clone and install in editable mode:
git clone https://github.com/sharky-3/morse-programming-language.git
cd morse-programming-language
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
python -m pip install --upgrade pip
python -m pip install -e .
python -m pip install -r requirements.txt- Run tests:
python -m pip install pytest
pytest- Play with the internals:
morse_lang/lexer.pyβ Morse β text decodingmorse_lang/morse_map.pyβ core Morse symbol mapmorse_lang/cli.pyβmorsecommand-line entrypoint
You can now iterate on the language, extend the Morse mapping, or experiment with new features.
Enjoy writing code in dots and dashes!
If you build something cool with Morse Lang, feel free to share it or open an issue/PR on the GitHub repo.