ExplainCode is a natural language programming language that enables you to create AI pipelines, work with datasets, and execute algorithms using a syntax that's easy to read, write, and understand.
- AI pipeline support (LOAD_MODEL and PREDICT steps using HuggingFace Transformers)
- First class LIST and DICT support with APPEND, REMOVE, GET
- Powerful functional utilities like SORT, FILTER, MAP, REDUCE
- Familiar Python-like TRY/CATCH error handling
- In-memory execution with no intermediate files
- Use ExplainCode in a clean CLI or full featured PyQt5 IDE
These are the steps to install ExplainCode system-wide:
git clone https://github.com/devanshvpurohit/ExplainCode.git
cd ExplainCode
pip install .All usage examples assume you've installed ExplainCode. You can run .epd and .eai files in two ways:
# Immediately run a file
explaincode examples/data_structures.epd
# Run file and print verbose log showing generated Python
explaincode examples/data_structures.epd --verbose
# Run file and save Python source to disk
explaincode examples/data_structures.epd --saveexplaincode-guiMODEL AnalyzeSentiment
INPUT: text
STEP 1: PRINT "Analyzing..."
STEP 2: LOAD_MODEL "sentiment-analysis" -> model
STEP 3: PREDICT text -> result
STEP 4: PRINT result
STEP 5: RETURN result
END MODEL
ALGORITHM FilterHighNumbers
INPUT: numbers
STEP 1: SORT numbers -> sorted_list
STEP 2: FILTER sorted_list WHERE x > 50 -> high_nums
STEP 3: PRINT "High numbers found:"
STEP 4: PRINT high_nums
STEP 5: RETURN high_nums
END ALGORITHM
ExplainCode/
├── explaincode/ # Core Package Source
│ ├── compiler.py # Compiler, AST & CLI logic
│ ├── interpreter.py # Learning Mode IDE & Interpreter
│ ├── concepts.py # AST concept explainer
│ ├── stepper.py # Step-by-step visual execution tracer
│ ├── errors.py # Pedagogical error guidance tutor
│ ├── challenges.py # Practice challenges & hints
│ ├── progression.py # Concept mastery progression tracking
│ ├── transition.py # 5-level Python transition scaffolding
│ ├── analytics.py # Anonymous educational research metrics
│ ├── learning_gui.py # PyQt5 learning widgets
│ └── lang/ # Language definitions & LSP
├── vscode-extension/ # Official VS Code extension
├── tests/ # Test suite
├── examples/ # Example scripts
├── pyproject.toml # Python packaging config
└── README.md # DocsWhen you open an .epd file in ExplainCode it transforms into a complete pedagogical environment that bridges natural-language algorithmic thinking and conventional Python programming:
- Concept Explanation - Click Explain to analyze your code's AST and learn the programming concepts (Variables, Conditionals, Loops, Data Structures, Functions, Error Handling).
- Equivalent Python - Click Show Python to see the equivalent Python generated by
ExplainCodeCompiler. - Statement Stepper - Step through your algorithm line-by-line while inspecting variable values, condition branches and loop iterations.
- Practice Challenges - Learn by solving interactive challenges at different difficulty levels with 3-tiered hint system.
- 5-Level Python Transition - Move from natural language -> ExplainCode -> Dual View -> Fill-in-the-blank Python -> Independent Python.
- Pedagogical Error Guidance - Get beginner-friendly error explanations (Problem, Concept, Expected, Suggestion) alongside technical errors.
- Research Analytics - Optional anonymous learning metrics and CSV/JSON export capabilities for educational reasearch.
ExplainCode has an official VS Code extension in the vscode-extension folder:
- Highlights syntax for
.epd,.eaiand.explainfiles - Adds the following commands:
ExplainCode: Show Equivalent PythonExplainCode: Explain ConceptsExplainCode: Open Learning Mode GUIExplainCode: Run File in TerminalExplainCode: Open Learning ChallengesTo install, copy thevscode-extensionfolder to~/.vscode/extensions/devanshvpurohit.explaincode-2.0.0/or install it from the VS Code Extensions Marketplace.
Contributions of all kinds are welcome! Please consider forking this repository and submitting a PR with your changes. If you find any issues, please report them here: https://github.com/devanshvpurohit/ExplainCode/issues
Empowering ideas through code. One step at a time.