3 ms·
I want a language that's essentially a "unified meta-DSL" that gives you different mini-languages for different purposes. Today's languages don't scale up or d
by atombender 7y ago
I want a language that's essentially a "unified meta-DSL" that gives you different mini-languages for different purposes.
Today's languages don't scale up or down very well. For example, you can't write cache-optimized algorithms in Ruby and you can't write a sleek ORM in C.
Languages like Rust and C++ try to bridge the worlds by starting out being "near the metal" and then building high-level primitives on top, and that's a good start, but even with Rust's macro system — which does allow you to write some DSL-like stuff — you're always targeting Rust syntax.
Neither is every going to let you operate in a region without type annotations, for example, even though it's more productive for the programmer when experimenting/sketching, prototyping or in some contexts like shells or game scripting.
As an example, think about how much boilerplate there is around writing tests. Even though Go has a test framework built in, and tests can be nice and small, you still end up writing a lot of this:
func TestUppercase(t testing.T) {
v := Uppercase("hello")
if v != "HELLO" {
t.Errorf("expected HELLO, got %q", v)
}
}
instead something like:
test "Uppercase" {
Uppercase("hello") => "HELLO"
}
I write a lot of YAML-based table-driven tests that I wish were just actual code, because it is code.
- pdamoc 7y agoI want something very similar. A language powerful enough to get almost everything done with very few and very well thought through escape hatches in form of DSLs. For example, Elm has a mechanism for writing shaders: vertexShader : Shader { position:Vec3, coord:Vec3 } { u | view:Mat4 } { vcoord:Vec2 } vertexShader = [glsl| attribute vec3 position; attribute vec3 coord; uniform mat4 view; varying vec2 vcoord; void main () { gl_Position = view * vec4(position, 1.0); vcoord = coord.xy; } |] I can think of at least a few other DSLs that would be useful: some logic/query languages (SQL/Datalog/GraphQL) and maybe a highly mathematical visual language like gezira (vpri). It would also be very useful to be able to write things in a lower level language for performance optimization (where needed).