Share your repls and programming experiences

← Back to all posts
🐍 I made my own version of Python in JS! 🐍 + JS
h
RayhanADev

A bit of work but after seeing @fuzzyastrocat‘s (who this title belongs to) Python interpreter in C I decided to make my own! One conundrum I cannot program in C so why not use Javascript!

Presenting Python in Javascript!

Pretty basic interpreter, but I assure you’ll have indentation errors for days! I decided to implement basic Python features such as:

  • functions
  • print()
  • logic (if/else)
  • operations
  • “good readability (aka whitespace for daysss)”

So try it by messing around in the .pyjs file! Also if you want to see the tree breaking down your file switch the _debug variable to true! Happy coding!

Voters
LandofStorie
ryanbrwr
maxina
MarcusWeinberger
realTronsi
mkhoi
Kookiez
BCP
MAX365
iocoder
Comments
hotnewtop
elipie

Interpreted in interpreted

shudders

Hmm, next all you gotta do is make JS in python! (jk)

RayhanADev

@elipie hahahahha I can’t do any worse than that can I lmao.

elipie
hg0428

Or make js in this version of python made in [email protected]

RayhanADev

@hg0428 actually I can’t because it doesn’t have everything

hg0428

If you add what you need to it then you [email protected]

RayhanADev

@hg0428 yessir!

fuzzyastrocat

@RayhanADev It has functions... if they're a first class citizen as in python then yes, you can actually do it. Now, that might require the input to be in the form of a crazy function expression, but it is possible since first-class functions are turing-complete alone.

Stan085

@RayhanADev yeah, rlly, not even open()

realTronsi

nice!

(also did you see my cries for help)
RayhanADev
realTronsi

@RayhanADev

school forcing me to do this thing where you help ppl, so I convinced them to let me make a website for someone. Now I'm stuck since I'm horrible at frontend
RayhanADev

@realTronsi ahh I see. Okay I’ll help.

realTronsi

@RayhanADev I'll send you an invite and we can chat there

realTronsi

@RayhanADev ok lmk when you're free today :D

RayhanADev

@realTronsi wanna work?

realTronsi

@RayhanADev oh hey, sorry for the late response ut sure

realTronsi

@RayhanADev im back

RayhanADev
fuzzyastrocat

Nice!

Idea: rather than being run in JS, transpile (translate) the Python code into JS code. That way Python could run "natively" on the web!

RayhanADev

@fuzzyastrocat I actually only got the idea about that when you mentioned it earlier today hehe I’ll work on it!

HahaYes

@fuzzyastrocat yo how did you just jump from 800 cycles to 1200 cool

fuzzyastrocat

@HahaYes Python in C + Remains of askew 2nd update + Real 3D + Build your own language in C = +400 cycles

RayhanADev

@fuzzyastrocat 2 among us console in python = +500 cycles

fuzzyastrocat

@RayhanADev My cycles strategy: spam high-quality, high-effort posts in as much quantity as possible.

That way I can barely keep up with the people who post one or two low-quality posts which relate to a trendy item.

RayhanADev

@fuzzyastrocat My cycles strategy:
1. Make good project
2. Post to share
3. Watch it get 10 upvotes and die
4. Get a bag of gummy bears, pay my brother a dollar (bet we have that I’m losing) and make something else

fuzzyastrocat

@RayhanADev You mean you don't use developer tools to trick your brother into thinking your posts have 500 upvotes? :D

RayhanADev

@fuzzyastrocat dude my older brother is one of the smartest people I know. I can’t fool him if I tried my hardest (I tried!)

fuzzyastrocat

@RayhanADev
> hack into repl.it
> literally change the number of upvotes on your post
> genius

RayhanADev

@fuzzyastrocat ah yes, now can you teach me about Repl.it’s rest api xd.

HahaYes
Stan085

@RayhanADev sometime i wll make somethin for .py to .cpp in C++ lol

Stan085

@fuzzyastrocat how do you not have your post in a blockquote lel

RayhanADev

@Stan085 nice! Good luck!

fuzzyastrocat

@Stan085 \> doesn't make it a blockquote, just shows it as a literal >.

ELDER054

Nice job! Mine is the opposite of yours, I created JavaScript in Python! https://repl.it/@Elderosa/JS-in-Python#main.py

programmeruser

Nice!
(not trying to advertise, but a made a Lua Interpreter in JavaScript here)

MarcusWeinberger

Wow, this is pretty sick!

RayhanADev

@MarcusWeinberger thanks my dude! (ˊᗜˋ)/ᵗᑋᵃᐢᵏ ᵞᵒᵘ*

programmeruser

I cannot program in C

so you should learn how to program in C.

RayhanADev

@programmeruser i know, I’m just too attached to JS. But I have decided that over Christmas breakI will be learning C.

programmeruser

@RayhanADev if you do want to learn C try https://learn-c.org. Learning C++ after that isn't too hard.

TsunamiOrSumth

hi rayhan please help, ren shoulve invited you 🥺🥺🥺🥺🥺🥺

RayhanADev

@TsunamiOrSumth lmao omfg 999 cycles xD. I’m screenshotting.

RayhanADev

@TsunamiOrSumth also me no get invite

TsunamiOrSumth
TsunamiOrSumth

@RayhanADev gg 1000

RayhanADev

@TsunamiOrSumth HAHHAHAHAHAHAHA 1000 GG THANK YOU hAA

CoolGuy27

@RayhanADev input() and eval() no work big sad :(

RayhanADev

@CoolGuy27 lmao big sad :(
it took me quite a while to get here actually and input would be ridiculous to add xD

CoolGuy27

@RayhanADev lol i get that you did a great job with everything you added. i could only do NOTHING

RayhanADev

@CoolGuy27 hahaha rip yeah. I’ll work on and try to add me (actually I wanna try and make it transpile so Python for the Web)

CoolGuy27

@RayhanADev that would be genius!

RayhanADev

@CoolGuy27 credit to fuzzy, I’m working on it!

ThisUserTaken

I'm starting to miss the dancing shiny furret...

RayhanADev

@ThisUserTaken hahahhahahhahahhahahahah. Well look at @HelperFurret and make yourself feel better!

jort57

I made my own version of python in python heehee

RayhanADev

@jort57 smh and I made my own too:

jort57
jort57

@jort57 try to make a python shell inside of the python shell you made

Hamburgr

@RayhanADev How about making a new version of python in python

:O

Hamburgr

@Hamburgr and then make a new version of python using your old new version of python

Hamburgr

@Hamburgr its pyception

badst

get on repl dash i have a question to ask you :)

jort57

How do yall even make this I would like to request a tutorial in C, C++, or Python.

RayhanADev

@jort57 sorry can’t help you because I don’t know the C family and despise Python but I can give a decent tutorial on NodeJS (which I used in this)

jort57

@RayhanADev ok sure i know nothing about js

jort57

@jort57 also python is best

elipie
jort57

@elipie thank for tutorial, but whats the point of the language if it doesnt execute anything? :/

jort57

@jort57 what why is it duplicate wth

realTronsi

@jort57 tutorial you say?

fuzzyastrocat

@jort57 That tutorial is my tutorial. The reason it doesn't execute anything yet is because that's part 1 of 2, if you read the title or the ending (where it clearly says "next time, we'll implement execution"). The second part isn't out yet, this stuff takes time which I often don't have.

jort57

@fuzzyastrocat oh i see. sorry bout that.

fuzzyastrocat

@jort57 Nothing to be sorry about, just clearing things up :D

JBloves27

Very cool!

RayhanADev
JBloves27