libimportx banner

libimportx

6 devlogs
11h 6m 7s

Call functions written in other languages as if it's the same language!
NOTE: This is currently only written in Python, i will write it in JS and other languages next ship
it IS kinda useless now but i am having to ship now instead of later …

Call functions written in other languages as if it’s the same language!
NOTE: This is currently only written in Python, i will write it in JS and other languages next ship
it IS kinda useless now but i am having to ship now instead of later because of lockin sidequest please dont vote less because of this pls

This project uses AI

I used AI for one test. Specifically testtheclient.sh in itzmetanjim/libimportx-python. Everything else is AI-free.

Demo Repository

Loading README...

tanjim

Implement importx() ImportxOpaque ImportxModule ImportxNamespace

yay! now it is essentially done. you can use it now

however its currently essentially useless since i did not implement it in any language other than python yet

Changelog

in libimportx-python

Attachment
0
tanjim

Made the exportx implementation in Python

i made the python implementation for exportx and also some tests for it

Changelog

in libimportx

for pesky ft reviewers: the screenshot is technically “output” not “code”
for normal people the screenshot shows me testing the client:

  • first the thing that is exporting send over the token, it is correct so i send +
  • now i send a request to read the variable und which does not exist, so the client returns an error, errors are prefixed with minus
  • then i read mydict which is successful so its prefixed with plus
  • i try to read a file but files cant be sent over JSON so it uses this special syntax. i can still interact with the file using its methods
  • i try to read a function similar story
  • i call the function a few times, the function is supposed to return true then false then so on which it does
  • i try to read the json module however modules cant be sent over JSON
  • i try to read the function json.dumps
  • i try to call json.dumps but i didnt put any args so it errors
  • i made a mistake with the next one, i forgot to make the args an array so the client thought each char was an argument
  • then i call it correctly (twice) and it works
Attachment
0
tanjim

Refine the protocol

yeah turns out the previous one had many errors and was unimplementable so i fixed than and made it better

  • The JSON output always starts with + or - for success and error. This means I can read one byte to see if it is successful or not.

  • Dynamically generated functions (like functions returning functions) could not be serialized before because they didn’t have an identifier as they were not in any variable. Now it allows both static and dynamic functions.

  • Compiled languages and languages which dont use # for comments would straight up not work since without a shebang the OS would not be able to figure out how to run it. Now the library itself figures it out.

  • Data that could nto be serialized (eg file objects) would not work, now it just uses a special opaque type. so objects that dont exist/cant be moved to the other language can be used as well. (so i could write to a file object through languages!)

Changelog

here is a diagram i made to explain how the opaque object thing works.

Attachment
0
tanjim

Document the api

wait what im documenting it before making it?? yes you heard that right. the reason im doing this is for procastination so that i have a clear and consistent implementation plan. i will have to make this in a million languages so im making sure i dont have to improvise

Changelog

here is this diagram i made to explain the protocol loosely

Attachment
0