mcpField
P
polyglot-integration

polyglot-integration

github.com/aj-geddes開発373421 回インストール34 週間前に更新
リポジトリ

polyglot-integration について

polyglot-integrationは、異なるプログラミング言語間の連携を支援するスキルです。ネイティブアドオン、言語バインディング、gRPC通信のガイドと実践方法をまとめています。

主な機能

  1. 01Node.jsネイティブアドオンのガイド
  2. 02Node.jsからPythonを利用
  3. 03PyO3によるRust連携
  4. 04Py4JによるJava連携
  5. 05gRPCによる多言語通信

活用シーン

  1. 01他の言語からPythonのMLモデルを呼び出す
  2. 02高性能なC、C++、Rustコードを連携する
  3. 03レガシーシステムを接続する
  4. 04多言語マイクロサービス間で通信する

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill polyglot-integration

インストール後、Claude Code で/polyglot-integrationを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

references/
grpc-polyglot-communication.md
java-from-python-py4j.md
nodejs-native-addons-c.md
python-from-nodejs.md
rust-from-python-pyo3.md
scripts/
validate-pipeline.sh
templates/
pipeline.yaml

詳細

ポリグロット統合

目次

概要

異なるプログラミング言語で書かれたコードを統合し、それぞれの独自の強みとエコシステムを活用します。

使用する場面

  • C/C++/Rust でパフォーマンスが重要なコードを扱う場合
  • 他の言語から Python の ML モデルを利用する場合
  • レガシーシステムを統合する場合
  • 言語固有のライブラリを活用する場合
  • マイクロサービスのポリグロットアーキテクチャを採用する場合

クイックスタート

最小限の動作例:

// addon.cc
#include <node.h>

namespace demo {

using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::Local;
using v8::Object;
using v8::String;
using v8::Value;
using v8::Number;

void Add(const FunctionCallbackInfo<Value>& args) {
  Isolate* isolate = args.GetIsolate();

  if (args.Length() < 2) {
    isolate->ThrowException(v8::Exception::TypeError(
        String::NewFromUtf8(isolate, "Wrong number of arguments")));
    return;
  }

  if (!args[0]->IsNumber() || !args[1]->IsNumber()) {
    isolate->ThrowException(v8::Exception::TypeError(
        String::NewFromUtf8(isolate, "Arguments must be numbers")));
// ... (see reference guides for full implementation)

リファレンスガイド

詳細な実装については、references/ ディレクトリを参照してください。

ガイド内容
Node.js Native Addons (C++)Node.js Native Addons (C++)
Python from Node.jsPython from Node.js
Rust from Python (PyO3)Rust from Python (PyO3)
gRPC Polyglot CommunicationgRPC Polyglot Communication
Java from Python (Py4J)Java from Python (Py4J)

ベストプラクティス

✅ 推奨事項
  • 適切な IPC メカニズムを使用します
  • シリアル化を慎重に扱います
  • 適切なエラー処理を実装します
  • パフォーマンスへのオーバーヘッドを考慮します
  • 型安全なインターフェースを使用します
  • 統合ポイントを文書化します
❌ 禁止事項
  • 複雑なオブジェクトを境界を越えて渡さないでください
  • メモリ管理を無視しないでください
  • エラー処理を省略しないでください
  • 非同期コードでブロッキング呼び出しを使用しないでください

コメント