Threads for antonz

    1. 1

      Nice summary!

      1.3 / Jun 2014 A buffered channel can be used as a simple semaphore.

      I would’ve sworn buffered channels existed with the same behavior since the beginning, and indeed:

      The Go 1.3 memory model adds a new rule […] This is not a language change, just a clarification about an expected property of communication.

      They just codified existing behavior, so I don’t thinks this counts as a new feature.

      1. 1

        Oh, okay, thanks! My focus was mainly on the newer versions.

      2. 4

        I decided to compare this to the Go changelog hosted on go.dev and I have to say I like yours significantly more. The go.dev changelog feels bloated and while it is probably useful to people developing Go or doing very heavy and specific work with it, it isn’t very good for the average person. My one suggestion would be to add some way to click on a feature and have it go to the more in-depth changelog on go.dev. I don’t know if this is possible with the current way the bigger changelog is setup, but it would be neat.

        1. 4

          I think they complement each other. Go’s release notes list every single feature, while mine focus on the major ones (so it’s quite subjective).

          But for those major features, mine actually provides more information than the official release notes, because of the links to the proposal and commits.

        2. 4

          Very nice abridged changelog. Go currently does this nicely, but here the one-sentence, commit-like, summary is a great way to read through changes.

          1. 5

            Thank you! I’d really like to see the Go release notes include links to proposals and commits. No idea why they don’t.

            1. 4

              I wondered this on the golang-dev mailing list, and Russ replied:

              It’s an interesting question, one I’ve thought about before. I think that the majority of users aren’t and shouldn’t be reading the code to learn more, so the links would be distracting and unhelpful. Links might also lead to comment threads on those CLs, which is not really what we want. […]

              (Full response at the thread.)

              1. 2

                That “shouldn’t” is doing such an interesting thing! Like, for the average changelog reader, it’s better they don’t know the implementation details and (in)advertently rely on something they shouldn’t, this is for their own good. (no valence assigned here, just legitimately interesting.)

                1. 1

                  I don’t think we know why he thinks they shouldn’t. It could be patronizing, as your redescription suggests, but it could also be empathetic (they don’t want to read it and for good reason.) I think this same issue comes up when Rob Pikes quote is referenced.

          2. 2

            Yet another way to iterate, and especially yet another way to iterate over maps and slices. Oddly enough, no sorted/stable map output still.

            I hoped Go wouldn’t go the route of having many ways to do things.

            For a while it really looked like it would be able to avoid feature creep. I remember talks by Rob Pike about how “maybe we’ll still add generics[1] , but the language is otherwise done”. Now every release changes the language, creating more redundance, increasing the amount of “legacy things” that people have to be aware of.

            What happened? What’s with the claims of the early Go conferences saying that the language is done, that things would instead happen in the ecosystem and standardlib now?

            Don’t get me wrong, I am not anti-iterator. I like iterators. I just think they essentially come too late when other mechanisms are already established and up till now were considered close to idiomatic. Yes, there have been multiple was, but what Go has now is yet another way.

            It looks like the goals shifted, and I wonder why and what these goals are now.

            [1] And that was decided long before anyone really used Go, I think pre-1.0.

            1. 1

              The person behind all the recent changes seems to be Russ Cox.

              Russ has been working on Go since 2008, but apparently something has changed in his view of the language lately.

              1. 1

                There are two kinds of language: a living language undergoing change, and a dead language.

                1. 1

                  There are two kinds of language: a living language undergoing change, and a dead language.

                  Depends on how one is conducting the change I guess. If the change is being done without regard to backwards compatibility, then one leads to another.

                  1. 1

                    I don’t understand what you mean by backwards compatibility. Is there something about Go iterators that violate this?

                  2. 1

                    I don’t think Rob Pike in his talks argued about Go needing to be dead, when he said that Go is done, and that the changes would mostly be outside of the language itself.

                    It’s more complex than that. Languages that added all the features they could think of include PHP, Perl, but also JavaScript, etc. They are all in different states of being alive, depending on whom you ask.

                    The same could be in a way said about C, various LISP dialects, etc.

                    Then there are languages like Smalltalk that sometimes see new iterations, but are at least small.

                    (no positive or negative judgement of any of these language - these are just examples of how both what alive and change can mean)

                    So it really depends on both the definition of being alive and the definition of change. The statement was about Language (as in spec) changes, not eg. libraries, ecosystems.

                    1. 0

                      It is an abuse of the flagging system to mark me as trolling for expressing an authentic point of view. See my elaboration and use better judgement in the future.

                  3. 5

                    IMO time.After should be deprecated.

                    1. 2

                      There are cases where it’s the simplest thing:

                      select {
                        case <-ctx.Done():
                          break loop
                        case <-time.After(5 * time.Minute):
                          do something
                      }
                      
                      1. 1

                        But then someone comes along and start calling this code in a loop.

                        1. 4

                          Which will be fine starting with 1.23, due to be released in August. That’s the point of the article there is just more discussion of the problem than the fix.

                          I ran the time.After loop from the post with 10M iterations and the current release-branch.go1.23 and the heap stays under 3MB. Prior to the fix this would have been several GB.

                          1. 3

                            I’d argue that allocating 10M timers in a loop is still not the best idea, even if the GC collects them all. NewTimer + Reset seems to be a better alternative for loops.

                            1. 1

                              NewTimer + Reset seems to be a better alternative for loops.

                              The soon to be 1.23 documentation says otherwise:

                              There is no reason to prefer NewTimer when After will do.

                              See my reply to the sibling too.

                              1. 3

                                Well, the documentation is wrong (for the loop use case). And your code measures memory usage after garbage collection. Add debug.SetGCPercent(-1) and see the difference: https://go.dev/play/p/ZwZKtR8VxA1?v=gotip

                                1. 2

                                  You are right that the NewTimer/Reset method will avoid allocating a new timer in each iteration and this will be significant in tight loops and many iterations.

                            2. 1

                              Unless I missed something, 1.23 doesn’t have any impact on time.After.

                              1. 1

                                https://pkg.go.dev/time@master#After

                                Before Go 1.23, this documentation warned that the underlying Timer would not be recovered by the garbage collector until the timer fired, and that if efficiency was a concern, code should use NewTimer instead and call Timer.Stop if the timer is no longer needed. As of Go 1.23, the garbage collector can recover unreferenced, unstopped timers. There is no reason to prefer NewTimer when After will do.

                                Here is the full runnable example since the blog post doesn’t seem to include the getAlloc() function it references:
                                https://go.dev/play/p/LxRat4CBNOY?v=gotip

                                I have reduced the number of iterations here because the sandbox has resource limits but the difference between a 1.22 and a tip run is still clear. You can increase it to a much larger number in you local run.

                                1. 2

                                  Thanks for following up, I wasn’t aware of this change. I wonder how they’re doing that.

                      2. 8

                        Author sounds like a dumbass. Glad he chose to rewrite in Rust and not Zig. This isn’t lobster.rs quality content IMO.

                        Actually I think this is just barely disguised click bait designed to convert to some clicks on his stupid AI startup ads.

                        1. 15

                          While the author’s attacks on the Rust community are inappropriate, your response probably says something about the Zig community as well.

                          1. 7

                            Indeed. It says that we have fewer people like OP in it because scammy business models and mindless ranting are aggressively discouraged.

                          2. 10

                            I flagged this as ‘unkind’. Calling someone a “dumbass” is not lobsters quality commenting. The post may have some issues but the frustrations are not invalid, nor are they unique to the author. Being unable to see that is a weakness.

                            1. 7

                              One other angle here is that there’s definitely this genre of posts:

                              Clearly outline some “tribal” themes (like new language vs. established language), but keep the factual content to the lowest rungs of Waddler’s ladder, such that everyone gets to participate.

                              I don’t think such posts land in a useful way: they do promote a lot of vigorous, if not vitriolic, discussion, and sometimes they can lead to insightful comments, but mostly its a waste of everyone’s time. The thing is, we all love engaging in flamewars, even though we also realize that they are not good. Disagreeing over the internet is addictive.

                              One useful metric here is comment to upvote ratio.

                              So, I’d say this post is a useful thing to share in t-lang Zulip, as it is useful user experience for language designers, but amplifying it to a larger audience is probably a wrong call: this is going to generate some clicks for medium, but I don’t think it’ll make anyone here a better programmer.

                              1. 3

                                That’s all fine, flags and votes are a totally reasonable way to express approval or disapproval. I read some of the angry bits and simply ignored them, instead trying to understand the actual problems that the author ran into - problems I believe exist, and should not even be controversial, I don’t think. Calling them a “dumbass” while complaining about low content is simply worthy of a flag, and so I provided one.

                                1. 13

                                  The “unkind” flag is justified, but I think it’s also appropriate to call out people who abuse news aggregation sites with low quality content whose main purpose is to promote crypto scams or AI crap. I don’t launch personal attacks often, but I stand behind this one. This article is not genuine.

                                  1. 5

                                    I hear you and I think that’s perfectly valid - I thought the insult was egregious, that’s all. I just didn’t want to flag and not say anything, I find it strange to do so. If I’m going to flag it then I think the least I can do is tell you about it. There’s no ill will on my part.

                                  2. 3

                                    I don’t have an opinion I am ready to articulate publicly about this particular lexical choice :)

                                    I do want to point the general issue that going just by “flags and votes” is not always the right call. There are some posts that generate engagement, but which, imo, this particular community is better without. Which is of course just my opinion which is reasonable to disagree with :)

                                    1. 2

                                      Perfectly reasonable. I’m entirely willing to believe that this article falls under “not right for lobste.rs”.

                                      1. 1

                                        There are some posts that generate engagement, but which, imo, this particular community is better without

                                        Yes, but that’s exactly where flags are the right call!

                                2. 3

                                  Different people can hold different tastes and opinions (and choices of career) without personally attacking each other. Intolerance in online communities doesn’t scale.

                                3. 5

                                  Oh, didn’t realise this was posted here; was wondering where the sudden influx of stars was coming from. Glad people like it!

                                  1. 2

                                    legit is really nice, thanks for making it! I just love the limited scope and lightweight implementation.

                                  2. 2

                                    This is a laudable project. The content is well written and I think the approach to the material makes sense for most of the languages listed (at least the ones with which I am already familiar). However, codeapi in its current incarnation does not expose type errors. In some languages, this is probably fine. But, specifically for TypeScript (which I believe is on the roadmap), it will be difficult to demonstrate its value over JavaScript since whatever type errors one might be trying to demonstrate that TypeScript can guard against are skipped without warning and the code is run anyway.

                                    1. 2

                                      Yeah, I cut some corners specifically with TypeScript. Will add type checking as soon as someone decides to work on a “Try X” guide for TypeScript.

                                    2. 11

                                      Looks like a much needed upgrade to Learn X in Y minutes which, back in 2014-2015, was one of my favorite sites and introduced me to all kinds of interesting languages and ideas. Another great resource is Try It Online which has 681 languages you can run!

                                      1. 2

                                        I think it’s important to provide not only the playgrounds, but the actual interactive guides. “Learn X in Y minutes” is a great source for these, at least for languages that don’t have their own author-provided tutorials (like Bash or C).

                                        Writing interactive tutorials for libraries and CLI tools is another niche that deserves attention. Take a look at the curl guide, for example, it’s so much better with interactive examples.

                                        The only thing that bothers me is that I seem to be the only person willing to write these interactive guides :)

                                        1. 1

                                          I agree — I always figured that Learn X in Y Minutes was more useful as a quick reference guide for languages and tools that you were already loosely familiar with than for directly learning new tools.

                                          This tool that you’ve created here definitely nails the interactive learning part better, but the primary fear that I have in recommending this to new learners is that it will eventually lock down increasing portions of accessible content in the effort to commercialize and monetize. I totally get that this tool is a demonstrative usecase for your more widely applicable underlying commercial service; I just wonder if there’s at least some assurance that you can give with regards to the continued usability of the site.

                                          With that said, this tool that you’ve made is fantastic. Thank you for building and contributing it to the commons for others to freely benefit. It’s especially neat that you can play with things beyond common programming languages and I’m exceptionally impressed by how quick and responsive it is.

                                          1. 2

                                            Thank you for the detailed feedback, Haneef! I’m glad you find the guides useful.

                                            I have no plans to monetize the content. The “Try X in Y minutes” section of the site will be available for free (and without sign up) as long as it’s financially viable.

                                      2. 1

                                        Just popping in to say that Codapi looks really neat!

                                        1. 1

                                          So, it looks like it uses docker for isolation (although looks like even that might be optional), but, by necessity of its use case, the API is unauthenticated.

                                          I don’t know, I wouldn’t run a server that can execute arbitrary code from unauthenticated HTTP requests without being paid a significant sum of money to do so. And even then.

                                          Using docker for isolation also means that running the API itself on docker is at least tricky, requiring higher privileges than a normal server. Being in Go makes it less operationally annoying (I don’t like to write Go, but man, is it nice to deploy), but not safer.

                                          1. 1

                                            For many use cases, it’s much easier to use the cloud version.

                                            For self-hosting, a separate server without access to sensitive data is a must. Otherwise, it’s pretty safe.

                                          2. 2

                                            This is really filling a gap, not only for polyglot notebooks but also to give AI the ability to run and build code. The fact that the cells engine is decoupled from the UI and potentially the data flow engine (need to check that) makes it a great foundational building block.

                                            1. 2

                                              Well, there’s an API, so AI could definitely call it. If you have a specific use case in mind, I’m ready to check out if it could work.

                                              1. 1

                                                Thanks! Nothing concrete right now, but the two use cases I see for me are updating and running cells with quite a bit more data than a single notebook (dozens of files between 200-1K loc), and then maintaining variants of a “notebook”/codebase, like what would the result be if I change just that small part of the program.

                                                1. 1

                                                  Thanks! Nothing concrete right now, but the two use cases I see for me are updating and running cells with quite a bit more data than a single notebook (dozens of files between 200-1K loc), and then maintaining variants of a “notebook”/codebase, like what would the result be if I change just that small part of the program.

                                              2. 1

                                                Can you give some details how this works? It’s pretty interesting that a single query could be translated to different engines.

                                                1. 4

                                                  Oh, it’s not actually translated, it’s run as is on each of the DBMSs. That’s the point — to see how this exact SQL query performs on different engines.

                                                2. 2

                                                  Looks neat, but you seem to think that an outer join and a left join are the same thing. That’s not true. (incorrect page: https://antonz.org/sql-cheatsheet/ )

                                                  I did a tutorial today where I explained how joins worked to a student. You can view the whiteboard here for my explanation: https://jamboard.google.com/d/17V39ADf01zcRs3OIDtQqwc41d7To8LKjzOzIXHOsnd0/edit?usp=sharing

                                                  1. 3

                                                    Of course I don’t think so. Nor does the article say so.

                                                    1. 8

                                                      I think they’re saying it because the linked page has a heading “Outer JOIN (LEFT JOIN)” and some text “An outer (left) JOIN, on the other hand, says [definition]”. I don’t know if you intended it, but this parenthetical looks left join is an alternate name for outer join, and having only one definition implies they have the same definition. If you don’t mean to say so, that would be a good place to add a sentence like “While outer join and left join are very similar, the difference is that…”

                                                      1. 1

                                                        Perhaps that’s confusing, but it is a completely standard use of parentheses in English.

                                                        1. 4

                                                          Do you have a source for it being standard English to use parentheses to note — if I understand correctly — alternative pieces of text that, if all substituted for the pieces of text before them (in some context-dependent way) would give an equally true sentence?

                                                          As a native English user, the only ‘English’ writing in which I’ve ever seen that use of parentheses is the Encyclopedia of Mathematics, which was translated from Russian and somewhat often uses grammar that sounds odd in English. Some examples of this use of parentheses in that encyclopedia can be seen in https://encyclopediaofmath.org/wiki/Vector and https://encyclopediaofmath.org/wiki/Neighbourhood. Personally, I find it confusing, particularly when they use parentheses both in this way and in the more usual way of clarifying, rather than replacing, something preceding.

                                                          1. 3

                                                            Something similar is used commonly in mathematical writing in English, but only along with the word “respectively” or the abbreviation “resp.”. See https://linguaphiles.livejournal.com/2058743.html.

                                                            1. 2

                                                              I don’t have a source, but I’ve definitely seen it, although it’s not super common. E.g.: A right- (resp: left-) handed person is someone who writes with their right (left) hand, and is usually left- (right-) footed.

                                                              1. 1

                                                                I wouldn’t consider that the same phenomenon, when it’s marked with “resp.” (after German “bzw.”), whereas here and in the EoM it’s unmarked and looks the same as the standard use of parentheses to clarify what was just said.

                                                            2. 1

                                                              When one is writing a piece like the OP, the goal is to be understood by the audience (whoever that may be). Conforming to standard syntax is not usually a goal, in and of itself; it’s desirable mostly inasmuch as using familiar grammar will help you to be understood. Saying “this text may be confusing, but it’s standard” misses the point: the goal was never to be standard—it was to be understandable!

                                                          2. 2

                                                            Fair enough, silly of me to think so. pushcx is right that I think “Outer (left) join” is confusing/misleading.

                                                          3. 1

                                                            Looking at both Postgres and SQL Server, LEFT JOIN and LEFT OUTER JOIN are equivalent as are JOIN and INNER JOIN. Both INNER and OUTER are optional keywords, included for compatibility.

                                                            Am I missing something?

                                                            1. 2

                                                              A left join is an outer join, but not all outer joins are left joins.

                                                              In the tutorial whiteboard, I called a full outer join simply “outer join”, which is maybe confusing you, and was probably a bad idea on my part.

                                                          4. 2

                                                            Oh this is excellent. Always love to see work being done in making documentation better. It’d be amazing to see if these interactive examples could be embedded into documentation generators like Sphinx too

                                                            1. 3

                                                              Thanks! Yes, they can be embedded in the Sphinx documentation.

                                                            2. 1

                                                              I’m working on interactive code playgrounds in the browser for different languages. If you happen to be interested in trying it out, please let me know.

                                                              And if you think that it’s a terrible idea — please tell me. I’m obviously biased here and need other opinions.

                                                              1. 2

                                                                Not a terrible idea, but it is a busy space:

                                                                • for data science languages/setups you have binder, google colab, cocalc, kaggle kernel, azure notebooks
                                                                • for C/C++ there is compiler explorer and related projects + a few others
                                                                • for Rust there is the rust playground
                                                                • for javascript and web stuff there is jsfiddle and many others
                                                                • there is also the more general-purpose replit.com

                                                                None of these are “perfect” (except maybe jsfiddle. I have very little bad to say about jsfiddle), but out of curiosity is this meant to be an alternative to some of these or a completely different thing?

                                                                1. 1

                                                                  It supports multiple languages, so in some ways it’s similar to repl.it.

                                                                  But it’s specifically designed for embedding in articles, product documentation, online courses, mobile apps, etc. — so it’s much more lightweight.

                                                                  It can also be self-hosted with custom sandboxes (e.g. in the enterprise environment to provide a playground for working with some internal libraries).

                                                                  1. 3

                                                                    sounds cool! feel free to drop me a link :)

                                                                2. 1

                                                                  And if you think that it’s a terrible idea — please tell me. I’m obviously biased here and need other opinions.

                                                                  I don’t think it’s a terrible idea but it is hard to do securely. You need to run compilers and then untrusted code in a way that doesn’t allow an attacker to do anything bad. I’ve seen others shut down because people uploaded either code to do bitcoin mining or code that contained the PoC code for the latest CVEs (if there’s a container or VM escape vulnerability, for example, expect bots to submit the code to try it).

                                                                  1. 1

                                                                    Sure, the attack surface here is huge.

                                                                3. 2
                                                                  1. Attempts to fetch the spec from the owner’s GitHub repo https://github.com/OWNER/NAME

                                                                  Horrible idea, assuming Github is the only one place where stuff happens or is hosted, also in that exact namespace. I’ve been a Github user since 2009 and I didn’t manage to grab the nick I usually use or would use in any new package manager, so it’s not the “canonical name”. Unless I personally give “wink’s_github_user/package” as the real name, it would be 100% wrong to assume it. To elaborate, if I had an sqlite extension and you provided a package registry website, I would probably register “wink/awesome” but it might be hosted on “github.com/winks/awesome-sqlite” - but the user “github.com/wink could add a repo “awesome-sqlite” and beat me to getting downloaded and installed. If that is not the case, you need to rewrite your explanation ;)

                                                                  Not saying you’re doing worse than others, but also not better.

                                                                  Sneaky edit: With Go, I atleast know I need to use ‘winks/awesome-sqlite’ in the code for an automatic Github lookup, but there’s no way I would be misled to register some “wink/awesome” package/name somewhere.

                                                                  1. 2

                                                                    You won’t register “wink/awesome” in the registry if your username is “winks”. Because, well, “wink” is not owned by you.

                                                                    This invalidates the rest of the assumptions.

                                                                    Of course, in this imaginary scenario you can host your package elsewhere and name it whatever you want. The manager supports this as well (by using full URLs).

                                                                    1. 1

                                                                      Point taken, but this paragraph is still unclear:

                                                                      We’ll bootstrap the registry with known packages, so the manager will work right out of the box.

                                                                      So does that mean you will decide that my package will be winks/awesome-sqlite because it’s hosted there? Maybe it’s again just the phrasing but I am confused how canonical the github repo is is.

                                                                      1. 2

                                                                        In the registry, the “name” part can be whatever you want, but the “owner” part is your GitHub username.

                                                                        We need an owner ID, and since there is no globally approved source of usernames, the GitHub username is the next best thing.

                                                                        Of course, we could add domain to the mix, but that would be massive overkill for such a niche package manager.

                                                                  2. 4

                                                                    Very nice write-up and a great exercise in keeping things simple, applying YAGNI, avoiding feature creep, etc.

                                                                    1. 1

                                                                      Thanks a lot! Some nice-to-haves (like the “latest” version) can be omitted, but overall I tried to keep things simple.

                                                                      Using Go also helps towards this path :)

                                                                    2. 4

                                                                      This comports with my experience building a rudimentary package manager for Apache NiFi around five years ago. We needed to deploy pre-configured workflows to NiFi (and MiNiFi eventually) using its API. During a few sprints, I put together a package format, a build process for packages, a service to host the packages, and a rudimentary list-packages function with a manifest file to install them. It was a fun project. I hoped to open-source it because it worked so well for us, but I parted ways with that company before it was polished enough to do so.

                                                                      1. 2

                                                                        I also found it surprisingly fun! Challenging enough to be interesting, yet possible to implement in a reasonable timeframe.

                                                                        Now I think it’s perfectly fine to build a niche package manager if you need one.

                                                                      2. 2

                                                                        Can I ask what makes the other languages seem “bloated”?

                                                                        1. 4

                                                                          For Rust, Nim and Zig, it’s the sheer number of features. Hare, on the other hand, has too few (not even a hashmap).

                                                                          1. 12

                                                                            Interesting, when I looked at the list of features, to me it seemed like a lot compared to Zig.