Skip to content
Sign upLog in
← Back to Community

Mixed Language Repl?

Profile icon
harperjohnHacker

I would like to create a repl that creates a C and/or C++ library, that I can call from Python using ctypes.

And in general, I would like to be able to use mixed/multiple languages, and/or use the results of one reply (say a library) in another repl.

Voters
Profile icon
AhmedMc2
Profile icon
harperjohn
Comments
hotnewtop
Profile icon
Highwayman
Profile icon
teymour

@Highwayman
I always assumed Polygott was a language of itself :)

Profile icon
Highwayman

@CaptainAnon
eh, kinda. It’s just a make file.

Profile icon
teymour

@Highwayman
I just created one and realised that!

Profile icon
harperjohn

@Highwayman
Interesting! Curious though... if I go to https://repl.it/languages - I don't see polygott? But your link does work for me.

Profile icon
Highwayman

@harperjohn
it’s a beta language technically.

Profile icon
harperjohn

@Highwayman
ahhhh, ok... so "available", but not "visible"/documented yet?

Profile icon
Highwayman

@harperjohn
basically

Profile icon
DIVVVID

It is called bash now.

Profile icon
Highwayman

nah, polygon was actually dropped in favor of the more efficient nix repl.

@DIVVVID

Profile icon
teymour

Yes. You can configure the command you want to run when you press the run button in your .replit file. You can configure this to build the C (and/or C++) libary as a Python extension module and then run a Python program.

Profile icon
lynnlo

To add on to this, you can use this line to set the run command.
run = "{$command}"
Check this article to find out more : https://docs.repl.it/repls/dot-replit

Profile icon
harperjohn

Thanks

@CaptainAnon
and
@tharlynnhtetong
!

Is there a way to make the run "context" or "file" specific?

For example, if I have a repl with two files. Say one is C and one is Python, can I make it so that when the C file is the active tab, that "run" means to run the C file? and then if I switch to the python file, have run mean run the python file?

Profile icon
teymour

@harperjohn
I don't think that's possible. Given that the C file is only a library, you don't need to run it directly and can just build it before installing it into your Python environment.

Profile icon
harperjohn

@CaptainAnon
Good point! I guess what I really meant was "someLib.c", "someMainLibTester.c" and "pythonLibTester.py"

When I was the tab with the C file (with a main) it would run the C file, and then vice-versa for the Python.

If that is not possible... is it possible for repls to share the same virtual/temporary "repl space" so that I could have two browser tabs open, with two different repls (one C and one Python), but sharing the same "current directory" or at least having visibility to the each other's "current directory"?

Profile icon
teymour

@harperjohn
You could use the shell (cmd/cntrl + shift + P) to run your programs (and not use the run button).

Profile icon
harperjohn

@CaptainAnon
I am in my python Repl and I open a shell to build by C library, but CMake is not installed. How do I install CMake into by python repl?

(Which is really a more general question, how can I make my python reply have all the tools that are in my c repl?
And, going in the other direction, how do add packages to the python in my C repl?)

Profile icon
teymour

@harperjohn
I'm not sure. Have you tried using a polygott repl?

Profile icon
harperjohn

@CaptainAnon
I played a bit more with a polygott repl and it does have cmake installed! And by using the run -l c and the run -l python commands I was able to alternately run both of these files/languages!!!

I realize that polygott is new/beta, but is there some (even beta) docs on it?

Does polygott have all the languages installed/configured?

Also run --help prints
Usage: run-project [-sb] [-l language]

What is/are the [-sb] option(s)?

And is the "run" command (and other command) documented? I could not find it mentioned in the "docs" page?

Profile icon
teymour

@harperjohn
I'm afraid I haven't used the Polygott repl very much (at all). To configure the command which is run when the run button is pressed you can use a .replit file to specify the command. Relevant documentation page.

Profile icon
NishantMehta2

I wanted to code an Arduino with C and C++, but it only let me use 1 language. :\

Profile icon
dragonhunter1

@NishantMehta2
All repls have C and C++ installed. Even blank ones, I think it comes with Linux so you can make it work you just have write your code and then gcc it.