curist | 2 years ago | on: Moonbit: Fast, compact and user friendly language for WebAssembly
curist's comments
curist | 3 years ago | on: Ask HN: Why did Frontend development explode in complexity?
curist | 3 years ago | on: WasmEdge
curist | 3 years ago | on: How I Built Zig-SQLite
curist | 4 years ago | on: The Problem with Macros
> But learning programming language theory is the best part :)
That's very true :)
curist | 4 years ago | on: The Problem with Macros
This might be another reason why I find macros less appealing: macros introduce DSL in form of normal s-expression, but they don't actually behave like a function; macros introduce their own mini-language/syntax.
In the last example you provided, I bet the macro implementation would look like a little interpreter? If that's the case, having a function call like
doTexture(myTexture, ['op1', 'op0', 'opR'])
and let doTexture handle each cases(ops), might be able to achieve the same behavior, right?I'm not trying to argue that macros are unnecessary, I really want to like them! Just most of the time, I find functions are sufficient enough.
curist | 4 years ago | on: The Problem with Macros
People use callback function to achieve almost the same thing
function doTexture(texture, fn) {
beginTextureMode(texture)
fn()
endTextureMode()
}
doTexture(myTexture, () => {
drawCircle()
drawRectagle()
})
At the cost of being more verbose, we get the benefit of one thing less to learn; and simplicity is a powerful feature IMO.I guess why this is less popular in lispy languages is because
1. macro
2. callback functions introduce more indent levels :(curist | 5 years ago | on: Speed Is the Killer Feature
curist | 5 years ago | on: Solid – A declarative JavaScript library for building user interfaces
curist | 6 years ago | on: Hippy: React Native Alternative by Tencent