Would be cool if all these new types of patterns could also be used in places where we already have more primitive pattern matching (assignments / for loops) but couldnt find anything about that.
Does anyone know anything about that?
Indeed, in Haskell or OCaml, pattern matching is much more pervasive, and algebraic types make it much nicer to use. Still, even what they did in Python is quite useful in many cases. It’s not the first case of a dynamically typed language to do that either: Erlang has been doing it for a long time.
Tomorrow seems to be a very bad day for all those poor souls, who didn’t have time/resources to switch to py3 yet.
Fortunately enough it can be easily fixed with pip<21
but it will definitely add additional grey hairs to some heads.
As one of those poor souls, thanks. We have eight years of legacy code that Just Works and so seldom gets touched, and a major 3rd party framework dependency that hasn’t updated to Python 3 either. We just got permission and funding to form a new engineering sub-group to try to deal with this sort of thing, and upper management is already implicitly co-opting it to chase new shinies.
Python 3.0 was released in 2008. I personally find it hard to feel sympathy for anyone who couldn’t find time in the last twelve years to update their code, especially if it’s code they are still using today. Even more so for anyone who intentionally started a Python 2 project after the 3.0 ecosystem had matured.
Python 2.7 was released in 2010. Python 3.3 in 2012. Python 2.6 last release was in 2013. Only from this date people could easily release stuff compatible with both Python 2 and Python 3. You may also want to take into consideration the end of support date of some of the distributions shipping Python 2.6 and not Python 2.7 (like Debian Squeeze, 2016).
I am not saying that 8 years is too fast, but Python 3.0 release date is mostly irrelevant as the ecosystem didn’t use it.
Python 3.0 was not something you wanted to use; it took several releases before Python 3 was really ready for people to write programs on. Then it took longer for good versions of Python 3 to propagate into distributions (especially long term distributions), and then it took longer for people to port packages and libraries to Python 3, and so on and so forth. It has definitely not been twelve years since the ecosystem matured.
Some people do enough with Python that it’s sensible for them to build and maintain their own Python infrastructure, so always had the latest Python 3. Many people do not and so used supplied Python versions, and may well have stable Python code that just works and they haven’t touched in years (perhaps because they are script-level infrastructure that just sits there working, instead of production frontend things that are under constant evolution because business needs keep changing).
Some of our toolchain broke in the last few weeks. We ported to python3 ages ago, but chunks of infrastructure still support both, and some even still default to 2. The virtualenv binary in Ubuntu 18.02 does that; and that’s a still-supported Ubuntu version, and the default runner for GitHub CI.
I think python2-related pain will continue for years to come even for people who have done the due diligence on their own code.
Small tip regarding virtualenv
: Since python 3.3 virtualenv comes bundled as the venv
module in python, so you can just use python -m venv
instead of virtualenv
, then you are certain it matches the python version you are using.
virtualenv
has some nice features which do not exist for venv
. One of the examples is activate_this.py
script, which can be used for configuration of remote environment, similar to what pytest_cloud does.
virtualenv has some nice features which do not exist for venv
Huh, thanks for pointing that out. I haven’t been writing so much Python in the last few years, and I totally thought venv
and virtualenv
were the same thing.
Consider, at a minimum, the existence of PyPy; PyPy’s own position is that PyPy will support Python 2.7 forever because PyPy is written in RPython, a strict subset of Python 2.7.
Sympathy is not required; what you’re missing out on is an understanding that Python is not wholly under control of the Python Software Foundation. By repeatedly neglecting PyPy, the PSF has effectively forced them to create their own parallel Python 2 infrastructure; when PyPI finally makes changes which prevent Python 2 code from deploying, then we may see PyPy grow even more tooling and possibly even services to compensate.
It is easy for me to recognize in your words an inkling of contempt for Python 2 users.
Every time you hop into one of these threads, you frame it in a way which implies you think various entities are obligated to maintain a Python 2 interpreter, infrastructure for supporting Python 2 interpreters, and versions of third-party packages which stay compatible with Python 2, for all of eternity.
Judging from that last thread, you seem to think I am one of the people who has that obligation. Could you please, clearly, state to me the nature of this obligation – is its basis legal? moral? something else? – along with its origin and the means by which you assume the right to impose it on me.
I ask because I cannot begin to fathom where such an obligation would come from, nor do I understand why you insist on labeling it “contempt” when other people choose not to maintain software for you, in the exact form you personally prefer, for free, forever, anymore.
Your sympathy, including any effort or obligation that you might imagine, is not required. I don’t know how to put it any more clearly to you: You have ended up on the winning side of a political contest within the PSF, and you are antagonizing members of the community who lost for no other reason than that you want the political divide to deepen.
Maybe, to get some perspective, try replacing “Python 2” with “Perl 5” and “Python 3” with “Raku”; that particular community resolved their political divide recently and stopped trying to replace each other. Another option for perspective: You talk about “these threads”; what are these threads for, exactly? I didn’t leave a top-level comment on this comment thread; I didn’t summon you for the explicit purpose of flamewar.
Finally, why not reread the linked thread? I not only was clearly the loser in that discussion, but I also explained that I personally am not permanently tied to Python 2, and that I’m trying to leave the ecosystem altogether in order to avoid these political problems. Your proposed idea of obligation towards me is completely imagined and meant to make you seem like a victim.
Here are some quotes which I think display contempt towards Python 2 and its users, from the previous thread (including your original post) and also the thread before that one:
If PyPy wants to internally maintain the interpreter they use to bootstrap, I don’t care one way or another. But if PyPy wants that to also turn into broad advertisement of a supported Python 2 interpreter for general use, I hope they’d consider the effect it will have on other people.
Want to keep python 2 alive? Step up and do it.
What do you propose they do then? Extend Python 2 support forever and let Python 2 slow down Python 3 development for all time?
That’s them choosing and forever staying on a specific dependency. … Is it really that difficult for Python programmers to rewrite one Python program in the newer version of Python? … Seems more fair for the project that wants the dependency to be the one reworking it.
The PyPy project, for example, is currently dependent on a Python 2 interpreter to bootstrap and so will be maintaining their own either for as long as PyPy exists, or for as long as it takes to migrate to bootstrapping on Python 3 (which they seem to think is either not feasible, or not something they want to do).
He’s having a tantrum. … If you’re not on 3, it’s either a big ball of mud that should’ve been incrementally rewritten/rearchitected (thus exposing bad design) or you expected an ecosystem to stay in stasis forever.
I’m not going to even bother with your “mother loved you best” vis a vis PyPy.
You’re so wrapped up in inventing enemies that heap contempt on you, but it’s just fellow engineers raising their eyebrows at someone being overly dramatic. Lol contempt. 😂😂😂
If I didn’t already have a long history of knowing other PyPy people, for example, I’d be coming away with a pretty negative view of the project from my interactions with you.
What emotional word would you use to describe the timbre of these attitudes? None of this has to do with maintainership; I don’t think that you maintain any packages which I directly require. I’m not asking for any programming effort from you. Indeed, if you’re not a CPython core developer either, then you don’t have the ability to work on this; you are also a bystander. I don’t want sympathy; I want empathy.
You have ended up on the winning side of a political contest within the PSF, and you are antagonizing members of the community who lost for no other reason than that you want the political divide to deepen.
And this is where the problem lies. Your behavior in the previous thread, and here, makes clear that your approach is to insult, attack, or otherwise insinuate evil motives to anyone who disagrees with you.
Here are some quotes which I think display contempt towards Python 2 and its users
First of all, it’s not exactly courteous to mix and match quotes from multiple users without sourcing them to who said each one. If anyone wants to click through to the actual thread, they’ll find a rather different picture of, say, my engagement with you. But let’s be clear about this “contempt”.
In the original post, I said:
The PyPy project, for example, is currently dependent on a Python 2 interpreter to bootstrap and so will be maintaining their own either for as long as PyPy exists, or for as long as it takes to migrate to bootstrapping on Python 3 (which they seem to think is either not feasible, or not something they want to do).
You quoted this and replied:
This quote is emblematic of the contempt that you display towards Python users.
I remain confused as to what was contemptuous about that. You yourself have confirmed that PyPy is in fact dependent on a Python 2 interpreter, and your own comments seem to indicate there is no plan to migrate away from that dependency. It’s simply a statement of fact. And the context of the quote you pulled was a section exploring the difference between “Python 2” the interpreter, and “Python 2” the ecosystem of third-party packages. Here’s the full context:
Unfortunately for that argument, Python 2 was much more than just the interpreter. It was also a large ecosystem of packages people used with the interpreter, and a community of people who maintained and contributed to those packages. I don’t doubt the PyPy team are willing to maintain a Python 2 interpreter, and that people who don’t want to port to Python 3 could switch to the PyPy project’s interpreter in order to have a supported Python 2 interpreter. But a lot of those people would continue to use other packages, too, and as far as I’m aware the PyPy team hasn’t also volunteered to maintain Python 2 versions of all those packages.
So there’s a sense in which I want to push back against that messaging from PyPy folks and other groups who say they’ll maintain “Python 2” for years to come, but really just mean they’ll maintain an interpreter. If they keep loudly announcing “don’t listen to the Python core team, Python 2 is still supported”, they’ll be creating additional burdens for a lot of other people: end users are going to go file bug reports and other support requests to third-party projects that no longer support Python 2, because they heard “Python 2 is still supported”, and thus will feel entitled to have their favorite packages still work.
Even if all those requests get immediately closed with “this project doesn’t support Python 2 anymore”, it’s still going to take up the time of maintainers, and it’s going to make the people who file the requests angry because now they’ll feel someone must be lying to them — either Python 2 is dead or it isn’t! — and they’ll probably take that anger out on whatever target happens to be handy. Which is not going to be good.
This is why I made comments asking you to consider the effect of your preferred stance on other people (i.e., on package maintainers). This is why I repeated my point in the comments of the previous thread, that an interpreter is a necessary but not sufficient condition for saying “Python 2 is still supported”. I don’t think these are controversial statements, but apparently you do. I don’t understand why.
I also still don’t understand comments of yours like this one:
Frankly, I think that you show your hand when you say “really important packages like NumPy/SciPy.” That’s the direction that you want Python to go in.
Again, this is just a statement of fact. There are a lot of people using Python for a lot of use cases, and many of those use cases are dependent on certain domain-specific libraries. As I said in full:
So regardless of whether I use them or not, NumPy and SciPy are important packages. Just as Jupyter (née IPython) notebooks are important, even though I don’t personally use them. Just as the ML/AI packages are important even though I don’t use them. Just as Flask and SQLAlchemy are important packages, even though I don’t use them. Python’s continued success as a language comes from the large community of people using it for different things. The fact that there are large numbers of people using Python for not-my-use-case with not-the-libraries-I-use is a really good thing!
Your words certainly imply you think it’s a bad thing that there are, for example, people using NumPy and SciPy, or at least that you think that’s a bad direction for Python to go in. I do not understand why, and you’ve offered no explanation other than to hand-wave it as “contempt” and “denigration”.
But really the thing I do not understand is this:
You have ended up on the winning side of a political contest within the PSF
You seem to think that “the PSF” and/or some other group of people or entities in the Python world are your enemy, because they chose to move to Python 3 and to stop dedicating their own time and resources to maintaining compatibility with and support for Python 2. The only way that this would make any sense is if those entities had some sort of obligation, to you or to others, to continue maintaining compatibility with and support for Python 2. Hence I have asked you for an explanation of the nature and origin of that obligation so that I can try to understand the real root of why you seem to be so angry about this.
Admittedly I don’t have high hopes for getting such an explanation, given what happened last time around, but maybe this time?
Your behavior in the previous thread, and here, makes clear that your approach is to insult, attack, or otherwise insinuate evil motives to anyone who disagrees with you.
As Corbin has said themselves multiple times, they are not a nice person. So unfortunately you can’t really expect anything better than this.
Why will tomorrow be a bad day? pip will continue to work. They’re just stopping releasing updates.
From my OpenStack experience – many automated gates could go south, because they could do something like: pip install pip --upgrade
hence dropping support for py2. I know, that whomever is involved in this conundrum, should know better and should introduce some checks. But I also know, that we’re all humans, hence prone to make errors.
pip install pip --upgrade
should still work, unless the pip team screwed something up.
When you upload something to PyPI, you can specify a minimal support Python version. So Python 2.7 will get the latest version that still supports Python 2.
And indeed, if you go to https://pypi.org/project/pip/ you will see “Requires: Python >= 3.6”, so I expect things will Just Work for most Python 2 users.
99% of the time, I would prefer a software like this to simply insert the corrected command into my shell history so that I can hit the up arrow and review it before executing it. Automatically executing something that I didn’t type does not appeal to me at all, and I think there are more than a few people that feel this way
By default, it just shows you the command it wants to run and allows you to ask it for another, run it, or ignore it. You have to change the settings to make it just run the command.
It’s worth noting that the comment about non-transitive equality really is more a consequence of Python’s chained binary operators. In Python, if OP1
and OP2
are binary operators, then the expression x OP1 y OP2 z
is defined as exactly equivalent to (x OP1 y) and (y OP2 z)
, but with a guarantee that y
is only evaluated once. This means that the operands on the two “ends” of the chain are never compared to each other, and that any comparison behavior between them is never considered.
And since Python has operator overloading, it’s possible to define types which use different logic when comparing to values of different types. As in this case, where OrderedDict
checks only keys/values when comparing to dict
but checks keys, values and order when comparing to another OrderedDict
.
It’s even possible to define behavior so that values of distinct types are interchangeable in various operations; for example, any two values which compare equal via ==
and which define __hash__()
in a way that produces the same result will be treated as equivalent when used as keys. So:
>>> d = {0: 'foo'}
>>> print(d[0.0])
foo
This works because 0 == 0.0
and hash(0) == hash(0.0)
.
Transitivity for a relation R
simply means x R y ∧ y R z ⇒ x R z
which normally holds for equality. The way Python chains comparison operators is thus not the issue here, the issue is that OrderedDict.__eq__
is not transitive while normally equality is.
I’m aware of the definition of transitivity, thanks.
However, the specific example given is cited as confusing because the chain of operators succeeds when it “shouldn’t”, and I was giving the reason why it is that way, which is, as I said, due to the way Python handles operator chaining (i.e., in x == y == z
, x
and z
are never compared to each other). And the expectation that ==
should always be transitive is generally not a good one to have – equality comparisons can be difficult and complex depending on the domain one is working with.
I was just quoting the definition to show that transitivity is seperate from the chaining of operators, my apologies if it came across as condescending.
I still fail to see how the chaining of operators matters for this example. The only reason why people would expect x == z
in x == y == z
is precisely because of transitivity. If you look at another example of chaining of operators like x < y > z
it’s obvious that there is ofcourse no direct comparison between x
and z
.
I am aware that in a lot of domains (including Python as demonstrated here) there are a lot of exceptions to the transitivity of equality and that transitive equality is hard to achieve. However that does not mean that it should not be the goal to get as close to it as possible to avoid confusion.
Speaking of non-rransitive equality, it’s also worth noting that equality over floats is non-transitive in general. This is as a results of floats being a necessarily imperfect representation of the reals, where equality is transitive by definition.
I always felt like SPAs were created to make data on pages load faster, while simplifying for mobile web, but they ended up making development more complicated, introduced a bunch of bloated frameworks, required tooling to trim the bloat, and ultimately tried to unnecessarily rewrite HTTP.
Yeah, we started with “no need to load data for the header twice” and ended up with bloated multi-megabyte javascript blobs with loading times in tens of seconds. :(
I think the focus shifted more from “need to load data faster” to “need to be able to properly architecture out frontend systems”.
Even though I still “just use jQuery like it’s 2010”, I can’t deny there aren’t problems with the ad-hoc DOM manipulation approach. One way to see this is that the DOM is this big global state thing that various functions are mutating, which can lead to problems if you’re not careful.
So some better architecture in front of that doesn’t strike me as a bad thing as such, and sacrificing some load speed for that is probably acceptable too.
That being said, “4.09 MB / 1.04 MB transferred” for the nytimes.com homepage (and that’s the minified version!) is of course fairly excessive and somewhat ridiculous. I’ve always wondered what’s in all of that 🤔
“need to be able to properly architecture out frontend systems”
An absolute shitload of websites are built with React that could be built entirely with server rendered HTML, page navigations, and 100 lines of vanilla JS per page. Not everything is Google Docs.
Recent example: I recently was apartment hunting. All the different communities had SPAs to navigate the floor plans, availability, and application process. Fancy pop up windows when you click a floor plan, loading available apartments only when clicking on “Check Availability” and so on.
But why? The pop up windows just made it incredibly obnoxious to compare floor plans. They were buggy on mobile. The entire list of available units for an apartment building could have been a few kilobytes of server rendered HTML or embedded JSON.
Every single one of those websites would have been better using static layouts, page navigations, and regular HTML forms.
One reason for a lot of that is that people want to build everything against an API so they can re-use it for the web frontend, Android app, iOS app, and perhaps something else. I wrote a comment about this before which I can’t find right now: but a large reason for all of this SPA stuff is because of mobile.
Other than that, yeah, I feel most websites would be better with just server-side rendering of HTML with some JS sprinkled on top. But often it’s not just about the website.
I don’t think an API and server-side rendering have to be incompatible, you could just do internal calls to the API to get the data to render server-side.
That’s what we’re doing. We even make a call to API without HTTP and JSON serialization, but it’s still a call to an API which will be used by mobile app.
Having done this, I feel this is the way to go for most apps. Even if the backend doesn’t end up calling a web API, just importing a library or however you want to interface is fine too, if not preferable. I’m a big fan of 1 implementation, multiple interface formats.
I’ve worked in that industry. A large portion of it is based on the need to sell the sites. Property management companies are pretty bad at anything “technical,” and they will always choose something flashy over functional. A lot of the data is already exposed via APIs and file shipment, too, so AJAX-based data loading with a JavaScript front end comes “naturally.”
I agree. So, to answer the titular question, I would answer: websites and native applications.
Developing “stuff” that feels like a website fitting the HTTP paradigm is mostly straightforward, pleasant, inexpensive, and comparatively unprofitable.
Developing “stuff” that feels like an application fitting the native OS paradigm is relatively straightforward, occasionally pleasant, often expensive, and comparatively unprofitable.
If we’re limiting our scope to a technical discussion, it seems straightforward to answer the question. Of course, for better or worse, we don’t live in a world where tech stack decisions are based on those technical discussions alone; the “comparatively unprofitable” attribute eclipses the other considerations.
That’s how I remember it. I also remember building SPAs multiple years before React was announced, although back then I don’t recall using the term SPA to describe what they were.
To answer how:
Accessing characters like "a"[0]
was only added in ES5, originally you had to use "a".charAt(0)
.
If a browser does not support this way of accessing characters "a"[0]
will be interpreted as trying to access a property with the name ‘0’ which does not exist on a string so it will evaluate to undefined
.
To answer which ones:
Mostly older browsers that do not fully support ES5, I think IE took a really long time to support it.
My only real complaint with Hugo is the difficulty in making your own themes. I did not find their documentation for theme-makers to be very helpful at all.
I understand the concepts of partials and that they piece the page together into different “puzzles” by using variants of a partial, but I don’t understand how to change which page gets which assembled “puzzle”.
The first comment on the lwn post has a reference to a themeless setup for Hugo. The themeless theme sets up a barebones Hugo site. It might be helpful in learning theming because there is very little in the templates and css files to it is easier to work with them than more established themes.
I actually found creating my own theme pretty straightforward, especially after trying to do it in Pelican. In a simple case you need only two templates (“list” and “single”), as opposed to a dozen in Pelican. Because of this it’s also easier to create a non-blog in Hugo, as many templates required by Pelican stop making any sense when you don’t create a typical blog.
I think I just need to start fresh as I think I went about it wrong after looking at what @eb commented. I did some very dirty solutions to get things working early on and I think that is contributing to the current issues.
That’s not true at all, in Pelican you only need index
and page
templates, everything else can be empty. Explicit is better than implicit so if empty files bother you then you can hide them on your system file browser or something.
My current site is built using Gatsby, which, while cool, is a nightmare to keep updated. I’d heard of Hugo, and figured porting my site would be fairly easy since it’s a single-digit number of blog posts and a super basic stylesheet.
After fighting with Hugo and their docs for at least three hours, I gave up and just wrote my own site generator. I’m sure Hugo is great for complex scenarios, as most static site generators probably are, but I wanted a home page, list of posts, a post page, and nice syntax highlighting. I couldn’t manage to get that with Hugo as easily as I thought it could be.
On the plus side, my site generator is the only one I’m aware of that uses the same syntax highlighting engine as VS Code, so all my code snippets are now super colorful!
I’m using Hugo for several projects and have a similar experience. I still cannot confidently say I know how to solve the simplest tasks like list posts with some conditions or create an archive page. This is mostly my fault, but Hugo’s documentation does not help.
I still need to get inlining of small assets working, but maybe I can use this as motivation to finish it soon! I’ll reply again once I’ve published it.
Check out Pelican. It’s using Jinja2 for better templating and it’s a really nice templating engine also used by Django.
Django doesn’t actually use Jinja2 (at least not by default, you can configure it to do so) but it’s own templating engine. They are however very similar since Jinja2 is actually modelled after the Django templating engine.
I would add a CI setup that gives you feedback reasonably fast to that list. Other than that 100% agree.
I’d add a qualification to that: a CI setup should only run integration tests. If unit testing (or worse: compilation) is dependent on a central environment, it lengthens the feedback loop, instead of shortening it.
Preach it.
Ideally unit tests should just be precommit hooks–letting us make progress by skipping them if need be. If the unit tests fail but the integration/acceptance tests pass, that’s okay in the short run.
I’m interested in the sorts of unit tests you’d be okay with skipping. To me unit tests are for more mathematical properties of functions and units of code where if they failed I’d be really concerned about correctness. Perhaps you’re unit testing too much? Or maybe I’ve misunderstood.
So, say a big customer comes in and specifically asks for 1000 units for an order. The pricing code is complicated, and because reasons (tight deadline, excited salespeople, whatever) the order is given to circumvent the code for orders of 1000 and just always return a certain value. This change breaks unit tests, but the thing’s on fire right now so it’s worth it to punt it along until the crisis is past.
Another example would be some midway refactor point where the code works and needs to go live to fix some other bug but the unit tests haven’t been fixed yet to reflect the new dependencies that need to be injected or the new APIs or whatever.
Tests are important, but they’re usually not deliverables to the business and it is important to be wise when deciding how much to let them guide us.
I’ve worked on a codebase where somebody diligently made hundreds of unit tests that a) failed to catch major, basic regressions in the money funnel (checkout) and b) only meant we had things to fight against during refactors.
In my own work, especially numerical stuff I’ve done, I still do 100% test coverage before shipping 1.0, and view it as negligent to ship libraries intended for external use with anything less than that. But, for a business application, needs must when the devil drives.
Ah that’s interesting, yeah I wasn’t thinking about it in terms of unit testing for business requirements at all. I was thinking entirely in terms of numerical/relational properties.
breaks unit tests, but the thing’s on fire right now
So remove/disable the unit test, instead of skipping it? It reflects historical requirements, not current ones.
The test isn’t wrong, it’s just in the way. Committing while skipping precommit hooks is less of a sin than removing the test and forgetting to put it back later.
Having lots of disabled flappy tests, or even worse removing tests which coworkers assume are present, is an anti-pattern to me.
If the unit tests fail but the integration/acceptance tests pass, that’s okay in the short run.
This is bonkers. If your system is built in such a way where this is possible, or even (as your later example kind of suggests) even sometimes necessary, your system is built incorrectly.
Or,
The test isn’t wrong, it’s just in the way.
This is a category error: there is no such thing as a failing unit test which isn’t wrong but merely in the way. Unit tests and the code they cover are inextricably interwoven. And there is no such thing as a change so urgent that there isn’t enough time to update failing unit tests. If your code base and processes have you believing either of these things are sometimes or even frequently true, you’ve dug yourself into a really bad hole.
—
In my own work, especially numerical stuff I’ve done, I still do 100% test coverage before shipping 1.0, and view it as negligent to ship libraries intended for external use with anything less than that.
This is also bonkers.
unit tests should just be precommit hooks–letting us make progress by skipping them if need be
I’d go the other direction: unit tests are an integral part of every class (insert unit of choice here) and run on every build without any additional overhead. Failing test means failing build.
Yes, this means tests must be fast.
I just wrote about this a few weeks ago: MPWTest: Reducing Test Friction by Going Beyond the xUnit Model
I’d also add:
Contrary to what you may have read in the Agile literature, the key to agility is the ability to change code quickly and safely. And the key to that is the ability to re-test code quickly and effectively. Fast-running automated tests (“unit tests”) are the key to agility.
Fully agree with your list.
I’ll just add automatic code formatting to the list of modern IDE conveniences.
After having used Prettier, gofmt and similar there is no going back.
That’s interesting to me because autoformatting code is really nothing new, it’s been around for decades. indent
is 44 years old and GNU indent
is 31 years old.
Is it autoformatting you like or is it more about having a fixed set of rules that applies to all code written in a language?
What I love about autoformatting, specifically when integrated in the editor and adopted by the majority of the community of that language, is that it removes the need to have discussions around where to put brackets, spaces, etc.
All you do is type code the way you like, hit save and have the tool ensure your code respects a consistent style. I don’t have to waste time reading a style guide or think about where I need to put spaces inside the brackets or not.
Even better, my code looks just like the code written by somebody else, which makes it easier to read.
Yeah it’s not clear on the gotchas on this with Rails. At my work we have over 9k schemas across multiple Postgres databases. This is a 10 year old rails app that was setup for multitenancy from the start. But I don’t think any of the points listed in the post are exclusive to Rails.
The only thing I could think of is the new support for multiple databases that was added in Rails 6. While we haven’t started reviewing that feature I’m not sure that’s going to give us any real advantages unless we moved away from multitenancy.
To address the slower setup times we keep a number of empty schemas with all of the necessary tables on the databases. This allows the app to just rename the schema to match how it would be named if it had just added the tenant.
We have found have so many schemas requires we keep a closer eye on how frequently the tables are getting vacuumed and analyzed. We have jobs that can be triggered to kick off a vacuum analyze for a set of tables that tend to be a sore spot for our more time sensitive customer work loads. We’re also reviewing tuning the vacuum settings for specific tables.
You do need to be careful when working on things that involve the search_path
. Think background jobs that will iterate across all of your tenants or features that may facilitate some type of connection between specific tenants.
And database migrations take a long time. As long as the migrations you’re making is safe with current version of the app it’s safe. It just blocks either deploying or enabling any new features that depend on the migration.
Do you have security concerns because you have to run online with a user capable of creating new schemas? Do you use a separate db user? Some separate service that uses a separate user?
I’m less concerned with the database user the app and background workers are configured to use. I would be thinking more on how to remove the manual access that could happen from a rails console.
Your questions did give me some ideas on where we can improve our monitoring. Thank you for that!
Author here.
But I don’t think any of the points listed in the post are exclusive to Rails.
Fair, I should’ve name the post differently. There’s one point about Rails though - conventions. Some of Rails assumptions can be annoying with schema-level approach.
To address the slower setup times we keep a number of empty schemas with all of the necessary tables on the databases. This allows the app to just rename the schema to match how it would be named if it had just added the tenant.
That’s a neat idea, thanks for sharing.
Right, I should’ve changed the title. My first idea for the post was a little different.
There’s 1 point about Rails - “conventionality”. Rails relies a lot on conventions, and some of can be a little annoying with schema-level.
I find it funny that in the intro to the article promises a minimal and modern setup, and immediately after the table of contents lists three external dependencies (pyenv, poetry and click).
I believe experienced developers can probably recognize when they don’t need an extra dependency, but new developers might actually think they need all of this stuff (they don’t, venv, requirements.txt and argparse are good enough 99% of the time).
I don’t think this is entirely fair, click is only a dependency of the example project not of the workflow and probably is mainly used instead of argparse to show how to use external dependencies with this workflow.
Also pyenv is just used to lock the python version used in the project, if you omit it the rest of the post would still work just fine.
I don’t criticize the author’s choice of external dependencies. I was just commenting on his choice of words, specifically calling such setup “minimal”…
I’ve seen several things lately where people advertise “classless CSS”. I’m not really into web development at all. My CSS and javascript skills are, at best, subpar.
So what’s so bad about classes in CSS? Why does it seem like it’s cool right now to not use them?
I do some light web development, and I think the benefit of ‘classless CSS’ is that you don’t have to go around adding the ‘class’ attribute to elements in html (and forgetting, or adding the wrong one, etc). It provides a ‘website theme’ without having to modify the existing html.
That said, I don’t use ‘classless CSS’ framework things because I want more control over which styles are applied to what.
I think a big part of the rise in popularity of ‘classless CSS’ is because of the rise in popularity of all the semantic elements introduced in HTML5. These semantic elements introduce a kind of structure to your html that is probably enough to do simple styling whereas before when everything was a div this was a lot harder to do.
I don’t really agree with a person’s “preferred name” is their name, their “legal name” is something else.
I tend to assume the best decisions are made close to where the most information is available, and vice versa.
Why would a state bureaucracy, none of whose members have necessarily met the person in question, have a better idea than the human living with it?
I disagree with your disagreement. I’ll take the example of my mother. She dislikes her legal name, and in 99% of circumstances drops her first name entirely and goes by her second name. Everybody knows her by her second name and she only uses her birth name where she legally needs to. She could change it so that her legal name and actual name lined up, but she has sentimental reasons for not doing so owing to who she was named after.
Her “preferred name” is her name as far as everybody is concerned, and her “legal name” is something else.
You also have the case of actors, who, for various reasons, need to avoid sharing stage names. Through use, their stage name often ends up becoming simply their name, as that’s what everybody addresses them as outside of a legal context.
I feel like both of our viewpoints are valid to some extent — I could argue that her name is still her name, she just goes by another name, and most people are simply unaware of her real name?
And yes, the case with the actors is quite a common one, such that here in Germany you can register your artist name (Künstlername) easily and it will be put on both the ID card and passport, so that you can use it and identify yourself with it just like you can with your normal name.
What makes the name a few bureaucratic entities have in their system her “real name”, one that she herself quite possibly rarely sees, over the name(s) that she and everyone in her day-to-day life refer to her as? Is it because it’s on her birth certificate? Is it because it’s the name some of these entities use? What if any of those were different from one another? What if she had two or more legal names in different countries?
In my country, your legal name is whatever you say it is, and you can change that whenever you want (provided you’re not trying to commit fraud or something). You may have some minor difficulty with certain institutions (passport office, banks, etc.) who want proof of this, but they generally just want to see that you’ve used the name elsewhere already (power bill, etc.) and your declaration that it is, in fact, your name. When would you define a name as a person’s “real name” in this situation? As soon as they start using it? Once the commonly-interacted-with entities have been notified of it? The majority of them? All of them?
For example, someone I worked with at one point used to have a double-barrel surname. They got fed up of systems mangling it in various ways, so they dropped the hyphen, taking the first part as a middle name and the second part as a new surname. There’s probably various systems they don’t interact with anymore that still have the old name in their systems, but it’s been changed in most places they deal with regularly. What’s their “real name” to you?
As the main article, the linked-to Falsehoods list, and other commenters have said, people have different names in different contexts, and you can’t just assume you can take a name from one context and use it in another. Really, you should ask for a name for whatever you’re using it for, and state as much. Most systems (or websites, at least) already understand this when it comes to payment - people just need to realise “billing” and “rest of the world” aren’t the only two contexts.
people just need to realise “billing” and “rest of the world” aren’t the only two contexts.
My favorite thing is when an e-commerce site has apparently separate names associated with your account as a whole, your billing address, and your shipping address, but they turn out to be not actually separate.
For example: I purchased a gift for my mom recently from a dealer that specializes in that particular thing, and gave my name for both the account name and the billing address, but used her name and address as the shipping address. The initial “we’ve received your order but not begun processing it yet” email had my name in it, but subsequent emails have all had hers.
in Germany you can register your artist name (Künstlername) easily and it will be put on both the ID card and passport, so that you can use it and identify yourself with it just like you can with your normal name.
That’s pretty damn awesome.
In Sweden changing your given names is a matter of an (online) form and a small fee.
Your last name is a bit more expensive to change, as it has to be checked against “known names” (such as ancient noble names) but is still a matter of a e-id submission and payment of a fee.
In Sweden changing your given names is a matter of an (online) form and a small fee.
That’s pretty awesome, I wish the government here would embrace online forms more. I don’t know how it works here but it should be fairly easy and inexpensive for people to change their names if they have a good reason for it (and it’s not done for fraud).
Your last name is a bit more expensive to change, as it has to be checked against “known names” (such as ancient noble names) but is still a matter of a e-id submission and payment of a fee.
I figure they also do checks to make sure you don’t name yourself anything weird (Hitler, Stalin, Mao?). Also, I know that some countries (France?) have white lists for names that are allowed, and I wonder if that still applies if you’re the one choosing it? Because it would kind of suck if your preferred name wasn’t “allowed” for some reason.
The rules are here (in Swedish): https://www.skatteverket.se/privat/folkbokforing/namn/bytaefternamn.4.76a43be412206334b89800020669.html
It’s been liberalized these last years. Double surnames used to be verboten. Some stuff is new, such as the possibility to change surnames to a more gender-preferred form (in the case of languages where that’s an option).
Note that there’s quite a long wait time however.
Regarding “offensive” names, that’s definitely a rule. A famous case involved parents wanting to give their daughter the names “Adolfina Stalina”. They were denied.[1] But there’s a famous example of basic free-form poetry with first names (although the person seems to have tired of being the butt of internet jokes and changed it to Salkert): https://twitter.com/inalvsmat/status/414156476849340417
[1] it’s possible the person could choose those names as an adult. The case hinged on wether these names could cause the person difficulties while she was a child.
No, plenty of people are aware of her legal name, but even for them, that’s not her name in any meaningful sense and it would be weird to refer to her by it. The only people who refer to her by her legal name are bank officials, healthcare professionals, and civil servants, all of whom are quickly corrected.
Take a look at it from this perspective: if you were given a name at birth, but practically everybody knows and refers you by another name, even those who know your birth name, which one is in practical terms more your actual name? Arguably, it would be the name people actually use to refer to you regardless of what your birth certificate might say.
The idea of people having a fixed legal name is quite a modern one.
Quick addendum. Here’s another interesting case, and I fall into this. I have what might appear to be two legal names, or rather I have one legal name, which has two forms in two different languages. I make active use of both forms depending on the circumstances. I used the Irish form of my name in personal circumstances and the English form in professional circumstances, not least because of there being a preponderance in the world of people who don’t understand that not every language is English.
Just to chime in on that addendum, since I originally omitted this from my comment: I also have two written forms of my name, in Gaelic and English. It’s just easier to use the English one in contexts where you’re going to be meeting new people more often than not and they’re unlikely to know the language. Both are my name though.
(It’s also my experience that people are happy to, and pretty good at, trying to guess the pronunciation of words, except when it comes to names, in which case they jump straight for the most incomprehensible one.)
Last I checked it was absolutely not easy.
cf https://www.anwalt.de/rechtstipps/der-weg-zum-kuenstlernamen_040484.html - in German
Gegenüber der Behörde sind die Angaben über den Künstlernamen glaubhaft zu machen. Das bedeutet, dass man gegenüber der Behörde glaubhaft machen muss, dass man überregional unter diesem Künstlernamen bekannt ist.
Which basically means you should be “well-known by that name and not only locally” and the internet didn’t really count. Maybe today it’s different if you can prove you have a million of followers on any social media thing.
I’m not ruling out that a few nerds did that with their online nicknames, but I never heard anyone following through.
For a transgender person, their preferred name is absolutely their name, and given the serious obstacles in many places to name changes (cost, requirements to post in newspapers, requiring approval from a judge, or even just having not done so yet) their legal name is likely to not be their name.
To me, a person’s legal name is their name, any other names someone or the people around them come up with (nick names, abbreviations, pseudonyms, affectionate names) are just aliases for the real name. I do agree, however, that more websites could skip asking for real name information and just ask for an alias (nickname), both for data protection reasons, and for convenience — there might be a lot of Patricks, but nobody else is going to pick a weird nickname like xfbs
.
To me, a person’s legal name is their name
And what of people whose name a legal system can’t or won’t represent?
And which legal name? Ones legal name can easily differ between regimes. Or even during time in a regime. Or have multiple legal names, in a single regime.
And what of people whose name a legal system can’t or won’t represent?
What do you mean by that? I can think of two cases: either at birth, the name is rejected (for example, Adolf Hitler is a banned name in many jurisdictions) or someone has a name written in another writing system (then you’d have to write it phonetically?).
And which legal name? Ones legal name can easily differ between regimes. Or even during time in a regime. Or have multiple legal names, in a single regime.
What does the regime have to do with your name?
What does the regime have to do with your name?
Ideally, nothing. In practice, it is your regime that sets up the laws for allowing or disallowing certain names.
For example, in France, breton names are routinely rejected by the current “regime” because they are not written according to the orthographic rules of the french language. Yet, breton is the language of people that have been living in the territory of the French state since before this state even existed. Heck, if I was born four years sooner my current name would be illegal (a Catalan name in fascist Spain). I would be extremely offended of being forced to use my legal, completely artificial, name.
The fact that something is “legal” does not make it legitimate. Some laws suck; and enforcing a “legal name” policy may suck as a result. Let us not increase the suckiness of the world by adopting this policy.
Another clear example is transgender people who live in countries where changing their name accordingly is illegal.
And what of people whose name a legal system can’t or won’t represent?
What do you mean by that?
Those are two good cases. Here are some more:
What does the regime have to do with your name?
In an ideal world, very little.
However, legal names are one way a regime makes their populace legible. As an example, my legal name is different in China (李毅) than it is in Taiwan (李逵) than it is in Australia (David Ryland Scott Robinson) than it is in the United States (Scott D Robinson and David Ryland Scott Robinson).
I get the impression that your particular legal name is probably not markedly dissimilar from the name you are most commonly known by in real life – that is, you probably go by your legal first name or a shortened form of it – because I think it’s easy for someone who has no real problems with their legal name to view it as the one unequivocally “real” name that everyone has.
I, on the other hand, not entirely uncommonly for someone from my region, have three names: two given names and a surname, and (this is the not entirely uncommon part) I have never gone by my first name in any capacity except official/formal ones, and then only grudgingly or until I was able to state my preferred name. I introduce myself to people as Secondname Lastname. My immediate and extended family, friends, and lovers have all called me by my second name (or a common shortened form of it, in the case of friends and lovers). Even as a child when my parents were upset with me and would scoldingly call me by my “full” name, they never included the first name. Many people who I’ve known since becoming an adult (and whom I thus got to introduce myself to, instead of them learning my name from an instructor calling roll and me informing them of my preferred name) are surprised when they find out, such as by seeing my debit card when we’re paying at a restaurant, that the name they know me by isn’t my first name. On top of all this, lately I’ve even come to identify more with the nickname form of my second name than the name itself.
So at least in my case, my legal name is basically just an identifier that is starting to feel increasingly arbitrary, that I was saddled with at birth, and that doesn’t reflect the name by/with which I actually identify. And I’m not even trans or a member of some other group for whom the burden of their legal name is even more onerous; in that case it probably would actually be worth all the heartburn to change my legal name instead of just being mildly annoyed at all the things in my life that have my full legal name on them, and websites that address me as Firstname (or even better, the ol’ all-caps-because-it-passed-through-a-mainframe-on-the-way-to-the-frontend FIRSTNAME) instead of Secondname or Sec.
At least Amazon lets me bill things to Firstname Lastname but ship them to Sec Lastname…
All of these comments are really amazing, I think I learned a lot. You have a good point there, I know of two similar cases, one is that I rarely bother to fill out my middle name anywhere even though it is technically part of my legal name, for brevity and because I don’t use it much. Also, I have a relative who, similar to you I suppose, has always been known by his second name.
I guess someone’s legal name still is their name, and that is important for a number of reasons, such as accountability, but the heuristic that people want to be addressed by their first name does not always hold. It doesn’t hold in Russia or the Netherlands (where people have diminutive forms of their names that they might want to use), not all countries might have a concept of first or last names, as we learned some people might not have names after all (one person mentioned Ashkenazi-jewish boys, who traditionally don’t get one until they are 8). Some people might have legal names that are not easily pronounceable (because they might use a different writing system). And, obviously, some people might have issues with their legal name for other reasons (such as a Spanish or French regime not allowing them to use the name they want, or if they are trans or something like that and their country doesn’t let them pick a name of the gender they prefer).
I often mention this tweet in discussions like this one. For those who don’t want to read a tweet, it’s a lawyer complaining that a person with a Hispanic-style name like “Miguel Fernando Lopez Ortiz”, who goes by “Mike”, can be disadvantaged in the legal system because the governmant’s own “legal name” systems can’t handle this type of name well and may turn it into a huge number of aliases (“Miguel Ortiz ALIAS Miguel Lopez ALIAS Miguel Fernandez ALIAS Mike Ortiz ALIAS Mike Lopez…”), and the existence of a large number of aliases in records for a person is often treated as evidence of criminal intent (“why does he go by all these different names, if not to hide what he’s doing”).
What’s your solution to that?
Or to the fact that my “legal name” is one that’s hard for many systems to represent correctly, even though it’s a fairly common case? I was given the same name as my father, so I legally have a “Junior” in my name; I’ve been listed in various systems, including quite official ones, under FIRST LASTJR (wrong), FIRSTJR LAST (wrong), FIRST MIDDLEJR LAST (wrong), etc.
Oh, wait. It took me a while to understand that. So, in the US, it is common to have multiple given names (middle names) but hispanic people have multiple last names, so his first name is Miguel and his last names are “Fernando Lopez Ortiz”, and so the system has to create aliases because any one of those last names are technically valid, and that looks suspicious because it looks like he’s known under multiple, different names when actually they are all his one, regular, legal name?
What’s your solution to that?
I’ve no idea, perhaps fix the system? Legal systems should be able to deal with people from other cultures properly anyways, so they should be able to represent “alien” names (especially in the US I suppose, where everyone is “alien” unless they are natives).
Also, I did not know that the “junior” thing is actually part of a legal name! I thought people in the US just named themselves after their father (something that I don’t think is very common here in Germany, or Europe, but I might be wrong) and then used “junior” and “senior” to disambiguate.
In naming traditions descended from Spanish culture, it’s common to have a composite first part to the name (so “Miguel Fernando” would be the given name, and should not be split into “Miguel” and “Fernando”). And it is common to have two family/surnames, one taken from each parent. Traditionally the first surname is taken from the father’s first surname, and the second is taken from the mother’s first surname; when sorting, the first surname is used first (so “Miguel Fernandez Lopez Ortiz” sorts under “L” by surname, not “O”).
And that’s without getting into more complex situations like a saint’s name.
that’s very cool and not at all reductive to say especially considering you live in a country that has a proven track record of denying representation to people whose real name isn’t their legal name and who want to set the record straight
that’s very cool and not at all reductive to say especially considering you live in a country […]
Be nice.
Is @twee both your “preferred name” and name?
It’s my preferred name for internet accounts, a point that I believe was addressed in the article:
It almost certainly doesn’t identify them uniquely, and importantly, it need not bear any relation to their “legal name”. As software engineers, we are descendents of a proud heritage of hackers who often take great pleasure in assigning and using names, called “handles”, which are completely unrelated to their given or legal names.
In real life people don’t refer to me as “twee”. But I’m not sure how that relates to @xfbs’s statement, which was what I don’t quite understand. Apologies if that’s just confusion on my part.
@xfbs followed up with their perspective. I don’t agree with it.
But, to my response, I was drawing the difference between “preferred name” and “name.”
In UK law, “legal name” isn’t really something that exists - insomuch as it does, it’s the same thing as a “preferred name. You might have a name registered with specific legal entities (the DVLA, the Home Office, the HMRC), and those are often more strictly regulated - for instance, the homeoffice will deny passport applications where the name is a swearword. Quoting Home Office guidelines: “The name by which a person wishes to be known is a matter for the individual.”
This is actually quite common in the Netherlands. For example, my name is Martin, but this is not my legal name, which is different and has two middle names. I don’t really publish this name on the internet (as a small barrier for potential identity theft), but usually it’s fancy names given to you during your baptism. It’s perhaps a bit less common for kids born today, but the majority of people over 30 have it.
Most Dutch forms distinguish between your colloquial every-day name and full legal name when this matters.
I actually got in to some problems with this after I moved abroad, I introduced myself as Martin (which is what everyone calls me, including my mother) but then later it turned out I wasn’t “Martin” at all; for example my ISP refused to help me as I said “Hi, this is Martin speaking, [..]” on the phone (English pedanticness, sigh). My (English) girlfriend at the time also filled in some council tax forms etc. with my colloquial name, and had some problems using this as a “proof of address”.
Now I just fill in my legal name everywhere, which is hard to pronounce for most non-Dutch people and I have to tell them to just call me Martin; it would be helpful everyone if I could just fill in both 🤷♂️ When I went to the A&E after I broke my arm a few years ago I could see it was my turn just by the look of of puzzlement and horror every time the staff called me out for triage, x-rays, and doctor consultancy, heh.
Granted, all of this is probably a pretty rare thing if you’re working on a system somewhere in the US, but generally speaking names are hard (“falsehoods people believe about names”) with many different edge cases and while I don’t really care how you call me, some people place a high value on this kind of thing.
off topic, but i do get a kick out of the way most native english speakers recoil at dutch names like rutger, martijn, thijs etc.
That’s actually really fascinating! I’ve never heard about that here in Germany. So where do these colloquial names originate, also from your parents or do they develop during childhood?
That’s actually really fascinating! I’ve never heard about that here in Germany.
It does exist in German(y) as well. As has been pointed out in another reply to you, it’s usually a shortened version of your full first name. In German it’s called the “Rufname”. To give a traditional German example, my neighbor (who has passed the 70 since quite a while) has “Wilhelm” as his first name. His wife, just as everybody else, calls him by “Willi”. Anywhere he needs to give an official address, he of course uses the full form of the name, and it’s what is placed on his mailbox.
(Not the person you responded to but also from the Netherlands.)
The colloquial name is the name your parents give you, usually the ‘official’ name is just a longer/more traditional name that that name was derived from.
So for example my name is Daan but my ‘official’ name is Daniël, for someone called Tom it would be Thomas etc.
From the parents. In @daanvdk’s examples the names are somewhat similar and the initials match, but note that differences can be larger. E.g. my sister’s official first name is Catharina, but her colloquial name is Karin.
Usually it’s just a shorter less fancy version of the full name. e.g. Johannus is John, Johan, Sjonnie, etc.
Yeah, that’s about how I would imagine it, with the problems you mentioned.
I’m not a big fan of not being able to choose anything, but looking at the possible problems until there’s a global shift or unification in how people use names I guess some of us have to live with using the legal name for all paperwork anyway.
Again, I’ve heard stories of people getting problems when airline tickets didn’t have their full legal names. so where do you draw the line? Is it worth having your non-legal name on the power bill and credit card, but airline tickets must be legal name again? Isn’t this a bit like having different online identities and not trying to leak information so they can’t be correlated? I guess people will just have to try if it works, and in your case, give up at some point.
The name I use day-to-day is not my legal name. In fact, the name on my email, my book, and all my published articles is not my legal name, either. Most people don’t even know I have a different legal name. The only time I use my legal name is for government correspondence.
so what about the case where one person has multiple different legal names in different legal systems? which one is their “name”?
i downvoted this as troll since this comment is low-effort, doesn’t offer any useful insight (why do you disagree with this?), and i honestly don’t see how it’s possible to come to this conclusion after having thought about this even a little bit.
I guess the author is mainly referring to doing server side rendering with Django. At least to me there is no reason why the mentioned API cannot be using Django while still adhering to the ‘cool’ SPA pattern.
Small Remark: Personally I would move the chaining of Transforms to within the data type (so add | Chain [Transform]
to Transform
). I think this would improve composability of transformations and also remove the need for the transform
-function since in toMatrix
and toCodeWorld
you could then just directly pattern match on the Transform
-type.
Other than that a very nice article showing a nice use case of why to prefer data over functions.
I’m unsure exactly what you’re suggesting. Can you please elaborate, perhaps by providing a full definition of the Transform
type that you had in mind?
Something like:
data Transform
= Scale Double Double
| Translate Double Double
| Chain [Transform]
Then the function toMatrix
would for example become:
toMatrix :: Transform -> M33 Double
toMatrix (Scale x y) = V3
(V3 x 0 0)
(V3 0 y 0)
(V3 0 0 1)
toMatrix (Translate x y) = V3
(V3 1 0 x)
(V3 0 1 y)
(V3 0 0 1)
toMatrix (Chain ts) =
foldr ((!*!) . toMatrix) identity ts
Thanks, but I disagree with this, for a couple of reasons: first, it makes Transform
into an N-ary tree with leaves of Scale
and Translate
, but a tree doesn’t match the thinking we’re trying to capture: a linear sequence of transformations that can be applied to something later. Second, you lose the nice connection to the free monoid, which means that concerns about structuring multiple transformations are now intermingled with the specification of a single transformation.
If the calls to transform
are too much syntactic noise, then I’d rather write this:
toMatrix :: [Transform] -> M33 Double
toMatrix = foldr ((!*!) . toMatrix') identity
where
toMatrix' (Scale x y) = V3
(V3 x 0 0)
(V3 0 y 0)
(V3 0 0 1)
toMatrix' (Translate x y) = V3
(V3 1 0 x)
(V3 0 1 y)
(V3 0 0 1)
Pretty poorly informed piece. Hilarious that it ends with “Go also seems to suffer from ignorance towards well established patterns that are proven to work” and then fails to provide a single example.
They’re not examples of ignorance. The Go team was well aware of how date parsing has been done historically but decided to try something more intuitive. The way they wrote the example was carefully chosen to make it look confusing. See https://golangcode.com/parsing-dates/ for how this is usually used.
I don’t have enough experience with Go to have an opinion about the specifics I just wanted to clarify what seemed like the intentions of the author to me. I get that you don’t agree with the examples but I think that’s something entirely different from claiming that they aren’t there.
Yes, datetime parsing and flag handling is what I was refering to.
Go is developed by smart people, I never assumed they are not aware of how timestamp formats look like in other languages. I assumed they did it differently anyway ignoring the established practices, that’s why i wrote ‘ignorance’. Maybe not the most fortunate wording, didn’t mean to offend.
I’m returning to a go project at work and feel a little more sensitive to these comments (so take with a grain of salt).
Timestamp parsing - I never do timestamp parsing without looking at the documentation (Oracle’s vs Java’s vs C#‘s vs SQL Server vs Javascript), so i feel that Go’s formatting being based on a magical date is “quirky”, but you can easily do date formatting/parsing just by referring to the one magical date ( 01/02 03:04:05PM ’06 -0700 ) which seems pretty cheap for the large amount of flexibility.
XML - I’ve dealt with more of this than I’d like and ran into awkward parts when dealing with multiple namespaces (canonicalization is a pain) but for straightforward xml, Go is pretty delightful to deal with. I haven’t needed anything faster or more complicated.
Flags - Again, Go is fairly idiomatic (based upon very old-school Unix command line sensibilities), but the Flags package gets so much stuff absolutely correct (built in help, connects to custom object parsing, default values). I’ve never used it but I believe the Go community really likes Steve Francia’s cobra, if you want/need more complicated stuff.
The compiler is one of the things that has gotten more complicated (dealing with multiple modes for dynamic objects, etc), but everyone appreciates it being:
and the Go team spends lots of time keeping those in mind.
Modules - My last usage of Go is actually before modules landed so I need to get caught up on them. I never really liked some of the awkwardness of GOPATH (especially since there were multiple tools that handled pinning versions).
The last comment is… interesting. I’m pretty confident that the Go team isn’t ignorant of “well established patterns that are proven to work”, but have strong (idiomatic) design opinions. I happen to like the design aesthetic of the language, but realize it’s not for everyone.
I’m a bit curious about the magical date you mentioned, how does go deduce from that whether it is the 1st of february or the 2nd of january?
It’s not that magical. It’s basically just the same as “classic” string parsing with strptime() and %Y
and whatnot, but instead of %Y
you use 2006
, and instead of %d
you use 01
, etc.
The idea is that instead of %Y-%m-%d
you have a more human-readable 2006-01-02
. It’s quite easy to memorize too, since 2006
is the year, and after that it just increases from high to low. Also see some examples from the docs.
In other words, it’s a lot less magical than strptime(), IMHO. For example for this comment I looked up if it was %m
or %M
for day-of-month, and then it turns out it’s actually %d
.
The idea is that instead of %Y-%m-%d you have a more human-readable 2006-01-02.
One can only imagine the ease-of-use if they had picked an order that was used in more than one country on this planet. Feels a bit like the usual jingoism.
It’s quite easy to memorize too, since 2006 is the year, and after that it just increases from high to low.
It’s timezone > year > second > minute > hour > day > month. There is nothing logical about it, except that it looks the way some American’s prefer to write their date.
I think the other part is that each portion has a different number (the month is always 01, the day is always 02, etc).
If you work with go dates regularly you end up memorizing the order pretty quickly.
That said, I think it’d have been nice if they’d used the 13th December instead since 2006-12-13 is less ambiguous.
Unfortunately, that would’ve meant not having a nice way to make _2
indicate no leading zero. No easy tradeoffs.
You have a better memory than me. I’ve been with Go since 1.3 and I still have to look up the documentation every time. I think that if they wanted to do dates like this, they should have gone with the ISO format 2000-01-02 03:04:05. That would have been way more intuitive to way more people.
It’s less the quality of my memory, and more that I was working with date parsing on a regular basis for a couple of weeks. If you don’t do it often there’s no way you would memorize it.
It is a bit American centric, but the date in documentation is also written
Mon Jan 2 15:04:05 MST 2006
Thank you for the feedback!
Timestamp parsing - I never do timestamp parsing without looking at the documentation.
To me %m
just seems more intuitive than 01
for referencing the month, because ‘m’ is a mnemonic for month, but ‘01’ doesn’t tell me much. One thing it does tell me though, is that the number to be formatted is 0-padded, which is admittedly a nice touch.
[…] the Flags package gets so much stuff absolutely correct […]
Yes, agreed. I think the API is great, I just criticized the perceived quirkiness of the resulting command interface.
Go is not a bad language (far from it), I just believe some of the bold design decisions to not be the best choice.
In contrast, in Rust, calling an async function does not do any scheduling in and of itself, which means that we can compose a complex nest of futures without incurring a per-future cost. As an end-user, though, the main thing you’ll notice is that futures feel “lazy”: they don’t do anything until you await them.
If I have 3 futures that I’d like to run in parallel, how do I actually “start” them running before I block on any of their results coming back?
For example:
a = async1()
b = async2()
c = async3()
// ideally a/b/c are all running "in the background" at this point
a.await
b.await
c.await
Or am I misreading what they’re saying there?
For this use case you can join multiple Futures into one, for more info: https://rust-lang.github.io/async-book/06_multiple_futures/02_join.html
Alternatively, just use a language with a native code formatter. Examples: zig fmt
, go fmt
, etc.
Then you can use whatever your muscle memory dictates while typing in code, and still have a consistent format applied on saving.
Then you can use whatever your muscle memory dictates while typing in code
Are you suggesting people sit there hitting space 4 times to align their code?
People do. (I do, when I’m using a language like renpy where it doesn’t support tabs for indentation at all.)
If you’re not, then what exactly is the point of using spaces to indent? If you’re just autoexpanding tabs, then your tab expansion is controlled by your tabstop setting, and so you don’t experience any difference when editing code (except that you may need to press backspace four to eight times instead of one when de-indenting & you will find that your source files will be a few hundred bytes longer).
I think most programmers who prefer spaces (including myself) autoexpand tabs, at least in my environment.
Main reasons I have for using spaces:
Consistency between different environments
As the author of a piece of text, I don’t think I have any right to impose my indentation-width preferences on other readers or editors. If code I have written becomes less readable when the tabstop is set differently, then I have failed to write clean code, and no changes to spacing will fix that underlying problem.
Consistent visual width for characters
We already have all sorts of characters that have widths other than 1 (even in monospace fonts, where characters have widths that are integer multiples of the glyph width). Even within ASCII, CR ought to be zero glyphs wide, while LF is sqrt(-1) wide, and backspace is -1 glyphs wide.
Possibility to set guides/constraints for line length
Line length constraints are typically with respect to number of characters. In other words, it’s line length rather than line width.
We already have all sorts of characters that have widths other than 1 (even in monospace fonts, where characters have widths that are integer multiples of the glyph width). Even within ASCII, CR ought to be zero glyphs wide, while LF is sqrt(-1) wide, and backspace is -1 glyphs wide.
So yes ofcourse LF and CR are exceptions to this rule, however when I think of code I think in lines and columns and not one long string of characters, so to me the characters that represent these columns are the ones that matter when thinking about character width. Regarding backspace and non-ascii characters my strong belief is that those do not belong in source code altogether.
Line length constraints are typically with respect to number of characters. In other words, it’s line length rather than line width.
Not entirely true, indeed linters/formatters tend to look at line length, however every text editor I have used tends to visualize these kinds of constraints with a line at a certain line width. Not having to worry about this distinction however is exactly my point about why I think spaces work better for this purpose than tabs. Also although most constraints are indeed implemented to look at line length, I think the motivation behind why that constraint was put in place is usually because of line width which further emphasizes why it is nice to not have a distinction between these two.
Hi, creator here, thanks for submitting and please share any feedback or thoughts you might have!
Without more context it’s difficult at a glance to know how to interpret “Harmful”.
It looks like it’s saying “Mozilla’s implementation of the Serial API is harmful” but it sounds like what it’s actually saying is “Mozilla considers the Serial API to be harmful” which is very different!
Hmm, yeah, good point. The wording is taken from their own site which is linked to when one clicks on the status.
Suggestion on how it could be improved?
Personally I have no idea what this website is about. Perhaps add a few lines on top that explain what it is?
Further down I’ve written:
Maybe replacing/extending the current “Background” in the top with something similar? Maybe like this:
I think you need even more context than that. What is Web API? Why is it controversial? The nice thing about the FAQ format is that you can spend the first 1–3 items answering questions like these and anyone who already has this context can just skip over them.
A design note—the text in the FAQ expands to fill the full width of the screen (or at least the 1,280 pixels of my browser window), and there is also no margin between the text and the edge of the screen. Both of these things make the text harder to read. You might consider limiting the width of the text to 800 px or 40 em (very approximate numbers) and, on smaller screens, adding at least 10 px of whitespace on either side.
Suggestion on wording and such is much appreciated, this is just something I threw together quickly in an afternoon to try and gather references in these topics :)
Perhaps you’d consider changing the colour scheme? To me, green = GOOD and red = BAD, which makes it hard to understand what’s actually going on at first glance.
In what way? Green = positive about the state of the spec, Red = negative about the state of the spec, isn’t that the correct way?
I think the problem is that it’s not immediately obvious that this ‘judgement’ of good vs bad is about the spec. At first glance this just looks like chrome has everything green and is thus good, while firefox/safari have everything red and are thus bad.
Yeah, good feedback, will try to find time to improve it asap
“Harmful to Users” or “Deemed Harmful to Users” perhaps? The key point that needs communicating is that Mozilla has determined that implementing the spec would be harmful to its own users, e.g. someone might use the serial api to modify their insulin delivery device.
Intentionally omitted.
Well, Mozilla’s own description of their “Harmful” label is “Mozilla considers this specification to be harmful in its current state.”
That the focus is on the spec, not the implementation should get clarified
“Harmful” doesn’t mean anything on its own, you have to tell a person what is being harmed.
Totally, but that’s better explained by the ones considering it to be harmful than for me to try and summarize and maybe misinterpret
By using the single word “Harmful” I’d argue that you have summarized. It’s just that that summary is ambiguous and prone to misinterpretation, as others in this thread have pointed out.
How would you summarize it better? I would love to do it better
Maybe “Mozilla considers it harmful” or “No plans to implement”? I know these are more wordy than what you’ve got now, but I can’t think of a shorter bit of text that still conveys the right meaning.
Added an issue for it to ensure it doesn’t get lost: https://github.com/voxpelli/webapicontroversy.com/issues/1
Perhaps “Rejected” instead of “Harmful”?
Though Mozilla themselves refer to it as “harmful”.
They often haven’t rejected the specs though, rather they have found that they in their current state would be harmful to the web.
Remember: All of these specs are drafts and still under discussion, even though Chrome has decided to ship them
Yea, I get that, I just don’t feel that “HARMFUL” is representative of what’s going on.
For example, the Safari side of things talks about anti-fingerprinting challenges, which is fair.
I don’t get the sense that the Chrome side is actively trying to enact more ways to fingerprint, but rather they’re trying to build a browser environment that competes with OS functionality, which I think is also fair (ideology aside). I’m not sure how Safari feels about this, given that they’re a purveyor of iOS and macOS and probably don’t love the idea of browsers competing.
Meanwhile I’m not sure what Mozilla’s agenda is. They’re no longer providing Firefox OS, but also it’s not clear that Firefox is interested in pushing browser functionality forward, while also experimenting with ads/sponsored content by default.
My personal bias, as someone who uses Linux and benefits greatly from cross-platform applications like browser apps, is that I like the idea of these additional WebAPIs and it doesn’t sound intractable to make them robust against fingerprinting. The cost of not advertising the functionality by default and even requiring the user to manually enable them seems more than worth it.
My wish for something like the Web API Controversy page (which I appreciate exists as it’s a handy dashboard to keep track of!) is that it didn’t make the premise of the proposals seem nefarious and intractable. :)
I think it would be nice to link to discussions directly in the details, e.g. https://github.com/mozilla/standards-positions/issues/336
I prefer to link to the most official kind of reference and have it refer to the discussions they feel are relevant, feels like that has a better chance of being up to date and staying as objective as possible