Bog – small, strongly typed, embeddable language
21–30 of 55 posts
Re: Bog – small, strongly typed, embeddable language
#22Thank you for posting this. > let {print} = import "std.io" An idea obvious in hindsight that I hadn't thought before - if import returns an environment and let can destructure, then a pattern match can bind an explicit subset of that import. Something like: `(let {print read} (import io) (print (read)))` Further down I find essentially that example (with input instead of read) and destructuring assignment within fun…
Isn't this exactly what CommonJS does/did?
To expand, the following was common before destructuring but with CommonJS:
var some_func= require('some_module').some_func
Which, as you know, would probably usually be done like this today, where we have destructuring: let {some_func} = require('some_module')Re: Bog – small, strongly typed, embeddable language
#23Pretty interesting. I'm a professional user of Lua, and while I love it, I really get frustrated at a lot of aspects of it, especially how loose the typing is. I've long wished there were more strongly typed alternatives, but just nothing compares to the performance, stability, and quality of documentation of Lua. I'm not sure how I would embed this in a non-Zig project, though.
There’s a C embed example in the examples folder
Re: Bog – small, strongly typed, embeddable language
#24Somewhat related is yesterday's post about the Cyber programming language, also built on Zig and also embeddable: https://news.ycombinator.com/item?id=34553236 (Not affiliated with either, just can be easy to miss stories on here sometimes, and I figured anyone interesting in Bog might also be interested in Cyber)
Cyber also seems to be under more active development at the moment.
https://github.com/vexu/bog/graphs/contributors
https://github.com/fubark/cyber/graphs/contributors
[0] https://github.com/fubark/cyber/blob/master/docs/docs.md
Re: Bog – small, strongly typed, embeddable language
#25Re: Bog – small, strongly typed, embeddable language
#26Love how this language is explained with code only.
Re: Bog – small, strongly typed, embeddable language
#27Thank you for posting this. > let {print} = import "std.io" An idea obvious in hindsight that I hadn't thought before - if import returns an environment and let can destructure, then a pattern match can bind an explicit subset of that import. Something like: `(let {print read} (import io) (print (read)))` Further down I find essentially that example (with input instead of read) and destructuring assignment within fun…
Something I hate about about c is that you don't know where the hell somefunc() came from. Some languages have foo.somefunc() which I think works quite well although iffooisrealllylong.function() is a risk. I suppose this gets you the best of both worlds. Although using let does seem a bit weird to me. It seems conceptually misleading.
I think you mean something you hate about not using an IDE with the language. One can do `from onoz import *` in python and Java to have a similar "wait, where did do_magic() come from?" experience, and then Scala will see your wildcard import and raise you implicit methods, which can die in a raging fire tornado
Re: Bog – small, strongly typed, embeddable language
#28Thank you for posting this. > let {print} = import "std.io" An idea obvious in hindsight that I hadn't thought before - if import returns an environment and let can destructure, then a pattern match can bind an explicit subset of that import. Something like: `(let {print read} (import io) (print (read)))` Further down I find essentially that example (with input instead of read) and destructuring assignment within fun…
Funny, I find this syntax very obtuse: it looks to me like "print" is being defined as, well, the print function, through a very roundabout name collision. What happens if there is a typo and the code says: let {ptint} =... What error message comes up?
There's not much difference between `obj.attr` and `obj['attr']`.
Re: Bog – small, strongly typed, embeddable language
#29Thank you for posting this. > let {print} = import "std.io" An idea obvious in hindsight that I hadn't thought before - if import returns an environment and let can destructure, then a pattern match can bind an explicit subset of that import. Something like: `(let {print read} (import io) (print (read)))` Further down I find essentially that example (with input instead of read) and destructuring assignment within fun…
Something I hate about about c is that you don't know where the hell somefunc() came from. Some languages have foo.somefunc() which I think works quite well although iffooisrealllylong.function() is a risk. I suppose this gets you the best of both worlds. Although using let does seem a bit weird to me. It seems conceptually misleading.
Re: Bog – small, strongly typed, embeddable language
#30Earlier quoted context omitted.
Have you heard of Teal ( https://github.com/teal-language/tl )? It's like typescript for Lua made by Hisham. It also has the concept of declaration files so you can import (and type) existing Lua modules if needed.
I haven't, but I might have to do a lot of work to get it working, as my typical use of Lua is deeply embedded and customized, and doesn't allow any filesystem access. I will definitely look into that, though, thank you. The only real Lua dialect I'm familiar with in that area is Moonscript.
- https://luau-lang.org (interpreted / sandboxed)
- https://terralang.org (JIT interpreted)
- https://nelua.io (Lua -> C)
- https://typescripttolua.github.io/ (TS -> Lua)
- https://github.com/teal-language/tl (Teal -> Lua)
- https://github.com/sumneko/lua-language-server (IDE only typing)
With minimum effort you can get a lot of benefit from using Sumneko's Lua language server.