6 ms·
Code-GUI bidirectional editing via LSP
- kennykartman 1y agoI know basically nothing about CAD, but I know thet fornjot exists and wondered if it might be useful to your purposes, in case you don't know about that. But well, the project is very cool and I love the idea of using LSP for something more!
- EGreg 1y agoWhoa … you can use various unicode characters in titles on HN?
- jamesbvaughan 1y agoI was surprised by this too! I actually did a search for that character in order to check before posting this: https://hn.algolia.com/?q=%E2%87%84 https://hn.algolia.com/?q=%E2%87%84 I was a bit concerned that HN's algorithm might down-weight posts with non-ASCII characters in titles to discourage people from trying to attract attention with them, but it seems like it's fine?
- harrylepotter 1y agoWe do quite a lot of this using webviews in vscode over at Darwinium. Similar process that involves postMessages between the UI container and the host containing the LSP. Biggest challenge I had with this was figuring out how to map a diagnostic from the language server (which is inherently range-based) to a UI component that would display it - it involves a fairly intricate pubsub system and mapping UI components explicitly to parts of a tree. Would love to share it eventually.
- FloatArtifact 1y agoThis is really interesting being able to do bi-directional editing. This is desperately needed for accessibility software to get at underlying text. I would use it for semantic editing of code by voice. However, getting at GUI elements would be amazing.
- jesse__ 1y agoIt's concerning to me that the LSP idea is .. a thing. Casey Muratori observed years ago that it's just a way worse way of doing libraries. Like, you're introducing HTTP where there could just be a function call into a DLL/SO. What's the benefit there? Just make vim/emacs/$editor speak some native protocol and be done with it. Then you GUI is just welded directly into the running editor process.. right?? There's no security risk there that wasn't present before as far as I can tell because you were already planning on running the LSP on your local machine..
- ukuina 1y agoYou're going to love MCP.
- whattheheckheck 1y agoWhat is up with mcp... feels like CORBA
- disqard 1y agoIt's like if CORBA and COBOL had a baby :P Seriously though, it does combine the "RPC IDL" aspect of the former, with the "Use English" aspect of the latter.
- chamomeal 1y agoI’ve definitely wondered about this. Like why does the language-understanding standard have to be a server specifically? Just cause it’s a good architecture to build around? I think I’ve heard that vscode has benefitted hugely from it starting out with a client-server architecture from the start, since it started as a browser based editor. Things like editing code directly on servers via ssh or in containers is easy for vscode cause its client-server all the way down. Vscode and LSP are both Microsoft products, maybe Microsoft has been pushing the client server thing?
- jesse__ 1y ago> I’ve definitely wondered about this. Like why does the language-understanding standard have to be a server specifically? I don't think it does. I think it's a bad architectural decision that web bros thought sounded cute. > Things like editing code directly on servers via ssh or in containers I mean, vim and emacs have supported editing over ssh for like .. longer than I've been alive probably. > I think I’ve heard that vscode has benefitted hugely from [clinet-server architecture] IMO VSCode is a giant steaming pile; I'm not sure what the huge benefits could have been. It's intolerably slow, uses an insane amount of system resources, and the debugger barely works most of the time.
- disconcision 1y agoHere's a similar example using lean widgets (in the live programming part of the talk): https://www.youtube.com/watch?v=c5LOYzZx-0c https://www.youtube.com/watch?v=c5LOYzZx-0c
- Bjartr 1y agoI know it's not quite the same, and maybe it's just the demo video doing it, but this reminds me of the Light Table IDE http://lighttable.com/ http://lighttable.com/
- legobmw99 1y agoThe idea of a language server also being some other kind of server is almost fiendishly clever to me and I'm shocked I hadn't seen other people play with this before. Definitely can think of applications to game programming -- a sufficiently dedicated engine team could fork their language's LS and allow you to e.g. integrate the map editor's feedback into the source code. I know hot-reloading is considered super valuable in games, but this is almost the dual of that idea. So clever!
- sitkack 1y agoIt is referenced down in the wonderful tree of knowledge, but I thought I would lift this info up to the top level. A system like this called a "bimodal editor" from the work of Ravi Chugh [1] see the project Sketch-n-Sketch [2] these kinds of systems got a big kick in the pants with Bret Victor's talk Inventing On Principle [3]. That in turn kicked off a wonderful dynamic execution Clojure IDE called lighttable [4] There are tons of other great research projects and researchers in this fascinating space. Comment is not meant to exclude. [1] https://people.cs.uchicago.edu/%7Erchugh/ https://people.cs.uchicago.edu/%7Erchugh/ [2] https://ravichugh.github.io/sketch-n-sketch/ https://ravichugh.github.io/sketch-n-sketch/ [3] https://vimeo.com/906418692 https://vimeo.com/906418692 [4] https://web.archive.org/web/20250616031034/http://lighttable.com/ https://web.archive.org/web/20250616031034/http://lighttable... (demo video plays)
- sitkack 1y agoBrian Hempel https://people.cs.uchicago.edu/%7Ebrianhempel/ https://people.cs.uchicago.edu/%7Ebrianhempel/ also from uchicago has some great bimodal projects.
- LarMachinarum 1y agoi wonder: could this kind of bidirectional flow be used to turn any LSP-capable editor (without it having to have any collaborative editing function integrated) into a collaborative editor that real-time-syncs any modification by any connected user with all other users who have the modified file open?
- love2read 1y agoRelated: https://chromewebstore.google.com/detail/ghosttext/godiecgffnchndlihlpaajjcplehddca?hl=en https://chromewebstore.google.com/detail/ghosttext/godiecgff... > Write in the browser with your text editor.
- necovek 1y agoThis is a great idea: I'd never think of using LSP for this! As a software developer, I always get frustrated when I am doing some graphical work and struggle to neatly parametrize whatever I am drawing (wooden cabinets and furniture, room layouts, installation plans...) and switch between coding where that makes most sense and GUI where it doesn't. The best I've gotten was FreeCAD with Python bindings (I've got a couple of small libraries to build out components for me), but while you can use your own editor, the experience is not very seamless. And then I start imagining tools like the one here, but obviously doing it just right for me (balancing the level of coding or GUI work).
- ttoinou 1y agoI think we’re a lot of developers who are frustrated by constantly needing to choose between code or GUI… both have their use case, but I feel like there must be a system that combines both.
- krebby 1y agoHow about a visual programming language? Plenty of 3D and CAD software uses a VPL for procedural design, which helps a ton to bring out the benefits of both
- adastra22 1y agoAny examples?
- krebby 1y agoGrasshopper for Rhino is a big one, or VisualCAD/CAM. Blender, Houdini, or Unreal Blueprints are others. It gives you the exploration benefits of a UI plus the procedural benefits of code. Inputs tend to be auto-bound which makes exploration much, much faster. I'm working on one for web map data visualization: https://youtu.be/GJ0ftFB8r4I?t=871 https://youtu.be/GJ0ftFB8r4I?t=871
- baobun 1y ago
- rao-v 1y agoIsn’t the python based build123d the current best CAD in code solution? The problem with OpenSCAD is that it cannot export solid geometry, just a final mesh. More broadly, I was genuinely shocked to realize, when I was playing with it, that there is no cross CAD file format that captures even simple design concepts like “this hole is aligned to the center of this plate” or even “this is a 2mm fillet”. STEP (the file format) mostly just captures final geometry. I think CAD people just … redesign the part again if they need to move from say Fusion 360 to FreeCAD or whatever. How do they live like that?!
- ethan_smith 1y agoThe interoperability problem stems from CAD kernels using proprietary B-rep representations and constraint solvers, with STEP's AP242 standard attempting to address this by including Product Manufacturing Information (PMI) and semantic annotations, though adoption remains fragmented.
- rao-v 1y agoI’d have assumed that somebody had a format for just the basic operations … but it looks like even that is just being considered
- fwip 1y agoI don't think they change programs very often, and only very rarely in the middle of a project.
- rao-v 1y agoI think this maybe why! Of course it’s great for vendor lock-in. But given how many companies need to work with diverse suppliers, there must be a whole bunch of re-creating models happening. There is no chance that everybody is using the same CAD tool
- rjsw 1y agoThe big example of this is Airbus on the A380 [1], design offices were using different versions of CATIA, we added some features to STEP to allow wiring harnesses to be modelled explicitly. [1] https://en.wikipedia.org/wiki/Airbus_A380#Production_and_delivery_delays https://en.wikipedia.org/wiki/Airbus_A380#Production_and_del...
- bitwize 1y agoSee also: zoo.dev, started by an acquaintance of mine.
- mikewarot 1y agoThis is close to the functionality that Borland Delphi had back in the 1990s. The pascal language and the design of their GUI toolkit were a really good impedance match, so you could freely switch between GUI design and editing the text version of it. Doing so for languages like C++, was a sea of boilerplate that you couldn't touch, which is why I never moved away from Pascal. Similar fragility was evident in WxPython and it's builder. I'm glad to see that LLMs can provide a match for less well suited Language/GUI pairs. We all deserve to get that kind of productivity.
- lmz 1y agoDelphi's form files weren't pascal. The gui-sync was in my memory just editing the class definition when adding components / event handlers.
- RossBencina 1y agoBorland C++ Builder did the same thing as Delphi, used the Delphi VCL class library, worked great.
- williamcotton 1y agoWhile it doesn’t use an LSP (which is a great idea!), this project of mine does bidirectional mapping between a GUI and a shell pipeline: Screenshots and GIFs for the explanation! https://github.com/williamcotton/guish https://github.com/williamcotton/guish
- jasonjmcghee 1y agoHey nice - this stuff is so much fun to me. I've worked a number of experiments like this too, especially related to live coding. Love seeing it in the wild. I built a small project where you can live-code Love2D. The running program updates in real time (no saving needed) and see all values update in real-time, via LSP. https://github.com/jasonjmcghee/livelove https://github.com/jasonjmcghee/livelove And also added the same kind of interactivity like a number slider and color picker that replace text inline, like yours (though via vs code extension: https://gist.github.com/jasonjmcghee/17a404bbf15918fda29cf69b8fdfd9af https://gist.github.com/jasonjmcghee/17a404bbf15918fda29cf69...) Here's another experiment where I made it so you could "drag and drop" to choose a position for something by manipulating the editor / replacing a computed position with a static one, on keypress. https://clj.social/@jason/113550406525463981 https://clj.social/@jason/113550406525463981 There's so much cool stuff you can do here.
- phatskat 1y agoI’ve been wanting to get into game programming and was looking at Love2D. I don’t know much Lua outside of what I’ve picked up with NeoVim configs. This looks like it could be a great way to get my feet wet - I don’t do well with math and physics programming, but I used to make things in Flash back in the day that were similar to the particles demo and being able to quickly change things and see the updates makes it a lot easier for me to grok. Thanks for sharing!
- jasonjmcghee 1y agoDo it! It's a lot of fun. Highly recommend adding code definitions https://github.com/LuaCATS/love2d https://github.com/LuaCATS/love2d And getting the lua LSP. It reminds me a lot of processing / p5js. So easy to get something fun up and running quickly.
- madmod 1y agoI love your project. I am making something with LSP and your code was a great example of what is possible.
- low_tech_punk 1y agoSo if we replace LSP with MCP, the UI might control the code in interesting ways!
- rtcode_io 1y agoSee https://new.rt.ht https://new.rt.ht for bidi i⇄o sync demos! The PDF ones are especially fun! The whole playground is built for bidi sync!
- low_tech_punk 1y agoWait, what is this?! It's really cool
- cetinsert 1y agoSee more at https://rtcode.io https://rtcode.io
- SwiftyBug 1y agoThis is awesome! If someone created a Interface Builder on top of that, I feel like I might even go back to making iOS apps. Xcode makes the whole experience so terrible that it sucks the joy out of it.
- WillAdams 1y agoI've suggested this sort of interactivity for (Open)PythonSCAD: https://lists.openscad.org/empathy/thread/GAX4QYYRUC3CEH572IJSUUR6GCNTSQYC https://lists.openscad.org/empathy/thread/GAX4QYYRUC3CEH572I... The devil is in the details though, and I worry about the UI becoming cluttered and unmanageable.
- taeric 1y agoReminds me of the excitement I got on seeing https://www.youtube.com/watch?v=4tyTgyzUJqM https://www.youtube.com/watch?v=4tyTgyzUJqM. I still get excited about trying something like this again pretty much every time I see it. Have yet to really get any traction on anything. :( A lot of folks had fun watching Minecraft built using a live code session, if I recall.
- legobmw99 1y agoHot reload in Java is still a crucial part of my workflow for modding Minecraft, but it doesn't have the other direction where an action in the game could alter the code
- taeric 1y agoAh, fair. Seems that is probably more applicable to image based development than it is typical batch processed source files? Doesn't seem too strange to have your code editing a data file, for example. No reason you couldn't treat your source as a data object, in some sense. Though, I'll note Common Lisp explicitly warns against editing literal objects. Such that I'm assuming this was considered and largely agreed to be a bad idea. :D
- pjmlp 1y agoI guess it is about time for the usual Lisp, Smalltalk, Cedar and Oberon remarks. Why do cool ideas take so much time to be embraced in mainstream? Retoric question, naturally they weren't VC friendly with exponential growth capitalising user acquisition. /s
- ogoffart 1y agoFor Slint [https://slint.dev https://slint.dev], a (native) GUI Toolkit, I've also developed a LSP server that do live preview and editing. You can try it online at https://slintpad.com https://slintpad.com : if you click on the toolbar button to enable the right panel, you can edit the properties from the UI, and this is all done through the LSP and can be integrated in any editor that supports it.
- czei002 1y agocool! how does this work? e.g. how do you know which UI element matches which text element, do you track it while rendering? How do you propagate changes in the UI? do you update the text and then re-render the whole UI?
- ogoffart 1y agoI use the the code lenses of code action feature of the LSP so that the user can start a preview. The LSP server will then open a native window on desktop. Every time the users do some change in the code, the editor sends the document and we re-render the preview. I use the textDocument/documentHighlight request to know when elements are being selected from the code so I can highlight them in the preview. When selecting an element in the preview UI, my LSP server sends a window/showDocument to position the cursor at the right location. And if the user changes property or do change in the file, we do a workspace/applyEdit command with the changes. Btw, the code is there: https://github.com/slint-ui/slint/tree/master/tools/lsp https://github.com/slint-ui/slint/tree/master/tools/lsp
- nico 1y agoVery cool concept. Would love to see something like this for web development. Where making changes in the browser could be persisted seamlessly to code
- deleted 1y ago[deleted]
- junon 1y agoI'm about to set off on this journey too with a code-first PCB editing suite for myself to work on. Seems like this is a good piece of prior art to reference as I need to build similar tooling. Thanks for posting!
- pshc 1y agoThis stuff is a dream of mine, editors in different modes that can collaborate seamlessly. Keep up the good work!