How can I combine C/Fortran with JavaScript?

I’m working on a project where I need heavy numerical calculations to be real-time visualized with something flexible like D3.js. Are there frameworks out there that would let me painlessly achieve this? Or do I need to use some sort of “glue” code written in, say, Python?

4

What you’re asking for is interoperation between C/Fortran and Javascript, interopation can be done in a great many ways, the most common two that come to mind however are:

Foreign Function Interface (FFI) bindings and Inter-Process Communication (IPC).

FFI is where a standard agreed upon protocol is built into the assembly at compile time which allows access to the assemblies facilities by foreign languages. There are a variety of FFI standard interfaces, but I am familiar with none that allows an interpreted language to interface with a compiled language or vice versa; the concept doesn’t fit with using interpreters as their scripts are plain text with no assemblies to interface.

That said, the interpreter may have facilities for FFI access. Node.JS comes to mind as a javascript interpreter that likely has facilities for FFI access. Alternatively you could use your C program to host a javascript interpreter like Chrome’s V8 engine to have your C execute the javascript directly if this would help you, though I don’t suspect it would.

Inter-Process Communication (IPC) is where you run the process in one language, and the other process in the other language, and then use a form of IPC to communicate between the two. Commonly this is done via shared memory space where both processes can put data into that memory space and read from it to send messages back and forth. The same technique is used with files sometimes though this is a high-overhead technique due to the IO costs, it does however afford a durability in the event of either or both processes crashing, or even the machine losing power.

The shared memory technique for IPC often comes in a couple flavors:

  • A parent process calling a child process and using “pipes” to send messages directly to the child process. I believe Node.JS suggests this technique for it to interoperate with other languages
  • Named pipes which are system-wide shared memory spaces registered with the kernel and accessible by an identifier

Other than shared memory or disk, the other largely used IPC technique is network communication. Whenever your browser accesses a website it is communicating with another process, so this is IPC, and in this way web services have become a hugely common way of accomplishing IPC. Direct TCP techniques are still used as well as even UDP for certain tasks, but the point is the network may act as a communication layer between processes just as a memory space or disk space may.

All of this said, my suggestion is you use web services for IPC as your language interoperation technique, because you wish for visualization on a browser.

That’s all. I hope you learned something, carry on 🙂

1

Write a CGI, make an HTTP server and a browser do the rest.
If you need more performance later, you can turn it into a FastCGI.

If you (your bosses) are really that desperate into making it look like there isn’t a browser doing the heavy hauling, look into including a WebKit widget (cross platform) or embedding an MSIE frame (all-around easier and faster, but only available on Windows, and might raise issue with MSIE versions) into your windowed app.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật