TechLang is a hacker-themed, stack-based programming language implemented in Python. It features its own custom interpreter, language parser, and playful syntax (ping, crash, upload, etc.). The project includes a CLI, a GUI, and a web-based playground.
TechLang is designed for experimenting with:
- Language design
- Interpreter building
- Syntax parsing
- Fun and engaging programming constructs
TechLang/
├── techlang/ # Interpreter & parser logic
│ ├── interpreter.py # Main interpreter entry point
│ ├── parser.py # Tokenizer and syntax parser
│ ├── executor.py # Command execution dispatcher
│ ├── core.py # InterpreterState and core types
│ ├── basic_commands.py # Core language commands
│ ├── variables.py # Variable operations
│ ├── stack.py # Stack operations
│ ├── control_flow.py # if, loop, while, switch, try/catch
│ ├── data_types.py # Arrays, strings, dicts, JSON
│ ├── struct_ops.py # Structured types
│ ├── file_ops.py # File I/O operations
│ ├── net_ops.py # HTTP client and server
│ ├── graphics_ops.py # Graphics rendering (Pillow)
│ ├── database.py # SQLite3 database operations
│ ├── memory_ops.py # Memory management
│ ├── math_ops.py # Math and date/time functions
│ ├── thread_ops.py # Threading and concurrency
│ ├── system_ops.py # System and process operations
│ ├── debugger.py # Debugger with breakpoints
│ ├── class_ops.py # OOP: classes, inheritance, methods
│ ├── function_ops.py # First-class functions, closures
│ ├── decorator_ops.py # Python-like decorators
│ ├── context_ops.py # Context managers (with statement)
│ ├── async_ops.py # Async/await and event loop
│ ├── help_ops.py # Help system
│ ├── imports.py # Module imports
│ ├── aliases.py # Command aliases
│ ├── macros.py # Macro expansion
│ ├── blocks.py # Block depth tracking
│ ├── formatter.py # Code formatter
│ ├── linter.py # Code linter
│ └── __init__.py
│
├── tests/ # Pytest-based unit tests (776+ tests)
│ ├── test_interpreter.py
│ ├── test_database.py
│ ├── test_database_advanced.py
│ ├── test_data_types.py
│ ├── test_json.py
│ ├── test_string_ops.py
│ ├── test_comments.py
│ ├── test_debugger.py
│ ├── test_file_ops.py
│ ├── test_graphics.py
│ ├── test_math_ops.py
│ ├── test_memory.py
│ ├── test_network.py
│ ├── test_threads.py
│ ├── test_system.py
│ ├── test_formatter.py
│ └── ...
│
├── docs/ # Comprehensive documentation
│ ├── general.md # Syntax and rules
│ ├── core.md # Core commands
│ ├── control-flow.md # Control structures
│ ├── data-types.md # Data structures and JSON
│ ├── file-io.md # File operations
│ ├── network.md # HTTP and networking
│ ├── graphics.md # Graphics and visualization
│ ├── database.md # Database operations
│ ├── math.md # Math and date/time
│ ├── memory.md # Memory management
│ ├── concurrency.md # Threading and async
│ ├── system.md # System and processes
│ ├── debugging.md # Debugger guide
│ ├── cookbook.md # Recipes and patterns
│ ├── examples.md # Example programs index
│ └── help-cli.md # CLI and help system
│
├── examples/ # Sample TechLang programs (26 files)
│ ├── hello.tl
│ ├── loop.tl
│ ├── if.tl
│ ├── vars.tl
│ ├── functions.tl
│ ├── arrays.tl
│ ├── strings.tl
│ ├── string_operations.tl
│ ├── dictionaries.tl
│ ├── json_demo.tl
│ ├── database.tl
│ ├── files.tl
│ ├── network.tl
│ ├── graphics.tl
│ ├── memory.tl
│ ├── threads.tl
│ ├── debugger_demo.tl
│ ├── cookbook_multifeature.tl
│ └── ...
│
├── playground/ # Optional GUI playground (Tkinter)
│ └── gui.py
│
├── techlang_web/ # Flask-based web playground
│ ├── app.py
│ ├── templates/
│ │ └── index.html
│ ├── static/
│ └── uploads/
│
├── .github/ # GitHub Actions CI/CD
│ └── workflows/
│ ├── pytest.yml # Test suite
│ └── lint.yml # Code linting
│
├── cli.py # CLI for running .tl files
├── format_tl.py # TechLang code formatter
├── run_tests.py # Test suite runner
├── requirements.txt # Python dependencies
├── README.md # This file
├── DOCUMENTATION.md # Master documentation index
├── DEV.md # Developer guide
├── AGENTS.md # AI agent guide
├── PLAYGROUND.MD # Playground guide
└── .venv/ # Python virtual environment
git clone https://github.com/devaanshpathak/techlang.git
cd techlangpython -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activatepip install -r requirements.txtfrom techlang.interpreter import run
code = "boot ping ping print"
print(run(code)) # Output: 2# Using the bundled script
python cli.py examples/hello.tl
# With console entry (after `pip install -e .` or packaging), use the `tl` command:
tl examples/hello.tl
# Start interactive REPL
tl -i
# Verbose mode
tl -v examples/hello.tlcd techlang_web
python app.py- Visit:
http://localhost:8080 - Paste or upload
.tlcode and see output
python playground/gui.py- Docs:
docs/gui.md - Examples:
examples/gui_ttk_demo.tlexamples/gui_text_canvas_demo.tl
python run_tests.py- Covers interpreter logic, variables, loops, stack, conditions, functions, input, database operations, and more.
boot, ping, crash, print, set, add, sub, mul, div, input, upload, download, debug, import, alias, hack
Three styles supported: # single-line, // C-style single-line, /* */ multi-line blocks
loop ... end, if ... end, while ... end, switch/case/default, try/catch, def ... end, call
- Conditional Macros:
macro name if condition param do ... end- Expand only when condition is true - Nested Macros: Macros can invoke other macros with full parameter substitution
- Macro Libraries: Load reusable macro collections from external files
- REPL Integration:
:loadmacrocommand for interactive macro loading - See Advanced Macro Guide for details
- Persistent State: Variables, functions, and macros persist across commands
- Introspection:
:stateshows all variables,:macroslists macros - State Management:
:resetclears state without restarting - Macro Loading:
:loadmacro fileloads macro libraries interactively - Command History: Full readline support with persistent history
- See REPL Guide for complete reference
- Arrays:
array_create,array_set,array_get,array_push,array_pop,array_map,array_filter - Strings:
str_create,str_concat,str_length,str_substring,str_split,str_replace,str_trim,str_upper,str_lower,str_contains,str_reverse - Dictionaries:
dict_create,dict_set,dict_get,dict_keys - JSON:
json_parse,json_stringify,json_read,json_write(full Unicode support)
file_read, file_write, file_append, file_exists, file_delete, file_list
HTTP: http_get, http_post, http_status
Server stubs: server_start, server_route, server_stop
graphics_init, graphics_draw_line, graphics_draw_circle, graphics_draw_text, graphics_show
math_sin, math_cos, math_sqrt, math_pow, math_random, math_pi, math_e
CRUD: db_create, db_insert, db_select, db_update, db_delete, db_execute, db_close
Advanced: db_begin, db_commit, db_rollback, db_tables, db_schema, db_indexes, db_connect, db_disconnect
mem_alloc, mem_free, mem_read, mem_write, mem_dump
thread_create, thread_join, thread_sleep, async_start, async_wait
System: sys_exec, sys_env, sys_time, sys_date, sys_exit
Processes: proc_spawn, proc_wait, proc_kill
breakpoint, step, continue, inspect, watch, unwatch, clear_breakpoints
- Classes:
class Name ... endwith fields, methods, and constructors - Inheritance:
class Child extends Parentwith method overriding - Instance Methods:
method name params ... endwithselfreference - Static Methods:
static name params ... end(no instance needed) - Field Access:
get_field,set_fieldfor instance data - Type Checking:
instanceoffor runtime type checks - See OOP Guide for complete reference
- Function Values:
fn name params do ... endcreates callable values - Closures: Functions capture outer scope variables
- Function References:
fn_ref funcName vargets reference to existing function - Higher-Order Functions:
map_fn,filter_fn,reduce_fnfor functional programming - Partial Application:
partial func newFunc arg=valbinds arguments - Function Composition:
compose f g composedcreates pipelines - Lambda Expressions:
lambda name param "expr"for simple transforms - See Functions Guide for complete reference
- Decorator Definition:
decorator name mode do ... end(mode: before/after/both) - Apply Decorator:
decorate func decoratorwraps function with decorator - Built-in Decorators:
@logand@timefor common use cases - See Decorators Guide for complete reference
- Built-in Contexts:
with timer do ... end,with suppress do ... end - File Context:
with file "path" do ... endfor automatic file handling - Lock Context:
with lock mutex do ... endfor thread safety - Transaction:
with transaction do ... endfor database rollback - Custom Contexts:
context name enter exit do ... end - See Context Managers Guide for complete reference
- Async Functions:
async def name do ... endfor coroutines - Await:
await coroutine -> resultfor async results - Task Spawning:
spawn coroutine -> task_idfor background tasks - Gathering:
gather t1 t2 t3 -> resultsfor parallel execution - Task Management:
task_status,task_cancelfor control - See Async/Await Guide for complete reference
- throw/raise:
throw "message" [ErrorType]to raise exceptions - try/catch: Catch and handle thrown exceptions
- Exception type available for conditional handling
help or help <command> to see built-in docs.
All in the examples/ folder:
# Basic Examples
python cli.py examples/hello.tl
python cli.py examples/loop.tl
python cli.py examples/if.tl
python cli.py examples/vars.tl
python cli.py examples/functions.tl
python cli.py examples/input.tl
# Data Structures
python cli.py examples/arrays.tl
python cli.py examples/strings.tl
python cli.py examples/string_operations.tl
python cli.py examples/dictionaries.tl
python cli.py examples/data_types_demo.tl
# Advanced Features
python cli.py examples/json_demo.tl
python cli.py examples/comments.tl
python cli.py examples/alias.tl
python cli.py examples/switch_try.tl
python cli.py examples/while_loops.tl
# System Integration
python cli.py examples/database.tl
python cli.py examples/files.tl
python cli.py examples/network.tl
python cli.py examples/graphics.tl
python cli.py examples/memory.tl
python cli.py examples/threads.tl
# Debugging & Recipes
python cli.py examples/debugger_demo.tl
python cli.py examples/cookbook_multifeature.tl
# OOP & Functional Programming
python cli.py examples/oop_demo.tlOr try them in the web playground.
- Python 3.10+
flask(for web)pytest(for tests)tkinter(optional GUI)sqlite3(built-in Python module)
Install all with:
pip install -r requirements.txt- ✅
Database transactions and schema introspection(Completed) - ✅
Debugger with breakpoints and stepping(Completed) - ✅
JSON support for modern data interchange(Completed) - ✅
String manipulation operations(Completed) - ✅
Multi-line comments(Completed) - Error highlighting in web playground
- Bytecode version of TechLang
- Language transpiler to Python
- Foreign key support in database
- Time-travel debugging (step backwards)
- Conditional breakpoints
Crafted for hackers, students, and language lovers who want to build something weird, beautiful, and programmable.
Comprehensive command reference grouped by category. For detailed documentation, see DOCUMENTATION.md.
boot, ping, crash, print, upload, download, debug, hack, lag, sleep, yield
set, add, sub, mul, div, input
- Conditionals:
if x > 5 ... end - Loops:
loop 10 ... end,while x < 100 ... end - Switch/Case:
switch x ... case 1 ... case 2 ... default ... end - Pattern Matching:
match expr ... case > 10 ... case == 5 ... end - Error Handling:
try ... catch [errVar [stackVar]] ... end - Functions:
def name ... end,call name
- Arrays:
array_create,array_set,array_get,array_push,array_pop,array_map,array_filter - Strings:
str_create,str_concat,str_length,str_substring,str_split,str_replace,str_trim,str_upper,str_lower,str_contains,str_reverse,string_interpolate,string_match - Dictionaries:
dict_create,dict_set,dict_get,dict_keys - Structs:
struct Type field1 field2 ... end,struct new,struct set,struct get,struct dump
json_parse, json_stringify, json_read, json_write - Full Unicode support for modern data interchange
file_read, file_write, file_append, file_exists, file_delete, file_list
- Client:
http_get,http_post,http_status - Server (stubs):
server_start,server_route,server_stop
graphics_init, graphics_draw_line, graphics_draw_circle, graphics_draw_text, graphics_show
- Trigonometry:
math_sin,math_cos,math_tan,math_asin,math_acos,math_atan - Arithmetic:
math_sqrt,math_pow,math_random,math_round,math_floor,math_ceil - Conversion:
math_deg2rad,math_rad2deg - Constants:
math_pi,math_e - Date/Time:
now,format_date,sys_time,sys_date
- CRUD:
db_create,db_insert,db_select,db_update,db_delete,db_execute,db_close - Transactions:
db_begin,db_commit,db_rollback - Introspection:
db_tables,db_schema,db_indexes - Connections:
db_connect,db_disconnect
mem_alloc, mem_free, mem_read, mem_write, mem_dump
- Threads:
thread_create,thread_join,thread_sleep,thread_status,thread_result,thread_list,thread_wait_all - Async:
async_start,async_wait - Synchronization:
mutex_create,mutex_lock,mutex_unlock - Queues:
queue_push,queue_pop
- System:
sys_exec,sys_env,sys_time,sys_date,sys_sleep,sys_cwd,sys_exit - Processes:
proc_spawn,proc_kill,proc_wait,proc_status
breakpoint, step, continue, inspect, watch, unwatch, clear_breakpoints
- Modules:
package use module,call module.function - Macros:
macro name params do ... end,inline name args - Aliases:
alias short command - Imports:
import name
- Single-line:
# commentor// comment - Multi-line:
/* comment */
help - List all commands
help <command> - Show specific command help