A question I've been wondering about recently is w...
# thinking-together
n
A question I've been wondering about recently is why aren't programming languages more... modular? Like, why isn't there a system for using X interpreter/compiler with Y syntax? Every language is bound to a specific runtime environment and syntax, but would it be possible to mix and match these somehow?
c
Well theres LLVM and WASM which is kind of like that
✔️ 1
n
this question is partially inspired by seeing that, interestingly, Python and JavaScript are much faster than Java and C# for AWS Lambda (serverless computing.) So I'm curious to what degree you can swap out the runtime with the same code
@Chet Corcos LLVM is a good example. But I'm curious if there's something like that for interpreted langs? A common backend for multiple syntaxes/standard libs
c
Yeah, interesting. WASM is actually even better in some ways -- its an intermediate representation. Languages compile to WASM, and WASM can run on various runtimes...
❤️ 2
For what its worth, I'm not too familiar with WASM but I know there's a lot of coolaid over there.
I'm reminded of this talk I saw a while ago: https://vimeo.com/341873497
e
Languages today are inextricably linked with very complex runtimes. You can't even consider running Elixir or Erlang without the special virtual machine. That runtime has a very clever heap-per-thread architecture, unique among languages, and if you have a task to do that requires 300,000 simultaneous threads, you are going to get pounded with memory management problems in any conventional runtime. Languages also don't agree on data types. C has a 2 value boolean. JS has a 3-value boolean (undefined, true, false), and Beads has a 4-value boolean (undefined, error, true, false) in order to have a uniform top and bottom value for all data types. These types of minute details make data interchange basically impractical between languages, so the idea of a universal runtime is unrealistic in this universe.
💯 1
m
there was an attempt a (long?) time ago called parrot to provide a vm for multiple dynamic languages: https://en.wikipedia.org/wiki/Parrot_virtual_machine
n
v
People help each other, share each other's code. It would be very inconvenient if people used many different syntaxes for same language
💯 1
j
One thing that would make that hard is translating the standard library/built in types. You not only would have to translate the code you’re working with, but everything it depends on. At that point, what’s the benefit?
Important to note that GraalVM works based off of hand-written interpreters for other languages. They had to go and write an interpreter for Ruby that can be run inside that VM and interoperate with an interpreter for JS/Python, etc.
GraalVM works because of a lot of manual effort, and because it’s built on tremendous compiler technology that lets those interpreters run efficiently without as much hand-optimization.
Java has poor startup time. But it’s not really because the runtime is bad per se. It’s more that the language spec requires behaviors that are very hard to implement with a system that starts up quickly. GraalVM offers an alternative that avoids a lot of that, but I believe its AOT compilation isn’t 100% compatible with other JVMs, and it’s a huge engineering effort.
a
Counterpoint to @Vladimir Gordeev’s comment: "We can make machines do it any way we like, and we can have policies that can allow you to do both. Remember, a real engineer doesn't want just a religion about how to solve a problem, like object-oriented, or functional, or imperative, or logic programming. This piece of the problem wants to be a functional program. This piece of the program wants to be imperative. This piece wants to be object-oriented. And guess what, this piece wants to be logic-based. And they all want to work together usefully. And that's because of the way the problem is structured, whatever it is. And I don't wanna think that there's any correct answer to any of those questions. It would be awful bad writing a device driver in a functional language. It would be awful bad writing anything like a symbolic manipulator in a thing with complicated syntax. It's awful bad to write a numerical program in anything but Fortran." —Gerald Sussman

https://www.youtube.com/watch?v=O3tVctB_VSU

👍 1
d
@noahtren My work at http://loyc.net is specifically aimed at solving bits of that problem. I'd like to build a system that will have syntax modules, semantic modules, and a multi-language standard library.
😮 1
So far I've made the most progress on the syntax side. I haven't made a lot of progress in recent years, but I'm hoping to find someone around here with whom to partner up and design more of this. In contrast to projects mentioned above that are focused on dynamic languages, I want to focus mainly on static typing with dynamic typing as (1) a special case (like C#'s
dynamic
) and (2) an code generation target (JaveScript).
d
re: hard to share across inconsistent languages Maybe that would look different if there was one common representation, and other languages were just (or could be added as) projections to/from it. I think that would fit in with what David is doing with LOYC?
re: JavaScript faster than Java on AWS lambda Maybe that's a matter of which is faster to parse and interpret, if that's how it works (note: I'm only vaguely aware of what AWS lambda is). For example, compare: (a, b) => a+b Versus: class X { public static int plus(int a, int b) { return a+b; } }
@noahtren I have my own ideas about replacing a compiler (and programming language), with composing regular old programming paraphernalia that generate the code you want, from whatever data / syntax you want. The main difference is that it's not something separate from the code that's "written in it", and it replaces programming language as a (metaphorical) framework, with language as a (literal!) code library. I'll DM you