Better HN
topnewbestaskshowjobs
Log inSign up

codedokode

9,867 karma · joined Aug 20, 2015 (11y ago) · 5,528 submissions

PHP developer from Russia.
Submissions

comment 4y ago · link · parent

The post mentions CRLF line end syntax, I don't understand why anyone should bother with it. Use \n only, it works everywhere including Windows. Any modern IDE can handle Unix line endings. The same about file paths, use forward slash (/) everywhere and don't waste your time supporting DOS era standards.

I think the core.autocrlf option in Git is more harmful than useful (for example, it can change file hashes and break something) and should be removed. An option to warn about unwanted \r characters on commit might be useful though.

comment 4y ago · link · parent

SAT solvers are used in package managers to resolve dependencies.

SAT solver is a tool that determines whether a given boolean formula can be True (it is called SAT) or not. If it can be True, a SAT solver provides values for variables so that you can check that they are correct.

For example, a Boolean formula

   a & (b | c)
Can be True if a = True, b = True and c = False.

SAT solver can be useful for resolving dependencies in a package manager. Imagine if a user wants to install package A with version >= 1.0, but package A depends on other packages and might conflicts with some packages as well. The package manager converts these requirements into a boolean formula like this: let's say that if variable A₁₀ is True, then package A version 1.0 is installed, if A₁₁ is True, then package A version 1.1 is installed and so on.

First, let's express user's desire to have any version of A installed. Here is the rule:

    A₁₀ | A₁₁ must be True
Let's say A version 1.0 requires B version 1.0 or 1.1. We can then write a rule, that if A 1.0 is installed, then B 1.0 or 1.1 must be installed as well:

    !A₁₀ | (B₁₀ | B₁₁) must be True
Now, let' say that B 1.0 conflicts with C 1.0 and both cannot be installed at the same time. We can express that as a formula as well:

    !(B₁₀ & C₁₀) must be True
Finally, we cannot install two versions of the same package, so let's write that too:

    !(A₁₀ & A₁₁) & !(B₁₀ & B₁₁) must be True
Now we can combine all the rules into a single formula. All the rules must be true, so we join them using AND operator:

    (A₁₀ | A₁₁) & (!A₁₀ | (B₁₀ | B₁₁)) & !(B₁₀ & C₁₀) & !(A₁₀ & A₁₁) & !(B₁₀ & B₁₁)
Now we can give the formula to the SAT solver. If will solve it and give a set of versions that need to be installed in order to satisfy all requirements. Or it will prove that this is impossible.

Another use of SAT solver is verification of programs: if you have two pieces of code without loops and you want to make sure that they are equivalent, you can convert them into boolean formulas and use SAT to prove that for any given input they produce the same output.

comment 4y ago · link · parent

I noticed this problem with other images too. Sometimes animations change too fast, you see points moving, you look at them, but at the same time the formula changes, and you miss it. Especially bad when the formula is written under the image, far away from moving points.

Basically, you should not have several things changing in different places at the same time because human can only focus at one point. Maybe it would be better to add pauses in the sequence, animate one thing, wait a little, then animate other thing. Let the user stop and think a bit about what he/she have seen.

For example, in the image "Repeated addition of a point P" the points and lines are constantly moving, and I don't have time to look at the formula. I see that it is changing, but I cannot read it while looking at the animation. Maybe it would be better if the points stopped moving for a while, then the formula would change, then you give some time to read and comprehend it and then points continue moving.

Or maybe you could write all the formulas on the side, and have a box or selection moving over them. This way the viewer can see how the formulas are related to each other and doesn't have to remember previous ones.

Also, in the image "Point addition is associative and commutative" formulas seem to be random and do not illustrate anything. For example, I see 5P + P = 6P, then 2P + P = 3P, then 6P + P = 7P. So what it should mean?

Maybe a better way to illustrate these laws would be to have two images that produce the same result, for example P + 6P = 7P and 3P + 4P = 7P. It is easier to compare images side-by-side.

Instead of percent sign it might be better to use "mod" as percent sign is understood only by programmers but not by people familiar with mathematical notation.

To illustrate addition you might use a circle (or an ellipse, or even a square, why not) instead of a straight line. This way the wrapping behaviour would be more obvious. To illustrate multiplication, you could draw several sequential arcs (so that the multiplication is represented as several additions). And for negation, two arcs extending in the opposite direction from zero.

I don't understand how to illustrate inverse numbers though. Maybe several arcs that start at zero, end at 1 and number of them is the inverse value?

For the last illustration it definitely would help if it had some key points on the side, showing what we have done and what we are doing now.

comment 4y ago · link · parent

> There is actually no perfect solution

There is one: choose the size so that the image is displayed without scaling.

comment 4y ago · link · parent

Interesting, but you can see how AI makes mistakes at [1]. It perceives a dog as a small car for a moment.

[1] https://youtu.be/fwduh2kRj3M?t=792

comment 4y ago · link · parent

I don't understand though how a "network scan" (I assume sending a broadcast packet and receiving a response) can raise ping time from 3 to 150 ms.

comment 4y ago · link · parent

Many of the settings are unnecessary, for example, input file format switch: I would prefer a computer to figure out this for me. And there is no need for all those "display X" switches because you can display everything at once.

comment 4y ago · link · parent

This is just an example of poor GUI design. The author didn't make any attempt to think of user experience and just mechanically converted OpenSSL CLI options into widgets. This is not how one does GUI design [1].

For example, let's take "Input format" switch. Our computers can do billions of calculations per second, cannot they determine file format automatically? And show a warning if the format doesn't match file extension?

Or let's look at checkboxes, determining which information should be displayed: "print serial number" and so on. Cannot a program just display all important information at once without toggling any checkboxes?

Of course, CLI interface is good for using in scripts. But not every CLI program matches that purpose: utilities intended for use in scripts should output data in machine-friendly format like CSV or JSON or TOML or even specially invented CLIML, but not in plain text. Otherwise scripts will break every time they stumble upon a filename with spaces. Sadly, despite decades of evolution, many CLI programs are not machine-friendly yet.

I use openssl maybe once a month or once a year and I cannot remember a single option. I would rather prefer to type "crypttool /some/file.pem" than spend time finding out which options I need to specify.

And obviously if I had to manage a company-wide PKI with its own CA I would definitely prefer a well designed GUI tool.

[1] Please note that I am not a designer. I just learn things by observing other people's work.

comment 4y ago · link · parent

Youtube has not much value as a video hosting. You can host your video anywhere else easily.

Youtube's value is viewers that will accidentally discover your video. Nobody will watch your videos if you publish them at your own website.

comment 4y ago · link · parent

Isn't reverse engineering a code with annotations much easier than without them? And reverse engineering the code often takes significant time in large projects.

comment 4y ago · link · parent

> The sunsetting of IE11 and the rise of evergreen browsers that implement the latest JavaScript standard means that developers can once again run standard JavaScript code without transpilation.

This is a wrong assumption. There are lot of smartphones that do not get updates and have browsers that can be several years old.

Therefore transpiling and polyfills are not going away anywhere soon.

Of course, supporting different browsers can insignificantly increase development costs. It might be impractical to try to support Internet Explorer 7. A safe and reasonable choice would be to make sure that site looks and works perfectly in any browser released 5 years ago and is usable in a 10-year old browsers.

Obviously there are cases when this rule can be amended, for example, if you are making a game requiring a fast GPU and a mouse, then you can ignore smartphones and old browsers. But for a general website, like a corporate website, an online store, a social network, this seems like a sane default choice. You can extend support to 12-15 years old browsers if you feel confident in your skills.

comment 4y ago · link · parent

Probably because nobody was watching.

comment 4y ago · link · parent

> Why is it so easy?

Because nobody was watching when they meddled with voting machines. If there was someone oberving or at least a camera, this would be easy to discover.

comment 4y ago · link · parent

> No matter what anyone did, the currency would lose value week after week, month after month.

Cannot one convert their money to dollars or gold and start getting profit from inflation?

UPD: I forgot that in such cases governments usually impose large tax on currency conversion. Obviously you can't outsmart the government.

comment 4y ago · link · parent

As I understand, one cannot convert shared_ptr to unique_ptr, so if we declare an argument to add_two_numbers() as unique_ptr, then we won't be able to pass a shared_ptr to it.

comment 4y ago · link · parent

> You'll get 4 instructions (don't forget to put __attribute__((noinline)) on add_numbers()):

That's 4 instructions only for add_numbers(), but add_two_numbers_smart_way() still is unoptimized.

comment 4y ago · link · parent

You are right. First version of code actually used std::shared_ptr<Data>(new Data) (and produced similar code), but then I thought that it is unfair that we create a struct on a stack in Rust, so I changed the code. I should have used gcc with -Wall that detects the problem (clang doesn't).

comment 4y ago · link · parent

Indeed! Rust fails to notice that Arc cannot be accessed from different thread and makes unnecessary locked increment/decrement in add_two_numbers_smart_way().

comment 4y ago · link · parent

I think that there is implicit clone() in C++ code because when we pass a shared_ptr to a function, its reference count gets incremented (and decremented later) and it would be unfair if we used move instead of clone in Rust.

comment 4y ago · link · parent

Because we might need add_numbers() to be able to work with reference-counted data. Obviously this program by itself is useless, but these functions could be a part of a larger program.

comment 4y ago · link · parent

Maybe, but in the example functions have only one argument with a pointer, so there cannot be any aliasing. And there is no need for locks because there is no pointers shared between threads.

3292.

Why Rust easily optimizes out smart pointers where C++ cannot?

28 points · by codedokode · 4y ago · 60 comments

comment 4y ago · link · parent

> telemetry is a good thing

It is good only if it is "opt in". But in the wild we see that lot of software doesn't even provide an opt out and doesn't warn about telemetry when installing or starting a program.

If it is such a good thing, why developers prefer not to disclose its usage?

comment 4y ago · link · parent

Sadly, 2FA won't help against malicious developer or a developer selling package to a malicious owner.

Maybe ther should be a paid service that would manually review packages and provide a curated repository? I can't see other solutions. Either you review the code or you pay someone to do it or you isolate every library into a sandbox.

comment 4y ago · link · parent

Very interesting, never heard of this. I love Hacker News for being able to learn something new from comments. Although I cannot agree with labeling "horizontally nanocoded CPU" as "No instruction set". There are instructions, they are just low-level.

I wonder, can Turing machine count as "Zero Insturction Set"? Technically there is no sequence of instructions.

comment 4y ago · link · parent

You should not use somebody else's car to gather topological data without permission.

comment 4y ago · link · parent

Nobody tells you about ads and tracking when you buy a TV. Therefore a consumer can be easily fooled.

comment 4y ago · link · parent

Note that this applies only to eCall system. Any other system that might be installed in a car doesn't have to stick to these rules.
1
109110111
185