‹ BackHN Continuity

Thread

Vx – One Language, Every Chip

75 points · 53 comments · elffjs

Loading the complete thread in the background. This saved snapshot is available now. Refresh

  1. AnimalMuppet · · focus · HN ↗
    I haven't played with it at all, but the writeup looks promising. Moving a bunch of things into the type system and out of runtime crashes is one of the ways we make progress.
    1. dnautics · · focus · HN ↗
      I think this is wrong. Type systems should be simpler, and you should design it so that your language is easily and correctly statically checked. Not all invariants necessarily have to be verified at the same cadence (compile time)
      1. treyd · · focus · HN ↗
        > you should design it so that your language is easily and correctly statically checked.

        You do that by making the type system more sophisticated.

        If you have a really important invariant that you really don't want to be violated due to run-time behavior/input, it's a huge benefit to have a compiler that can statically check that it actually can't be. That's one of the main benefits of having type systems, not just describing the shape of data structures in memory.

        1. dnautics · · focus · HN ↗
          You can perform static analysis outside of the compiler without putting things in the type system?

          C is a bad language to do this with for various reasons, but as a simple example:

              char* buf = malloc(SIZE);
              free(buf);
              free(buf);
          
          There is absolutely no reason why static analysis should not be able to see what the problem is here.
          1. binary132 · · focus · HN ↗
            typesystems can be considered a kind of static analysis
          2. 0xdeafbeef · · focus · HN ↗
            uintptr_t x = opaque((uintptr_t)p); free((void *)x); free(p);

            How will you find such violations if opaque comes from so or some ffi, so compiler can't see through? you can't. It's heuristics. Sound type system is much stronger

            1. dnautics · · focus · HN ↗
              *ffi

              Christ. Even rust makes ffi unsafe

              1. treyd · · focus · HN ↗
                > Even rust makes ffi unsafe.

                Which is why every library that wraps C APIs provides safe wrappers that express the implicit expectations within Rust's type system. Yes the low-level calls are unsafe, of course they are, but then we expose them with a safe interface that consumers actually use.

          3. kfsone · · focus · HN ↗
            Sure, but what it is that makes you believe the compiler shouldn't be the one doing that analysis? Should it catch

            ``` ((void()(void) free)(buf); ((void()(void) free)(buf); ```

            It's been my experience people invested in static analysis think of it like some wholly additive extension.

            Compiler-independent static analysis is code applying rules. Someone has to write all the rules, align them with the language and the compiler. The user rarely reads the static analyzer's code or full rule definitions and is blissfully unaware of the full set of disconnects, inconsistences, and gaps between the coverage of the two.

            They only notice divergence in the analysis when it generates a false-positive warning or error.

            Static analysis adds compilation overhead. Sure, but I'd hazard that re-reading and in to some degree repeating the parsing/translation process that the compiler is going to do also introduces overhead.

            There are some languages that demonstrate sta-by-compiler capabilities with heinous compile times, but it doesn't have to be that way. We can engineer better, but at some point it requires a price. Better comments, boilerplate of some kind or another, annotating intent over idiom.

            A complex type system isn't ideal; with the right set of primitives you can achieve sophistication without complexity.

            ``` Freeable buf = malloc(SIZE); free(buf); // compiler error, you didn't check buf isn't valid. free(buf); // compiler error still if you fixed the above, free makes buf invalid. ```

            "Making the compiler do STA makes it slow". I don't think that's proven one way or the other. There are examples both ways. "complex" type systems frequently have slow compilers, but if you look more closely that's usually because they're trying to compensate for the disconnect between organically emerged complexity in their under-designed type systems.

            1. dnautics · · focus · HN ↗
              If it's so great, why does rust not put everything in MIRI into the compiler?
              1. steveklabnik · · focus · HN ↗
                Miri is a runtime thing so it can’t be in the compiler.

                The compiler could interpret all unsafe via it but then it would be very slow, defeating the point.

                1. dnautics · · focus · HN ↗
                  "can’t be in the compiler"

                  Can't is a strong word. You could 100% put it in the compiler. Yet you don't.

          4. imtringued · · focus · HN ↗
            ok but what if you call

            buf_create(SIZE)

            and

            buf_destroy(buf)

            now the compiler has to infer that buf_create creates a lifetime and buf_destroy destroys it.

            we're back to Rust's Box.

            1. dnautics · · focus · HN ↗
              Congratulations, you have hit upon one of the reasons why c is a bad choice. Other languages make this easier.
      2. classified · · focus · HN ↗
        So you prefer runtime crashes to compiler diagnostics, just so the type system can be simpler? I find these priorities backwards.
        1. dnautics · · focus · HN ↗
          > So you prefer runtime crashes

          Do you not understand what static analysis is?

          1. AnimalMuppet · · focus · HN ↗
            I understand quite well, thank you.

            Do you not understand that lots of people know what static analysis is, and still think that your position is fundamentally misguided?

          2. AnimalMuppet · · focus · HN ↗
            We understand that static analysis is less bulletproof than a compiler's type system. It doesn't always catch everything. If it does, it often says "may", and then you have to sort out the false positives from the real problems, and there can be a lot of them.

            And if you don't take every problem seriously, and do a full investigation, then you are risking a real problem that you don't fix, which can turn into... a runtime crash.

            1. dnautics · · focus · HN ↗
              You are describing static analysis as it has been done. Nothing stopping you from doing sa that rejects as strictly as rust for example does.
      3. AnimalMuppet · · focus · HN ↗
        But what does static analysis work on? The source code. If it's not in the source code, the static analyzer can't check it. So if you want to check something, even with a static analyzer, then you need some way to talk about that thing in the source code, which means it has to be part of the source language.

        Now, sure, you could have some kind of annotations in the comments or something, and a static analyzer that checked those, and you could get that to check pretty much anything that can be checked statically. But at that point, it's not really part of the language, is it?

        1. dnautics · · focus · HN ↗
          No. Work on the IR.
  2. api · · focus · HN ↗
    Why does this need a new language? Aren't there existing languages where these concepts can be expressed?
    1. classified · · focus · HN ↗

      [dead]

    2. paufernandez · · focus · HN ↗
      Yeah, Mojo.
    3. imtringued · · focus · HN ↗
      This language is basically a superset of Rust with a bunch of changes that could perhaps be added in the future.

      I think the compiler was written from scratch though.

    4. librasteve · · focus · HN ↗
      even when the underlying language is widely used (in this case, Rust) I think there is a case to coin a new language when (i) there is a bunch of new stuff, (ii) it ain’t gonna be adopted wholesale by the core team and (iii) it has a coherent toolchain and (iv) it makes promises to coders that are stable over time. Disclosure, I am the author of <a href="https:&#x2F;&#x2F;bil-lang.org" rel="nofollow">https:&#x2F;&#x2F;bil-lang.org that pulls the same trick as an extension &#x2F; transpiler targeting golang
  3. amelius · · focus · HN ↗
    &gt; Vx is the right language for the thing that must be correct and fast across ten kinds of silicon. It is not the right language for the thing you are still figuring out.

    Sounds like a great language for an AI to use then :)

  4. png732 · · focus · HN ↗
    Is there a backstory for this being named Vx? Seems a bit too close for comfort to the VxWorks OS, though there seems to be no connection.
    1. Skwid · · focus · HN ↗
      Better than I was thinking: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;VX_(nerve_agent)" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;VX_(nerve_agent)
    2. adityazero · · focus · HN ↗
      That story is buried in a long chat thread between me and Gemini.
      1. librasteve · · focus · HN ↗
        fwiw I recently tried this with ChatGPT. The result (<a href="https:&#x2F;&#x2F;bil-lang.org" rel="nofollow">https:&#x2F;&#x2F;bil-lang.org) came after I dumped the LLM as a name suggester. As a checker and idea source it was fine. The language name space is quite crowded!
  5. Cyan488 · · focus · HN ↗
    &gt; Heterogeneity belongs in the type system, not in the runtime.

    Is the intent that applications developed with this are compiled for target hardware on a machine-specific basis?

    e.g. I define a machine file for my i5 and GTX3080, and another machine file for my gnarly datacenter rack, and the compiler compiles specifically for each?

    That way the same source file is &quot;provable&quot; for different hardware configurations without relying on a runtime to be identicallu implemented?

    1. adityazero · · focus · HN ↗
      &gt; Is the intent that applications developed with this are compiled for target hardware on a machine-specific basis?

      Vx gives you the power to do so, but one can be conservative by putting all the values in the fleet&#x2F;*.vx files to extreme values. An analogy to that would be when we compile for X86-64, we can specify `-mcpu` otherwise by default the compiler picks a conservative backend.

      Vx allows one to define compute elements(number of cores, etc), memory elements (number of distinct memory elements, hierarchy if any) and their relationship (placement, ownership etc). Together they define the toplogoy of a machine. Toplogy goes into machine description files (see <a href="https:&#x2F;&#x2F;github.com&#x2F;vx-lang&#x2F;Vx&#x2F;tree&#x2F;main&#x2F;fleet" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;vx-lang&#x2F;Vx&#x2F;tree&#x2F;main&#x2F;fleet) and the compiler uses them to &#x27;monomorphize&#x27; the program based on that topology.

  6. yewenjie · · focus · HN ↗
    Why is it giving me Vlang vibe
  7. BatchJob · · focus · HN ↗
    Here we go again, why dont we try this again?

    <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Transmeta" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Transmeta

  8. pdpi · · focus · HN ↗
    &gt; Vx is the right language for the thing that must be correct and fast across ten kinds of silicon. It is not the right language for the thing you are still figuring out.

    A bit tangential, but I really *really* appreciate them making this distinction, and wish more people did this. Way too many tools try to advertise themselves as all things for all people, catering to all use cases, and that helps nobody.

  9. IshKebab · · focus · HN ↗
    Ugh guys... The front page of your project is the most important thing there is. If you can&#x27;t even be bothered to write it yourself then I don&#x27;t have much hope for the rest of your project.
    1. dev_dan_2 · · focus · HN ↗
      I would argue that it does a good job at pre-selecting its core intended userbase.
    2. Muromec · · focus · HN ↗
      Right, right? I see the llm smell seeping through the quotes shared here without even visiting
      1. airstrike · · focus · HN ↗
        [delayed]
    3. NBJack · · focus · HN ↗
      And it doesn&#x27;t seem to render correctly on mobile. I hit this myself trying to vibe up a side project; it looked slick, but it took multiple prompts (and at least an uploaded screenshot or two) just to make it mobile friendly.
    4. nvme0n1p1 · · focus · HN ↗
      It&#x27;s one of those projects you don&#x27;t even have to open the page to tell it&#x27;s AI slop, you can tell from the title.
    5. criemen · · focus · HN ↗
      It doesn&#x27;t even make sense.

      &gt; On Apple&#x27;s unified memory that transfer compiles to almost nothing. It is still written down, because data locality should be provable by reading the source rather than by profiling the binary.

      How does profiling the binary play into this? Elsewhere the hypothesis is &quot;it crashes&quot;, whereas profiling is about performance.

      &gt; Most languages treat the accelerator as infrastructure: you write math, and a large opaque runtime decides how to ship it. Vx treats it as semantics.

      What does that mean? Vx doesn&#x27;t treat the accelerator as infrastructure? Vx doesn&#x27;t have a large opaque runtime? &quot;You write math, Vx treats it as semantics&quot;. I don&#x27;t understand that.

      1. lmz · · focus · HN ↗
        Can sort of make sense of the transfer and performance bit as: the location is encoded as part of the data type instead of some sort of automatic spillover to main memory that will behave differently based on data size.
  10. dev_dan_2 · · focus · HN ↗
    Always nice seeing others arriving at similar conclusions! Those two jump out to me:

    - &quot;Most compilers hard-code a cost model. Vx reads one. A machine file describes the memory hierarchy and interconnect of a real part, and the compiler admits or rejects placements against it.&quot; I also designed it so that the target system is described by a single file that is picked up by the static analysis - cool!

    - &quot;Where data lives is part of its type&quot; also doing that - when I got my project to an mvp state; I need to check out how vxlang does what it does: do they use a literal typesystem, or also compile checks outside of that? If its a type system, is it a dependent type system, or another flavor?

    Yet another motivation to finally get my side project starting (forth-adjacent, many similar claims with regards to compile-time checks as vxlang; however, I still have to achieve that, while they already seem to have at least those and more in place; kudos to the vxlang team!)

  11. jack_h · · focus · HN ↗
    I&#x27;m reminded of a number of critiques that have popped up over the years such as &quot;C Is Not a Low-level Language: Your computer is not a fast PDP-11&quot; and others I can&#x27;t remember at the moment. In essence our &quot;low level&quot; languages are designed to run on an abstract machine that hasn&#x27;t changed much since the 70s while the actual hardware it&#x27;s meant to abstract over has become incredibly sophisticated. As a simple example consider how many programming languages have something simple like SIMD support without dropping into compiler intrinsics or relying on the optimizer.

    I&#x27;ve actually created some experimental DSL embeddings around this idea before as I find it a fascinating area. Skimming through the Vx docs it seems like it is moving some of the abstract machine into the type system for greater flexibility.

    1. kurthr · · focus · HN ↗
      Many x86 CPUs most since the PDP-11 were designed were designed around the languages (often C&#x2F;C++) that they support. For example the introduction of AVX for SIMD with un-aligned memory and load-store cues for unrolling loops with pointers across memory boundaries without penalty. C++ of course also evolved.

      It&#x27;s important to note that there was a huge shift from RISC to CISC to speed decode and then to vectorization and virtualization. The former was driven at first to allow higher clock speeds, and then when that hit a power wall ~2004 to raise data throughput and allow multi-threading (which required code changes), and then multiple virtual machines.

  12. ricardobeat · · focus · HN ↗
    A website explaining a new programming language tries its best. It is still not enough, because AI-generated writing needs some level of human attention, rather than let it degenerate into slop.

    Please dedicate ten minutes of your time to reviewing your copy — so a person interested in your project walks away with understanding, not angry thoughts at three in the morning.

  13. dreamoffire · · focus · HN ↗
    “I’d like the best programming language! Look at what people like about Rust, Mojo and Zig and come up with specs for it!

    Oh don’t forget we need to think of the future… Make sure we can run on GPUs.

    Try not to sound too LLMy.

    Don’t mess up.”

    I wish you luck I guess

    1. librasteve · · focus · HN ↗
      I have come slowly to the view that LLMs are very good at this kind of thing and we can use them very productively. I’m tempted to say that this is optimal human+LLM collaboration.
      1. dreamoffire · · focus · HN ↗
        Are you not biased having created another PL in a similar fashion?

        This is collaboration in the same fashion as a group project in school. One kid never shows up or does any work and expects to put their name on it.

        It’s hard to take you all seriously when your first instinct is to pop open an llm to even name your project. I mean c’mon that’s the funnest part!

  14. ind-igo · · focus · HN ↗
    I&#x27;ve seen a lot of hype around this language, but I still haven&#x27;t found what&#x27;s the main advantage over using mojo.
  15. teo_zero · · focus · HN ↗
    &gt; One Language, Every Chip [...] CPU, GPU, NPU [...]

    Every chip? For example if I target an Intel Meteor Lake (I&#x27;m not picking a niche one), does it compile for this CPU, its integrated NPU and its Arc GPU?

    1. heartlights · · focus · HN ↗
      IIUC, anything supported by LLVM is fine. The language piggybacks on llvm mlir. So, you should be able to target that.
      1. teo_zero · · focus · HN ↗
        But Vx needs a &quot;machine file&quot; for each target hardware, and none is provided for Intel:

        &gt; The repository ships machine files for H100, H200, B200, A100, MI300X, Apple M4 and multi-GPU nodes

        So it seems it won&#x27;t work out of the box.

  16. Archit3ch · · focus · HN ↗
    &gt; One Language, Every Chip

    Every chip? I bet it can&#x27;t target analog chips, what with the pointer talk and all...

    1. librasteve · · focus · HN ↗
      TTL4?
  17. Lichtso · · focus · HN ↗
    Minus the NPU target, if you want Mojo in Rust there is <a href="https:&#x2F;&#x2F;github.com&#x2F;tracel-ai&#x2F;cubecl" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;tracel-ai&#x2F;cubecl
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.