# Call functions between modules

**URL:** <https://forum.heroiclabs.com/t/call-functions-between-modules/2550>\
**Category:** Runtime Framework\
**Tags:** server-framework\
**Created:** [April 22, 2022, 9:33am UTC](https://forum.heroiclabs.com/t/call-functions-between-modules/2550 "2022-04-22T09:33:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![formatCvt](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/formatcvt/32/1127_2.png) [@formatCvt](https://forum.heroiclabs.com/u/formatCvt)\
**Post date:** [April 22, 2022, 9:33am UTC](https://forum.heroiclabs.com/t/call-functions-between-modules/2550/1 "2022-04-22T09:33:57Z")

</div>

We already have a good approach that gives to mix programming languages and write code on Lua/TypeScript/Go (for example we can define RPC function in the TypeScript and write match handlers in Go) but we have no solution to call functions between modules.

For example we have a project with shared code between server and client

 ![typical-scheme](https://us1.discourse-cdn.com/flex020/uploads/heroiclabs/original/2X/9/9fbb3b641bffe31c8ab1cc98799b239473df4985.png)

That shared contains piece of code with huge CPU usage (data serialization in my case) that can be implemented on Go.  
We need something like local RPC function call in this case.

 ![hybrid-scheme](https://us1.discourse-cdn.com/flex020/uploads/heroiclabs/original/2X/a/aaa8cc9a711f125daed0f9650cac40f1bb056ac7.png)

---

<div class="post-metadata">

**Author:** ![zyro](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/zyro/32/14_2.png) [@zyro](https://forum.heroiclabs.com/u/zyro)\
**Post date:** [April 25, 2022, 1:20pm UTC](https://forum.heroiclabs.com/t/call-functions-between-modules/2550/2 "2022-04-25T13:20:46Z")

</div>

This would be interesting, and I can see it being useful for various CPU-intensive situations. However there would be unknowns to address, for example arguments passed to another runtime’s function would need to be marshaled in some way in a language-agnostic encoding. Same applies to getting results from that function back to the caller runtime.

For your specific use case of serialization I’m not sure it would be worth it. 🤔

---

<div class="post-metadata">

**Author:** ![formatCvt](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/formatcvt/32/1127_2.png) [@formatCvt](https://forum.heroiclabs.com/u/formatCvt)\
**Post date:** [April 30, 2022, 1:09pm UTC](https://forum.heroiclabs.com/t/call-functions-between-modules/2550/3 "2022-04-30T13:09:58Z")

</div>

may be you’re right 🤷

---

<div class="post-metadata">

**Author:** ![formatCvt](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/formatcvt/32/1127_2.png) [@formatCvt](https://forum.heroiclabs.com/u/formatCvt)\
**Post date:** [February 28, 2023, 1:38pm UTC](https://forum.heroiclabs.com/t/call-functions-between-modules/2550/4 "2023-02-28T13:38:26Z")

</div>

Hi! I’ve found new CPU-intensive cases - NavMesh/Path Finding, Bot AI/Aggression system and so on.  
About marshaling in some way in a language-agnostic encoding we can use RPC functions instead of just a module function (call any registered RPC function via `runtime.Rpc` to bypass networking) i think.

What do you think about ability to call rpc function in server runtime?
