HNHacker News
TopNewBestAskShowJobs

pierrebai

1,310 karma · joined October 13, 2011

submissionscomments
pierrebai··on Ask HN: Good C++ code bases to read?
Both problem could have been solve looooooong ago by introducing a type modifier akin to const that carries if a value is verified (or safe or non-null or other. Pick your synonym).

   int * p; // maybe null!
   int * verified p; // guaranteed non-null!
A looooong time ago (circa... 1994-1995) I designed a hierarchy of smart pointers and had a variety for non-null so that you could declare a function like:

   void foo(non_null_ptr<T>& p);
And know that you don't have to verify for null. All enforced at compile-time. (via the a function on ptr<T> returning a non_null_ptr<T>).

With language support around if() and others, C++ could have mde it even more convenient. Even C could have introduced such a tyupe modifier. Whenever I read about pointers being unsafe and how optionals and maybes are the solution, I roll my eyes, because non-null-ptr do the exact same thing.

The funny thing is C++ has a non-null ptr (with no language support guarantee though): references. Unfortunately, the language made them not resettable, which makes them unusable in many scenario when you'd want them to change value over time, like in most classes members.

pierrebai··on Ninja: A simple way to do builds
Of note, meson is mentioned to optionally use ninja as a build system, but the same is true of CMake.

On thing to note is that the simplicity of ninja means that a lot of things need to be repeated. For a project I'm working on, the input build.ninja file is 142MB. Just generating that files takes a few minutes.

I think an improvement would be to be able to split it in sub-trees and have ninja produce a "mark" file that has a date that represent when the last time the sub-tree was touched and to not even read any sub-tree files, even the sub-ninja file if an entire sub-tree date is older than the mark file.

pierrebai··on Four features that justify a new Unix shell
I'm sorry to say to for me, shell scripting has lost. All my scripts are written in Python, which a thin shell script wrapper to launch it.

Look at Oil. It tries hard to be bash compatible with optional buy-in to extension. Just use a superior language and give up on shell scripts, that's my advice.

pierrebai··on The Hypertext annotated version of “A Fire Upon the Deep” (1993)
It's a reference to caricature of evil villains twirling their mustache as they gratuitously enjoy the extreme suffering they inflict upon others with no rationale other than enjoying being evil.
pierrebai··on The Hypertext annotated version of “A Fire Upon the Deep” (1993)
If I'd rate my current collection of best SF I've read:

- Deepness in the Sky: super mustache twirling, one of the worst.

- Fire upon the Deep: I consider the blight to be twirling. Why treat lower civ that way? AFAIK, for mustache twirling.

- Iain M Banks: lotsa mustache twirling. Surface details and Player of Games in particular. My view of the culture AI is that they are constantly sarcastically toying with humans, and are thus secretly twirling.

- Fifth Season (Jemisin): no twirling. One of the most balanced novel on that front, every faction has believable reason to act the way they do.

- Book of the New Sun: no twirling, but OMG, stop what you're doing a good read these books! The tone and story was just perfect for me. Sure, it looks like a weird cross of SF and fantasy, but there is no fantasy at all in the novel in reality. Book of New Urth is, in comparison, just merely very good.

- Ancillary Justice (Lecki): some small twirling, but justified since it's an empire: absolute power corrupt. The twirling is commensurate with having a empress as head of state. She even becomes mostly sympathetic later.

- Left hand of Darkness: not only no twirling, but the power struggle is extremely believable. Great illustration of an interesting alien civilisation. Great for both world-building and character building. Another of those stop everything and just read it now novel.

- Roadside Picnic: no twirling. The conflicts and abuse of power are all believable.

- Collapsing Empire (Scalzi): lot of mustache twirling. Not DotS level, but not that far off. Plus, there is a plot point in the first novel that made me quit reading for a week. Incomprehensible because it was all of unbelievable (given the multiple characters behaviour before), idiotic and had zero impact on the rest of the book... so why write it. (Page 260 in my paperback version, for the record)

pierrebai··on Cargo-style dependency management for C, C++ and other languages with Meson
I'm going to agree with your parent poster. Just wait a few years. I'd even claim that having deprecated bits is a sign of acceptability and industry trust: the language is used widely enough to have grown multiple implementations of multiples features.

Sure, it might now be features Rust currently has, it will be technology X or programming trend Y that will appear down the line and which will be implemented by multiple teams.

pierrebai··on Discipline Doesn’t Scale
Well, you'll be happy to know that C++ pretty much allows that, but not for templates. You can use auto in parameters if the calling context allows inference, for example when writing lambda.

Similarly, you can use auto as a return type if the function implementation is immediately given and the compiler with infer the return type. The new starship operator (<=>) typical usage is pretty much declaring it with an auto return type and "= default" implementation.

pierrebai··on Discipline Doesn’t Scale
Both of your first two cases exist when people convert code bases that used raw pointers to shared_ptr. The normal intended usage of shared_ptr is to use make_shared and never have a raw pointer ever exist. The need to us shared_from this (or create a new independent shared ptr) happens only because some part of the code base is still using raw pointers for that particular class.

OTOH, C++ needs the ability to support old code bases because of its age. Of course a new language can forego this.

As for cycles, for GC language using ref-counting under the hood, the same problem applies. I've also seen memory leak from accidental keeping of pointers in fully GC languages. I've seen it happens in Java multiple times. Of course, two wrongs don't make right, but in this case GC is only solving one case.

But the more fundamental issue at play is that pointer cycles usually means a lack of up-front design and thought about how a program will work. As such, it is bad, but only a symptom of a lack of proper initial design which can manifest itself in all kind of places.

pierrebai··on C++ still isn't cutting it
C++ multi-threading is easy by not sharing data. Just have each thread produce a result and have a thread that accumulates the results via std::future.

I've converted many mono-thread C++ algorithm this way.

pierrebai··on The Serverless Revolution Has Stalled
One of the fundamental problem of serverless is intimately tied to its very selling point: that your code is run on interchangeable servers.

What that leads to is that everyone's code runs on any server. The requires strict inter-server security, authorization and roles.

On a normal server, you can run multiple processes (DB, front-end, back-end, etc) and rely on the fact they're running on the same server to not having to design roles and auth.

In serverless, you need to manage roles and auths for everything.

You see the same issues for data pipes, triggers and queues.

pierrebai··on There are only four billion floats, so test them all (2014)
The answer is that the bugs the article claims are corners cases, most of which will not matter in most practical uses of floating point maths... and some of which will is due to not emulating a weird IEEE floating point rule about rounding numbers of the form N.5 to the even number instead of up like everyone is taught in school.

So "wrong" as used in the article simply means "not the same as the IEEE behavior", not "wrong" as in "wildly inaccurate". It matters if you want 100% exact emulation to get identical results. It doesn't if you don't and just want speed.

pierrebai··on Fortunately, I don't squash my commits
If you work on a very large projects with many released version and need to cherry-pick fixes to back-port, you'd be very, very, VERY glad that each branch got squashed.

The story told in the article mainly shows to keep your PR focused. You can squash as long as you don't do 2-week-long 37-commits branches.

pierrebai··on How scientists resolved the mystery of Devil’s Corkscrews (2019)
In the tone of the ancient dispute, with its arrogance, self-assurance, the belittling of the other's ideas, the condescension, ones can see the burgeoning of every internet discussion boards.
pierrebai··on PG and Jessica
I would have liked an intelligent, articulated reply. Unfortunately, you merely got down-voted, for no other reason that I can see than not parroting the extolling.
pierrebai··on Democratic regression in comparative perspective: scope, methods, and causes
Quote:

> In fact, 2006 was the high water mark for democracy in the world, with the percentage of democracies peaking that year at 57% among states over one million population (Figure 1), and 61% of all states. 9 Since then the proportion of democracies in the world has gradually declined, to 55% of all states and 48% of states above one million population.

So you are in opposition to even the simplest provable fact provided in the article. And you wish to replace a statistic you don't approve of with... made up measurement? You then bring up that somehow, measurement of liberties would have a scientific basis? Liberties are not a physical quantities. They choose indicators and measured them. You chose to no indicators and simply stated your political bias.

I will choose to appreciate the more rigorous of the two.

pierrebai··on Embedded PDF viewer in Firefox 81 supports filling forms
In the early 2000 I coded a PDF library for an industrial printer suite. (Print, proof, impositions)

I personally think the structural PDF format is a really great format. It's entirely ASCII-based, a pure text format, yet it can embed arbitrary binary data and compress that data. The actual structure is simple and support just enough functionality, like a tree of object, dictionaries and arrays, unicode strings, date formats, etc.

I think if you limit yourself to pure structural PDF woulde have been a great format to standardize upon, much better than JSON or XML. It';s richer than JSON, simpler and saner than XML. Again, it's top-notch ability to embed binary is great. It has other great characteristics, for example you can update anything just by appending.

The ugly bits are in the "semantic" PDF: the page descriptions, media, etc. Even then, the early version of PDF were nice, mainly just simplified Postscript.

pierrebai··on Dynamic Scoping in C++
So, dynamic scoping are global variables... except with even way way way worse unpredictable behavior. Any function from three-level remote libraries can invisibly modify the meaning of code.

Sure, it allows for neat tricks, I suppose. It mostly allows impossible to diagnose error conditions since what happened actually depends on anything that may have happened before, invisibly.

I find it particularly amusing since fighting off global states has been a worthy goals of languages, libraries and framework. Without it, you can say goodbye to reproducible behavior and multi-threading.

(If dynamic scoping is thread-local, you still have the issue that anything can affect anything else, so nothing can be assumed to be reentrant anymore.)

pierrebai··on Microsoft Has a Large Presence at This Year's X.org Conference
How dare they design API to suit their need?

That a company wants its own API to move freely and faster is often described as evil when it is merely sensible for them. It used to cause lock-in, but nowadays there are enough tech stack that isolate you from the underlying API to make it irrelevant.

Do note that until, oh let's arbitrarily say 10 years ago, DirectX was ahead feature-wise to OpenGL and OpenGL was moving at turtle pace.

pierrebai··on C++ vs. Rust: an async Thread-per-Core story
Personally, I've written a few multi-threading implementations at various places and my accumulated wisdom is that any data received by threads has to be passed by values or be constant. Anything else is a lot of risk for little value.

I've also come to the conclusion that async/future are a bad idea for multi-threading. They're fine for managing mono-thread asynchronous events, but using them as a poor man's thread pool is begging for trouble. Among the problems are:

   - you do not know if the execution will be synchronous or not.
   - you often don't know and have no control on how many threads will be spawned.
   - it makes following the flow of data and execution much harder.
What I've come to rely on is the trinity of:

   - a thread provider (non-committal name, we all know it's a thread pool behind the scene), which provides the threads of execution.
   - a work item provider, which provides the input data to the algorithm.
   - a worker provider, which provide workers that receive a work item, execute an algorithm and produces a result.
Then something gets executed when all three are united. For the curious, the reason to have a work item separate from worker is that it allows the worker to be long-lived and re-used and, most importantly, allows containing heavier data. For example, a cache. The work item are light and are just the necessary data needed to process one... work item.

I've also sometimes divided the work item into two parts: a work item and a context. The work item is the changing data to be processed while the context is the almost constant data, and can be shared. (For example, configuration data.)

pierrebai··on A Requiem for a Dying Operating System (1994)
Isn't it?

What's more, and this keeps behind repeated and emulated, I do not understand how being arrogant, condescending, insulting, full of bad faith scorn and hatred is supposed to make me be part of a group or use a tech, API, stack, framework or what not.

"I'm a VMS user", they seem to say, "watch me be a nasty person."

pierrebai··on China Built a Vast New Infrastructure to Imprison Uighurs
These article have been decried as being staged by the chinese government. Here are other articles, from the BCC, about Uighurs:

   https://www.bbc.co.uk/news/world-asia-53657604
   https://www.bbc.co.uk/programmes/w3cszl3q
   https://www.bbc.co.uk/programmes/w172x2ys9gxqv4g
   https://www.bbc.co.uk/programmes/p08lf6zk
   https://www.bbc.co.uk/news/world-asia-china-50166713
pierrebai··on Congratulations for reaching a million, Gordon Linoff
What surprises me is that SO claims I'm not allowed to answer questions until i get points and suggest I ask questions... so how can he have not asked any and get started?

That has always been a real put off at SO. They actively don't want me to answer.

pierrebai··on The Common Lisp Condition System – Upcoming Book
I'm afraid to sound like a negative type, but to me this example is simply a callback?

The described EMPLOYEE-WORKING-DURING-HOLIDAY is akin to a system has a slot to register a callback (or signal which can be connected to receiver, to use a Qt-like design) which can handle the situation or decide raise an exception.

Again, I understand that it might be attractive to have a single unified system to handle the different possible situations instead of separate systems. I find it hard to imagine a case where the decision to be an exception-like, callback-like or restart-like is chosen dynamically at run-time by any or all participants. And like I said, I' d be afraid that if such a case come up, it would make understanding the design harder, not simpler.

For example, as much as Qt signal/slot mechanism is powerful and flexible, I've found that when used fully, it makes understanding the code hard because it becomes impossible to know what will happen when a signal is raised because the handling is so well uncoupled.

pierrebai··on The Common Lisp Condition System – Upcoming Book
Am I allowed to think the described use case less than compelling?

It's especially not compelling that the caller passed the wrong type, the called function would like a different type and somehow a different piece of code would know both end of the situation and fix it instead of the caller or callee.

It all seems like an artificial and convoluted use case.

Software design tend to know if they'd like to abort (throw) or report (callback) statically. Conditions may be general, but they seem to me to mostly allow unnecessary open-ended complex design.

If the supposed gain is that a single system can do it all, I again don't feel it is a convincing argument. In fact, I tend to prefer a one-goal system, where different use case are easily differentiable because they are different. IOW, that throwing an exception, calling a callback, sending a signal or converting a value should look different is a plus.

This is something I've noticed: one starts with a rigid design, then adds abstractions. But one reach a point over over-abstracting where the design becomes uncomprehensible because it is so generic that it becomes meaningless.

pierrebai··on The Wrong Abstraction (2016)
Checking for the type is the exact opposite of OO.

The correct OO would be to think about what the check represent, maybe abstract it in a base interface with pure abstract methods and derive from that interface.

What you describe is what people without understanding of OO do when they come from a language without OO.

pierrebai··on The Wrong Abstraction (2016)
Counter: Refactoring is far, far, far cheaper than duplication or wrong abstraction.

Duplication means you lose the wisdom that was gained when the abstraction was written. It means that any bug or weird cases will now only be fixed in one place and stay incorrect for all the places you duplicated the code.

About the rule of three: I personally extract functions for single-use cases all the time. The goal is to make the caller be as close to pseudo-code as possible. Then if a slightly different case comes up, I will write the slightly different case as another function right next to the original one. Otherwise, the fact that you have multiple similar cases will be lost.

pierrebai··on Time of maximum intersection of two moving polygons
The blog talks about many interesting mathematical problems. One strange thing is that there is gap of about four year between his most current entry (jan 2020) and the previous one (oct 2016).
pierrebai··on Microsoft duplicates data from Firefox without asking
The correct title should actually be "Edge imports Firefox data if you say yes when it asks you". Because that is what is happening. The article on Reddit is just wrong.
pierrebai··on Microsoft duplicates data from Firefox without asking
Your answer aligns with pretty much all the others. They have in common reprhasing the original situation or questions in extreme way possible.

Cake is a personal taste. Are technical choices a question of taste. Your arguing against debates and technical discussions.

It's telling that many examples given were using video feed or pickpockets as an analogy to telemetry. These are not interesting explanations. Going to extreme arguments is not illuminating.

pierrebai··on My family saw a police car hit a kid, then I learned how NYPD impunity works
Resisting arrest should not lead to death. There is no urgency to shoot someone who is drunk in the back as he is fleeing when you have his car in your possession.

Polices are using unnecessarily lethal force indiscriminately for offenses and in situations that don't require in the least. They have been getting positive reinforcement by being not prosecuted and being protected by their force and the system in general.

← PreviousPage 8 of 15Next →