#DomainSpecificLanguage

Jaro Reindersjaror@social.edu.nl
2025-03-22

There's a "bug" in this code, can you find it? (I have not found the cause yet.)

I think a block based language based on a #functional #DomainSpecificLanguage such as diagrams.github.io/ could reflect the structure of the image more directly and thus make such bugs easier to spot. But please don't take this criticism seriously until I've built such a block based language.

I found this through the great book: "500 Lines or Less" in the chapter on Blockcode:

aosabook.org/en/500L/blockcode

Block based program saying:

Repeat 10
  Left 5 degrees
  Repeat 10
    Forward 10 steps
    Left 14 degrees
  End Repeat
  Repeat 10
    Right 5 degrees
    Repeat 17
      Forward 13 steps
      Left 3 degrees
    End Repeat
    Back to center
    Right 3 degrees
    Repeat 11
      Pen up
      Forward 29 steps
      Pen down
      Right 4 degrees
      Forward -24 steps
    End Repeat
  End Repeat
End RepeatOutput of the block based program. It is an 8 armed spiral where each arm is made up of several strands and each has one loose strand, but there's also a lose strand coming out of the center.
2023-07-13

Part 9: Okay, champion of the delaying tactic that I am… In order to understand USD I _have_ to make a Domain Specific Language for it? Riiight?? I used the attached code to make the attached image. The files it makes are still a bit of a puddle... but they do render.

whynotestflight.com/excuses/he

CODE
```
public struct MultiBallStage {
    public init(count:Int) {
        self.count = count
    }
    let count:Int
    let minTranslate = -4.0
    let maxTranslate = 4.0
     let minRadius = 0.8
     let maxRadius = 2.0

    public func buildStage() -> Canvas3D {
        Canvas3D {
            //blue origin sphere
            Sphere(radius: 1.0).color(red: 0, green: 0, blue: 1.0)
            //the multi in multiball
            for _ in 0..<count {
                Sphere(radius: Double.random(in: minRadius...maxRadius))
                .color(
                    red: Double.random(in: 0...1), 
                    green: Double.random(in: 0...1), 
                    blue: Double.random(in: 0...1)
                )
                .translateBy(Vector.random(range: minTranslate...maxTranslate))
            }
        }
    } 
}
```Screenshot of  randomly sized, colored and placed spheres… AGAIN. Still 13 of them.  New colors and new layout.
रञ्जित (Ranjit Mathew)rmathew
2020-12-30

“Reflections On The Lack Of Adoption Of Domain Specific Languages” [PDF], Federico Tomassetti & Vadim Zaytsev (grammarware.net/text/2020/dsl-).

Via HN: news.ycombinator.com/item?id=2

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst