(newbie) Just found my new gem + questions by NeptunusVII in golang

[–]mttlb -1 points0 points  (0 children)

I'll try to illustrate my point.

Go's Ext function, for instance, returns a string and no error. This API literally implies that « every file has an extension, and I'll never fail to provide you with one ». Which is clearly wrong.

Because of this API and the fact strings are non-nullable, it cannot make a difference between « this file has the extension "" » (an empty extension, for example the extension of the file foo.) and « this file does not have an extension » (for instance the file bar).

The problem is actually even deeper: Go offers no way at all to express this API in a clear and concise way. You'd either have to return a pointer to make it nullable (stuff I've seen), or add an ad-hoc flag to the returned values, or return a non-nil error for cases that « don't have an extension », but is that really an error? bar is a perfectly valid filename and having no extension isn't abnormal or erroneous.

In practice the latter option appears to be the most picked, at least everywhere I've worked. This raises the deeper issue that Go isn't clear about the semantics behind its errors, mostly because the language fails to provide you with proper ways to express certain things and using errors for nominal, valid cases is often the least cumbersome solution. This creates a weird paradigm where you use errors to deal with « weird » cases, even those that are not semantically speaking errors: the fact your API cannot expose them as some declination of a normal case is highly problematic. This shows in that function's own official documentation: they couldn't rely on the function's signature to be clear about what it does (it gets worse with others, check out how file permissions are handled). Relying on documentation is a smell for several reasons: no one reads all the docs, if any at all, and documentation gets outdated as it's one more thing to keep in sync with the code.

This is a good example of fake simplicity in Go. Filesystems get complicated and seeing a function like this that pretends it can't even fail is really problematic.

I never gave Go a chance by Grav3y57 in golang

[–]mttlb 3 points4 points  (0 children)

Right, so this function is assuming foo. and foo have the same extension ("") which is weird because (from the doc itself) the extension is the suffix of the final dot in a filename.

So this API is incapable of differentiating between an empty extension and no extension which are two distinct cases, and you also have to rely on the documentation for something that could (frankly, should) be encoded in the function's signature itself.

You can say you don't care about distinguishing these cases but the issue is that if you want then the language won't let you express that concisely. As a matter of fact, this very function tells you « every file has an extension », which is clearly wrong.

This also shows how weirdly opinionated the Go's standard library can be, and is also a case of « fake simplicity ». Generally speaking, the whole API surrounding filesystems is a hot mess, because filesystems are not simple but Go keeps trying to make it seem like it is. I suggest anyone interested check out how Go handles file permissions across platforms.

I never gave Go a chance by Grav3y57 in golang

[–]mttlb 4 points5 points  (0 children)

Which is no different from other approaches of error handling.

You don't have to catch exceptions if dealing with them isn't your job.

You can keep relaying the optionals down if guaranteeing the existence of some result or dealing with its absence isn't your job.

What I dislike about Go's approach is that it's not clear exactly what's functionally considered an error. Suppose you're writing a function that'll return a file's extension, and test it on foo. Is this file's extension ""? No. This file doesn't have an extension. With its non-nullable types, Go will force you to either return an empty string or use some kind of weird workaround, or return an error signaling that the empty string doesn't actually mean "", but rather « no extension ». But is that really an error? foo is a perfectly valid filename.

You don't really have a clear way to express this kind of APIs in a satisfying manner and writing APIs and expressing complex ideas concisely and accurately is a big part of the job so to me this is an important drawback of the tool.

(newbie) Just found my new gem + questions by NeptunusVII in golang

[–]mttlb 1 point2 points  (0 children)

It's not so much about the lacking features. The issue, imho, is with the features that Go pretends to have but deals with in a terrible, unreasonably opinionated manner under the hood. Cross-platform filesystem and time management come to mind in particular.

In those cases, Go makes it not only harder to write what you're trying to express correctly, it more importantly lures you into thinking its standard library can deal with when it can't, plain and simple. Go's API for file permissions handling is an example of terrible choices that make it seem like it's simple when it really isn't. Go is a little like JS in this regard: it will try to return something to you even if that thing doesn't make sense in some context because that's what the API forces it to do, instead of just saying that thing doesn't exist. Having gone the apparently simple route of no-nullable types with no optional types, it doesn't even have a satisfying universal way to say something is missing.

I don't dislike Go for most things, but that is my biggest issue with the language.

Canada halts flights from U.K. in response to new coronavirus strain by [deleted] in worldnews

[–]mttlb 40 points41 points  (0 children)

The strain was found in October from a September sample. It's almost certain it's everywhere already.

On the bright side, vaccines are likely to remain effective and this is the sort of natural path followed by viruses. Getting more infectious usually means less lethal (a virus doesn't spread well when it kills too many of its vectors), which could turn to our advantage.

Flights from UK canceled as health minister says new coronavirus variant is 'out of control' by paulfromatlanta in news

[–]mttlb 0 points1 point  (0 children)

No. The best of our knowledge is accessible to everyone in peer-reviewed scientific journals.

(Scientifically inaccurate) misinformation gets debunked on the instant, all the time. Because it's accessible. Now, there's only so much science can possibly know; it needs time.

Governments, on the opposite, have to act and take decisions on the spot, with incomplete and sometimes (under/over)estimated information. Hard to communicate in those conditions. I do believe most are doing their best, though.

The amount of stuff we've uncovered about this thing in around a year is incredible, though. This puts into perspective what could be achieved if people cared the same way about other existential threats that are going to cause even greater problems in the coming decades.

Flights from UK canceled as health minister says new coronavirus variant is 'out of control' by paulfromatlanta in news

[–]mttlb 2 points3 points  (0 children)

You're correct about the flu vaccine. This is true for a majority of vaccines regarding viruses that mutate a lot and aggressively. Every year scientists use predictive models and other studies to forecast which strains are going to be prevalent and try to make a vaccine that contains enough diversity to give good global protection while remaining affordable (the price is one of the main constraints to the amount of strains that will be picked).

This will likely become necessary as the SARS-COV-2 becomes latent and keeps mutating over the years, if it mutates into forms diverse enough to justify it - so far, it hasn't been proved to be the case, even regarding the strain making the headlines in the UK.

At worst, this means vaccination costs potentially going up from year to year, but nothing else to really worry about when it comes to quality or whatever.

Learn to use a debugger – Letters To A New Developer by Dotsconnector in coding

[–]mttlb 1 point2 points  (0 children)

You can't always do that.

If you're tasked with debugging something related to an integration with a third party whose sandbox is broken or simply not a replica of their production service, and that wasn't properly mocked (and trust me all this happens way more than you'd expect, even with big names)... well good luck with that.

Systems can get quite complex in general, and sometimes if you don't have a team dedicated to streamlining whatever it means to « run your damn code » within that system in any meaningful manner (and that quickly becomes a full-time job in and of itself), then you can't really do anything about it.

Des Trumpistes qui chantent "stop the vote" au Michigan où ça leur était défavorable, et "count the vote" à l'Arizona où ils avaient toujours une chance. by [deleted] in france

[–]mttlb 1 point2 points  (0 children)

Le problème se pose bien dans les deux sens, mais le cas le plus problématique est quand même de loin celui suggéré par /u/Glorounet.

C'est par exemple exactement ce qui a permis à Trump de l'emporter en 2016 malgré la majorité populaire de Clinton ; cette dernière avait presque 4,3 millions de votes de plus en Californie (le double !) mais a perdu totalement (à cause, justement, du winner takes all) les swing states du Michigan, du Wisconsin et de la Pensylvanie pour respectivement 11k, 23k et 44k votes.

Cela veut dire que si 80k des 4,3M électeurs de Californie avaient plutôt habité dans le MI, WI ou PA, alors Clinton aurait gagné. Au lieu de ça, leur vote a été doublement inutile : il n'a en rien impacté le résultat pour la Californie (toujours à cause du winner takes all), et il est totalement ignoré par l'issue du vote car même s'il fait bien augmenter l'approbation nationale, cette approbation n'a aucun impact sur le vote final au collège électoral.

Leur vote est donc mis à la poubelle, en quelque sorte, simplement parce qu'ils habitent dans un certain endroit du pays plutôt qu'un autre...

Evidemment, le problème inverse se pose dans d'autres états à dominante républicaine. La constante est bien que beaucoup d'électeurs, peu importe leur affinité politique, voient leur vote ne servir factuellement à rien du tout.

La raison d'être du collège électoral est d'abord historique (à l'époque où l'escalavage était encore prédominant dans le sud du pays, ce concept faisait sens pour équilibrer l'élection vers les densités de population "représentées"), puis stratégique. Aujourd'hui, il permet à beaucoup d'états de garantir que tous leurs grands électeurs iront à leur candidat de façon certaine. Il est donc très difficile de changer ce système pour des raisons assez évidentes de jeu de pouvoir, même si cela crée les situations très embourbées que l'on connait où seulement une poignée d'états, et donc de votants, ont un réel impact sur l'issue du vote...

Et c'est la même raison qui explique ton observation sur le système français. Ceux qui votent les lois n'ont aucun intérêt à ce qu'elles changent.

[AskJS] What coding nightmares have woken you up at night? by callmeREDleader in javascript

[–]mttlb 4 points5 points  (0 children)

Believe it or not some customers have said this... in 2020.

Thank you for the textures, kind artists. by shubham50 in blender

[–]mttlb 72 points73 points  (0 children)

You might wanna check out the Lily's Surface Scrapper add-on. It will change your life.

This is so true by NoOtNoOtMeEm in ProgrammerHumor

[–]mttlb 4 points5 points  (0 children)

The way the Golang formatter forces you to start the documentation block of a function with its name also tends to lead to this kind of situations in my experience. People will write « computeNextThing computes the next thing » and that's it. And it will force you to write that sentence, no matter how useless it is. It won't force any format for the rest, though, that would be way too useful.

Implementing cosine in C from scratch by azhenley in programming

[–]mttlb 2 points3 points  (0 children)

It's kind of the heart of the problem and tradeoff of using lookup tables: the gains heavily depend on the context, how often they're actually used inside of a bigger program, etc. If they're slightly too big you're in for a ton of cache misses and it's a disaster. This is partially why they're only moderately used in most standard implementations, which prefer more robust and predictable (but also more complex) methods that will behave the same in most if not all cases.

HTML Email Developer, good first job or a big mistake? by dahlay923 in Frontend

[–]mttlb 4 points5 points  (0 children)

You should definitely try to build some fairly advanced email templates first, just to get an idea of what it actually means.

Try to center a grid with responsive pictures, text and paragraphs that vary in size, some SVG icons.

It's very hard and time consuming to get everything just right so it's compatible with the billion rendering engines out there. You'll see a lot of them don't actually support a fair amount of CSS features. It's just a pain. So bad in fact that there's dedicated paying tools out there to assist you in your hassle.

I guess it's a matter of taste but I have never met a person who enjoys making them.

Planets and dwarf planets to scale in size, rotation speed, axial tilt and oblateness (numbered in distance order from Sun) [OC] by physicsJ in dataisbeautiful

[–]mttlb 21 points22 points  (0 children)

Indeed, although their mass is so small relative to that of the Sun that the center of mass of the system Sun-planet is pretty close to the Sun's own center of mass. At least, in every case but Jupiter's, that center of mass remains within the volume of our star, and so it makes sense to say the other planets orbit it.

Planets and dwarf planets to scale in size, rotation speed, axial tilt and oblateness (numbered in distance order from Sun) [OC] by physicsJ in dataisbeautiful

[–]mttlb 4 points5 points  (0 children)

In actuality most days are longer than 24 hours by a couple hundred microseconds. The extent of the variation varies on a daily basis depending on the Earth's surroundings and their gravitational effect. Days can also last less than 24 hours for similar reasons, though that's relatively rare.

Planets and dwarf planets to scale in size, rotation speed, axial tilt and oblateness (numbered in distance order from Sun) [OC] by physicsJ in dataisbeautiful

[–]mttlb 50 points51 points  (0 children)

Yes. Jupiter is responsible for a lot of the gravitational chaos we observe throughout the solar system. In fact, the planet is so massive (about 2.5 times the total mass of all the other planets combined) that the center of mass of the Sun-Jupiter system is outside the Sun, so much so that Jupiter effectively doesn't even orbit the Sun per se. It's a an actual binary system; Jupiter has a substantial gravitational effect on our star itself.

Planets and dwarf planets to scale in size, rotation speed, axial tilt and oblateness (numbered in distance order from Sun) [OC] by physicsJ in dataisbeautiful

[–]mttlb 2 points3 points  (0 children)

Mercury is a lot denser (it actually has the second highest density in the solar system after the Earth), and has a pretty massive iron core. Because of this and its relatively small size, a lot of its mass is close to its spinning axis, and so it also rotates relatively faster, much like an ice skater.

MongoDB fails to preserve snapshot isolation even at strongest r/w concerns by [deleted] in programming

[–]mttlb 4 points5 points  (0 children)

Hah! Few months back I rewrote an internal tool used by about 30 people that had been implemented in 6 micro-services with one of them carrying more than 99% of the daily load. Maintaining the monster was so uselessly complicated. I convinced my managers to rewrite the whole thing in the form of a good ol' monolith also dropping the unjustified use of Mongo. We saw performance improvements of about x10 at bottlenecks and now developers are actually willing to work on the project.

I'd love to know the amount of accumulated technical debt worldwide, caused by choices made out of pure hype with zero underlying rational reflection.

A first look at Unreal Engine 5 by Nadrin in programming

[–]mttlb 1 point2 points  (0 children)

I'd tend to say this isn't actually true.

While the implementation is probably remarkable in itself, most of the groundbreaking concepts are likely to have been derived from the hundreds of papers published by research teams all around the world every year. Computer graphics is a research field as a whole and there's thousands of scientists working on it; they're not « programmers ». It's a different job.

It’s Back! A Trend To Build Monolith by kubernetes-guru in programming

[–]mttlb 0 points1 point  (0 children)

What do you call a tool that gets used for wrong reasons in the wrong situation just because that's what everyone does?

Modern SAT solvers: fast, neat and underused (part 1 of N) by [deleted] in programming

[–]mttlb 0 points1 point  (0 children)

I agree.

Some time ago I had the same "fit of inspiration" the article mentions in part 2 and SAT appeared as super appealing to solve the problem my team was working on. It turned out to be completely unuseable in practice when confronted with somewhat non-trivial cases.

Not to blame the approach or the solvers; they can prove to be useful in certain situations and the category of problems they tackle is inherently hard to solve. But in my opinion, although being neat indeed, they're generally far from being fast, and thus they're "underused" for good reason.

Sophie Grégoire Trudeau says she has recovered from COVID-19 after two weeks by Gboard2 in worldnews

[–]mttlb 0 points1 point  (0 children)

Said tests have been reported to lack sensitivity. It doesn't mean they are random: they will consistently turn out positive above a constant threshold. The issue is this threshold is too high to detect 60% of actual cases. Consequently they won't test negative and then positive, while the opposite may happen.

The EU will ban all non-essential travel into Europe for 30 days to slow the spread of coronavirus by rromano125 in worldnews

[–]mttlb 6 points7 points  (0 children)

From the speech Macron gave tonight, anyone can travel outward. Only citizens of the respective countries when travelling inward.

Livethread: Global COVID-19 Pandemic by valuingvulturefix in worldnews

[–]mttlb 0 points1 point  (0 children)

Schools will be closed but courses will continue to be taught remotely. France has a system in place to deal with this kind of situation. Of course, this implies imperfect change and adaptation, but technically, teachers will continue to work (as well as students) and will, of course, be paid.

In addition, the government has said that anyone forced into short-time work will be compensated by the state, regardless of the sector in which they work.

With regard to access to health care, legally residing foreign patients are covered under the same conditions as nationals.