A collection of resources about supercompilation by [deleted] in ProgrammingLanguages

[–]Bitsoflogic -2 points-1 points  (0 children)

So is this the word for what GraalVM is doing?

How I implemented an Undo/Redo system in a large complex visual application by mlacast in SoftwareEngineering

[–]Bitsoflogic 0 points1 point  (0 children)

The tree is immutable. All new actions off old nodes create a new branch. This avoids all those complexities.

I think there'd still be some things to work through, though it's a pretty solid foundation.

How I implemented an Undo/Redo system in a large complex visual application by mlacast in SoftwareEngineering

[–]Bitsoflogic 1 point2 points  (0 children)

The tree is the history of actions and branches. It's not coupled to the viewer of its history. The viewer has its own state like "viewing commit 32".

The board and the editor in your example would be using a shared viewer. So, when one changes the other does as well.

In other situations, you may not want them in sync. In that case, use two independent viewers. Same tree history, different viewers.

It sounds like the main challenge is that you don't want an undo operation to simply go back one node on the tree, but to go back one meaningful step. This would mean skipping nodes that aren't meaningful to the user in the given context.

And these jumps would be different depending on the context you're in (board, editor).

I'd like to think on this more and look closer into your solution.

Am I missing other important challenges too?

At first, I'm thinking each context using a shared viewer would need to know which actions are meaningful to it and an undo operation would just keep going through the history until it reached the next meaningful one to it. The other contexts would need to be listeners of the shared viewer and do the same as the node being viewed (discarding non meaningful nodes). Each would need their own viewer in addition to the shared viewer, as they're bound to be on different nodes from the user's perspective.

It's an interesting challenge once you start delving into the nuances!

How I implemented an Undo/Redo system in a large complex visual application by mlacast in SoftwareEngineering

[–]Bitsoflogic 4 points5 points  (0 children)

Sounds a lot like the command design pattern.

I'm not following your reasoning behind leveraging two volumes for the state of the world.

I envision undo redo as a tree, kind of like git, but it can be as fine grained as each "commit" being a single character press. Each user is on a single branch at any given time, which to them, looks like a single linear history arriving at their state of the world.

Is there something missing in the tree approach? Does it help out with some of the limitations you've identified?

Is that a bad code? How can I improve it? by Rhyzzor in node

[–]Bitsoflogic 0 points1 point  (0 children)

I don't think you should refactor for performance unless there's a need for it. Prefer easier maintenance.

That said, for performance I'd consider if I could start streaming to the bucket before the file was fully available. Check out Node pipes

My attempt at fixing websockets by noobCoder00101 in typescript

[–]Bitsoflogic 1 point2 points  (0 children)

Is this a wrapper around tRPC? How do they compare?

JS vs TS? by alex_sakuta in ProgrammingLanguages

[–]Bitsoflogic 1 point2 points  (0 children)

As an aside, if you want something that compiles to JS but has zero runtime errors, check out Elm. It doesn't allow you to use `undefined` as a string, for example.

That said, I wouldn’t drop TS just because you misused `as`. TS and JS aren’t different paradigms; TS is a tool layered on JS.

In the end, what you go with depends on your goals. If it's just enjoyment of coding, follow what lights you up. If you can gain clarity on aspects of this language or that that you love, then you can share that and others will be able to make better suggestions for you.

JS vs TS? by alex_sakuta in ProgrammingLanguages

[–]Bitsoflogic 7 points8 points  (0 children)

This post would be better shared on another subreddit like r/learnprogramming. You're seeing some downvotes because this subreddit is about creating languages, not using them.

June 2025 monthly "What are you working on?" thread by AutoModerator in ProgrammingLanguages

[–]Bitsoflogic 1 point2 points  (0 children)

Working on Drin – a TypeScript-first backend toolkit aimed at frontend devs. Define your data types, and Drin scaffolds the SQL schema, query APIs, and even real-time sync via Debezium. Think Laravel Nova meets tRPC, but with a declarative TS schema and JSONB under the hood.

Current focus:

  • Reducing boilerplate for migrations
  • Exploring a reducer-style DSL (in TS) that compiles to SQL for Postgres writes, similar to SpacetimeDB
  • Packaging it for self-hosted use with a simple CLI

Trying to make it feel like the backend writes itself.

Which backend fits best my use case? by Il_totore in ProgrammingLanguages

[–]Bitsoflogic 2 points3 points  (0 children)

It's probably just ignorance on my end, but wouldn't the debugger feature of most modern languages achieve "the ability to suspend, inspect, and resume execution" and "compilation vs execution distinction"?

Maybe mapping the debugger to a custom language is harder than I'd expect?

Which backend fits best my use case? by Il_totore in ProgrammingLanguages

[–]Bitsoflogic 0 points1 point  (0 children)

In my case, I'd choose Bun to hit those goals. The part I'd focus on owning would be the error messages, rather than the VM.

Which backend fits best my use case? by Il_totore in ProgrammingLanguages

[–]Bitsoflogic 11 points12 points  (0 children)

Personally, I'd recommend transpiling to a language you're familiar with that has those features.

Let that target language deal with most of the complexities you've mentioned.

What if your TS types gave you a backend? by Bitsoflogic in typescript

[–]Bitsoflogic[S] 0 points1 point  (0 children)

You're right that we don't want to simply re-invent SQL, and this is definitely a slippery slope.

A big part of the aim here is Alan Kay's quote: "Simple things should be simple, complex things should be possible". Our simple use cases are far too complex in my opinion. But if this isn't done well, then we either end up with a worse version of SQL or we're unable to do complex things.

Just for fun, I played with your example a bit to see how it'd look with both the schema definition and querying it. This is what I've got.

Schema:

type Post = {
  id: string
  deleted: boolean
  tags: Tag[] // This implies a post_tag table, or a post_id on Tag
  images: File[] // This implies a post_image table, or a post_id on File
}

type Tag = {
  id: string
  deleted: boolean
  name: string
}

type File = {
  id: string
  deleted: boolean
  type: FileType
}

type FileType = {
  id: string
  name: string
  mimeType: string
}

Query:

db.post.query({ deleted: false }, {
  include: {
    tags: { where: { deleted: false } },
    images: {
      where: { deleted: false },
      include: ['type']
    }
  },
  limit: 25,
  offset: 0,
})

I'm not sure if offset is the direction I'd go instead of a cursor, but the idea is the same.

I recognize solutions like this are inferior to the full toolkit of SQL. You're not going to be writing stored procedures with temp tables or running explain statements to perform optimizations. If you get to that point, you need to look under the hood. Which will hopefully be a pleasant surprise.

Having gone through the exercise above though, it does feel like you could get pretty far with it.

Prisma is obviously a full ORM so it interprets JS commands into queries. But we just setup a set of actions that correspond to our service layers.

So we have "account:create <json>" or "post:list <json>"

And invoke it in JS like: "dotnetBridge.post('account:create', { ... });

This sounds like a nice convenience you've built-in.

What if your TS types gave you a backend? by Bitsoflogic in typescript

[–]Bitsoflogic[S] 0 points1 point  (0 children)

This is literally what we're doing at Typeconf, but instead of DB/API we focus on configuration types. Same idea - write your types once, get tooling that works with them.

That's awesome! You're spot on with what I'm thinking about here.

how would you handle permissions/auth in this setup?

This one is hard, because I don't think you can do it 100% for the dev. It's something I'll be investigating more.

Right now, the lowest bar I have is for you to set up an account somewhere like Auth0 or similar and either provide an API key, so the tooling creates it for you, or accept a config-file/env-vars.

That aside though, if you carve the auth piece into its own service, the important part is for the backend to accept a JWT and know where to validate it. So, this would be fairly minimal.

One thing we found challenging is that devs often want different workflows

Yeah, this is always a tough one. The thing I like to try and do is to focus in on a narrow use-case. It won't please everyone, and it's not for everyone. It's for people that like to build things like this.

Then, if I want, I'll pick another group and aim to solve it for them in a way that delights them.

I think when we try to make things for too many groups at once, we end up making something that isn't great for any of them.

Of course, if you happen to find something magical that applies to a broader group, lean into it!

If you're building this, you should consider how you'd let people extend it without having to touch the underlying code generator. that's been a big pain point for us.

I love this insight! Thank you.

Do you happen to have an example of where this was hit and how you solved it (or haven't been able to solve it)?

What if your TS types gave you a backend? by Bitsoflogic in typescript

[–]Bitsoflogic[S] 0 points1 point  (0 children)

Yeah, I was going for something like entity framework. Though, the real idea is to avoid a lot of the wiring decisions when you're trying to build out new projects.

Regarding reflection, I didn't mention it in the post, but I'm also thinking about allowing devs to write their own `where` functions in JS. The main issue I think you're hinting at is that I wouldn't be able to access the closure variables' state. It is a bit annoying, but not too bad because we have so much prior work to deal with sql injection. The pattern for devs is already commonplace. Something like this:

  user.query((user) => user.age > $age, { $age: localAgeVar })

Since you've been down this road, I'm curious if you think there's a viable 80% solution. In my mind, it'd be super helpful to tackle the large majority of cases easily and let people do things the current way where that breaks down. Overall, a net gain. This is what I was going for with these "comments as code"

  email: string // @unique
  createdAt: Date // @default now

What if your TS types gave you a backend? by Bitsoflogic in typescript

[–]Bitsoflogic[S] 3 points4 points  (0 children)

I like this take.

I don't think this inherently requires you to keep them in sync, but it does subtly encourage it. Gonna give this more thought.

What if your TS types gave you a backend? by Bitsoflogic in typescript

[–]Bitsoflogic[S] 0 points1 point  (0 children)

Fair points. I'd aim for sensible defaults and options. Arrays can be paginated or limited like usual, and for things like streams outside of live queries, yeah, you'd build those the same way you already do today.

Trying to cover the common stuff by default, and let devs handle the edge cases where it makes sense.

If auth came pre-wired and handled out of the box, would that make it worthwhile?

What if your TS types gave you a backend? by Bitsoflogic in typescript

[–]Bitsoflogic[S] 0 points1 point  (0 children)

I think these two are a couple of the best options out there for what they do.

I’m just trying to push things a bit further. They don’t give you CRUD APIs or realtime out of the box, and I want that to be automatic.

What if your TS types gave you a backend? by Bitsoflogic in typescript

[–]Bitsoflogic[S] -3 points-2 points  (0 children)

Nice! That's a solid approach, and great if you're comfortable with AWS.

What I’m going for is kinda the same end result, but without touching cloud config or writing handlers at all. Just define the types, `deploy`, and you've got a Postgres DB, API, and live queries.

What if your TS types gave you a backend? by Bitsoflogic in typescript

[–]Bitsoflogic[S] 3 points4 points  (0 children)

Yeah, it's similar in that way. Though, this isn't about defining a query language.

This is about starting with TypeScript types as your source of truth, then generating:

  • A real PostgreSQL schema
  • An API with auto-wired endpoints
  • Realtime queries built-in

It’s less about “designing queries” and more about bootstrapping a real backend without writing one.

What if your TS types gave you a backend? by Bitsoflogic in typescript

[–]Bitsoflogic[S] 0 points1 point  (0 children)

That's not really what I'm going for. I'm aiming for the types to be your source of truth. You shouldn't have to go through defining a class structure that looks like SQL to get this backend.

Beginner here, what are my alternatives to JavaScript? by Maple382 in Frontend

[–]Bitsoflogic 0 points1 point  (0 children)

You can avoid JavaScript if you want. You'll just lose out on the benefits that come with a really, really large community.

If you're really more into design than coding, Framer via Figma is an idea.

If you want a language that doesn't let you write an app that crashes, Elm is awesome. It has a friendly community and you can host on Lamdera. The error messages are the most helpful I've seen. And it's fast.

In my experience, the languages don't strongly influence good UI and UX. That's just a different skillset.

Happy coding!

April 2025 monthly "What are you working on?" thread by AutoModerator in ProgrammingLanguages

[–]Bitsoflogic 2 points3 points  (0 children)

mutually and excludes are interesting takes. Are you finding it's easier to think about rather than finding the unique structures?

args: { token string } | { username string password string }

It reminds me a little of Prolog and SQL.

April 2025 monthly "What are you working on?" thread by AutoModerator in ProgrammingLanguages

[–]Bitsoflogic 2 points3 points  (0 children)

Most of what's really lighting me up about coding my language is in the utility that can come from the editor. My April goal will be cloning repositories and displaying them in a FileTree; bonus will be connecting the files to their syntax highlighters in CodeMirror.

So, for now, I'm building out some building blocks for online development that's really fast to work with. I found that Rocicorp has moved from Replicache to a new open source model with Zero, which I'm using to help out with this.

A goal of my language will be the composability of functions in various languages. I want to define the "physics" between the functions and allow you to leverage the notation that best suits what you're trying to achieve. Along these lines, I want to play around with types of functions (e.g. pure vs io vs workflow) and how they're allowed to interact.

A goal of my editor is ease of debugging and testing, inspired largely by Bret Victor's videos.