HN user

jackielii

32 karma
Posts7
Comments33
View on HN

Exactly the same thing happen to me: https://www.reddit.com/r/htmx/s/DuXyGgsCWK

I'm in an advisor position, and I tried very hard to mentor the team, explaining that learning this technology deepens your understanding of the browser. Whereas React etc isolates you from the actual environment you're working in - the browser.

On html/template, I like the security by default, and obviously it's built-in. But the dynamicness leaves too many open-ended questions unanswered. Templ is great, but the ergonomics leaves many things to be desired. After writing a few large production applications in it. I decided to create gsx: https://github.com/gsxhq/gsx

Templ tries to stay simple, but it sacrificies ergonomics for simplicity and verbosity.

Over the years, there are many proposals: inline elements, HTML tags, error hoisting. It's hard to retrofit into it.

Beside the above, I also tried solving the all the ergonomics problem I saw when using templ. E.g. auto class merging, easy javascript interpolation within attributes. Auto json interpolation etc

References:

- HTML-style component authoring: https://github.com/a-h/templ/issues/663 and https://github.com/a-h/templ/issues/1181

- Inline/anonymous templ functions: https://github.com/a-h/templ/issues/1150

- Passing Go data to JS: https://github.com/a-h/templ/issues/944 and https://github.com/a-h/templ/issues/838

- JSON helpers for frontend data: https://github.com/a-h/templ/issues/739

- Deprecating script-tag Go interpolation due parser complexity: https://github.com/a-h/templ/issues/1408

- CSS/class ergonomics: https://github.com/a-h/templ/issues/61

- Duplicate class behavior: https://github.com/a-h/templ/issues/902

- Conditional attributes / else-if: https://github.com/a-h/templ/issues/933

- Dev mode/watch ergonomics: https://github.com/a-h/templ/issues/318

- Dynamic HTML element helper: https://github.com/a-h/templ/issues/1113

I've done a few interviews like this recently. I always thought I was a OK programmer, judging from the feedbacks I get from colleagues. But after these interviews, I felt terrible. Doing my daily Leetcode as we speak...

Go nulls and SQL 4 years ago

I have an alternative solution to work with an existing struct that you can't change, e.g. protobuf generated code: https://jackieli.dev/posts/pointers-in-go-used-in-sql-scanne...

  type nullString struct {
    s *string
  }
  
  func (ts nullString) Scan(value interface{}) error {
    if value == nil {
        *ts.s = "" // nil to empty
        return nil
    }
    switch t := value.(type) {
    case string:
        *ts.s = t
    default:
        return fmt.Errorf("expect string in sql scan, got: %T", value)
    }
    return nil
  }
  
  func (n *nullString) Value() (driver.Value, error) {
    if n.s == nil {
        return "", nil
    }
    return *n.s, nil
  }
Then use it:
  var node struct { Name string }
  db.QueryRow("select name from node where id=?", id).Scan(nullString(&node.Name))
Go 1.18 4 years ago

Nothing is perfect. I focus on solving problems

I believe this is discussed and decided quite early on: https://docs.google.com/document/d/19kfhro7-CnBdFqFk7l4_Hmwa...

According to the Import Compatiability Rule for versioned Go, this implies that the new proto package must have a new import path. Since "github.com/protobuf/proto/v2" will incur great confusion with the proto2 syntax, we may take this time to use an import path like "google.golang.org/proto" (similar to how gRPC lives at "google.golang.org/grpc").

What I had in mind was that Go is an open source project, if C#'s solution is a good one, why not write up a proposal and try an implementation?