top | item 33690989

Show HN: Buzz, strongly typed scripting language written in Zig

140 points| giann | 3 years ago |github.com | reply

68 comments

order
[+] caioariede|3 years ago|reply
Love it! The only thing that was a “meh” for me was using pipe for comments. It’s the only thing that I found to be unintuitive, which I very much like to see whenever I’m looking at a new language.
[+] mcluck|3 years ago|reply
I kind of like it. It looks like a blockquote
[+] HKH2|3 years ago|reply
Do any other languages use it for comments?
[+] mysterydip|3 years ago|reply
Maybe I'm just old, but first thing I would look for in a strongly typed language is int vs float, but all I see here is num. Is a single numeric type expected for modern languages?
[+] hhvn|3 years ago|reply
I think it's more to do with it being a scripting language. Scripting languages are designed to be quick and easy to write, so instead of having to deal with int/float etc, the language can do it for you.
[+] Deukhoofd|3 years ago|reply
> Numbers are either internally i64 or f64 and are coerced from one to the other as needed

I agree, not quite my preference in scripting languages. I prefer to be able to deal with numeric representation.

[+] giann|3 years ago|reply
I'm not excluding the idea to allow the user to choose between the two. But the language must remain simple and relatively high level so I'm wary of going down that road.
[+] andyferris|3 years ago|reply
I too would really prefer int & float!
[+] 0cf8612b2e1e|3 years ago|reply
Are there any practical advantages to using Zig vs anything else? Presumably, the cross compilation means this should run everywhere for free, but would love to know if there was anything especially easy/hard with respect to the host language.
[+] pasabagi|3 years ago|reply
It's really good for interfacing with C or writing C ffi's. If you're the sort of person who normally programs in a high-level language, then drops down to C for performance, zig is pretty good for that.

(If you want to compare zig and C, there are frankly a lot of reasons to prefer it, at least in the abstract).

[+] jorams|3 years ago|reply
Looks neat! Reading the docs only a few things stand out as odd to me:

- The common types are written as fully lowercase, shortened words (str, num, fib) but then function types are written as Function(). That seems like a weird exception.

- The use of a comma to delimit object fields, but a semicolon to delimit static fields, seems arbitrary.

- If brackets around control flow blocks are required, which they seem to be, then parentheses around the conditions seem unnecessary.

[+] jerf|3 years ago|reply
Curious what the author is thinking of when calling this a "scripting language"? I personally don't have much trouble imagining a strongly-typed scripting language, but that definitely goes against the flow of the past couple of decades. Is it that it is garbage collected? That's about all I can see that would make this immediately obviously a "scripting language". It doesn't seem like it ought to be intrinsically as slow as what usually gets called a "scripting language".

To be clear, this is an honest question, and possibly something the author should consider answering, intended as feedback, not a criticism. I'm open to it. I'm also curious and I'm sure I'm not the only one. (Either way I definitely would suggest mentioning if it's garbage collected or not. It's an important point.)

[+] giann|3 years ago|reply
Author here. A few points make buzz a “scripting language” in my view: - runs in a VM - garbage collected - high level - “simple” meaning there’s only a handful of concepts to understand to use it

It’s true that we’re not used to scripting languages having a type system. But its a trend that is catching on: python has types, php too and typescript is at its peak in popularity to name a few.

[+] PartiallyTyped|3 years ago|reply
I don’t want to be that person but technically python is a strongly typed scripting language as it has no type coercion but instead uses structural typing.
[+] fzzzy|3 years ago|reply
You might be thinking about the distinction between statically typed and dynamically typed languages. There are plenty of strongly typed scripting languages. Python is strongly typed; JavaScript is weakly typed.
[+] 3a2d29|3 years ago|reply
Reading this comment, I realized I always thought:

Scripting == interpreted

Is that not the case?

[+] andyferris|3 years ago|reply
I love the idea of a statically typed scripting language! Overall it seems pretty cool.

Really the biggest distraction is that the static typing is lost between int and float with the catch-all num type. I think this will make it harder to program in, not easier (reasoning about where NaN, Inf, under/overflow, rounding etc might occur will depend on some choice it makes internally so as a programmer may need to give up and “assume the worst” everywhere!)

You can still keep it nice and easy and scripty with literals like 1 vs 1.0, and not worrying about number types other than signed Int64 and Float64.

[+] ninjabeans|3 years ago|reply
Is there any difference between a statically typed scripting language and a statically typed compiled language that compiles in <.1s?
[+] chomp|3 years ago|reply
I like this! It looks really comfy to write.
[+] semiquaver|3 years ago|reply
> No nonsense coercion

Given that the focus is on being unambiguous I found this line a bit amusing. Maybe it’s me but I can’t tell for sure whether this describes a quality of the language’s coercion mechanism or a promise that the language will include no such “nonsense” like e.g. javascript :)

[+] giann|3 years ago|reply
This means the language will never coerce things for you implicitly. Booleans are true and false not 1 and 0 or “true” and “false” etc.
[+] MrBuddyCasino|3 years ago|reply
Looks nice. Two things that turn me off:

- pipe for comments

- error handling via exceptions: I prefer monadic Result<Success, Error> types a la Rust, exceptions obscure control flow and are try/catch us unnecessarily verbose

[+] cmoski|3 years ago|reply
I find the choice to sacrifice | for comments rather peculiar. It's so commonplace for | to be or.
[+] melony|3 years ago|reply
Can the ffi be made more seamless? It's rather annoying doing it by hand.
[+] giann|3 years ago|reply
It’s planned yes
[+] rho4|3 years ago|reply
just for your information: the logo resembles islamic flags
[+] jcoder|3 years ago|reply
It’s pretty obviously an astronaut looking out at space. Buzz (Aldrin/Lightyear), get it? Would it be an issue if it did resemble an Islamic symbol?
[+] badrabbit|3 years ago|reply
I disagree, they usually have green or black. I don't recollect them using stars either.
[+] tmtvl|3 years ago|reply
Yeah, I think making the icon an octagon rather than a circle would help.
[+] snovv_crash|3 years ago|reply
No, it resembles a safety pin and stars, the well known Society for Communist Seamstresses flag.