TruffleInteropUsability
From APIDesign
Let's come up with own larger examples that exchange larger data structures and not just very small tests where only a few objects are participating in interop. In general, I am not so sure about the message annotations. You have to assume a very generic Java programmer (i.e., fresh beginner student). He also knows a bit how to type JavaScript. Can he use the API reasonably? Actually, what would be interesting is to do a “usability study” with some students. They get some documentation, they get an inter-op task. You let them work and observe. If they can solve the task without problems, the API is good.
An example of a usability study to follow is here. The cost was $49 per developer doing the study.
Contents |
Inter-op Usability Study
Please use README at https://github.com/graalvm/truffle as your starting point.
1. Setting Up
Download GraalVM, setup your IDE to allow you to develop against Truffle API. Write a main class that initializes the Truffle interpreter and evaluetes 'Hello World!' application in JavaScript, Ruby, R and one more language with Truffle interpreter. Package the application as a JAR file and execute it from a command line: java -cp yourapp.jar yourpkg.app.MainClass (or something like this).
2. Compare the Speed
Implement some well known algorithm in JS, Ruby, R and compare speed of the execution in GraalVM JS vs. regular JS, in Graal Ruby and regular Ruby and/or in GraalVM R and normal R. Find good examples in different languages here: http://benchmarksgame.alioth.debian.org Make sure the algorithm is warmed up - let it run for few seconds, repeat the computation few times to give the system time to optimize. Compare the speed of initial vs. optimized execution.
3. Java Interoperability
Re-implement inner part of your algorithm in Java. Use interoperability features of Truffle API to communicate between the scripting language and Java. Does the rewrite to Java influence the execution speed of your algorithm?
4. Expose Java Data
Expose a Java class like Address that has name, street, town, zipcode fields as an object usable from the Truffle languages. Write a program that constructs the Address instance in Java and passes it into a function written in Ruby/JavaScript/R and this function reads the fields from the object concatenates them into a sequence: {name} lives at {street} in {town} and returns it.
5. Write a Unit Test
Verify the Address concatenating algorithm by writing a unit test using JUnit. Execute it successfully.
Post-study questions (up to 5)
- How well the Truffle system fits into your developer workflow? What are the three most important issues that could make your experience better?
- Name at least three of the most difficult problems you encountered during task execution.
- Have you experienced any unexpected crashes or errors? If yes, did you find the error messages useful?
- Name at least three ways we can improve the documentation.
- Name at least three ways we can make the API easier to use (other than documentation).
What is a development stage of your API?
Technology preview.