TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

SWIG author on the complexity of SWIG

48 点作者 prog超过 13 年前

6 条评论

phaedrus超过 13 年前
I wrote a library that makes C++ callable from script languages, but instead of parsing headers it uses C++11 template metaprogramming and type inference, so it always parses exactly what the types are because it runs in the same compiler as your code. Unlike SWIG it is becoming simpler over time as I develop more powerful abstractions and I <i>do</i> understand 100% of how it works (although admittedly you have to have advanced C++ knowledge).<p>Definitely agree with the C++ corner cases thing being a challenge - at times I felt like I was writing another compiler on top of the C++ type system to handle the corner cases. But again, I used powerful abstractions to handle that. For instance, my library uses boost graph library and djikstra's algorithm to handle C++'s tangled web of automatic type conversions.<p><a href="http://github.com/dennisferron/LikeMagic" rel="nofollow">http://github.com/dennisferron/LikeMagic</a>
评论 #2940199 未加载
daeken超过 13 年前
I've been thinking about how to do this effectively and cleanly for a while now, and I wonder if the right path isn't to use clang to parse the C or C++ code and then generate interfaces from the LLVM IR. As far as I know, all the metadata you need is there, so it might prove simpler than parsing things on your own.
评论 #2940657 未加载
评论 #2938223 未加载
mynegation超过 13 年前
If it shows anything, it is a horrible language design of C++. I wrote a C++ front-end long ago, and it is excruciating.<p>Later, when I had to write native code to speed up Python, I always used plain old C and swig worked flawlessly.
评论 #2937706 未加载
评论 #2937744 未加载
lylejohnson超过 13 年前
I was one of the maintainers of SWIG's Ruby module during that rewrite he mentions, and I remember how difficult it became for me to really understand how the code worked. I would just hack features into the Ruby module and be glad when they seemed to work, but it always felt like a house of cards. Fortunately some more talented developers took my place when I gave it up.
sigil超过 13 年前
The SWIG author in question, Dave Beazley, also gave a couple great talks on the Python GIL: <a href="http://www.dabeaz.com/GIL/" rel="nofollow">http://www.dabeaz.com/GIL/</a>
gaius超过 13 年前
I had a bit of a nightmare with SWIG recently, glad to hear I'm not alone! <a href="http://gaiustech.wordpress.com/2011/08/03/ocaml-bindings-for-coherence-with-swig/" rel="nofollow">http://gaiustech.wordpress.com/2011/08/03/ocaml-bindings-for...</a>