Threads for zaynetro

  1. 28

    Go is like the Debian Stable of languages, and I quite enjoy that at this point in my career.

    1. 14

      Whilst I agree that the language has remained super stable over the years, let’s also note that the tooling around the language hasn’t. I personally had to migrate from GOPATH to vendoring dependencies, then to Godeps and now finally to Go modules.

      Two stories about working with Go:

      1. We run Jenkins on AWS and around year 2017 fetching Go dependencies would fail once in a while. It turned out that Google was blocking requests from AWS network. Once we configured a proxy running in GCP problems disappeared. Nowadays, we no longer need that proxy.
      2. I initially created a backend project in Go and then quit the company. I rejoined them 3-4 years after and to my surprise the project hasn’t undergone much work. Once I installed the latest Go version the project would just run so I didn’t need to migrate any of the code nor dependencies. That was such a nice experience especially compared to me migrating from Java 8 to Java 11… But that’s a totally different story and not the pleasant one.
      1. 5

        Yes, once on Reddit someone made a comment about the stability of Go vs Node, so I dug up an archived project from only 2 or so years before (predating Go modules). Getting it to run on the current version of Go with Go modules was trivial. I gave up on getting it to run with the current version of Node because even with a Yarn lock, it just did not want to install. Maybe I could have fixed it within a day, but it was different from “just working” as Go did.

      2. 13

        Working in the Go ecosystem has made aware of how much breakage in other ecosystems is basically needless churn. Go even has a code rewriter as part of the core toolset and they still never break stuff as a matter of principle. Other projects are like “someone could someday make a rewriter therefore let’s break the code now.”

        1. 8

          I am quite excited for generics, since the lack of generics was holding me back from using it much. Now that they have it, I think I will also enjoy the stability of Go.

        1. 3

          I absolutely loved “A Single Example” section.

          1. 8

            From my personal experience (just a few small hobby projects) I’ve noticed that I try not to use .clone() too early on in the design of the program. In the end I spend too much time trying to remove the clones that I distract myself from actually figuring out the algorithm.

            When I notice me going sideways I ask myself: “What is really wrong with me using clones in this program?” And the answer always is: “There is nothing wrong. It just looks ugly…”.

            So my personal tip: Just use .clone() when writing the program. You can remove them later on when needed.

            1. 3

              I’m a big fan of ZeroSSL for larger organizations for a lot of reasons. While LE is amazing at its mission of getting more of the internet on HTTPS, it lacks some of the features I think are well worth paying for. Having a REST API you can use to integrate internal tooling is really nice, allowing applications to request and manage their own certificates. It also offers email verification for certificates which is great for applications where the lack of IP whitelisting that Let’s Encrypt provides is a problem.

              All that said, if your org uses LE extensively as many do, I don’t think there is a real business usecase for randomizing it. If LE is down for a long period of time, then you might need to switch, but it seems strange to optimize for that edge case.

              1. 1

                Does the email validation mean that you can get a cert with no A record and no DNS control?

                1. 2

                  Yup! Let’s Encrypt didn’t want to deal with the headache of managing email at scale to automate that form of domain control, but there are a few RFC-standardized email addresses you can rely on, as zaynetro mentions. But the CA/Browser Forum baseline requirements only require (for “basic”/DV certs, anyways) that you prove you control a domain. There are lots of ways to do that, since that’s a social agreement.

                  1. 1

                    Sounds kind of crazy from the ACME perspective but email validation is acceptable to the CA/B baseline requirements and is basically the norm for DV certs for non-ACME issuers. The security implications aren’t great, and you need to make sure that e.g. no user can register one of the email addresses that’s acceptable to CA/B for this purpose, but it can be convenient for scenarios like issuing certificates for internal systems (not internet accessible) that use public domain names.

                    1. 1

                      it can be convenient for scenarios like issuing certificates for internal systems (not internet accessible) that use public domain names

                      I use DNS challenges for this purpose. Once I got tired of manually creating and cleaning the challenge-response records, I spent a few hours adapting one of the existing plugins to work with my DNS host.

                      I like this better than injecting email into the process.

                    2. 1

                      Looks like it: https://help.zerossl.com/hc/en-us/articles/360058295354-Verify-Domains

                      To verify your domains via email, first, select one of the available verification email addresses and make sure you have access to the associated email inbox. Typically, you will be able to choose between the following types of email addresses for your specific domain:

                      admin@domain.com, administrator@domain.com, hostmaster@domain.com, postmaster@domain.com, webmaster@domain.com

                  1. 8
                    let name = 'foo bar'
                    await $`mkdir /tmp/${name}`
                    

                    It seems it has shell escaping built-in. Nice.

                    1. 2

                      Yes, it does. 🙌

                        1. 6

                          Template literals is a JS feature but in the example above what directory would be created? foo or "foo bar"? I think the OP meant that with “built-in shell escaping” the example will create "foo bar" directory without the need for you to wrap spaces with double quotes.

                          1. 4

                            Yes, you are right. Zx escapes every argument which comes from ${}.

                      1. 1

                        I have been trying esbuild at work to see whether we can replace our old browserify and webpack builds. The results have been very promising with a single esbuild dependency replacing a multitude of webpack loaders and other dev dependencies. The build times were also much much faster.

                        The only two downsides that prevent us from migrating to esbuild are ES5 support (we need it for one project) and code splitting (we use dynamic import statements to fetch customer specific configuration).

                        1. 14

                          Using fish has the benefit of being able to use a real programming language to define helper functions and having all of those neatly stored in .config/fish, so there is no random mess in my $HOME.

                          1. 4

                            I have switched to fish this year and it has been a game changer for me. My configuration is now simple and I got a lot of features that I was missing out of the box.

                            1. 1

                              Also, the features that fish has built-in are usually implemented in a better way than those added on via scripting in zsh/bash.

                            2. 2

                              \o/ yay for fish

                              I particularly like being able to ‘save’ variables to my config within the shell.

                              1. 1

                                Eshell also has this benefit. It’s great!

                              1. 2

                                I have always used curl ifconfig.me. Easy to remember thanks to the name resemblance with a command utility.

                                1. 4

                                  For sure, for 1-off manual requests, I don’t think it matters what you use. But I argue that if you are writing code against it, or putting any load against it at all, you should just host it yourself. and upthread I say how in NGINX, it’s super easy.

                                1. 6

                                  Congrats on moving to full-time Gleam, Louis! I heard your episode with Inference and understand how difficult it is to have to switch between open source and paid work, especially with such a demanding project as Gleam and your work in Elixir.

                                  I’m hoping others start seeing the value of Gleam more and that you don’t have to worry about switching back and forth.

                                  1. 4

                                    Do you mind sharing the name of the episode or a link to it? I don’t seem to be able to find it…

                                      1. 1

                                        Thank you!

                                    1. 1

                                      Thank you! I hope so too!

                                      I’m going to try and only pick up short term contracts in future, as to be less disruptive to Gleam development.

                                    1. 7

                                      TLDR: Kotlin is nice but the fact that you can have a full dev environment only in IntelliJ makes it hard to adopt in the teams.

                                      There is an independent Kotlin language server but the repository says right off the bat:

                                      This repository needs your help!

                                      As for JetBrains position on the topic:

                                      We have no plans to support LSP at this time. Instead, we’re focusing on providing the best possible Kotlin development experience in our own IDE, IntelliJ IDEA.

                                      While I understand JetBrains’ motivation and I really like where language is going (I actually really want to try their new Compose for Desktop project) there might be some tensions when introducing the language. In fact I have recently removed a few Kotlin classes from our Java project to speed up build times and remove a lot of pain for me (I work in Emacs and use Eclipse’s language server for Java which knows nothing about Kotlin classes).

                                      As for the null safety example I guess it is is a common practice to use java.util.Optional nowadays:

                                      int subLength = 0;
                                      if (obj != null) {
                                        if (obj.subObj != null) {
                                          subLenth = obj.subObj.length();
                                        }
                                      }
                                      

                                      could be written as

                                      int subLength = Optional.ofNullable(obj).map(o -> o.subObj)
                                          .map(s -> s.length).orElse(0);
                                      

                                      Obviously, it is not as short as in Kotlin but a huge improvement over if/else nesting.

                                      1. 2

                                        Interesting – in Java, if I were trying to be concise, I’d probably turn to a ternary operator first, like

                                        int subLength = obj != null && obj.subObj != null ? obj.subObj.length() : 0;
                                        

                                        Still less concise than the Kotlin example but (to me, totally subjective) clearer than the Optional call chain and doesn’t require instantiating a series of intermediate objects.

                                        1. 1

                                          You can do the null checking in a less concise way in Java, but it becomes a pain for highly nested types from third party libraries. Additionally, having the optional types in Kotlin make it really easy to enforce when something might be null vs will never be with syntax that’s shorter than Java. I know Java has @Nullable and @NotNull, but I never got it to enforce the checks as easily as Kotlin. If you are working a big project and you don’t have a standard way to determine if something is nullable or not, you end up with null checks everywhere for safety, which is a pain. For new developers to Kotlin you can just tell them not to use !! in production code, and then you don’t get NPEs.

                                          There are other languages that have nicer optionals, but I think Kotlin does a good job while still working well with existing JVM libraries written in Java.

                                      1. 9

                                        This combined with the SIMD API is a huge deal for all of those Java/Scala big data frameworks. They can reduce the memory usage and GC issues with relatively little effort. They can also remove some fragile code that uses arrays of ints/doubles in a specific pattern in hope it’ll be autovectorized.

                                        Making Optional a primitive object will also fix the major complaint of optionals possibly being null.

                                        Edit: I forgot to mention the companion JEP that lowers the overhead of boxing Integer, Double, etc. which gives more performance gains for free.

                                        1. 2

                                          I have been dreaming about Optional never being null. Perhaps, my dreams will eventually come true. Just need to wait a bit more… and then maybe a bit more again…

                                          1. 2

                                            It will probably still be nullable for bAcKwArD-coMpTtIBiLiTy reasons.

                                            As far as I see, the current idea is that you may be able to opt-in explicitly with additional syntax tax by writing

                                            Optional.val<Float> maybeFloat = ....
                                            

                                            everywhere, instead of

                                            Optional<Float> maybeFloat = ....
                                            

                                            (I’ll elide my remark that it is called val despite value type being the previous name of inline type primitive type.)

                                            1. 1

                                              Yeah what you wrote seems correct. The design of primitive objects is very carefully constructed to create minimal backwards incompatibility and with the ability to retrofit it on as many places as possible with minimal changes. It’s annoying from the perspective of someone that’s writing new code, but given Java’s audience of huge, slow moving enterprise software the adherence to compatability is great. I’m curious to see how Kotlin and Scala will handle this.

                                              Also I agree it’s weird they’re still using .val despiteit being called primitive objects now.

                                              1. 1

                                                Agreed. I think the design largely considers that “just works” simply isn’t very Java-like, where everything has to be slightly worse than it could have been with the same effort.

                                                Scala will probably keep being a trash fire circling around the drain and for Kotlin it only becomes relevant as soon as Android starts supporting it (so not in our lifetimes).

                                                1. 1

                                                  Android has supported Kotlin for quite a while now. In fact, I doubt many new projects are written in Java anymore.

                                                  1. 3

                                                    I believe they meant once the Android not-JVM-runtime supports primitive objects and the associated bytecode/classfile changes, not once Android supports Kotlin.

                                        1. 12

                                          Oh my, those are some magic words right there. I wonder how it will be fatally flawed and disappoint.

                                          1. 16

                                            The price might be one issue: It will be retailing for $369. Compare that to Nokia feature phones that cost 20 Euros.

                                            1. 5

                                              I guess it really is a “premium feature phone”, which is another word for being expensive.

                                              1. 7

                                                On the other hand Nokia has been doing mobile phones for years and already had an infrastructure for building them. While this company seems to be doing everything from square zero. IMO this justifies the price.

                                                1. 4

                                                  It might, but the thing is with that price it is nearly guaranteed a flop. Who would want to spend that amount of money on a feature phone? Like I wish them well and I think it is a cool idea, but I couldn’t justify the price for anything.

                                                  1. 3

                                                    That explains it, but it doesn’t legitimize it. I could sell you a feature phone for $5000000 that would arrive in 20 years, because I currently have no idea how to build one, and it will take a while to find out.

                                                2. 1

                                                  I’m using one of those Nokia phones, for 8 years to be exact.

                                                  One thing I don’t expect this “new” feature phone to match is the battery life of my 8 year old one (3-4 weeks).

                                                  Considering the progress in battery technology and microprocessors, bundled with an eInk display, I would demand at least 4-6 months of battery life without charging.

                                              1. 1

                                                UPD: I will try owncloud. It has virtual file support on the desktop client and a similar thing on the Android app. Nextcloud seems to support it (virtual drive) soonish as well.

                                                1. 3

                                                  Nextcloud does this pretty well. It provides a Dropbox-like client for most platforms and on mobiles it exposes itself as a file store so integrates in the same way.

                                                  1. 1

                                                    Can I have some files to be always present on the device? Last time I read it was over WebDAV so I needed a connection if I wanted to access files.

                                                    1. 2

                                                      I don’t think you can if you use WebDAV. If you use one of their clients, the UI is just like DropBox / OneDrive / whatever: files marked as favourites will always be local.

                                                        1. 1

                                                          Oh I had missed that! Looks promising.

                                                        2. 1

                                                          Thanks! I will check it out

                                                    1. 2

                                                      Have you tried just using Syncthing, without the SMB share? There’s a native Android client. It works Okay, though I need to figure out a better way to arrange the sync destination/layout.

                                                      1. 1

                                                        I used to have only Syncthing on all of my devices but now have configured a SMB share so that it is a bit easier to browse the files. Also my family could use it to access a family photo archive.

                                                        1. 1

                                                          Right, I use Syncthing to back up my phone’s photos to my NAS, which has its own sharing/display mechanisms. Feels like a fairly good substitute for Google Photos sync, at least.

                                                          Do you feel that the SMB component is actually combining multiple solutions though? It sounds like the actual Dropbox-like selective sync is all done by Syncthing, but you’re augmenting the result with SMB for more usecases. It just so happens that Dropbox does all those things in addition to sync (sharing, album gallery, etc) but I feel more comfortable knowing that Syncthing will only safely sync files and not risk being exposed to weird sharing vulnerabilities.

                                                          1. 1

                                                            Syncthing works well for me for the same use case: backing up files from the device to NAS. The other way around is a bit more challenging. Let’s say I want to access my family photo archive (which is many gigs) from my phone. For this I was planning to use SMB share cause it lets me browse the remote folder and access the file I want. I guess it would be nice to have GUI for Syncthing to stop ignoring a file/folder and download it to the device.

                                                            1. 1

                                                              Yea you’re totally right about that. I also find syncthing is much simpler to reason about as one-way backups rather than by-directional data flow.

                                                      1. 2

                                                        The best I’ve seen is Mountain Duck but unfortunately while it is FLOSS there is no Linux port yet

                                                        1. 2

                                                          Looks rather similar to rclone.

                                                          1. 1

                                                            Hmm, maybe. rclone looks more like sshfs? It might be better than sshfs, but what Mountain Duck can do is sync the local (partial) copy of a directiory to the remote in the background / resume after connection loss etc, like Dropbox would.

                                                            1. 1

                                                              I have used Mountain Duck up to version 4 beta and I switched to rclone. The two services are pretty comparable, minus the UI for rclone. They both do partial/on demand syncing of files and mount most services.

                                                              I had fewer sync errors with rclone than I did when I was using MD. I mainly sync to google drive, box, and dropbox. I have lost some important work with MD when it failed silently on a bad connection. I haven’t experienced the same problems with rclone but I have also just been at home most of the time since I set it up.

                                                              1. 1

                                                                They both do partial/on demand syncing of files and mount most services.

                                                                Interesting… I can’t find anything about this in the docs. What does your setup look like?

                                                                1. 1

                                                                  This is what I use to mount a google drive mount. Take a look at the Rclone mount page, specifically to the vfs file caching section.

                                                                  $(eval tmp_dir := $(shell mktemp -d -t rclone-XXXXXXXXXX))
                                                                  rclone cmount --daemon \
                                                                           --allow-other \
                                                                           --dir-cache-time 48h \
                                                                           --vfs-read-chunk-size 32M \
                                                                           --vfs-read-chunk-size-limit 2G \
                                                                           --buffer-size 512M  \
                                                                           --vfs-cache-mode full \
                                                                           --daemon-timeout 5m \
                                                                           --cache-dir $(tmp_dir) \
                                                                           mount_name mount_folder
                                                                  
                                                        1. 2

                                                          Have you looked at perkeep (ex-camlistore)? Not sure it suits the problem though.

                                                          FWIW, I do the same as you do, I simply have like 3 syncthing folders that get synced to the different computers, or not.

                                                          1. 1

                                                            With perkeep isn’t everything always remote?

                                                            1. 1

                                                              I have read about perkeep a while ago but couldn’t really understand what it does. Perhaps, it is time to try it out

                                                            1. 6

                                                              This combination of SQLite and consistent backups looks nice. What I still don’t understand is how you deploy your application or migrate to another node.

                                                              Seems like SQLite supports read/write from multiple process so I can start another process and then terminate the previous one once it stops processing requests.

                                                              How about migrating to another node? You might want to install the updates or AWS has scheduled your node to be restarted. Does it mean that in this case I would need to stop all requests then wait until no more writes are happening to the database and then restore it from the S3 on another machine?

                                                              1. 3

                                                                Does it mean that in this case I would need to stop all requests then wait until no more writes are happening to the database and then restore it from the S3 on another machine?

                                                                That’s my understanding as well. One way to mitigate this would be to switch your application to read-only as you bring up a replacement node. For the duration of the restore process you’ll have degraded availability, but you won’t be “down”.

                                                                1. 3

                                                                  SQLite does support multi-process access to the same db file, but doing this over a network filesystem like NFS or SMB is strongly discouraged: most network filesystem implementations have problems with file locking, and improper locking can easily cause database corruption.

                                                                  So this wouldn’t work for migrating to another host. It would however let you update your server code, on the same host, without downtime.

                                                                  1. 1

                                                                    Yep, that was my understanding as well. Being able to switch to another process on the same host.

                                                                1. 7

                                                                  About that arm64/aarch64 TIER 1 case …

                                                                  This will kinda help you:

                                                                  https://up.bsd.lv/

                                                                  Description from the page itself:

                                                                  up.bsd.lv is a proof-of-concept of binary updates using freebsd-update(8) for FreeBSD 13.0-CURRENT and 12-STABLE to facilitate the exhaustive testing of FreeBSD and the bhyve hypervisor and OpenZFS 2.0, and to help elevate ARM64 to Tier 1 status. Updates are based on the SVN revisions of official FreeBSD Release Engineering weekly snapshots.

                                                                  Features:

                                                                  • Kernels are built with the GENERIC-NODEBUG configuration file

                                                                  • /etc/freebsd-update.conf is modified to use up.bsd.lv

                                                                  • /usr/sbin/freebsd-update is modified to “xargs” parallel phttpget (Thank you Allan Jude)

                                                                  • freebsd-update(8) does not output to the $PAGER

                                                                  Hope that helps.

                                                                  reply

                                                                  1. 1

                                                                    Thank you! m(_ _)m

                                                                    1. 1

                                                                      This looks really useful. Thanks!

                                                                    1. 2
                                                                      o 13.0-BETA1 aarch64 ROCKPRO64
                                                                      

                                                                      Can’t wait to try this out!

                                                                      1. 2

                                                                        I am running alpha on my rockpro64 and it works great!

                                                                        I have only two concerns:

                                                                        • Lack of support for freebsd-update. I hope this will work on the release but arm64 remains Tier 2…

                                                                        This may be because upgrading from this platform (arm64) or release (13.0-ALPHA2) is unsupported by freebsd-update. Only platforms with Tier 1 support can be upgraded by freebsd-update.

                                                                        • Lack of 4K HDMI output

                                                                        uboot shows the output but the kernel doesn’t boot.

                                                                        1. 2

                                                                          This is so encouraging to hear! I’m currently using a $30 AliExpress LCD for the Rockpro64 that maxes out at 1024x600 so the lack of 4K doesn’t bother me at all.

                                                                          1. 1

                                                                            Success! Took me a little bit of digging to feel comfortable enough replacing Linux on the eMMC but it’s all worked great. Really pleased to see this coming up via U-Boot’s EFI support.