Share your repls and programming experiences

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

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!

Commentshotnewtop
elipie (323)

Interpreted in interpreted

shudders

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

RayhanADev (1215)

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

hg0428 (174)

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

RayhanADev (1215)

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

hg0428 (174)

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

fuzzyastrocat (1463)

@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 (18)

@RayhanADev yeah, rlly, not even open()

realTronsi (842)

nice!

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

@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 (1215)

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

realTronsi (842)

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

realTronsi (842)

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

realTronsi (842)

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

fuzzyastrocat (1463)

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 (1215)

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

HahaYes (1284)

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

fuzzyastrocat (1463)

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

RayhanADev (1215)

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

fuzzyastrocat (1463)

@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 (1215)

@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 (1463)

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

RayhanADev (1215)

@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 (1463)

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

RayhanADev (1215)

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

Stan085 (18)

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

Stan085 (18)

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

fuzzyastrocat (1463)

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

Elderosa (24)

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

programmeruser (396)

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

MarcusWeinberger (596)

Wow, this is pretty sick!

RayhanADev (1215)

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

programmeruser (396)

I cannot program in C

so you should learn how to program in C.

RayhanADev (1215)

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

programmeruser (396)

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

TsunamiOrSumth (492)

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

CoolGuy27 (58)

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

RayhanADev (1215)

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

CoolGuy27 (58)

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

RayhanADev (1215)

@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)

RayhanADev (1215)

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

ThisUserTaken (235)

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

RayhanADev (1215)

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

RayhanADev (1215)

@jort57 smh and I made my own too:

code = input(“> “)
exec(code)
jort57 (16)

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

Hamburgr (6)

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

:O

Hamburgr (6)

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

pepelaugh (658)

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

jort57 (16)

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

RayhanADev (1215)

@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 (16)

@RayhanADev ok sure i know nothing about js

jort57 (16)

@jort57 also python is best

jort57 (16)

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

jort57 (16)

@jort57 what why is it duplicate wth

fuzzyastrocat (1463)

@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 (16)

@fuzzyastrocat oh i see. sorry bout that.

fuzzyastrocat (1463)

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