Threads for psidex

  1. 2

    Nothing too big, working on my flavour of Wordle clone; Sedordle.

    It’s getting close to finished but there’s a couple of small bugs that need ironing out and I want to add a practice mode

    1. 5

      In this case, passing a pointer into a function is still passing by value in the strictest sense, but it’s actually the pointer’s value itself that is being copied, not the thing that the pointer refers to

      Is this not how every language works when handling pointers?

      1. 6

        I think so, but I believe the main point of the article is how there are certain types, like slices, maps, and channels, that feel as if you’re passing them by value, even though they behave like references.

        This sometimes trips people up (like me), for example:

        1. 8

          I learned recently that go vet will give that warning on copying any struct which implements Lock() and Unlock() methods.


          package main
          type t struct{}; func (*t) Lock() {};func (*t) Unlock() {}
          func main() { a := t{}; _ = a }

          will trigger the vet warning.

        2. 2

          C++ references are distinct! For example in Python (and I imagine in Go as well) you can’t pass a reference to an integer. You can’t do

          x = 3
          # x now equals 4

          (in CPython you can by doing some stack trace trickery)

          This is kind of linked back to a fundamental C++-ism of built-ins being “the same as” other data types. Whereas Python/Java/Go/lots of other stuff have this distinction between builtins and aggregate types.

          Rust, being the true successor to C++ in so many ways, carries over references nicely tho…

          fn f(x: &mut i32){
              *x += 1;
          fn main() {
              let mut x:i32=4;
              println!("x={}", x);
              f(&mut x);
              println!("x={}", x);

          And beyond “changing the contents of an integer”, ultimately being able to change the variable itself (even replacing it with an entirely different object) is only really an option in systems languages.

          1. 1

            The only exceptions I can think of are:

            • perl - lists are copied
            • tcl - lists are strings
            • C - structurs are actually copied without explicit pointers
            • languages with explicit value types like C#
          1. 11

            Hetzner is awesome. I first used Digital Ocean too, but after getting more familiar with VPSs, I found Hetzner and used them since then. I think I started using Hetzner Cloud soon after they left beta status, which was already some years since ago. Have been very happy with them since then! :smile:

            1. 3

              I wish hetzner has other locations, including US and Asia. Digital oceans allows more locations. I guess the direct competitor here is scaleway, they both have limited selection of locations, and seems hetnzer having lower price now.

              1. 18

                I have two cloud servers at Hetzner. To be very very honest, a cloud provider with no presence in the US at all is really attractive for me. It’s not that I would outright cancel if they did create presence in the US, but I would become more wary of public response and opinion on the company.

                It’s a small matter of principle, I guess. I care about Europe, and feel like it’s threatened sometimes.

                At the same time, if you want to run a company with worldwide presence, I totally understand Hetzner is less attractive.

                1. 3

                  Yes, absolutely. Hetzner even has a data center in Finland, which is kinda rare.

                  1. 1

                    Another problem with a potential DC is that the US government can ask them to give over your data. That may not be an issue by itself, in theory, the government is working for the good of its citizens. But some governments, US included, are particularly bad at abusing this data to target groups of people to perform semi-legal or outright illegal operations. Additionally, once I have that data in a US datacenter, I can no longer guarantee my users that their data is fully private, as is the EU citizens’ right.

                  2. 4

                    vultr is probably a more direct competitor to DO in the vps space.

                    1. 2

                      Yep, with even lower price.

                      1. 1

                        Depends what you mean by lower price, Vultr definitely has lower priced options but seems to be more expensive for the same specs on Hetzner

                    2. 2

                      Seen as it was mentioned here, Scaleway seems to be the only cloud provider I’ve been able to find with ARM hosts available at a reasonable price. Yes, AWS has ARM, but they’re for literally 2.5x the price.

                      I’ve been pretty happy with them overall, despite being on the other side of the ocean.

                      1. 1

                        I have a single VM currently in DO because I use it to run a couple of services for my family (in the Caribbean) and also for when I am traveling home myself. Hetzner is great but the latency of going to Europe and back for something like a VPN adds up very quickly.

                        1. 1

                          Contabo (also in Germany, in fact right here in Munich) has even better pricing, depending on what server you want.

                          1. 2

                            Thanks, they seems offering bigger instances at similar pricing with hetzner. But their website looks really outdated, and makes feels like it’s a scam site :(

                            1. 1

                              I agree, looks like crap :) I even had to wait for them to “activate” my account or something, but I did get the VPS access date l data a few hours later. But it’s legit and it works so far at least.

                              As for the scam, they’re in Germany so that would make it pretty hard for them if they actually cheated, I think. So I don’t actually know what their game is. Maybe they oversell or something, which I don’t notice because I’m not using much of the resources.

                            2. 1

                              To bad they don’t offer any API that I can see. Love using Terraform for IaC.

                              1. 2

                                It seems like they haven’t even automated setup. There are probably manual steps involved in setup. But an api is an often requested feature. Let’s see how quick they can deliver it.

                        1. 2

                          Bizzarely my mobile provider (Three) blocks access to this domain. Works fine via WiFi!

                          1. 1

                            That’s really strange. I’ve been using it for several years via Do you have any guesses why?

                            1. 1

                              Unfortunately no idea; going direct to the IP works fine so a real mystery. Sadly there’s no mechanism to discuss this with them either, only thing I can think of is an accidental content block :/

                              1. 1

                                I suppose I asked for this treatment by describing myself as a “hacker”. :v(

                              2. 1

                                I’m on Three (UK) and can access your website fine

                            1. 4

                              In the toy example, why is exec used? Why not just from config import PEOPLE as people?

                              1. 7

                                Good question! Mostly the same, but I discovered few differences:

                                • your config file might have a different name (or a name that can’t be a Python module name). That can be worked around with importlib though.

                                • your config might not be in your PYTHONPATH, then you’d have to mess with sys.path to be able to import it

                                • the biggest difference is that you can pass a context to exec.

                                  In my toy example, imagine that the config was supposed to modify PEOPLE (so it could remove people from the list as well). You can achieve that with:

                                  all_people: List = ... # some code that loads people from the database
                                  globs = {'PEOPLE': all_people} # execution context for the config
                                  exec(Path('').read_text(), globs)
                                  # all_people is now modified by the config

                                  If you were to use import, you’d have to define callbacks to modify PEOPLE, which may be less aethetically pleasing (more nesting).

                                  As a real example: Jupiter config lets you modify the configuration as you want, e.g. append preprocessors. In file, you call get_config and get the configuration object. In order to bring get_config into the scope, I’d imagine Jupiter does something similar and passes globs = {'get_config': get_config} to exec.

                                So differences are fairly minor, but exec is a bit more flexible, so I prefer it now. However, for lazy and quick configuration files import config will do 95% of the job.

                                1. 2

                                  I used import to load a config file for an old Python project years ago, and the biggest pain points were the sys.path frobbing as you mentioned, reloading after changes (there are ways to do it, reload() in Python 2, importlib in Python 3, but there were some caveats with those, although I’ve since forgotten the details), and that it cluttered the FS with .pyc and __pycache__ stuff. Maybe there were other issues as well; this was years ago. I eventually switched it to exec().

                                  Here’s the config for that by the way:; I think it worked out rather well. It’s not hard to see how you could do with with a purely declarative config file, but basically that’s just wrapping a bunch of ifs.

                                  1. 1

                                    Passing a context to exec would be an anti-pattern to me. Explicit is better than implicit. The configuration should explicitly import whatever it needs.

                                    Likewise, the PEOPLE variable is magical. If you make a typo, have fun debugging that. Instead you can import a register_people function and use it. Following that pattern, there is no need to create the namedtuple Person yourself. Import the data structure from the application and you can also use the methods from it.

                                    I spent a while maintaining a buildbot configuration. We even had a few “unit” tests for the configuration.

                                    1. 2

                                      I don’t disagree – one is less nested, but implicit, another is more verbose, but explicit. Both can be type checked and linted (e.g. with Protocol), so I would say the differences are pretty minor.

                                      Yep, you’re completely right about importing People, that’s what I would do in my tools! I just wanted to keep the example simple.

                                      Something like jupiter config I’ve liked feels like a nice compromise? The only ‘implicit’ thing is import_config, which is hopefully not that magical (and yeah, also can be imported from the package as you suggested)

                                  2. 1

                                    Having made the same engineering choice (Python script for config, using exec), exec means you can just figure out the path to the code and be done with it. Imports require manipulating sys.path, which has the potential for breaking things if e.g. there’s another Python file in there with the wrong name.

                                  1. 18

                                    Having done some digging through the V source code, I’m not sure what to think. There are tons of TODOs scattered across the code, a lot of modules/functions are just stubs, and some types are just weird. A lot of features are not implemented, and variety of the author’s repositories are just placeholders. When asked about this, the answer is basically “soon”.

                                    Given V in its current state appears practically useless, I wonder if Volt is actually written in V, or if it’s just written in another language. Volt also seems to be doing some shady things.

                                    Given the current state of things, I’d say V is still a year or two away from being usable; if it ever becomes usable.

                                    1. 21

                                      Given the authors insistence on deploying closed source binaries, I was wondering if he was using it as a vector for malware. I would be pretty careful installing or trying any of his software.

                                      1. 9

                                        My brief inspection of Volt inside of a decompiler shows that it matches a LOT of what is going on in V – uses the same libraries, etc.

                                        While I have some doubts about whether it was actually written in V or just in C, it does, surprisingly enough, seem to be built on the same products that power V.

                                        1. 2

                                          Looking at, in the FAQ at the bottom:

                                          Why “V”?

                                          Initially the language had the same name as the product it was created for: Volt. The extension was “.v”, I didn’t want to mess up git history, so I decided to name it V :)

                                          1. 8

                                            Didn’t want to mess up Git history so kept the extension, but apparently so clumsy with Git that they failed to commit any of the definitely-existing, definitely-not-just-more-vaporware test files.

                                            I don’t know why anyone continues to extend the benefit of any doubt to this project or author.

                                            1. 9

                                              I also wonder about the sincerity of some of these commentators. Sure, some people might be young or inexperienced and need encouragement and all that, but then you have people who come across as scammers.

                                              Something must have gone wrong in culture if no one seriously calls out bullshit. Or if no one recognizes bullshit anymore. Makes good breeding ground for long cons, though.

                                              1. 2

                                                Well the thing that scares me is that if such an obvious scam works so well, the less obvious ones must be raking it in.

                                                1. 3

                                                  I just hope most of the “give the man a fiftieth second chance, he already labeled everything WIP” is insincere, which is a sad thing to hope for.

                                                  1. 6

                                                    It isn’t worth fighting over, my reasoning is now it is open source, people actually using it would quickly get annoyed and leave if it isn’t good, so the harm is limited. It is labeled WIP, so what more is there to do? Short of finding malware in released binaries I don’t see the point in intervening further.

                                                    Now it is just a strange form of entertainment and a lesson on human psychology. The trusting nature of some strangers is uplifting in some ways. Just think of a legitimately good project riding that wave to the top despite some hiccups.