News for hackers. Stuff that matters.
Re:ZetaVM, my new compiler project by marktangotango on Saturday April 29, 2017 @05:11PM (#14228771)
How does this project compare to nekovm? Sounds very similar.
Re:ZetaVM, my new compiler project by tachyonbeam on Saturday April 29, 2017 @05:18PM (#14228808)
Not familiar with Neko, but superficially, it seems that VM is designed for a specific programming language. It uses a bytecode IR whereas Zeta uses a textual one. Neko is also farther along, more mature and feature complete than Zeta.

I intend to take a more experimental direction with Zeta. It won't have an FFI, for instance. It will only provide a small set of minimalist APIs. The VM will be intentionally designed to avoid code rot and breaking changes.

Another thing I would like to experiment with is transparent compilation of pixel shaders to run on GPUs, the ability to run code in any language running on Zeta (given some restrictions) on both the CPU and GPU. I believe I have found a way to make this work, based on my type-specialization research.

Re:ZetaVM, my new compiler project by akkartik on Saturday April 29, 2017 @06:08PM (#14229037)
Hmm, I haven't heard this idea before that the FFI or surface area of libraries in a language causes bitrot. Could you elaborate on the connection? I can take version 1 of the C sources of Vim from back in '92 and compile them without trouble. I'm not aware of dynamic languages like Javascript or Python 2 having any bitrot issues either. Backwards compatibility seems like a pretty big constraint for everyone.

Edit 16 minutes later: I just tried your benchmark with my VM-like language (https://github.com/akkartik/mu), and the time taken was almost identical. Interesting exercise! Here's the Mu and Plush/0 programs side by side:

  $ cat fib.mu
  def fib n:num -> result:num [
    local-scope
    load-ingredients
    base-case?:bool <- lesser-or-equal n, 1
    return-if base-case?, n
    n <- subtract n, 1
    fib-n-1:num <- fib n
    n <- subtract n, 1
    fib-n-2:num <- fib n
    result <- add fib-n-1, fib-n-2
  ]

  def main [
    local-scope
    x:num <- fib 29
    $print x, 10/newline
  ]

  $ cat benchmarks/fib29.pls
  #language "lang/plush/0"
  var fib = function (n)
  {
      if (n < 2)
          return n;
      return fib(n-1) + fib(n-2);
  };
  var r = fib(29);
  print(r);
Re:ZetaVM, my new compiler project by tachyonbeam on Saturday April 29, 2017 @06:26PM (#14229111)
C has been fairly stable across time, but you gave to admit, a C program from 1992 still compiling as-is, that's an exception rather than the rule. The reason Vim from 1992 might still compile is actually because it doesn't have that much dependencies apart from standard C and POSIX APIs.

JavaScript has massive bitrot issues. The HTML DOM is huge and constantly changing. I have had my own web apps break multiple times over the years. As for Python and C, if you stick to the core language, and minimize dependencies, you might be Ok. The problem is that the more dependencies you have, if any one of them break, they can render your program broken... And if you're not there to fix it, your program remains broken forever.

My argument for reducing API surface and keeping APIs low-level and minimalist is that the smaller an API, the more difficult it is to implement it wrong. It's easier for two implementations to implement a smaller API and have the same behavior. It's also easier to test small APIs for conformance, etc.

Re:ZetaVM, my new compiler project by akkartik on Saturday April 29, 2017 @06:33PM (#14229140)
I think I see what you mean. However, all these previous languages would claim that the parts they control have not suffered from bitrot. The dependencies you're thinking of are not considered part of the language in each case. Is that right? How would you keep people from creating new libraries in your language for unanticipated use cases? Say a self-driving car library, or a command-and-control module for all the IoT devices in a house from 2029?

It seems to me that bitrot is fundamentally a result of change in the outside world. The only way to opt out of bitrot when the world changes rapidly seems to be to disengage from the world and become irrelevant. I'm fairly certain Mu will not suffer from bitrot in 30 years -- but it'll only be because nobody ever built anything with it :)

Re:ZetaVM, my new compiler project by tachyonbeam on Saturday April 29, 2017 @06:40PM (#14229167)
> How would you keep people from creating new libraries in your language for unanticipated use cases? Say a self-driving car library, or a command-and-control module for all the IoT devices in a house from 2029?

I can't prevent people from doing that. I can only put together the conditions to make it easy to write software that doesn't break, as much as possible.

> It seems to me that bitrot is fundamentally a result of change in the outside world.

Yes and no. On the one hand, some breakage is inevitable with changing conditions. On the other hand, the computers we have now provide the same basic facilities as computers did in 1969. It ought to be able to provide some stable building blocks, and hope that people will use them.

Currently, it seems to me that software breaks all the time, at a rate that is unacceptably high.

Re:ZetaVM, my new compiler project by sitkack on Sunday April 30, 2017 @01:57PM (#14232874)
I have come to the same conclusion as tachyonbeam, it is interaction with the outside world that causes bitrot. Rather than have APIs, we need communication protocol with simple semantics. The VM should interact over a constrained, well defined protocol, that protocol could implement a POSIX io model, but that would be up to the client to offer that abstraction over messages.

The surface area of POSIX is too high to build systems that can run for 10s or hundreds of years. Look at the design of Lua over Python. The assumptions it makes of the underlying platform are much much cleaner, thus it is more portable and easier to debug platform issues.

Re:ZetaVM, my new compiler project by akkartik on Sunday April 30, 2017 @02:05PM (#14232925)
Interesting. Can you show an example of how Lua's interface to the underlying platform improves on Python? Doesn't replacing APIs with protocols merely shift the breakage to higher-level logical errors rather than lower-level mechanical ones?
Re:ZetaVM, my new compiler project by sitkack on Monday May 01, 2017 @12:51AM (#14235642)
Lua is under-coupled with the base system. For the longest time it wouldn't even support dynamically loaded modules because it wasn't portable. It wasn't part of C89.

So when one uses Lua, it is up to the user to supply IO. This threading through the needle or hour-glass allows the users (embedder) to define how the scripts interact with the base system. This makes them more resilient over time, the interactions are better specified and highly mediated.

Somewhat analogous to the library vs framework dichotomy. Libraries survive better than frameworks do.

Re:ZetaVM, my new compiler project by akkartik on Monday May 01, 2017 @02:30AM (#14235947)
Fascinating! Seems to have some commonality with dependency injection, which is one of my interests (https://github.com/akkartik/mu#readme)

Can you point me at any Lua docs where I can read more about overriding IO in Lua?

Re:ZetaVM, my new compiler project by jerrysievert on Saturday April 29, 2017 @09:55PM (#14229781)
having fairly recently redeployed a MUD I worked on in the early 90's (telnet mud.legitimatesounding.com 4000 - https://github.com/JerrySievert/SillyMUD), I can't agree more.

I spent many hours fixing compile issues, memory problems that should have taken it down in the early 90's but didn't seem to matter at the time, and moving it to a modern socket API. I was quite surprised how much things had changed in 25 years.

Re:ZetaVM, my new compiler project by ternaryoperator on Saturday April 29, 2017 @05:24PM (#14228839)
>"The VM will be intentionally designed to avoid code rot"

How do you plan to do that?

Re:ZetaVM, my new compiler project by tachyonbeam on Saturday April 29, 2017 @05:35PM (#14228896)
The IR, once past an initial prototyping state, will not change. Things will be added to it later, but not removed. The IR and semantics will be designed, as much as possible, to eliminate corner cases and undefined behaviors. Zeta will favor robustness over tiny performance gains. I realize that completely eliminating undefined behaviors isn't necessarily possible, but we will do our best.

The outside world will be accessible through a set of APIs that are small, have limited surface area. For instance, sound output will be done by writing raw samples. Graphics will be done with pixel shaders (functions which given coordinates return a pixel color). New APIs will be added over time, new versions of APIs will be added, but the older APIs will remain functional.

There will eventually be a package manager, and it will have immutable package versioning. That is, you can publish v5 of libtern, and I can depend on it. You can later publish v6 of libtern, but you can't change v5, so you can't break my code which depends on v5 when you publish new versions of your lib.

Obvious caveat: Zeta will have no FFI. You won't be able to immediately use all the libraries you could use in another system. I still think that building a huge amount of code that doesn't break could turn out to be a huge advantage. We won't try to satisfy every use case out there... But I think there are a lot of interesting and useful programs which don't need much more than basic keyboard and mouse input, audio and video output, network and file access (think photoshop, audio editing software, IDEs, etc). We will probably end up adding APIs for other things like MIDI, etc later on.

Re:ZetaVM, my new compiler project by eropple on Saturday April 29, 2017 @06:06PM (#14229032)
> audio editing software

In the audio space, it is vital to support FFI for a plugin architecture because I can guarantee you your language isn't the-best-thing-since-sliced-bread for somebody who has stuff you really want available to you. Audio software lives and dies on the VST specification. (Audio Units are substitutable for VSTs--but the same problem remains.)

I admire your efforts, but perhaps you should understand the use cases of the things you want to use as examples before you try to employ them. It doesn't instill confidence.

Re:ZetaVM, my new compiler project by sitkack on Sunday April 30, 2017 @01:59PM (#14232888)
Your tone could be improved.
Re:ZetaVM, my new compiler project by tachyonbeam on Saturday April 29, 2017 @06:18PM (#14229075)
1. That depends on the audio editing software you want to run. You can build useful audio editing software without plugins.

2. We can build our own plugins

3. It's not impossible to translate or emulate existing VST plugins.

Re:ZetaVM, my new compiler project by eropple on Saturday April 29, 2017 @06:22PM (#14229093)
You can make useful audio software for a very tiny slice of a very picky market without a plugin architecture. Even crap like Audacity has a plugin architecture for a reason: because they know they don't support what people need and want.

And yes, you can build your own plugins. You cannot replace the thousands upon thousands of VSTs out there. You aren't replacing, for example, RealStrat, which is a supersampled virtual instrument, without re-recording the entire thing (do you know how? Is anyone going to bother doing it when they can use existing, conventional software?) and simultaneously reverse-engineering the algorithms used internal to it. You aren't replacing even something comparatively simple like an Amplitube without heavy-hitting, lots-of-money algorithmic research in the first place. (And, on top of that, I sure wouldn't want to deal with the patent encumbrances!)

And pardon my skepticism, but emulating latency-sensitive, CPU-intensive stuff like audio processing strikes me as a pretty foolish idea. When milliseconds count, your emulation layer just gets in the way. What benefit are you bringing to make additional failure cases and additional latency worth a user's time?

You aren't reinventing the entire audio world; as with many other fields, the lingua franca is C and not you and no matter how much you yell at the mountain the mountain's not gonna move. If you want to play, you have to play with (good metaphor for music in general, now that I think about it). Maybe you should rethink some of your decisions, or better constrain your ambitions. Because right now--and this may sound harsh but I'm saying it because I like seeing people succeed--it sounds like you're doing the software engineer That Guy thing and handwaving away difficult things because they aren't conducive to the postulates you're starting with.

Re:ZetaVM, my new compiler project by tachyonbeam on Saturday April 29, 2017 @06:34PM (#14229147)
I'm OK with not being able to replace every audio program ever written. That's an impossible goal. I also know that I can never satisfy every possible use case.

I'm also quite sure that an audio program with a plugin architecture will be feasible in Zeta, once it's more mature. The system is built for scripting, multi-language support and dynamically loading packages. It will be an excellent platform for plugins. You'll be able to define your own custom plugin language(s) easily, and then you'll be able to dynamically browse and load plugins from the package manager.

Re:ZetaVM, my new compiler project by eropple on Saturday April 29, 2017 @06:35PM (#14229150)
You're not parsing so I'm done trying. Good luck with it.
Re:ZetaVM, my new compiler project by coldtea on Saturday April 29, 2017 @10:48PM (#14229937)
Let's put it this way: WHEN (and IF) Zeta works, people can discuss its suitability for audio work, and how it would cater to the VST crowds. Until then, this is beyond premature discussion...
Re:ZetaVM, my new compiler project by tachyonbeam on Sunday April 30, 2017 @06:05PM (#14234111)
I think people fail to understand, too, that I'm OK with having modest goals for Zeta. This system is going to be an experiment. If it doesn't become hugely popular, it's not the end of the world. If some things don't work out, we can try something different. At the end of the day, I think some things really have to be tried out before we can decide if they're viable/useful or not.
Re:ZetaVM, my new compiler project by yumaikas on Monday May 01, 2017 @12:03AM (#14235488)
I suspect that some of that confusion comes from the fact that you directly compare yourself to LLVM, and that you haven't mentioned much about ParrotVM or NekoVM, which are both efforts in this space. It's also worth saying that the CLR and DLR are both efforts here as well.

When you compare yourself to LLVM, you phrase the comparison as only an advantage (Zeta will be easier to use than LLVM), rather than a tradeoff (Zeta will aim for ease of use before performance, as opposed to LLVM).

I don't suggest that you start hedging your writing, but am just pointing out that if you make big comparisons, people will assume great ambition on your part.

Re:ZetaVM, my new compiler project by eropple on Sunday April 30, 2017 @10:50AM (#14231774)
In the large, sure. But "if you're going to say you can do X, you should have a good idea of what X is" is pretty baseline, I think.
Re:ZetaVM, my new compiler project by tachyonbeam on Saturday April 29, 2017 @06:31PM (#14229132)
@eropple Replying to myself since HN doesn't let me reply to your comment.

As previously stated, my goal with Zeta is not to replace all existing VMs and to satisfy every use case. It's an experiment, it's an opinionated system. I'm going to do things differently from other implementations and try to demonstrate interesting things along the way. Even if Zeta never becomes popular, I know it will make people talk, and I hope it inspires other systems.

Re:ZetaVM, my new compiler project by zem on Sunday April 30, 2017 @04:18AM (#14230638)
elm is a good example here - there is no ffi for somewhat similar reasons (specifically, that it can make safety guarantees about not crashing at run-time if you don't allow arbitrary javascript code to be called), and that has both helped write reliable code, and hindered it's usefulness in larger applications that have to play with the existing world of js libraries and components
Re:ZetaVM, my new compiler project by eropple on Saturday April 29, 2017 @06:32PM (#14229136)
You can click on the post itself to reply to it.

I'm not telling you not to have opinions, to be clear. I'm suggesting maybe you shouldn't adjust those pince-nez and pronounce so hard. Many systems exist the way they do for reasons that Software Developer That Guy cannot divine from outside; you just happened to hit on one that I know a little bit about.

(Photoshop is another example; professional-level tools require professional-level expansion. Because everybody's definition of "professional" is different.)

Re:ZetaVM, my new compiler project by __s on Saturday April 29, 2017 @05:54PM (#14228983)
What about WebAssembly? It's hit 1.0 now, & it's designed so that 1.0 wasm will never become deprecated

My own thoughts have been considering a wasm vm in kernel space. No need to ever exit kernel space; the wasm vm provides sufficient sandboxing. Wasm binaries could run on any architecture. Hopefully come up with a method that browsers can efficiently run wasm in directly in the kernel's sandboxing rather than having wasm-in-wasm. Syscalls could be exposed through wasm's import/export system. Kind of like that Metal idea in "The Birth & Death of JavaScript"

Re:ZetaVM, my new compiler project by tachyonbeam on Saturday April 29, 2017 @06:20PM (#14229083)
WASM may remain stable, but it provides no APIs to the outside world AFAIK. The DOM keeps changing, and if the APIs are implementation-dependent, then WASM doesn't guarantee non-breaking at all.

Another advantage that Zeta has is that it will come with useful building blocks for dynamic languages. With WASM, you have to implement your own dynamic typing, GC, JIT, etc, and the current WASM implementation doesn't yet support JITting.