Timeline for Writing an API that is syntactically valid in multiple programming languages
Current License: CC BY-SA 3.0
17 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 23, 2014 at 20:42 | vote | accept | Anderson Green | ||
Mar 23, 2014 at 20:42 | answer | added | Anderson Green | timeline score: 0 | |
Mar 18, 2013 at 15:02 | comment | added | Jimmy Hoffa | Read up on FFI and interoperation techniques if you want your library usable by multiple languages. I wrote an answer to someone regarding FFI here read further on wikipedia and google. | |
Mar 18, 2013 at 15:02 | comment | added | CodesInChaos | IMO it's more important to follow platform conventions than having an identical API. Having a similar API is probably a good idea, an identical API probably not. | |
Mar 18, 2013 at 4:32 | comment | added | Anderson Green |
@mortalapeman It wouldn't be necessary to implement a completely new programming language. Instead, I could simply use a restricted subset of an existing programming language (such as Java) instead of creating a completely new language. To keep things simple, I'd also need to use a single data type as the input and output of every function. So String[] theStr = ["Hi!"] in Java would become var theStr = ["Hi!"] in JavaScript.
|
|
Mar 18, 2013 at 3:35 | comment | added | Nate W. | Yeah don't do this. As everyone is saying, this is going to be way more work than you think, and it's not really going to benefit you as much as you hope. | |
Mar 18, 2013 at 3:34 | answer | added | user40980 | timeline score: 4 | |
Mar 18, 2013 at 3:18 | comment | added | mortalapeman | @AndersonGreen I think your plan is going to be more work than you think. You're talking about writing your own language as an abstraction in top of another language. You'll have to implement operators as well as the key words and all the semantics associated with them. It would probably be easier to do what ipaul said. | |
Mar 18, 2013 at 3:01 | history | edited | Anderson Green | CC BY-SA 3.0 |
added 14 characters in body
|
Mar 18, 2013 at 3:00 | comment | added | Anderson Green | @mortalapeman Each "polyglot" function would only depend on a small number of "language-specific" functions. As soon as I had written a few "language-specific" functions for a particular language, I would be able to port a large number of "polyglot" functions to that language with only a few minor semantic changes. | |
Mar 18, 2013 at 2:53 | comment | added | mortalapeman | What isbadawi said. While your api may be syntactically valid, the use of it may not be idiomatic for one or more of the languages you are targeting. I personally would rather use an API that takes advantage of the language features available so I don't have to write more code. | |
Mar 18, 2013 at 2:53 | comment | added | Anderson Green |
@ipaul In C, I would implement printSomething as printf(thingToPrint). In Java, it would be System.out.println(thingToPrint). In Ruby, it would be puts(thingToPrint) .
|
|
Mar 18, 2013 at 2:50 | comment | added | ipaul | Ah, okay. Normally, this is done by picking one language in which to implement (i.e. C) and then using tools like SWiG to bang out interfaces that call the C code from other languages. As someone using your library I should care that you have a method called 'proofOfConcept' but I shouldn't care how you chose to implement it. | |
Mar 18, 2013 at 2:49 | comment | added | Ismail Badawi | infoq.com/articles/API-Design-Joshua-Bloch; "it is almost always wrong to transliterate an API from one platform to another" | |
Mar 18, 2013 at 2:47 | comment | added | Anderson Green | @ipaul I'm trying to write an API that will be compatible with as many programming languages as possible. Of course, it would be necessary to write a few "language-specific" functions to handle if-statments and while-loops, and then write an entire function for the body of each while-loop and if-statement. | |
Mar 18, 2013 at 2:47 | comment | added | ipaul | I'm not sure why this would be helpful. Can you describe the problem you're trying to solve? | |
Mar 18, 2013 at 2:44 | history | asked | Anderson Green | CC BY-SA 3.0 |