Skip to content

Repository files navigation

ExplainCode 3.0

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.

Highlights (v2.0.0)

  • 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

Installation

These are the steps to install ExplainCode system-wide:

git clone https://github.com/devanshvpurohit/ExplainCode.git
cd ExplainCode
pip install .

Usage

All usage examples assume you've installed ExplainCode. You can run .epd and .eai files in two ways:

Command Line Interface

# 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 --save

Graphical User Interface

explaincode-gui

Examples

AI Sentiment Analysis

MODEL 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

Data Filtering

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

Project Structure

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          # Docs

📚 Learning Mode

When you open an .epd file in ExplainCode it transforms into a complete pedagogical environment that bridges natural-language algorithmic thinking and conventional Python programming:

  1. Concept Explanation - Click Explain to analyze your code's AST and learn the programming concepts (Variables, Conditionals, Loops, Data Structures, Functions, Error Handling).
  2. Equivalent Python - Click Show Python to see the equivalent Python generated by ExplainCodeCompiler.
  3. Statement Stepper - Step through your algorithm line-by-line while inspecting variable values, condition branches and loop iterations.
  4. Practice Challenges - Learn by solving interactive challenges at different difficulty levels with 3-tiered hint system.
  5. 5-Level Python Transition - Move from natural language -> ExplainCode -> Dual View -> Fill-in-the-blank Python -> Independent Python.
  6. Pedagogical Error Guidance - Get beginner-friendly error explanations (Problem, Concept, Expected, Suggestion) alongside technical errors.
  7. Research Analytics - Optional anonymous learning metrics and CSV/JSON export capabilities for educational reasearch.

VS Code Extension

ExplainCode has an official VS Code extension in the vscode-extension folder:

  • Highlights syntax for .epd, .eai and .explain files
  • Adds the following commands:
  • ExplainCode: Show Equivalent Python
  • ExplainCode: Explain Concepts
  • ExplainCode: Open Learning Mode GUI
  • ExplainCode: Run File in Terminal
  • ExplainCode: Open Learning Challenges To install, copy the vscode-extension folder to ~/.vscode/extensions/devanshvpurohit.explaincode-2.0.0/ or install it from the VS Code Extensions Marketplace.

Contributing

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

License

MIT Licensed.

Empowering ideas through code. One step at a time.

About

A human-readable algorithm language with Python compiler and LSP support.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages