Show HN: Buzz, strongly typed scripting language written in Zig
github.com
github.com
#|
This is a multi-line comment
#|
And they can be nested because this is really just a reader macro
|#
|#
I don't think I've ever seen a standalone | for comments, especially since it's so often used as bitwise or logical or.And here they use \ for bitwise or, and the word `or` for logical or.
Internally, float and int are completely different types, 2’s compliment vs ieee754. Conglomerating them to a “number” feels like weak typing.
(Disclaimer: I’m a grumpy C++ engineer.)
Edit: it does look like a neat/useable language though!
The problem I do see with combining int and float is that it means that you always have to be careful with == on any pair of numbers, where a language that does distinguish between the two gives you a clue about when equality will work and when it won't.
But that's a flaw in the number type, not a weakness in the type system.
I agree, not quite my preference in scripting languages. I prefer to be able to deal with numeric representation.
Python, Ruby, or Lua do that. That's less "nonsense" than doing the same but hiding it from the user.
"num" also gives a false impression: before checking, I expected JS's (or Lua < 5.3) behaviour: everything is a double, and you only get 53 bits of integer precision (which is quite frustrating).
An alternative if you want
> simple and relatively high level
is to use decimals, at the cost of complicating the implementation.
No I mean as an actual type, instead of `num` juggling representation internally.
I definitely wouldn't break it out into int, long, float, double, and unsigned variants. That would be too low level for this kind of language.
https://hackage.haskell.org/package/base-4.17.0.0/docs/GHC-N...
(If you want to compare zig and C, there are frankly a lot of reasons to prefer it, at least in the abstract).
- 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.
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.)
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.
Anyways I don't mean to take away from your work;. It looks very cool.
Scripting == interpreted
Is that not the case?
Compiled/interpreted is kind of besides the point.
Julia (compiled, btw), ruby, python, php, perl, bash, JavaScript thus are all scripting languages.
Java, c, c#, go, f# rust, zig, Erlang, some flavors of lisp, node-style javascript, are not.
There are some corner cases. I consider elixir, for example to be a scripting language for it's own compiler which produces a very much non-scripted result.
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.
The main difference between a scripting language and a non-scripting language in my opinion is that a scripting language is called through a host program, which offers configuration and a standard library, while a non-scripting language runs by itself, using the operating system as its environment.
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 :)
- 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
The logo is black, which seems to qualify as "green or black"?
Red and white are also very common (ottoman flag, turkey, tunisia).
> I don't recollect them using stars either.
"Star and crescent" has been common muslim iconography since the 14th century, and the ottoman empire (which introduced them).
It seems to be an extremely dark purple, on a white background it's genuinely indistinguishable from black.
> it isn't a crescent, cuts off at the bottom.
Which is close enough to a crescent for
> resembles islamic flags
to be a perfectly valid take.
It's reaching.
Props to you for seeing it, but I don’t think it’s obvious at all until pointed out.
You already lost me there. ¯\_(ツ)_/¯
https://suzdalnitski.medium.com/oop-will-make-you-suffer-846...
Buzz is not an OOP language.