Live data from Hacker News

Moonbit: Fast, compact and user friendly language for WebAssembly

moonbitlang.com

101–110 of 162 posts

Re: Moonbit: Fast, compact and user friendly language for WebAssembly

#101
post #90

I’ve been considering trying my hand at a C-like WASM language, with most features mapping directly to WASM instructions. Surprised no one’s done something like that yet. Very cool tech

What about AssemblyScript? https://www.assemblyscript.org/

Re: Moonbit: Fast, compact and user friendly language for WebAssembly

#102
post #10

Earlier quoted context omitted.

I think the Rust and Go comparisons are because they’re popular languages with first class WASM support but I agree

Why didn't they include Zig and AsssemblyScript, then?

No clue, maybe they performed too well :p

Re: Moonbit: Fast, compact and user friendly language for WebAssembly

#104
post #9

The site compares it to Rust and Go but to me the comparison is AssemblyScript. It’s also WASM-native and new with relatively little ecosystem around it. But compared to Moonbit it’s a familiar language to anyone that’s used TypeScript. So why use Moonbit over AssemblyScript?

Because Moonbit is a modern language, while AssemblyScript is carrying forward the mistakes of the past. For example, Moonbit supports pattern matching and most language constructs are expressions. AS doesn't have pattern matching and consists primarily of statements. Moonbit has algebraic data types; it's not clear to me that AS does. There might be other differences at runtime, but it's difficult to tell from just…

> Because Moonbit is a modern language, while AssemblyScript is carrying forward the mistakes of the past.

No language has "no mistakes".

For instance, let's take a language like Scala, which appeared 20 years ago. Has it avoided mistakes of the past? Or lets take Rust, which appeared 8 years ago. Is it "perfect"? Same with Moonbit; it will make tradeoffs and mistakes and whatnot.

Mistakes are not always technical in nature either. They can be mistakes in positioning, strategy, community, governance, poor documentation, etc.

Re: Moonbit: Fast, compact and user friendly language for WebAssembly

#105

Hi, I am the lead of this project, you can try it now with our online IDE, https://try.moonbitlang.com (F5 to run) The docs are available https://github.com/moonbitlang/moonbit-docs , the compiler would be publicly available when we reach the beta status (expected to be the end of Q2 in 2024). Feel free to ask me any question

* Is there a need to differentiate func and fn? * Part of the function signature is "->" to indicates what it returns. Is this arrow needed? * For new types, you use syntax "struct User". I think Go got it right in this case where types are created with "type User struct", which can also create function types for fn variables like "type AssignUser func(name: String, id: Int) -> Int". * Does it help the lexer/parser to have the ":"? In function signature, do you need the ":" in func(name: String)? Could it be "func(name String)"? Same with type declaration but not assignment "mut elems: List[Int]", could that not be "mut elems List[int]"?

I'm picking nits. Overall I like it.

Re: Moonbit: Fast, compact and user friendly language for WebAssembly

#106
post #83

Earlier quoted context omitted.

It clearly states: it targets web assembly. So, this should answer your question I think

> It clearly states: it targets web assembly. So, this should answer your question I think Not sure what you're implying. Here's an example of doing graphics using Rust and WASM - http://cliffle.com/blog/bare-metal-wasm/#making-some-pixels And another: https://blog.logrocket.com/implement-webassembly-webgl-viewe... Given that MoonBit is developing their own IDE and it is hosted on the web, I would think one could pro…

A WebAssembly runtime is a pure compute+memory sandbox. It can only interact with the host environment in three ways:

1. The host calls an exported WASM function

2. The WASM runtime runs code that calls an imported function

3. The host reads/writes the WASM runtime's memory/globals

In your example, the WASM build process spits out two artifacts - a WASM module and a JS module. The JS module defines the actual JavaScript host functions that manipulate the canvas, and then exposes those functions to the WASM instance.

Re: Moonbit: Fast, compact and user friendly language for WebAssembly

#107
post #83

Earlier quoted context omitted.

It clearly states: it targets web assembly. So, this should answer your question I think

> It clearly states: it targets web assembly. So, this should answer your question I think Not sure what you're implying. Here's an example of doing graphics using Rust and WASM - http://cliffle.com/blog/bare-metal-wasm/#making-some-pixels And another: https://blog.logrocket.com/implement-webassembly-webgl-viewe... Given that MoonBit is developing their own IDE and it is hosted on the web, I would think one could pro…

> I would contribute in this realm becase I'm a graphics and UI person and also enjoy working with new programming languages.

Maybe the case of Makepad will interest you then: https://news.ycombinator.com/item?id=36567681

https://github.com/makepad/makepad

Re: Moonbit: Fast, compact and user friendly language for WebAssembly

#108
post #88

Earlier quoted context omitted.

Yeah, Go has to embed the whole runtime and that amkes for huge payloads. I'm interested in your experience as I've been working on wasm SPA with Go. How does it crash? Seems to me that there are examples of stable webapps (for instance using go-app). Were you using a framework or raw syscall/js call? Have you tried compiling with tinyGo?

I've been using my own wrapper/library around syscall/js. It crashes mostly due memory issues/allocation. My own app worked fine until a point and then it started crashing. I applied several temporary fixes by limiting the amount of memory it allocates at start-up. Then optimised various libs to use less memory such: - instead of generating the html in pure Go using x/html package and applying it to the DOM later I c…

I see. In my experience, the wasm target is very allocation-sensitive.

I've had to implement a few free-lists myself and went for allocation hunt.

Perhaps it's a memory leak somewhere.

If you have some code example, maybe I can have a look.

Re: Moonbit: Fast, compact and user friendly language for WebAssembly

#109

Hi, I am the lead of this project, you can try it now with our online IDE, https://try.moonbitlang.com (F5 to run) The docs are available https://github.com/moonbitlang/moonbit-docs , the compiler would be publicly available when we reach the beta status (expected to be the end of Q2 in 2024). Feel free to ask me any question

The docs don't seem to cover how you're supposed to interact with the host environment from within Moonbit. How do you define imported and exported functions?

Re: Moonbit: Fast, compact and user friendly language for WebAssembly

#110
post #60

Earlier quoted context omitted.

Is having a dedicated fn keyword necessary? I mean, what’s the fundamental difference between a func and a fn ?

Not strictly necessary, we are not decided on it. For func the annotation is required, while fn does not need any type annotation

I would strongly recommend to only go with one syntax, and not differentiate between regular functions and lambda statement
Post reply on HN