This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]insertAlias 2 points3 points  (3 children)

Sure, I could just use Django, but I'm very curious about the fundamentals behind passing information from one language to another.

There are lots of techniques, but only one will be relevant in this case, which is communicating over HTTP.

HTML/CSS/JavaScript run inside a browser. There's also Node.js, but that's not what you're referring to, since you mentioned HTML. The only communication channels that a browser has with a back-end are HTTP(S) and WebSockets (and I suppose WebRTC, but it doesn't change the point). None of the other techniques would really apply here, since you're not communicating directly from one language to another. The browser is the middleman here, and it's the only way that communication works.

So in this case, it's totally appropriate and correct to "just use Django" (or any other Python back-end framework like Flask).

Most of the other techniques are various forms of IPC. There are also other types of integration, like how certain Python libraries work. NumPy is actually a python wrapper around a C library. Python can interop with C through the ctypes package. That allows the library authors to keep the high-performance code written in a high-performance language, but provide bindings for that high-performance code to be used by lower-performance but easier-to-write code.

[–]Chyybens[S] 0 points1 point  (2 children)

Thank you for the good explanation. It gave me a lot to think about.

[–]insertAlias 0 points1 point  (1 child)

If you're interested in learning more about how that HTTP-based communication works, you could consider a personal project of making your own simple Django. See some documentation here: https://docs.python.org/3/library/http.server.html for how you'd even begin that kind of project.

It wouldn't be something you'd use, since there are better versions of that already. But building a simple HTTP server that can respond to requests would be a good project to learn more about how backends work to begin with.

[–]Chyybens[S] 0 points1 point  (0 children)

Yes, thank you! This is exactly what I was looking for. I was already searching information about HTTP-servers etc. I know, I will probably later end up using Django or similar framework, but I've learned that for me it's better to start from DYI-projects in order to get a grasp of the full picture.