javathon
v1.1.4
Published
A project to run mixed JavaScript and Python code
Downloads
139
Maintainers
Readme
Javathon
Javathon is a lightweight, powerful tool that enables developers to seamlessly execute Python and JavaScript code blocks together in a single file. By using a simple .jt
file format, Javathon eliminates the need for switching between environments, making it perfect for projects that require the strengths of both languages.
Whether you’re building web applications, analyzing data, or exploring automation, Javathon makes it easier to combine the power of JavaScript and Python effortlessly.
Key Features
- 🛠 Run Mixed Code: Write and execute Python and JavaScript in a single file.
- ⚡ Asynchronous Execution: Smoothly handles mixed-language execution with shared contexts.
- 📦 Simple CLI Tool: Easy to install, configure, and use from anywhere on your system.
Installation
Prerequisites
- Ensure you have Node.js installed on your system.
- (Optional) Have Python installed and added to your system's PATH for Python support.
Install Javathon Globally
Use npm to install Javathon globally:
npm install -g javathon
Getting Started
1. Create a .jt
File
Write your code in a .jt
file, separating Python and JavaScript code blocks.
example.jt
// JavaScript Section
console.log("Hello from JavaScript!");
<%
// Python Section
print("Hello from Python!")
%>
2. Run the .jt
File
Execute your file using the javathon
command:
javathon example.jt
3. View the Output
The example above produces:
Hello from JavaScript!
Hello from Python!
Writing .jt
Files
.jt
files allow you to switch between Python and JavaScript seamlessly. Use the following syntax:
- JavaScript Code: Write as plain JavaScript directly in the file.
- Python Code: Wrap Python code in
<% ... %>
blocks.
Example:
// JavaScript Block
const name = "Javathon User";
console.log("Hi, " + name + "!");
<%
// Python Block
name = "Javathon User"
print(f"Hello from Python, {name}!")
%>
Advanced Example
Here’s a practical example with loops and variable sharing:
example.jt
// JavaScript Section: Define a shared variable
let numbers = [1, 2, 3];
console.log("Processing numbers in JavaScript:", numbers);
<%
// Python Section: Process the same numbers
print("Processing numbers in Python:")
for number in [1, 2, 3]:
print(f" -> {number}")
%>
// Back to JavaScript
console.log("Done processing numbers!");
Output:
Processing numbers in JavaScript: [1, 2, 3]
Processing numbers in Python:
-> 1
-> 2
-> 3
Done processing numbers!
Development
Want to contribute or test Javathon locally? Follow these steps:
Clone the repository:
git clone https://github.com/Skosanalindo061/Javathon cd javathon
Install dependencies:
npm install
Run the tool locally:
node src/index.js example.jt
Troubleshooting
Common Issues
Python Not Found:
- Make sure Python is installed and added to your PATH. Download Python.
File Syntax Errors:
- Ensure
.jt
files use valid syntax for both languages.
- Ensure
Dependencies Missing:
- Reinstall Javathon:
npm install -g javathon
- Reinstall Javathon:
Roadmap
Here’s what’s next for Javathon:
- 🌐 Add support for more languages (e.g., Ruby, PHP).
- 🛠 Improve error handling and debugging tools.
- 🚀 Enhance
.jt
syntax with better context sharing between languages.
Contributing
Contributions are welcome! Submit issues or pull requests on GitHub.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Author
Created with passion by Lindokuhle Skosana.
Feel free to reach out with feedback, suggestions, or questions.
Quick Example
javathon example.jt
Output:
Hello from JavaScript!
Hello from Python!
Javathon: Where Python meets JavaScript. Happy coding!
Creator
Javathon was created and is actively maintained by Lindokuhle Skosana.