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

Starting directory names with capital letter is not a good idea. While that might look nice, it requires more keypresses when typing it in the terminal. So /apps or /soft would be better than /Programs.

It is convenient in case-insensitive filesystems like those used in Windows or Mac, but not in Linux. By the way it would be better if Linux also switched to case-insensitive filesystem, or even a filesystem where similar looking characters from different alphabets are considered the same. So that A is always A no matter what alphabet is used.

Also I don't like the way they hide classic directories like /bin. Instead, they should just not create these directories; well-written programs should not require their presence.

comment 4y ago · link · parent

I cannot recommend a book or an article, but just wanted to give an idea: automated testing is when you make a script do what a human tester would do. So maybe you should read about testing software in general. How test planning is done, how do you choose test cases.

You start with listing requirements (what a program/a class/a function is expected to do or not to do) and then write tests that verify that it is indeed so.

The easiest thing is writing unit tests. Pick a function, define requiremens and write a test for every requirement. If your code is not very modular and it is difficult to isolate a class or a function in order to test it, then maybe you should refactor the code first.

comment 4y ago · link · parent

> There aren't for you as a customer.

I guess it depends on the bank or on the country. In Russia some banks have a small fee (usually about $1-$2 per month) for using a debit card, some don't have and some will charge a fee unless you spend more than a certain amount every month or deposit a specific amount. There can also be a small fee for issuing/reissuing a card.

Then there are indirect costs. You will probably want to receive SMS notifications when your account is debited or credited, and this is not free for cards that don't have a monthly usage fee. There can even be a fee for withdrawing funds from a debit card (using issuer bank's ATM).

Recently I read through different banks' terms and there are lot of things they can charge you for. For example, one bank will charge a fee for counting coins or small bills if you bring too much of them. Or there can be a fee for withdrawing money in bank's office below certain limit.

Generally, it seems that banks don't like customers who don't pay a fee - directly or indirectly (when making a purchase).

comment 4y ago · link · parent

Bank cards have many disadvantages:

- there are fees and commissions for using a card, and there are limits on how much cash you can withdraw daily/monthly

- bank also charges the merchant and it makes prices higher for everyone

- bank knows what and where you buy, collects this information and can resell it

- your name is written on the card and encoded inside, so when you pay the merchant can identify you

- cards have a magnetic tape that is unencrypted, can be easily copied. It seems like the only use for this tape is to allow criminals to copy the card.

- new cards include RFID label that allows reading data about you and charge your account

- if you are suspected to be an "extremist", then the bank will allow you to withdraw only about $150 per month. And you can become a suspect if you post something wrong on the Internet.

Cash is obviously better.

comment 4y ago · link · parent

It's not "completely free". If you transfer more than 100 000 roubles/month (~ $1360) then it costs 0.5% of the amount. There are also limits of about several hundreds of roubles per month.

If the recipient wants to withdraw the cash in less than 30 days after receiving the payment, the bank may request documents that prove compliance with anti-laundering regulations. If you fail to provide such written documents then the bank will charge a fee of about 5-10%.

Also it is not secure because anyone who has your phone number can learn in what banks you have accounts. And if you have an account in Sberbank, anyone can lookup your name by your phone number. Very convenient for criminals and scammers.

comment 4y ago · link · parent

I see comments saying that heating with electricity is more efficient than with gas. So, will it cost less?

comment 4y ago · link · parent

> Therefore, by the time the ambitious 32-core Elbruses arrive, chips from AMD and Intel will be orders of magnitude faster and more efficient in terms of performance-per-watt than they are today.

I think that is wrong assumption because CPUs nowadays don't become "orders of magnitude faster" in several years.

comment 4y ago · link · parent

If you read the article, you'll see that the difference in performance is not that huge:

> SPEC CPU 2017 2.62 (base) ~ 3.15 (peak) times slower

> PGbench/PostreSQL 1.7 (read only profile) ~ 3.3 (read write profile) times lower

So, Elbrus is just 2-3 times slower in these tasks than powerful Intel's CPUs that took millions of dollars to design. As Elbrus has lower clock frequency and larger process node, so this is expected. It is difficult to outperform a CPU that has smaller transistors and more of them; you need either to have more transistors or they have to be smaller; or both.

But Elbrus loses a lot in Java tests:

> Java 23 ~ 26 times higher response time

I guess this could be because Java JIT doesn't support Elbrus architecture.

comment 4y ago · link · parent

Tests are not a replacement for comments or documentation. Tests check that A() returns x but don't explain what is A, x and why it should return it.

comment 4y ago · link · parent

So if you added several classes and functions, you describe them all in a single commit message? Probably you don't document them at all.

comment 4y ago · link · parent

Rust libraries use comments for generating documentation and testing. Here is an example of such documentation: [1]. It is difficult to believe that this code would be better without comments.

At least classes and public methods should have comments (except trivial ones).

[1] https://docs.rs/chrono/0.4.19/chrono/naive/struct.NaiveDateT...

comment 4y ago · link · parent

I don't like this idea. Nobody will read your comment in this case. I prefer comments to be visible by default without having to run extra tools. Also, usually a commit adds many functions and classes and it's difficult to describe them in one message.

comment 4y ago · link · parent

> the more unique you appear

If your fingerprint is unique and doesn't change then yes, you stand out. But if your fingerprint changes on every page load, then you become indistinguishable from other users.

comment 4y ago · link · parent

I think that allowing overflows to go unnoticed is a mistake. Overflow on addition should cause an exception by default. It should be easy to implement in hardware and as it is UB in C, correctly written programs wouldn't break.

For example, imagine if you are counting money and because of the overlow millions turn into several cents.

Another evil thing is indirect jumps. They should be implemented using an index into a jump table.

comment 4y ago · link · parent

> You do not need to update the entire screen all the time, you can do partial updates

You forget that you are expected to keep up to 8 reference frames. And you need to update them too.

> You do not need to update the entire screen all the time, you can do partial updates

This would work only until first keyframe.

comment 4y ago · link · parent

Playing video is very expensive task. Just updating 4K screen at 60 frames per second requires transferring of 3840×2160×60 ~ 497 million pixels or 1,49 Gbytes per second (if you skip every fourth byte). It will take at least several instructions (in the best case) to calculate value of every byte so the CPU should be able to perform billions of instructions per second.

I doubt you can do it without a "modern PC" with hardware graphic accelerator.

Also modern codecs require lot of computations and lot of memory. For example, codecs like VP9 require to buffer up to 8 frames for reference. That would take 8×3840×2160×4 ~ 265 Megabytes of RAM. The program will need to extract bits, decode arithmetic coding and calculate lots of IDCTs.

I did some research to see if it is possible to play Youtube video on 8-bit CPUs. What I found is that there is little hope for this. It's better to develop your own video compression format.

comment 4y ago · link · parent

An expansion card is recommended for this OS, so there are hundreds of kilobytes or even several megabytes, not "mere kilobytes".

comment 4y ago · link · parent

As I understand, Linux doesn't have a kernel-to-driver API so "upstreaming" a driver means that you have to maintain it and update every time something in the kernel changes.

Windows driver model is so much better. Windows driver model allows you (in theory) to run drivers written 20 years ago.

Linux model doesn't scale because the more drivers the kernel includes, the more work is required to update them when something changes.

Also Linux model doesn't allow reusing unmodified drivers by other operating systems. So developers of other OS's have to duplicate the work that already has been done.

comment 4y ago · link · parent

I wanted to note that abbreviations for signals like DI or AI are not very good for understanding, long names like DATA_IN or ADR_OUT would be better in my opinion.

comment 4y ago · link · parent

6502 is a very simple CPU and you can learn all of its instructions in several hours. But as it uses 1-address instructions, the code gets pretty verbose. For example, to add 10 to a variable you will have to write:

    LDA var
    CLC
    ADC #10
    STA var
That's 4 lines and many keypresses for a single addition! You might want to invent slightly more high-level language that would compile into assembly, like this:

    var, var2 = variables(2)
    var += 10
    var2 << 5     # Assign 5 to var2
By the way, you can use Python and operator overloading so that the lines above written in Python will generate assembly code when executed. I have used << instead of = in assignment because Python doesn't allow to overload it.

comment 5y ago · link · parent

I doubt there are any floating point numbers because FP is very slow to emulate (for example, just to add two numbers you have to shift mantissas and 6502 has no fast way to do it). If I was writing a game for an 8-bit CPU, I would use fixed point numbers (for example, 8.8 numbers which use 8 bits for integral part and 8 bits for the fractional part, or maybe 10.6, or 12.4 numbers).

6502 cannot multiply or divide (division is a costly operation even on modern CPUs) so I would use adding or subtracting logarithms for this purpose. 12-bit precision logarithm table requires just 8 Kb RAM (and you can get 13-bit precision with interpolation).

The disadvantage of this approach is that every time you convert a number from linear to logarithm or vice versa you get approximately up to 0.3% error (for 12-bit logarithm). So multiplying or dividing several numbers in a row is fine, but if you have to alternate multiplication with additions you will accumulate an error. So I would look for formulas that avoid this. But for a game a little error in calculations is not noticeable.

Also one might think that the most time-consuming part for pseudo-3D game is math and calculations. I doubt that. The most of CPU cycles are usually spent in rasterisation and applying textures. Is is easy to calculate positions of 3 vertices of a triangle, but it takes a lot of time to draw it line by line, pixel by pixel, and if you want to have textures this time can be multiplied 5x-10x.

comment 5y ago · link · parent

The game uses ray casting, not ray tracing. Ray casting is when you send a ray once for every column of pixels to get a distance to a wall. Also, if the walls are only horizontal or vertical the calculations get simpler.

Also I wonder how you can achieve clock frequency like 300 MHz without a cache. Shouldn't CPU stumble on fetching every command?

comment 5y ago · link · parent

There is a myth that if you are a paying customer then you are not a product. As we see, for more and more companies like Wacom, Microsoft or Apple you are a product no matter if you pay or not.

Have some self respect and vote with your wallet against such companies.

comment 5y ago · link · parent

It is an interesting language, but it is very low-level and it lacks many functions that you have to implement from scratch. For example, as I remember, there is no filter with custom response curve. Or there is a low-pass filter but you cannot choose its type, rolloff slope or modulate it with an oscillator. There is no spectrum viewer.

So you will have to reimplement functions that are built-in into modern DAWs. And it is not an easy task, for example, to implement filters you'll have to deal with equations with complex numbers.

comment 5y ago · link · parent

The article still doesn't answer how scrolling a page can cause layout change. Layout change occurs when elements are added or removed from DOM or when they change their size. I assume there is some Javascript that updates styles on scroll event.

comment 5y ago · link · parent

This complicated decoding makes a pipeline longer. This means that in case of branch misprediction there would be a large penalty.

comment 5y ago · link · parent

You can compare transistor count per mm^2 instead of nanometers.

comment 5y ago · link · parent

ALSA is already overcomplicated. What I expect from ALSA is being able to enumerate audio devices and being able to send audio to hardware without any transformations. The rest is the work for the userspace daemon.

comment 5y ago · link · parent

For someone these are problems and for someone the problems are completely different.

For example, I don't consider issues with hardware drivers Linux's problem. Users should not buy random hardware and expect it to work in Linux. Instead there should be an official list of recommended hardware and users should buy only it. If there is no NVIDIA on the list then you should not buy NVIDIA's card.

Or I don't notice any problem with multiple monitor support because I don't have them.

But there are some real problems, for example:

- no API for drivers that would allow reusing drivers in other OSes or maybe run them in the userspace.

- no support for running Windows drivers that exist for almost any hardware

- no sane way to install and run (third-party) software. Many programs require you to run scripts as a root, they silently add their keys, add their servers to package manager's source list (basically, they install a backdoor that gives them full control over your system).

- no sane way to run software without giving it too much privileges. If you run a program, it has complete access to your home directory, cookies, browsing history, hardware serial numbers, scanning WiFi (which can be used for geolocation).

comment 5y ago · link · parent

I think geopolitics is about US wanting to have control over chip production (being able to start or stop it, being able to ban certain countries and companies from getting access to the latest technology). I doubt conflict between China and Taiwan means anything here. China is not going to attack Taiwan which has US support.
1
116117118
185