Threads for kiwec

  1. -1

    Please stop releasing TUI frameworks for Python. The language is way too slow and makes these tools a pain to use.

    To whoever is starting to write a reply - no, it cannot be optimized. Python will always take a bit to start the program.

    1. 10

      I find this comment very surprising.

      The stopwatch app from the Textual tutorial starts running for me in less than a quarter of a second - it’s fast enough that I didn’t even notice the delay until I tried to eyeball-measure it just now.

      The whole point of TUI apps is that you’re going to spend some time in them. Does a quarter of a second to show the initial screen really matter to anyone? That’s way faster than loading a web application in a browser tab.

      Thinking about it, I don’t think I’ve ever used a TUI written in any language where the startup speed has bothered me.

      1. 2

        Java/scala usually has a 1-3 second startup time, which is too long for me, but I agree – that’s the only one I can think of.

      2. 7

        To whoever is starting to write a reply - no, it cannot be optimized. Python will always take a bit to start the program.

        It depends. Maybe startup time doesn’t really matter for someone’s particular use case. While there will always be some baseline startup time from Python, there are cases where you can optimize it and possibly bring it down to a level you find acceptable.

        At a job, I was tasked with figuring out and speeding up slow start of a Python program. Nobody knew why the bloody thing was taking so long to start. Part of it was network delays, of course, but part was Python. I did some profiling.

        This little Python program was importing a library, and that library imported something called pkg_resources. Turns out that pkg_resources does a bunch of work at import-time (nooo!). After some digging, I found that pkg_resources was actually an optional dependency of the library we were using. It did a try … import … except: …, and could work without this dependency. After digging into the code (both ours and the library’s), I found that we didn’t need the facilities of pkg_resources at all.

        We didn’t want to uninstall it. Distro packages depended on it, and it was possible that there were other programs on the system that might use it. So I hacked up a module importer for our program that raised ModuleNotFoundError whenever something tried to import pkg_resources.

        I cut a nearly one-second start time down to an acceptable 300 milliseconds or so, and IIRC a fair portion of the 300 milliseconds was from SSH.

        Know your dependencies (direct and indirect). Know what you’re calling (directly and indirectly) and when you’re calling it. Profile. And if your Python startup times are slow, look for import-time shenanigans.

        1. 3

          Program startup speed is important for some applications but negligible compared to other aspects like usability, accessibility or ease of development, wouldn’t you agree?

          1. 1

            Program startup speed and performance is an important part of usability. It’s bad for software users when the software they use is full of latency, or uses so many system resources it bogs down their entire computer.

            1. 2

              Agreed, it’s part of usability. But it depends on the numbers. Saying “stop writing TUIs in Python” because of 200ms (out of which something can be shaved off with optimization) sounds extreme.

          2. 2

            I completely agree with the unsuitability of Python for TUI / CLI projects! (Especially if these tools are short-lived in their execution.)

            Long ago (but still using today) I’ve written a simple console editor that has ~3K lines of code (25 Python modules) which imports only 12 core (and built-in) Python modules (without any other dependencies) and mainly uses curses.

            On any laptop I’ve tried it (even 10 years old) it starts fast enough. However recently I’ve bought an Android device and tried it under Termux. It’s slow as hell, taking more than a second to start… (Afterwards it’s OK-ish to use.)

            What’s the issue? The Python VM is slow to bootstrap and load the code (in my case it’s already in .pyo format, all in a zip with zipapp). For example just calling (on my Lenovo T450) python2 -c True takes ~10ms meanwhile python3.10 -c True takes ~14ms (python3.6 used to take ~20ms). Just adding import json adds another +10ms, meanwhile import curses, argparse, subprocess, json (which is perhaps the minimal any current-day project requires) yields a ~40ms startup.

            With this in mind, this startup latency starts to pile-on and it has no solution in sight (except rewriting it in a compiled language).

            Granted, even other languages have their issues, like for example Go, which is very eager in initializing any modules you have referenced, even though will never use, and thus easily adds to startup latency.

            (I’ll not even touch on the deployment model, where zipapp is almost unused for deployment and https://github.com/indygreg/PyOxidizer is the only project out there trying to really make a difference…)

            1. 2

              Have you tried the framework?

              1. 2

                Why would I? It only has buttons and checkboxes implemented. And according to comments in here is still taking 1/4 of a second to start on a modern CPU.

                EDIT: In the demo video, the demo takes 34 frames to boot. At 60fps, that’s more than half a second.

                1. 5

                  I guess it will never be succesful then, like that slow-as-hell Slack thing /s

                  1. 4

                    The popularity of a chat app - particularly one that most people use because it’s what their workplace standardizes on - is driven much more by network effects than by the quality of the standard client app. It is bad that the Slack client is slow, and this is made worse by the fact that there aren’t a whole lot of alternative clients for the Slack network that a person who is required to use Slack as part of their job can use instead of the official, slow, one.

              2. 1

                I think that the problem with your assessment is the assumption that the users of this framework have the knowledge to use a different language or want to use a different language than python. Nobody is forcing you to use it and if folks are releasing tools using it, nobody is forcing you to use those. For those that want to add a TUI front end to a script they made, this seems like a good option.

                1. 3

                  I think Ink is overall a better TUI framework than this, and let’s face it, Python really is slow, JavaScript is much better.

              1. 11

                Original post: https://linus.schreibt.jetzt/posts/qemu-9p-performance.html

                I love the clickbait title. QEMU always makes me click.

                1. 4

                  Glad lobste.rs is here to take that with a bit of humour!

                  To nitpick: neither one is really “canonical” or “original”, one is just my employer’s blog and the other is my own :)

                  1. 4

                    Your blog is way more readable :D

                1. 8

                  After reading this I thought that it would be better if it were an extension that did this without having to click a button and for websites other than twitter. I decided to search and found https://addons.mozilla.org/en-US/firefox/addon/redirector/?utm_source=addons.mozilla.org&utm_medium=referral&utm_content=search

                  1. 13

                    I prefer bookmarklets for a few reasons:

                    Compatibility

                    Bookmarklets work on all devices. Deskop, iOS and Android.

                    Security

                    I can easily read and understand the code.

                    Flexibility

                    They are easy to change. For example in this one, I will probably update the array of nitter instances regularly.

                    Usability

                    I can organize them just like my other bookmarks.

                    Sharing

                    Sharing a bookmark is as easy as copy/pasting a line of text

                    1. 8

                      For what it’s worth, I really like bookmarklets for the security reasons alone. I know they they aren’t running any code until I click on them (unlike extensions). It’s much easier to check that nothing nefarious is going on behind the scenes. Even the simplest extensions have multiple files of boilerplate code, and they can be updated remotely. I hate to think what would happen if the developer’s account got compromised for any of the popular extensions.

                      Unfortunately, it seems like Chrome on Android doesn’t support bookmarklets – or at least fails on ones imported from my desktop.

                      1. 7

                        Extensions are updated remotely without user interaction? That is another scary aspect.

                        For me, the bookmarklet works fine on Chrome on Android. I have to use it from the address bar though. I named it “t2n” and when I am on a Twitter page, I type “t2n” into my address bar. Now from the list of suggestions I click on the bookmarklet and it works.

                        1. 8

                          Bookmarklets can’t get sold to a hostile data-collecting advertising company while you weren’t paying attention.

                      2. 2

                        Yeah these are good points. Have you also see Fraidycat which has slightly different aims?

                        1. 1

                          This looks awesome! I’ve been looking for something similar for a while. Thank you for sharing :)

                        2. 2

                          that’s fair but i personally find extensions more convenient 🤷

                          1. 2

                            Problem with using a redirect extension is:

                            • It doesn’t always redirect
                            • Often, the nitter instance is throttled so you have to disable the extension
                            1. 2

                              redirection via an extension sometimes just doesn’t work? not all that surprising I guess.

                              an extension could pick a random instance just like the bookmarklet though

                          2. 1

                            I’d did not know bookmarklets worked on iOS. That’s pretty rad!

                          3. 4

                            This is the extension I use https://libredirect.github.io/

                            1. 1

                              Privacy Redirect is similar. Found some alternatives I didn’t know about in there.

                            1. 5

                              They fell for the metaverse meme… As always, their priorities just don’t align with what users want.

                              1. 7

                                That’s a bit dismissive when most of the article is not about their new VR/3d space feature and rather about improving the existing situation. And as all of these are released at once, they seem to have the capacity to do it both (and it also doesn’t mean anything gets faster if your stop developing the other part).

                                1. 2

                                  Like “metaverse” or not, having an open alternative for it is a positive thing.

                                  1. 0

                                    You do what?

                                    1. 2

                                      Drizzle: the most influential software project you’ve (probably) never heard of

                                      I did hear of it and linked the relevant project.

                                  1. 12

                                    This is “Superb”? https://puu.sh/IZ2xr/5b5cf8df39.png

                                    I’ll stick to man pages.

                                    1. 1

                                      What is the point of that paper exactly?

                                      1. 4

                                        To point out that existing protocols for IDEs (or whatever) to talk to language services are insufficient and to propose one way to address it: by reconfiguring the IDE automatically to account for the different protocols that are required to talk to the services for the language.

                                        1. 3

                                          I think the abstract provides a clear summary.

                                        1. 9

                                          The network is called the ‘fediverse’, not ‘Mastodon’.

                                          1. 15

                                            The network is called the ‘fediverse’, not ‘Mastodon’.

                                            I’d just like to interject for a moment. What you’re referring to as Fediverse, is in fact, GNU/Fediverse, or as I’ve recently taken to calling it, GNU plus Fediverse.

                                            1. 2

                                              While we’re at it, Mastodon is not ‘private’. It’s social media, the polar opposite.

                                          1. 4

                                            Worst date notation to date. Why would you do that??

                                            1. 1

                                              Amazing ad post, however, when right clicking the taskbar you have to wait half a second for the menu to show up since Windows 10. It was instant before. Why isn’t Microsoft fixing their product before thinking about new features?

                                              1. 1

                                                All it needs to make it look real is to simulate Windows’s janky window-appear animation.

                                                1. 1

                                                  Wow, thanks a lot for that list! From my (unsuccessful) research, I had assumed there were very few alternatives to the big ones. I’m happy that I got proved wrong.

                                                  I’ll have fun experimenting with those, as yandex has been putting up russian captchas for a while, making it unusable for me :(

                                                  1. 10

                                                    Chicago 95 is nothing new. The fonts in the screenshots don’t match Windows’s, and that’s a huge difference.

                                                    1. 5

                                                      Implementing a minecraft classic server is hard enough, but on modern versions? There are so many packets you need to handle, it’s amazing you were able to get it to a working state.

                                                      1. 2

                                                        By pressing one key with my left thumb I have access to:

                                                        • Arrow keys
                                                        • Home/End
                                                        • Ctrl+C, Ctrl+V macros

                                                        All without moving my fingers. Right hand gets access to a numpad.

                                                        For the other layers, nothing really interesting. I have a toggle layer for qwerty so I don’t have to rebind keys in games. Also, media controls and compose key for accents. https://github.com/kiwec/qmk_firmware/blob/kiwec/keyboards/planck/keymaps/kiwec/keymap.c

                                                        1. 2

                                                          question for all the layer-switchers here: how do you get the tap/hold speed right? doesn’t it really bother you when a key that would otherwise yield an immediate result has a delay? ( i haven’t been able to get past this minor annoyance )

                                                          1. 3

                                                            Yes, it bothers me. The only keys I use that have different usage on hold are escape (alt on hold) and the compose key (rctrl on hold). Even if you can type just fine, it not producing instant feedback on the screen is always annoying.

                                                            1. 2

                                                              I don’t. I used to have for example tap for space, hold for shift, but just could not find the timing to fully eliminate typos on that sort of thing. Eventually I decided that “almost never happens” wasn’t good enough for me.

                                                              At this point I only use tapdance and layers - no tap/hold keys.

                                                              For layer switching I never had single-tap lock via the standard qmk functions. I ran with hold-for-layer for a long time and then switched to a slightly custom solution where pressing two thumb cluster layer switchers engages locked mode. In this mode I stay in the last layer switched to, single tapping a different layer key to stay in that one. Tapping two layer keys again returns to the standard hold-to-get-layer-and-release-for-base-layer mode.

                                                              Locked mode is excellent for extended number entry / navigation or gaming.

                                                            1. 3

                                                              Python 3.8 still works even on older Windows 7.

                                                              What reason is there to stay on 3.6?

                                                              1. 13

                                                                I have a project I inherited that doesn’t run on 3.7 and I don’t want to figure out why. I assume the problem is the dependencies use async as a variable name, but I don’t want to figure out how to fix that.

                                                                1. 4

                                                                  On larger projects you end up with enough dependencies and stuck in a weird situation because of it. (For us we had tried upgrading Celery multiple times through multiple releases, ended up with game-breaking bugs each time, and ended up just pinning that for a while, meaning we were stuck on Python 3.6 for a long time.

                                                                  I had tried to debug the Celery stuff to send the fixes upstream (and I did send up a timezone fix!), but the main thing is just that because of dependency graphs on larger projects you can end up getting a bit stuck, even if your own code works A-OK.

                                                                  1. 2

                                                                    I have a project where the packaging system (that generates an installer for the project, providing the exact python env to the user) only works on a specific python version.

                                                                    I’m sure I could spend hours getting it to work again, like I did for the current version. Or I could just stay on Python 3.6. What reason is there to upgrade?

                                                                    1. 2

                                                                      I would make the effort.

                                                                      It should be far easier to do this incrementally than find that everything is broken once you fall out of the support train.

                                                                  1. 8

                                                                    Watch out: I used to use this extension, and got banned from recaptcha (infinite captcha wall, and audio solving not available). Most websites that have require recaptcha or that use cloudflare are terrible so this wasn’t a big loss, but you will no longer be able to access archive.is.

                                                                    1. 2

                                                                      When did you last use it? I’ve been using AdNauseum for years (including on mobile) and have not had this problem. Captchas are all normal and I can definitely access archive.is.

                                                                    1. 18

                                                                      This “the browser’s default styles suck therefore every webpage has an imperitive for CSS” meme is depressing. Like, yes, I sort of agree that since browser defaults are garbage it is responsible to include a couple lines of CSS to fix them. But that isn’t a reason we need CSS! We could fix the browsers!

                                                                      I think some CSS is super useful for other reasons, but it should always be possible to disable it and get a usable, readable webpage.

                                                                      1. 4

                                                                        Yes, while I support Gemini and related minimalist projects, I think there is also room for a simple web browser that basically just implements reader mode, no CSS or JS at all. It would only be useful for reading articles, not web apps or more complicated interactive websites, but for many use cases that would be more than adequate. Such a browser would be much simpler to implement, and might be possible for an individual to build from scratch, although parsing modern HTML5 is no joke (certainly much more complicated than gemtext).

                                                                        1. 3

                                                                          Yeah, I do agree with you. But I don’t think the browsers will ever fix that at source. Plus, design is so subjective that one person may find the browser defaults to be just fine, whereas other may loath them.

                                                                          1. 5

                                                                            But I don’t think the browsers will ever fix that at source.

                                                                            Yes, because that would break websites that use CSS. But if you come from a standpoint where websites wouldn’t use CSS, then browsers would immediately change default styles to be more readable. See the reader mode example used in the article: it doesn’t just make the page unstyled, it also makes it readable, like browsers would do by default if CSS didn’t exist.

                                                                            1. 3

                                                                              It would be very easy to detect unstyled websites and always put those in reader-mode. There’s a small gotcha if we’d want to allow JS in that reader-mode (to provide a default style for interactive elements) cause JS can set CSS, but that’s trivial to work around.

                                                                              Maybe we just need a head Element to instruct the browser to use reader-mode.

                                                                              1. 2

                                                                                Yes, because that would break websites that use CSS.

                                                                                It shouldn’t. The browsers don’t all use the same defaults, and their defaults can be changed to some extend already without breaking pages. Webpages with a lot of CSS use a reset so that browser defaults don’t matter. Webpages with only a little responsibly written CSS are already written to consider browser defaults a feature.

                                                                                We’re not talking about a heavy theme from the browser here, just changing obviously bad defaults. Some browsers already use sans-serif by default, all should use a sensible sans-serif font from the system. Most already have some padding around the body, just need to make it reasonably sized (I find 5% left and right pretty good, but more than 1 or 2 em for sure). And so on. Maybe creme or slate background color based on if the browser is in dark mode or not. This kind of thing.

                                                                                1. 4

                                                                                  We’re not talking about a heavy theme from the browser here, just changing obviously bad defaults.

                                                                                  Changing the default margin to center text is a big change. It would break a lot of websites.

                                                                                2. 1

                                                                                  I don’t think it would break anything. The cascade ensures this wouldn’t happen.

                                                                                  A i understand it, it goes browser style > website style > user style with each in turn taking precedence over the last.

                                                                                  1. 3

                                                                                    I don’t think it would break anything. The cascade ensures this wouldn’t happen.

                                                                                    If every websites expects no margin to be set, and you set a default margin, a lot of websites will break. It should be obvious.

                                                                                3. 4

                                                                                  We’ve all seemed to forget that we used to call web browsers “user agents”. They are an agent of the user and should be something the user controls!

                                                                                  You wrote:

                                                                                  As you can see from the screenshot above, the text spans the entire width of the screen. I also think that the text is too small. Even on my little 13” MacBook Air screen, constantly scanning my eyes from the far left to far right of the screen really strains my eyes.

                                                                                  This is why I think CSS should continue to exist.

                                                                                  In Netscape Navigator 4, I used to be able to set my preferred link color, background/foreground, fonts, etc. I was able to configure my user agent in such a way that it was comfortable for me to use. I’d expect in a world where the browser exists as a true engine of hypertext instead of as some quasi-hypertext/quasi-remote terminal engine, we’d see even deeper customization options than that.

                                                                                  1. 6

                                                                                    You still have a “user agent” and it still is customizable to a pretty high degree.

                                                                                    It just also happens to let web page authors suggest how to display the page, as a default in case you don’t choose to override it. And some people are good at coming up with helpful, useful styling. Some people are less good at it. But the world is richer for the variety they produce, just as the world is richer for the fact that we didn’t all standardize on exactly one font and list of rules for typesetting at the advent of movable type, but instead got a wide variety of books which experimented with different ways of doing things.

                                                                                    And the real logical conclusion of your argument is to require everyone to become as skilled at putting together their own user-specific styles are you are, which would ironically be a terribly disempowering thing for most users, who don’t want to put in that kind of time and effort.

                                                                                    1. 1

                                                                                      I think all modern browsers support user CSS. This takes precedence over any other CSS, so any element that is styled in your user CSS will see that style, even if it is also styled by the site’s CSS. CSS is very powerful and includes things like regex matches, so I can add a little superscript [pdf] next to any links that link to .pdf files and add a health warning next to any links that go to Facebook in my user CSS.

                                                                                      1. 1

                                                                                        Does my browser support user CSS? Certainly! Is that particularly useful in a world where a hyperlink to another site may be represented as an <a> tag, a button, a span/div with an onclick() handler, … … …? Not particularly: I either spend time building my user CSS to fit every site I interact with (hah!), or I use some type of best-effort tooling. And that’s often a huge pain. If you’ve never looked at the hoops Firefox jumps through to generate a ‘reader mode’ page, you should.

                                                                                        A counterfactual history where we didn’t get the ability to drive pixel-perfect design and instead picked up <article> and <menu> and other semantic friends early would look very different: my user agent could allow me to describe how I want to see my data presented, but more importantly, that control would exist over every site I visit.

                                                                                        1. 1

                                                                                          A counterfactual history where we didn’t get the ability to drive pixel-perfect design and instead picked up and and other semantic friends early would look very different: my user agent could allow me to describe how I want to see my data presented, but more importantly, that control would exist over every site I visit.

                                                                                          There was a problem with this history (which is what the W3C was pushing with XHTML): semantic markup makes it very easy to separate adverts and content and a UA will then always make the decision not to show adverts. When web standards are driven by a company that gets the vast majority of its revenue from adverts, this model could never exist. It’s far better from their perspective if the browser just renders pixels and the difference between ad pixels and content pixels is completely opaque.

                                                                                  2. 2

                                                                                    One of the original intents is that users would provide their own stylesheets. I don’t think that’d be as practical even in the 90s though; sites presume a default stylesheet that may not match your custom reality, nor would sites likely to use the same selectors or semantics elements for exactly the right purpose.

                                                                                    1. 2

                                                                                      Why wouldn’t that work? I understand not every single person is going to implement their own stylesheet, but os and browser vendors would likely have a nice default style and some themes one could choose from.

                                                                                      For people who want more, there would probably be a subreddit with fancy stylesheets to download for free. Browsers could make this easy by adding a button that makes it easy to switch between them.

                                                                                  1. 3

                                                                                    Some of these points should obviously be out of scope. Want to pause clipboard monitoring? Just close the software. Want it encrypted? Come on, even your browser history isn’t.