ABCDEFGHIJKLMNOPQRSTUVWXYZ
1
Foreign Function Interface (ffi)JNAPanama: Foreign Function & Memory APIJNIclongdtype-nextcoffijavacppjextractJNR
2
description: Clojure's java interop provides access to a huge number of high quality libraries. Similarly, the JVM's ffi options provide access to many high quality libraries written in languages like C, C++, Swift, Rust, etc.
3
Underlying implementationJNI bindings to libffiIncluded in JVMIncluded in JVMJNA, support for Panama or other options likelyJNA, graalvm ffi, java17+ panamapanamaJNIpanamalibffi via jffi
4
Widely Supportedwidely supported, likely to decline in favor or panamaAvailable in Java 22+widely supported, likely to decline in favor or panamayes, also extensibleyes, also extensibleAvailable in Java 22+widely supportedAvailable in Java 22+widely supported, likely to be phased out in favor or panama
5
Graalvm native image supportyespartial, https://www.graalvm.org/latest/reference-manual/native-image/native-code-interoperability/foreign-interface/yesyesyespartial, https://www.graalvm.org/latest/reference-manual/native-image/native-code-interoperability/foreign-interface/yespartial, https://www.graalvm.org/latest/reference-manual/native-image/native-code-interoperability/foreign-interface/probably?
6
Automatic API generationyes, via clongyes, via jextractvarious tools including javacppyesyes, via clongno, could be supported by clongyesyes?
7
Goofy JavaismsYes, structs require bytecode generation or java codeYes, Java or bytecode generation required for calling native functionsStruct usage is awkwardclojure centric APIclojure centric APIVery Java centric API?
8
PerformanceAcceptable, but slowest option listedBestSimilar to Panamasame JNAsame as JNA or java17+ panamasame as panamasame as JNIsame as panamaSimilar to JNI
9
Requires writing c++yes
10
Documentation, examples, tutorialsadequateadequatemany examples, limited documentationgreat documentation, limited examples?many examples, auto generated docs are meh?limited
11
Native datatypes support: ie. support for allocating, reading, writing, and manipulating native datatypesno missing features, but minimalno missing features, but minimalno missing features, but minimalno missing features, but minimalyesDSL for serialization to/from native datatypesno missing features, but minimalno missing features, but minimal?
12
Memory Management Supportminimalprovides support, but mostly diynominimal, but programmatic API generation is well suited to creating higher level APIs which do support automatic memory managementprovides some support via various native containers. API is also suitable for building higher level APIs with automatic memory managementyes, but must be specified explicitlynono?
13
Distributing native resources: ie. support for distributing native resources in jars and loading them.Includes library loader that can extract libraries from jarsNo support?same as JNA, Includes library loader that can extract libraries from jarssame as JNA, Includes library loader that can extract libraries from jarsNo supportYes, provides tools and library loaderNo supportNo support
14
Extensiblenononoyes, can be extended to new ffi implementations and API supports custom code generationyes, can be extended to new ffi implementations. also provides protocols that can be extended for other purposessupports custom serialization.???
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100