Live data from Hacker News

Graal and Truffle could accelerate programming language design

medium.com

81–90 of 204 posts

Re: Graal and Truffle could accelerate programming language design

#81
So, judging by the slides for that "one vm to rule them all" talk [1], it's Java all the way. One has to generate AST in a form of Java code and deal with Java ecosystem. And it feels all very very complicated for all the wrong reasons.

I guess some people from the Java world could find something useful there, but it's very unlikely to attract anyone else.

[1] https://lafo.ssw.uni-linz.ac.at/pub/papers/2016_PLDI_Truffle...

Re: Graal and Truffle could accelerate programming language design

#82
post #31

Earlier quoted context omitted.

Because most developers don't care and code everything on the UI thread. Additionally Swing has bad defaults, so it requires effort to make the required set of calls to make them look better. Back in the Sun glory days, there were Sun blogs like Filthy Rich Clients, which lead eventually to a book http://filthyrichclients.org/ . It was a consequence of Sun not getting what it means developing GUIs for the consumer sy…

Android does a bunch of things to keep you off the UI thread(IO throws an exception, handlers, Async Tasks, etc). You still have to GC at some point and when that happens chances are you're going to drop frames. Unless you're very aware of the garbage you're creating you'll take more than ~5ms which is usually enough to push you over 16ms with the other work that goes on during a frame.

Measure Java performance by how Android works is not a good measure.

Dalvik is well known on Java world for having a JIT and GC implementations that worse than what most commercial embedded JVM are capable of.

Things have improved with ART, but even there there are quite a few performance improvements that Google could eventually do.

Soft real time Java GCs for embedded devices are being used in ground station controls of missiles and a couple of US Navy weapon systems. They surely don't want GC glitches in battle situations.

The Android team seems to only bother with "good enough" in what concerns Android performance.

As a side note, just check how many Android releases are they going through and yet real-audio support isn't quite there. Even Windows Phone has better support for it, and they do have WinRT and .NET on them.

Re: Graal and Truffle could accelerate programming language design

#83
post #76

Judging by LuaTruffle, the Lua example, then this framework is useless. LuaTruffle appears to implement the syntax of Lua but none of the semantics. For example, no metatables and no coroutines. Lua is unparalleled in its support of coroutines, and metatables are what make optimizing Lua _difficult_. Without implementing either of those things you've neither demonstrated the ability of the framework to implement nove…

Truffle+Graal could actually easily implement all of those things, LuaTruffle is just one of the less developed ports. JRuby+Truffle has highly efficient analogues of most of the things you mention.

Re: Graal and Truffle could accelerate programming language design

#84
post #41

There's actually a fairly long history of cross-language VMs, with various degrees of success. What usually happens is that they work fine for languages that look, semantically, basically like the native language on the VM. So LLVM works well as long as your language is mostly like C (C, C++, Objective-C, Rust, Swift). Parrot works if you language is mostly like Perl 6 (Perl, Python, PHP, Ruby). .NET works if your la…

> It's a great tool if you work in the JVM ecosystem and want to play around as a language designer. Except that it's not really exposing much of the JVM from what the article mentions, it just uses the JVM as a base. That is, Truffle languages can talk to other truffle languages, but I'm not sure how easy it is for a truffle language to talk to a JVM language. From everything I read, it seems like people thought Par…

I liked Parrot, but it didn't move in the right direction. No useful AOT and JIT from the start kind of turned me down.

Re: Graal and Truffle could accelerate programming language design

#85

Earlier quoted context omitted.

The big question is "Would you want to use this in a mission-critical project?" Emscripten lets you write webapps in C, for example, but outside of sharing common libraries across server/Android/iOS/web clients, few people use it. Pretty much every professional job I've had used polyglot programming of some sort - when I was in financial software it was mixed Java/C/Fortran numerics, when I founded my first startup i…

The idea of Truffle language interoperability is to avoid switching the representation at the language boundary. Objects carry their type information with them that includes the semantics on how to access their properties. This also allows Truffle to fake up the existence of an object without actually performing allocations (e.g., a table in raw buffer format can be interpreted as an array of objects). This clear sep…

[deleted]

Re: Graal and Truffle could accelerate programming language design

#86

Earlier quoted context omitted.

The idea of Truffle language interoperability is to avoid switching the representation at the language boundary. Objects carry their type information with them that includes the semantics on how to access their properties. This also allows Truffle to fake up the existence of an object without actually performing allocations (e.g., a table in raw buffer format can be interpreted as an array of objects). This clear sep…

Right, and my point is that this won't work unless you dictate a common memory layout for all Truffle objects. And if you do that , then you lose the ability to make trade-offs about object representation that depend upon access patterns that only the programmer can know. The whole reason we have different programming languages is because not all domains of computation face the same trade-offs.

It works without common memory layout between Truffle languages. It even simplifies the ability to use diverse physical memory layouts within the same language. The programmer specifies the logical layout based on the semantics of a language. The runtime decides how to map this logical layout onto the physical hardware. It can take into account the trade-offs the programmer decided to choose.

Re: Graal and Truffle could accelerate programming language design

#87

Earlier quoted context omitted.

The big question is "Would you want to use this in a mission-critical project?" Emscripten lets you write webapps in C, for example, but outside of sharing common libraries across server/Android/iOS/web clients, few people use it. Pretty much every professional job I've had used polyglot programming of some sort - when I was in financial software it was mixed Java/C/Fortran numerics, when I founded my first startup i…

That's exactly how Truffle's cross-language-interface works though. Instead of paying the high cost of conversion, data stays in its existing representation and it is the interface code that is recompiled to fit. An example is JRuby+Truffle where in its C extensions, pointers to Ruby objects act to the C code as if they are pointers to MRI data structures, but behind the scenes Graal compiles code that accesses them…

Interesting. What happens if the native memory layout doesn't support a feature that the extension code requires? For example, what if a JRuby+Truffle script calls into a C library, which allocates a struct and invokes a Ruby callback with it, which then wants to access the fields via reflection? C doesn't normally include type information with its structs, so how would the Ruby code know the memory layout of the object?

What if it's not the C extension in your project that does the allocation, but a closed-source third-party library that your C code calls into? Do you need to recompile all source code to generate the appropriate typemaps?

Re: Graal and Truffle could accelerate programming language design

#89

Before anyone gets too excited, make sure you look at what a compiler using Truffle actually looks like, and remember that Java is far from an ideal language for writing a compiler. I'll use their SimpleLanguage (their primary tutorial lang) as an example. Parser [1] shows how lack of sum types makes code messy. Lots of "factory.createStringLiteral" kind of calls. At least Java has a mature parser generator. Implemen…

Well can't we just use another language for JVM (e.g. Kotlin or Scala)

Re: Graal and Truffle could accelerate programming language design

#90

Earlier quoted context omitted.

Right, and my point is that this won't work unless you dictate a common memory layout for all Truffle objects. And if you do that , then you lose the ability to make trade-offs about object representation that depend upon access patterns that only the programmer can know. The whole reason we have different programming languages is because not all domains of computation face the same trade-offs.

It works without common memory layout between Truffle languages. It even simplifies the ability to use diverse physical memory layouts within the same language. The programmer specifies the logical layout based on the semantics of a language. The runtime decides how to map this logical layout onto the physical hardware. It can take into account the trade-offs the programmer decided to choose.

Right, and my point is that the reason people continue to use C++ or Rust over JVM languages is because there are some use-cases where the JVM's decision about how to map the logical layout onto physical memory causes unacceptably high memory usage and/or cache misses, or prevents them from taking advantage of clever serialization formats (Cap'n Proto, for example, loses much of its performance benefits on the JVM without the use of sun.misc.unsafe). Will Truffle allow the programmer to override Graal's decisions on this and manually specify memory layout? And if so, how are conversions between different language formats specified?

If you already buy the JVM's premise of "just let the compiler do it, we'll figure out the most efficient representation", then this is a non-issue. But there are still programmers out there who believe that Rust or C++ or Go or CPython or whatever presents a better memory layout for the tasks that they wish to accomplish, or language designers who think they can do better than all of the above, and these are the users that Graal+Truffle is trying to win over. What's the story for them?

Post reply on HN