9 ms·
Buzz: A lightweight statically typed scripting language
- spenczar5 3y agoI admire people who make projects like this. But it is so alien to me to try making something like a language. What is the motivation, and the goal? Surely it is practically a one-in-a-million chance to actually unseat Python or bash or Lua. I could never really justify using something like Buzz in a professional setting, just because it is too obscure and new. And look - if it is just for the joy of it, I get it! But I wonder if there is ambition in there too.
- AYBABTME 3y agoIt's useful to have embeddable languages that fit one's preferred style and featureset. It's also not as hard to implement as you'd think. Common usages are anything requiring configurable behavior: game scripting, feature extension, distributed computing plugins, etc.
- echelon 3y ago> actually unseat Python or bash or Lua These languages each have enough warts that lots of people and languages are chipping away at them. Go and Nim are doing the strong static typing that "feels like scripting" thing. Even Rust is making a bit of a dent, despite it being a systems language with memory semantics. There's plenty of room for all sorts of projects to try. Don't count anyone out. Even if the language never gains momentum, its ideas or developers might have some other effect. And even Nimrod was once in this state.
- PerryCox 3y agoThis is an excellent point and I think that while most languages will fade away in time, if they even contribute one new idea the project is worthwhile. If we had asked programmers in 1991 what the point of Python was, the responses would have probably been similar to the parent comment, and look at where it is now. I played around with Vala (a C# style language that compiled to C on Linux) back in 2010 and while I never used it for anything serious, it was fun to try out new ideas and see how they could work. There is value in these projects, maybe some of it will carry over into other languages, in others they may be the dominant language in 10 years.
- Jach 3y ago> If we had asked programmers in 1991 what the point of Python was, the responses would have probably been similar to the parent comment, and look at where it is now. I disagree, because back in 91 Guido released some rationale along with the language: https://www.tuhs.org/Usenet/alt.sources/1991-February/001749.html https://www.tuhs.org/Usenet/alt.sources/1991-February/001749... > This is Python, an extensible interpreted programming language that combines remarkable power with very clear syntax. > This is version 0.9 (the first beta release), patchlevel 1. > Python can be used instead of shell, Awk or Perl scripts, to write prototypes of real applications, or as an extension language of large systems, you name it. There are built-in modules that interface to the operating system and to various window systems: X11, the Mac window system (you need STDWIN for these two), and Silicon Graphics' GL library. It runs on most modern versions of UNIX, on the Mac, and I wouldn't be surprised if it ran on MS-DOS unchanged. I developed it mostly on an SGI IRIS workstation (using IRIX 3.1 and 3.2) and on the Mac, but have tested it also on SunOS (4.1) and BSD 4.3 (tahoe). > Building and installing Python is easy (but do read the Makefile). A UNIX style manual page and extensive documentation (in LaTeX format) are provided. (In the beta release, the documentation is still under development.) etc. Docs/tutorials were later fleshed out even more but always had some rationale: https://docs.python.org/release/1.4/tut/node4.html https://docs.python.org/release/1.4/tut/node4.html Clojure has an explicit rationale page: https://clojure.org/about/rationale https://clojure.org/about/rationale If the authors don't even make a value proposition themselves, I assume the language is a learning exercise and won't take it seriously. Also not really worth critiquing things I don't like about it. Indeed, I see on the introduction: > It started as a toy language following the excellent book Crafting Interpreters by Robert Nystrom. Nothing wrong with that! Sometimes the value is mainly for the author, and that's great. Probably not going to contribute any new ideas though.
- bmitc 3y agoNothing is making a dent in Python. It's momentum is almost unfathomable in certain fields.
- corethree 3y agoI don't know about Nim, but Go does not feel like scripting. It feels like C-style programming. Really old school and not good for scripting at all.
- brabel 3y agoCompletely agree... but when people like a language, they may still want to write scripts in it even though it may be really uncomfortable. That said, Nim is actually designed to feel like a scripting language... for example, you don't write a main function at all, just code away (this is an actual hello world program in Nim): echo "hello world" So, out of statically typed languages, Nim is probably one of the best choices for scripts.
- rickydroll 3y agointeresting. has chatgpt/copilot been trained on nim to the point where they creates code as good they do with python? I ask because I've always treated coding as a necessary evil. When I worked as a programmer, I never gave 2 shits about the language I was required to use. I'd write a specification, code to the specification and tried to update the spec if I need to deviate from it. Because of my damaged hands, now, I do not have enough typing capacity to learn a new language the old trial and error way. chatgpt is my accessibility tool for creating code. I've learned how to give chatgpt a spec, skip the coding step and goto validation. I've trained myself and chatgpt/copilot to generate python code like I had created it, making desk and unit testing easier and faster. Learning a new language would start with a specification of the problem as above, then seeing what chatgpt/copilot generates. However, it is easier to learn if the LLM model understands the language. It is sometimes hard to tell the difference between hallucinations in the code vrs hallucination in the specification.
- cb321 3y agoIt ultimately depends upon what you mean by "as good". There is no clear single metric. Once you have >1 metric it becomes a subjective "who's priorities?" game of weighting them / projecting them into a single metric. The best answer to a question like yours is: give it a try on some easy problems and see what you think yourself. No one else can really know the kinds of problems / answers / code you most work with (and sometimes the future is pretty murky even to oneself, even in these vague categories). Disclaimers issued, some things can be said which might help. Since Nim is primarily a highly ergonomic static ahead-of-time compiled language with code running as fast as C often does, errors may be caught more conveniently. Because Python is popular, especially for teaching programming, training coverage will always be better, but Nim has some core features & keywords "kinda similar" to Python which may help on the other side. Not sure about 4.0, but ChatGPT-3.5 does poorly on basic Nim things without Python equivalents. To give just one concrete example (out of many), `a,b = b,a` is a common way to manifest swapping in Python while in Nim one uses `swap a,b`. So, if you are willing to do more "compiler-assisted clean-up" or have a/develop a knack at steering the random sampling toward code which compiles, Nim could be about as effective as Python used this way. In terms of code entry work for your specific hands problem, parentheses can often be left off in Nim code and in general it seems to have much less punctuation / syntactic noise. Of course, keys can be rebound & such & maybe you do that, too. Nim definitely has more powerful abstraction mechanisms like user-defined operators, templates, and syntax macros.
- gloryjulio 3y agoI won't even use my own language. But writing compiler is a great practice!
- padjo 3y agoIt’s surprisingly easy to write an interpreted language and I’d highly recommend it as a learning tool. You get a really good intuitive sense of how programming languages work by doing it.
- quickthrower2 3y agoEspecially if you are happy with the parent language’s semantics around arithmetic and basic types.
- wokwokwok 3y agoFYI, for the interested, https://github.com/buzz-language/buzz/issues/209 https://github.com/buzz-language/buzz/issues/209 > You have to use the nightly build of zig. ie. `brew install zig && zig build` will not work.
- flohofwoe 3y agoZVM (https://github.com/tristanisham/zvm https://github.com/tristanisham/zvm) is a good alternative to keep uptodate with Zig nightly versions and also quickly switch to a stable version when needed.
- djur 3y agoWhat should I be looking for here that distinguishes it from other lightweight statically-typed scripting languages? Performance? Tooling? Particularly good FFI? There are some syntactic quirks that don't convey any obvious benefit, like the use of '>' to indicate a return type. Since this language uses C-style prefixed type identifiers, why not do that for functions as well? Alternately, why not use the much more common ':' or even '->'? The use of a doubled return type (`> str > int`) to indicate yields is obscure, and the fact that the second type is the yielded type is surprising (yields come before the final return, so I'd expect the types to be in the same order). Similarly, I understand the mimetic quality of '[str]' for 'array of str', but '{str, int}' doesn't have the same ring since key/value pairs are separated by ':'. Comments starting with '|' feels like pure quirk. I don't really mind quirk in a tiny language like this, but there's a point where "funny syntax" becomes a bigger takeaway from the documentation than any actual features.
- basro 3y agoWhat would be the other lightweight statically typed scripting languages? There really aren't many.
- Deukhoofd 3y agoI've used AngelScript in the past for some hobby projects, and had a lot of fun with it. https://www.angelcode.com/angelscript/ https://www.angelcode.com/angelscript/
- deleted 3y ago[deleted]
- cabalamat 3y ago> There are some syntactic quirks that don't convey any obvious benefit, like the use of '>' to indicate a return type. [...] why not use the much more common ':' or even '->'? Agreed. New languages should use similar conventions to popular existing languages, for the sake of familiarity, unless there are obvious benefits to doing something else. > Similarly, I understand the mimetic quality of '[str]' for 'array of str' It's quite Haskell-like. > but '{str, int}' doesn't have the same ring since key/value pairs are separated by ':'. Indeed. `{str:int}` would be better.
- lifthrasiir 3y agoNot explicitly mentioned in the guide, but Buzz has a garbage collector [1] (can also be inferred via a casual mention of upvalues). So it has more focus on scripting than static typing I guess, but the language design doesn't look so to me. [1] https://buzz-lang.dev/reference/std/gc.html https://buzz-lang.dev/reference/std/gc.html
- IshKebab 3y agoStatic typing is orthogonal to scripting or GC.
- naitgacem 3y agoEnglish is not my native language, and "orthogonal concepts" always mean something along the lines of "mutually exclusive" in my head.
- tubs 3y agoIt is used to say that there isn't really a relationship between them.
- teo_zero 3y agoNot at all, it means independent from each other. Like the x and y coordinates of a point in a plane: you can set one of them to the value you want and it won't affect the other. This only happens when the x and y axes intersect at 90°, hence the "orthogonal".
- quickthrower2 3y agoGood explanation. I first got confused by this colloquial use of orthogonal even though having done a course on vector spaces!
- lifthrasiir 3y agoYes, but "statically typed scripting language" is a quite unusual combination of words [1], and there seemed nothing to back up the "scripting" concept, so I thought it might be something more akin to Nim or Zig (i.e. "scripty system programming"), and it wasn't. That was a missing line of thought that I should have explicitly stated, sorry for the confusion. [1] Especially when no type inference was mentioned.
- mdgrech23 3y agoI mean this looks awesome and all but I feel like constantly developing/learning new languages and frameworks has been such a giant waste of resources in our community in general. I hope things stabilize in the future. I've got 15 professional years under my belt at this point and I don't feel like an expert in anything.
- flohofwoe 3y agoI think the only reason why there was a temporary "language bottleneck" in the late 90s and early 2000s was that CPUs got too complex around that time to deal with the resulting code generation complexities in a "homebrew compiler". LLVM and later projects like Cranelift changed that, and now it's possible again for individuals and small teams to create new languages which have competitive performance. In my book that's great, competition and experimentation is always a good thing for progress (even when it means there's also many more hobby projects that won't move the needle).
- chupapimunyenyo 3y agoThe comments here are so bitter. I love the syntax and will definitely try the language
- lelanthran 3y ago> Objects, list and maps variables are only reference to them. Meaning you can't assign a new list to a constant variable but you can modify the list itself. In what contexts is this useful? I know it matches some other languages view of `constant`, but I feel that this sort of behaviour is very surprising to a user. Assuming the following code: object Person { str name = "Joe", | Fields can have default values int age = 35, } const me = Person{...} const [int] list = [4, 5, 6] In what contexts is it useful to allow the name of `me` to be changed, or the length of the list to be changed, while disallowing the variable to reference a different underlying object? Wouldn't the expectation of a programmer be the other way around? IOW, a symbol that is declared as constant can be a reference to any constant object, so the programmer can always assign that symbol to another constant object, but the objects themselves should not be mutable.
- hannofcart 3y agoI guess this works like the Javascript `const` keyword.
- pkulak 3y agoJava too. Rust is the only language I’ve used where “immutable” means everything through the whole reference tree is also immutable. Well, only language that allows mutation at all.
- IshKebab 3y agoAnd C/C++. Probably other value based languages like Go and Zig. JavaScript probably behaves like that because `const` was tacked on (and it's dynamically typed so there's no place to mark parameters as const). There is Object.freeze() which sort of makes something immutable, but it's not really the same. Java doesn't even have const so I guess they just didn't care about const correctness or didn't have time to add it.
- cowsandmilk 3y ago
- hannofcart 3y agoHonestly, except for some of the syntactic quirks, this looks fabulous. I definitely think there's a need and space for type-safe embeddable scripting languages like this. Lua usually dominates this space but the lack of type-safety always kept me from adopting it wholeheartedly. With Zig also in the picture, I can totally imagine an ecosystem that uses something like Buzz for scripting the high level parts of an application, Zig for the lower level performance critical stuff, and leveraging interop with the vast abundance of C libraries out there.
- lifthrasiir 3y agoIf you need Lua but also type-safety, how about Luau [1] then? [1] https://luau-lang.org/ https://luau-lang.org/
- hannofcart 3y agoWow, this looks great. With gradual typing too! Helps slowly port existing Lua projects over. Thanks for linking to this.
- TheCipster 3y agoYou might find https://nelua.io https://nelua.io interesting.
- erlend_sh 3y agoThere’s also Teal, a typed dialect in Lua, written in plain Lua: https://github.com/teal-language/tl https://github.com/teal-language/tl
- Herbstluft 3y agoSomething that the page does not seem to comment on: will easy embeddability, like with lua, be a priority for this project? Especially in Zig (obviously). It's the most interesting question and use-case that comes to mind.
- benrutter 3y agoThis comment section is very "why write a Language?" oriented. I love reading about new languages!! I work with data scientists a lot so I'll probably always use Python professionally, at least for the foreseeable future. But Python, JavaScript etc are huge languages with massive histories of practical trade offs and compromises. It's always exciting to see what someone's dream language looks like! Besides, learning languages like Rust and Clojure has taught me a huge amount that's transferable to coding in other languages like Python. I like the idea of a lightweight json focused / typed scripting language a lot!
- djur 3y agoI would hope that if someone designs their dream language they can explain what excites them about it. I'd love to read that.
- bmitc 3y agoFor me, it's that this language already exists in F#. Other than "lightweight" (.NET probably inatalls just as fast as Python these days, though), it is the statically typed scripting language, in my opinion.
- christophilus 3y agoI love me some F#, but F# isn't a scripting, and it's compile times were pretty terrible the last time I used it on Linux. It's been a while, though, so maybe things have improved.
- bmitc 3y agoWhy do you say it's not a scripting language? You can write .fsx files and run them as scripts, and there's a nice REPL. Using Polyglot Notebooks, you can even combine several languages, including F# and PowerShell, and documentation and run the notebooks as scripts. Were you running F# with modern .NET, i.e., .NET5+?
- edgyquant 3y ago
- pkulak 3y agoFun! I’m always on the lookout for a new scripting language. I hate Bash, and Python just isn’t my style, even though it’s currently my default. Something like Kotlin would be my dream, but that’s still pretty hard to use for quick scripts. Going to look closely at this.
- di4na 3y agoIf you are interested in writing down more of what problems you have with scripting languages, feel free to shout me an email. Should be in profile. I have been slowly working on a model of what problems i see in this domain and my own ideas to "fix" (or more like try to) them. So would love to see other perspectives.
- cjdell 3y agoYes! We're finally challenging the notion that scripting languages must inheritly be dynamically typed. Some say that types are too much of an overhead for small programs but I find it impossible to reason about the design of software without types. I even opt for TS over JS for throwaways...
- junon 3y agoThere have been statically types scripting languages for ages. Embeddable ones, too. That's not new.
- cjdell 3y agoAny in particular that you're a fan of? (Genuinely curious)
- jlokier 3y agoNimScript comes to my mind. You get most of the Nim language, which is statically typed and versatile. But NimScript is interpreted immediately, like running a Python script, instead of compiled to an optimised binary like regular Nim.
- otteromkram 3y agoIf you don't want to run awkward searches through your main Google account, DuckDuckGo provides decent results.
- cjdell 3y agoI didn't know DuckDuckGo could find me results about a particular person's preferences. Yes you can Google pretty much anything that you can have a conversation about and never speak to anyone. What is your point?
- replwoacause 3y agoNot really sure he has one. I was confused too.
- sherjilozair 3y agoI’ve been trying to find a maintained typed scripting language. Thank you for building!
- teo_zero 3y agoWhat makes a language a "scripting" one?
- flohofwoe 3y agoFor me it's when it's useful for writing adhoc utility tools distributed as source, and directly runnable from source code in the terminal and without requiring a manual compilation step (but maybe requiring installing a runtime). E.g. Python, JS/TS with node.js/deno, Lua, Bash, Powershell qualify as scripting language, but C, C++, Rust are not. Of course there's a grey area of compilers which allow compiling and running a "script" via shebang.
- teo_zero 3y agoSorry, but I strongly disagree with your explanation. It seems to categorize languages on the basis of what tools are available or widely used. That's not a property of languages. A language can be designed once and then interpreters and compilers (and transpilers) can be made available for it. Python is a classic example: it's most commonly interpreted, but can be compiled when performance matters. C is usually compiled, but tcc offers the option to directly run it from source (-run). History has given us both compilers and interpreters for various dialects of BASIC since the 80s. Honestly I can't imagine why a language designer should decide upfront if the result of their study will be interpreted or compiled. And I have no idea what choices should they make to characterize it as a "scripting" language.
- mek6800d2 3y agoSlight correction: TCC is not interpreting the source file - it compiles and links the program and then runs it.
- naasking 3y ago> A language can be designed once and then interpreters and compilers (and transpilers) can be made available for it. While strictly true, some language features are awkward or unsuitable for scripting purposes. For instance, C++ templates and Haskell's type classes with extensions that make overload resolution Turing complete. You can do this, but it seems like a poor choice where the language ostensibly has runtime evaluation and type information available, and so you don't need to so strictly stratify the types and values. This collapses effectively two programming language levels into one, and considerably simplifies quite a bit of the runtime, compiler/interpreter, and the programs that can be expressed in the language
- SeasonalEnnui 3y agoI have seen a few comments expressing a desire for a statically typed scripting language. I’ve been using a new workflow for a couple of years I’d like to share. Install .NET 8, and create a new C# Console application. From .NET 6 onwards, it uses the new “top level statements” style which is effectively like the blank slate of a script file. The barrier to entry has never been lower. (https://learn.microsoft.com/en-us/dotnet/core/tutorials/top-level-templates https://learn.microsoft.com/en-us/dotnet/core/tutorials/top-...) This lets you take advantage of a really healthy toolchain/package manager ecosystem. You can take this a step further by using VS Code with the Polyglot Notebooks extension to get a Jupyter-style experience with C# code. (https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.dotnet-interactive-vscode https://marketplace.visualstudio.com/items?itemName=ms-dotne...)
- tabokie 3y agoNice logo!
- Alifatisk 3y agoIs there a compiled list of all these new languages? Also, my only concern in the future is that I have to download 10+ different runtimes to my machine to be able to co-operate with others. But I guess Docker solves this.
- tines 3y agoThis looks awesome! Couple of questions: 1. Does it support any type inference? 2. It looks like objects have to explicitly declare what protocols (interfaces?) they implement when the object itself is declared. Is that true? If so, why did you opt for that rather than the typeclass approach where the struct is declared separately from its interface implementations?
- johnwbyrd 3y agoWe don’t need any more computer languages. Still, you will run right off and invent another one. Let me guess, your amazing new language uses IEEE-754 math and fixed-precision integers. Your amazing new language is broken. https://www.quora.com/What-are-some-things-that-only-someone-who-has-been-programming-20-50-years-would-know/answer/John-Byrd-2 https://www.quora.com/What-are-some-things-that-only-someone...
- aragilar 3y agoA language without easy access to IEEE-754 math and fixed-precision integers that is supposed to run on common/standard hardware (i.e. not for FPGAs or more specialist hardware) is broken for the majority of the tasks it will be doing. That's not preventing you from having other numerical types which meet the needs of various groups (e.g. arbitrary precision types or types for financial maths), but to explicitly exclude them even though the hardware provides them is a problem.
- johnwbyrd 3y agoClassic premature optimization, assuming that hardware functions must be revealed in language features. If you can't get your integers closed under addition from the get-go, what hope do you have of writing a secure programming language?
- replwoacause 3y agoLooks nice!
- h8hawk 3y agoDoes it have REPL? Scripting without REPL is just weird for me.