Threads for rdfi

  1. 8

    I’m never one to advocate for a web stack given an alternative but I wonder how much of this is down to using the GPU, rather than anything to do with C++ vs JavaScript part. If you use WebGL / WebGPU to do the transitions / animation then I’d expect that this should be completely fine in the browser. If you write CPU-side C++ to do the transitions then the RPI 4’s CPU might struggle at 4K.

    1. 2

      I suspect you’re right. My gut feeling is that you could achieve these affects with CSS transitions, and the performance would be good. Probably wouldn’t amount to much code, or take very long, either.

      1. 3

        I tried to do this in the browser with CSS transitions and animations first. Nothing seems to be GPU accelerated on the pi. Performance was really bad and CPU usage very high.

        I didn’t try webgl. At the time I thought it would be easy to do with native OpenGL. It’s just 2 triangles and a texture right?

        It turned out to be a little bit more involved than that but I ended up sticking with it.

        1. 2

          You probably didn’t do anything to ensure the browser is accelerated. Firefox wouldn’t enable it automatically because the GPU is not on the qualified list. For good reason – WebRender is still glitchy on v3d. But you can use the old GL layers backend with layers.acceleration.force-enable, that would run CSS transforms on the GPU just fine. (That backend will be gone eventually but for now it still exists.)

          1. 1

            I tried to do this in the browser with CSS transitions and animations first. Nothing seems to be GPU accelerated on the pi. Performance was really bad and CPU usage very high.

            Oh, cool, I didn’t see CSS mentioned in your post. I don’t think that CSS effects really turned out to be the big deal they were introduced as, but they have been around for probably ten years. They’re very standard, so I’m surprised they’re not GPU accelerated on the Pi.

        2. 1

          WebGl / WebGPU does tend to be impressively performant and quite viable for many projects — as long as the target is a platform that doesn’t have any trouble running a browser in the first place. In this case you’d still have the overhead of a browser just to get to your app, and even if the platform could run your code just fine you’ve lost access to all the resources the browser itself is hogging. For the Pi and other embedded platforms that’s often a deal breaker.

        1. 1

          one could also create a socket connection between nodejs and .net and do the same communication over it.

          1. 1

            Using TCP has some downsides cuz other processes in the same machine could maliciously or accidentally connect to it. Especially if it talks http, miscreants might be able to get a browser to send requests to it with CSRF attacks. Various commercial products have shipped RCEs doing this, so you at least need authentication in the protocol to not introduce vulns.

            Using a pair of anonymous pipes as stdin & stdout works fine.

            On cursory reading it sounds like Windows might not yet have socketpair even though some support for AF_UNIX sockets has existed for a while now.

            1. 1

              That’s true, and since they are consumed as stream all would work with no changes. Using sockets has the added complexity of having to choose a port. stdin and stdout are already there and ready to use.

            1. 9

              But here is where the problem lies, it’s surprisingly rare that I find myself editing only one file at a time.

              And that’s why Emacs exists. It even has a best-in-class set of vim keybindings. And it has a wonderful extension language. It’s a Lisp Machine for the 21st century!

              1. 15

                That just means he needs to learn more Vim. It does indeed support tabs, and splits too, and IMO does it better than most IDEs. And you can get a file tree pretty easily too with Nerdtree. I have no issues with editing a bunch of files at once in Vim. Features like being able to yank into multiple registers is much more of a help there.

                1. 8

                  I suspect one problem people have with vim and editing multiple files is that they only know about buffers, which can be a little tricky to work with, but I don’t think many people realise it does actually have tabs too.

                  I frequently open multiple files with vim -p file1 file2 which opens each file in a tab, and you can use gt, gT, or <number>gt to navigate them. There’s also :tabe[dit] in existing sessions to open a file in a new tab.

                  I generally find this pretty easy to work with and not much harder than doing something like Cmd-[ / Cmd-] as in some IDEs.

                  1. 3

                    There is some debate on whether tabs should be used this way in Vim. I used to do it this way and then I installed LustyJuggler and edited all my files without tabs.

                    But if it works for you, more power to you!

                    1. 3

                      As a sort-of an IDE power user, I would argue that editor tabs are a counter-productive feature: https://hadihariri.com/2014/06/24/no-tabs-in-intellij-idea/.

                      1. 2

                        That said, while you can work with tabs like this, that’s not entirely the idea of them. Tabs in Vim are more like “window-split workspaces” where you can keep your windows in some order that you like. With one buffer in one window per tab you do get a pretty similar workflow to tabs in other editors, but then again you could get a similar workflow with multiple buffers in one window even before Vim got tabs.

                        Guess tabs fall in the tradition of vim naming features different than one would imagine: buffers is what people usually understand as files, windows are more like what other editors call splits and tabs are more like workspaces.

                        1. 4

                          Oh, to be clear I don’t have one buffer per tab. I do tend to use them more like workspaces as you say. Typically each of my tabs has multiple splits or vsplits and I’ll go back and forth between buffers - but having tabs to flip back and forth between semi-related things can be useful on a smaller screen too.

                      2. 3

                        One of the reasons why I love vim is that I find a lot easier to edit multiple files at once. I can open then with :vsp and :sp and shift-ctrl-* my way around them very fast, with NERDtree I can open a directory folder in any of these windows, locate the file, and there you go, I have them arranged in whatever way I want. It makes it super easy to read the multiple files and copy things around. I like my auto-complete simple, I find autocomplete distracting, so I just use ctrl-n, but I’m aware this is a fringe opinion, if you want a more feature rich autocomplete, You complete me works pretty fine for people that like these. Also, I can open any terminal with :terminal… My vim usually looks more like this https://i.redd.it/890v8sr4kz211.png nothing with to do with 1 file per time.

                        Does vim makes me super faster than everyone else? Probably not, it’s just a text editor, but it’s very maleable and I’ve been coding for many years now and I haven’t ever seen the need to not use it. When I need to work on a new language I just install a bunch of new plugins and things get solved.

                        Nothing against VS Code, but it’s also only super powerful with the right plugins and configurations, there’s more of it out of the box, but without them it would also just be a simple text editor.

                        1. 2

                          What’s a good resource to start learning emacs?

                            1. 1

                              I gave emacs a try through mg(8), a small editor that ressemble emacs a lot (no LISP though) and is part of the default OpenBSD system. It comes with a tutorial file that takes you on a tour to discover the basics of emacs, starting with the navigation. This is like vimtutor, and it’s great !

                              It also let you discover emacs as a text editor, AND NOTHING MORE! Which is refreshing and helped me reconsider its usefulness for editing text 😉

                          1. 7

                            So this would produce an app with a .net runtime, a JS runtime/Chromium and a node.js runtime? If so, that seems a little excessive to me.

                            1. 3

                              This is crazy. I’m just happy that I’m a spiral theory of history believer and hope this soon will go away back to compiled languages with portable GUIs.

                              1. 2

                                It would, and that certainly won’t be as performant as a native app. There are other use cases for it though. It allows calling .NET code from Node and vice-versa, so there might be no-UI related situations where it still might be useful.

                                I named it ElectronCGI because I imagine that’s what most people would be interested in using it for since .NET Core is cross platform but there’s no easy way to create cross-plat GUIs with it.

                                There are also other “lighter” alternatives to Electron that would work with this, for example DeskGap (https://deskgap.com/) however I haven’t had time to try it out yet.

                                Also, in theory it would be possible to use Blazor with this and have nearly 100% .NET code for a cross plat GUI application, and that (I imagine) is appealing for that crowd.

                              1. 1

                                CGI? Am I one of the few people who thought of something completely different?

                                1. 1

                                  Computer Generated Imagery or Common Gateway Interface? It’s the latter that inspired the name

                                1. 1

                                  Sounds like the request and response object formats could do with having a request id field, so that it would be possible to reply to requests out of order?

                                  1. 1

                                    They do have an id, and they can come out of order. However, the implementation for .net is is not taking advantage of this right now. It’s something that I’m planning to do in the future

                                    1. 1

                                      Ah! Makes sense. So, you want to optionally make each request run asynchronously. C# has futures, right? Are those nice and easy to work with in C#? (And if there’s CPU blocking work, the application code could hand it off to a thread pool presumably.)

                                      1. 1

                                        The requests already run asynchronously but the way the code is done right now there’s an await on each async request before picking up the next one. In theory it’s not to hard to make it fully async using a concurrent queue for the responses.

                                        C# does have something that can be thought of as a future/promise, it’s called Task. They are pretty easy to work with, in fact async/await came from C#.

                                        1. 1

                                          Thanks. I’m not really into that whole ecosystem so I didn’t have any idea of whether async was easy and widely supported, or whether it was more like Twisted back in the bad old days where you could try to be async but every single library available on pypi would screw it up for you by blocking, save a tiny handful which had been written specially to work with Twisted.

                                  1. 1

                                    So that’s it, I hope I’ve helped explain why we should use passwords with … combinations of several numbers, symbols and characters

                                    Unfortunately not. And it’s not recommended.

                                    https://www.troyhunt.com/passwords-evolved-authentication-guidance-for-the-modern-era/

                                    1. 1

                                      That’s not really a fair criticism since what Troy’s article says is that making people pick passwords with, for example symbols, does not necessarily improve security, e.g. “P@assw0rd” is not much better than “Password”.

                                      However that doesn’t change the fact that if more symbols are used than just letters the search space that an attacker has to go through is larger.

                                      The post is from the point of view of what hoops an attacker has to go through to get to a password, and about what developers should do to make that as hard as possible.

                                      Troy’s post is from the perspective of the user who has to pick a password and how restrictions such as having to use numbers and symbols or not being able to copy and paste do not lead to users picking better passwords.

                                      1. 2

                                        Adding characters is far more effective at increasing the state space than expanding the alphabet. For example, assume you have a 10-character alphanumeric password; that’s 62^10 = 59.5 bits of state. If you add some special characters to your alphabet (let’s say eight of them), you’re up to 70^10 = 61.3 bits. If you add a single alphanumeric character, for 11, you now have 62^11 = 65.5 bits.

                                        Alphabet is, for most intents and purposes, a complete waste of time. Passwords need to be longer and not in known dictionaries. Any other requirement is between useless and actively counterproductive.

                                        1. 1

                                          Any other requirement is between useless and actively counterproductive

                                          It was never suggested that using symbols should be a requirement. The only suggestion in the post regarding this matter is that a password manager should be used.

                                          Also, there were no suggestions about password lengths other than longer passwords are better than shorter ones, and the more character types the better. All of that is all true irrespectively of the discussion about making symbols in passwords be mandatory.

                                          I agree that that type of requirement is counter productive, but I don’t see how the post has anything to do with that.

                                    1. 1

                                      One consequence of always having to chase the shiny new thing is that often good programming practices are not center stage. Robert Martin speaks of this in .Net Rocks and he also has a blog post where he says this continuous relearning requires massive amounts of time and effort and does not pay off very well in terms of extra productivity.

                                      As a contractor though, I think you need to “ride the waves”. The highest paying gigs are always on the shiny new thing…

                                      1. 1

                                        The Churn post was posted here previously, here is the discussion: https://lobste.rs/s/1pylbt/churn