Re:How to Use the Foreign Function API in Java 22 to Call C ...
by neonsunset on Wednesday May 08, 2024 @02:10PM
(#40301219)
Why not give C# a try instead? It has everything you ask for and then some.
[ Parent
| on HN ]
Re:How to Use the Foreign Function API in Java 22 to Call C ...
by neonsunset on Thursday May 09, 2024 @01:47AM
(#40305619)
Wow, you all are sure mad enough to go out of your way and downvote my comments elsewhere.
Stay in the swamp :)
Re:How to Use the Foreign Function API in Java 22 to Call C ...
by coldtea on Thursday May 09, 2024 @05:17AM
(#40306496)
Because "some inconvenience/unmet requirement" from a language is not an invitation to "throw out the whole platform and your existing code and tooling, and learn/adopt/use an entirely different, single-vendor platform".
Except if we're talking about some college student or hobbyist picking their first language and exploring the language space...
Re:How to Use the Foreign Function API in Java 22 to Call C ...
by imtringued on Thursday May 09, 2024 @10:02AM
(#40308341)
He would still have to call out to the C++ function.
Re:How to Use the Foreign Function API in Java 22 to Call C ...
by neonsunset on Thursday May 09, 2024 @10:46AM
(#40308773)
Assuming it is "sort for 128bit records", that's something C# does really well - writing optimized code with structs / Vector128<T> / pointer arithmetic when really needed without going through FFI and having to maintain separate build step and project parts for a different platform.
But even if it was needed, such records can be commonly represented by the same structs both at C#'s and C++'s sides without overhead.
An array of such could be passed as is as a pointer, or vice versa - a buffer of struts allocated in C/C++ can be wrapped in a Span<Record128> and transparently interact with the rest of standard library without having to touch unsafe (aside from eventually freeing it, should that be necessary).