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

> You can multi-arch a distribution

I use multi-arch, but it is buggy. Several times, when trying to install a 64-bit library, apt was suggesting to remove tens or hundreds packages to satisfy the dependencies. That included the packages that I have installed manually and it is strange that apt tries to remove them.

Also, when using multi-arch, you can accidentally install a 32-bit kernel and then half of applications stop working.

comment 4y ago · link · parent

Strange, I thought that all RISC CPUs typically have 32 registers. I guess I was wrong about ARM.

comment 4y ago · link · parent

I think that it would be better if I could use 64-bit kernel with 32-bit applications.

32-bit applications are better in almost every aspect: they use smaller ints and pointers and use less memory, they can be used on both 32-bit and 64-bit systems, they don't waste energy on computing extra bits. The only disadvantage is that they cannot use more than 2Gb of RAM, but almost every aplication I use doesn't need so much RAM. On x86, 32-bit apps also have slightly less GPRs.

So the perfect solution would be a 64-bit kernel with mostly 32-bit applications except for those cases when you need more than 2Gb of RAM.

But instead many developers refuse to provide 32-bit versions of applications for Linux, and provide worse 64-bit versions. And Linux distributions compile everything for 64-bit, even if the application is never supposed to use even 1 Gb of RAM.

So everything is wrong with 64-bit support in Linux.

comment 4y ago · link · parent

They wouldn't be solved because the problem is that newer versions of shared libraries are not compatible with older applications. There is no problem with ELF or PE formats - ELF is supported on Linux natively, and PE is supported using Wine.

APE format doesn't solve the problem with shared libraries changing over time, it dosn't solve the problem that different plaforms provide different APIs (for example, windowing APIs, audio APIs etc).

comment 4y ago · link · parent

This APE format is not "write once run anywhere", because it targets a specific architectrure (64-bit x86) and won't run on other architectures. Just a toy format and I see no use for it.

What we need instead is better support in Linux for legacy Linux and Windows applications so that Linux could run any proprietary software written for it or for Windows (because there are no sources for it and it cannot be recompiled). Today it is not so: for example, very old Firefox builds don't run or crash on modern Linux.

comment 4y ago · link · parent

It seems like governments around the world want to push people to keep their money in the bank. But this is an awful idea: first, in this case the government can track all your spending (even if the law doesn't allow that, they can ask the bank informally). Second, the government can always limit how much you can spend or withdraw.

For example, if there is a financial crisis, the government can limit how much you can withdraw from your account. Those with cash might be able to buy currency or precious metals, but those who trust the bank will be screwed.

But to be honest cash is not much better. For example, the government can introduce a cash reform, and also set limits for exchanging old currency to new one.

comment 4y ago · link · parent

Interesting. The reason for a bug seems to be that ^ and $ in regexps match a boundary of any line, not boundaries of a string. This have already caused problems in the past, as far as I remember, but Ruby developers didn't change the behaviour of these characters.

So if you write a regexp like /^[0-9]$/, a string "Any characters\n12345\nAny characters" will match the regexp.

comment 4y ago · link · parent

It is a bug in tzinfo. It should not execute random files when given invalid timezone identifier.

The app doesn't know what is a "valid" or "invalid" timezone, it is tzinfo's responsibility to check it.

UPD: in fact tzinfo tried to validate a timezone identifier but did it the wrong way. It used a regular expression like /^...$/ and using ^ and $ is a mistake here. This allows to bypass validation by passing a multiline identifier.

comment 4y ago · link · parent

Regarding the article, I think that "small" tools are better for scripting (but they should be made scripting-friendly; many Linux CLI tools are not), and complicated tools are better for usage by humans.

For example, take a word processor. You probably don't want to use one tool to type the text, then copy it into another tool for spell checking, into third tool to add equations, fourth tool to find and download clipart images, and so on. You want to have everything integrated.

comment 4y ago · link · parent

While the idea that there can be a lot of small and composable tools sounds good in theory, in practice the implementation is very poor. To use tools in a script, they should have standartized machine-friendly input and output formats, but instead they have arbitrary and difficult to parse formats. It means that they are not intended for use in scripts.

- spaces or newlines in file names are often not handled properly. Some linux software based on shell scripts requires that a user install it to a path that has no spaces.

- the output format is often arbitrary and not machine-friendly. For example, `ls -l` output is difficult to parse properly. Some programs might output a file size with different suffixes, like 10k or 10M, that you have to parse.

- output format often depends on locale settings and scripts can break if used with different locale

So the programs that rely on line-oriented inputs/outputs like `grep`, `wc`, `ls` (without -l), `sort` work relatively good, but other programs that produce more complex output, are unusable for scripting.

Scripts often use ugly hacks like parsing output with `sed` or, even worse, `awk`, a 40 years old cryptic legacy tool. Instead they could use something like JSONpath, for example `parse $.*.size -- ls -l` to get sizes of all files (although I don't think that using JSON is a good idea; it's hard to read by human. I think something indentation-based like YAML would be better; however, YAML itself is overengineered and I recommend against it).

Also the shells are an awful choice for scripting. For example, there is no syntax to write a glob pattern to select all files including dot-files, but excluding pseudo-files like . and ..

To conclude, "Unix philosophy" of composing utilities using shell scripts is often advertised as a superior and innovative approach but in practice it is a bunch of inconvenient to use programs glued together with unrealiable buggy scripts written in outdated language. It is easier to use Python and ignore all this "philosophy".

By the way, `/proc` filesystem also is not scripting-friendly and not standartized. So it is usable only as a debugging tool for humans.

comment 4y ago · link · parent

I guess that the amount of SRAM for microcode is limited so you cannot write a lot of code this way. Also, microcode might be used only for slow, rarely used instructions, and it doesn't make much sense to optimize them.

comment 4y ago · link · parent

For example, I might install RabbitMQ on a dev server. I do not need any clusters there.

comment 4y ago · link · parent

> The firewall solution to a new/unexpected open port is a default deny rule.

In case with a single node, it doesn't make sense. If you open a port, you probably want to be able to connect to it, otherwise why would you open it? And if you don't want anyone to connect, then don't open a port. There is no need for a firewall in case with a single node, unless you want custom rules like "only host A can connect to host B".

There should not be "unexpected" open ports. Software should not open ports on external interfaces unless permitted by administrator.

RabbitMQ should just have a switch to disable all unnecessary clustering features, but for some reason they don't want to implement it.

comment 4y ago · link · parent

> because by default firewalls usually block all incoming traffic

In Debian by default all connections are allowed. And it makes sense: if you open a port, you probably want to be able to connect to it, otherwise why would you open it?

It doesn't make sense if you open a port (to accept connections) and then block this port with a firewall.

Of course this applies to cases when you have a single node, I understand that you might need firewall if you have several nodes.

comment 4y ago · link · parent

I don't need a cluster, I need a single instance, but RabbitMQ doesn't allow to disable clustering. That's the problem and instead of proper solution people suggest blocking it with a firewall.

comment 4y ago · link · parent

Because they can do more rolling carts around in Wallmart.

comment 4y ago · link · parent

You can filter out bad workers by preparing an additional well-labeled dataset and removing those who made even a single mistake in it. Also you can give the same task to several workers and check if they give the same label. However this won't protect against a bot using multiple accounts and giving answers based on a hash of a question so that the same question gets the same answer in every account.

comment 4y ago · link · parent

> I’m still shocked how low the quality of Mechanical Turk was

I don't know about Mechanical Turk, but there is a crowdourcing platform by Yandex. The pay is so low that the reasonable way to earn something is to find a task that is not properly validated and put random answers there from multiple accounts (because there are speed limits). Usually those are tasks by naive foreign companies not knowing about validation.

So if you want high quality you need to implement proper validation, triple check every label by different people and do not expect that someone is going to do it for $5/hour. And maybe you should learn how a crowdsourcing service looks from the worker's side, for example, by registering and trying to do some tasks yourself or by reading forums for workers.

comment 4y ago · link · parent

Indeed, I didn't think about that.

comment 4y ago · link · parent

Firewall is unreliable as well. What if someone temporarily disables it and exposes vulnerable services? What if RabbitMQ opens a new port that you forgot to block in a firewall? Firewall is a hacky workaround, not a proper solution.

comment 4y ago · link · parent

1) Some tasks may take a long time to complete. For example, generating a report or converting a video file might take several minutes. You don't want a user to look at a blank page for so long, and browser might even close the connection because of timeout.

2) Reliability. Imagine, if a customer places an order in a store, but the server process crashes and the order is lost. The customer won't be happy about this.

A mesasge queue might help in both cases. Note that you might implement a queue in a SQL database as well, but this still will be a message queue.

comment 4y ago · link · parent

If you have a "tiny" cluster, then do you really need a cluster? Wouldn't a single node be enough for you?

comment 4y ago · link · parent

In theory I could learn Erlang and patch the source code as well, however, I would prefer a proper solution, not a hacky workaround.

It doesn't make sense if you first open the port and then block it with a firewall.

Also, this is a bad idea because firewall config is kept separately from RabbitMQ config, it is easy to forget that you have a RabbitMQ instance exposed to the whole Internet and accidentally unblock the port.

comment 4y ago · link · parent

> The typical action sequence is the user submits a request via the web application and the backend handles that message by adding a message to RabbitMQ. The consumer gets the message and makes a HTTP call to another web service to actually submit the request. From there, the polling logic takes over and subsequent messages on the queue each represent a polling attempt to retrieve the results. If a job has no results, the consumer places a message back on a queue so we can delay the next polling attempt by a (customer configurable) amount of time.

This looks like an overengineering to me, unless I have missed something. For example, I don't understand this part: "the consumer gets the message and makes a HTTP call to another web service" - why cannot that web service pull the message directly?

I would implement it like this: when a client submits a request, it is added into an SQL database, and RabbitMQ is used only to notify the consumer. The client gets back a secure Job Token that it can use for polling to get the status of the job. The consumer reads the job from the database, executes it and updates status in the database. The client uses polling to know when the job is done.

Of course, if you don't like polling, then you can use a WebSockets daemon that would notify a client when the job is done.

comment 4y ago · link · parent

Here is what I dislike about RabbitMQ: by default it opens several ports on external interfaces and doesn't provide an easy way to bind them to localhost only. To be specific, those are epmd port 4369, and RabbitMQ's ports 5672, 15672, and 25672. With help of Google I managed to move three of those ports to localhost, however the cluster communications port 25672 cannot be bound to localhost only. I found an issue on Github and developers' point is that it doesn't make sense to build a cluster from a single node, so you must have this port exposed to whole Internet so that any random stranger can connect to your RabbitMQ instance [1].

So it seems that RabbitMQ wants to advertise how scalable it is by enabling clustering by default and accepting connections from anyone even though it is not secure. It is targeted at large corporations with giant clusters and doesn't care about developers who just need a single instance. Despite my guess that most developers actually do not have a volume of messages that would justify setting up a cluster.

And as RabbitMQ is written in an exotic language (Erlang) I cannot even read the code.

This is the problem not only with RabbitMQ, Elasticsearch also has clustering settings enabled by default, so when you try to run two independent instances, they connect to each other and start exchanging data and creating problems without you expecting it. So annoying and so difficult to disable. In earlier versions, as I remember, they would also try to scan local network and connect to any node they could find.

[1] https://github.com/rabbitmq/rabbitmq-server/issues/1661

comment 4y ago · link · parent

Also in this case memory consumption will be lower because JIT'ed code takes space. I think that it is a good idea.

comment 4y ago · link · parent

If Internet access is not harming, then why do Bills like this exist?

comment 4y ago · link · parent

Recursion indeed can be useful when working with trees or graphs. However, I don't like using recursion instead of a loop, because you make reader to unroll your code in their head to understand what it really does. If you need to add two arrays of numbers, use loop or array addition, but don't use recursion as a replacement for a loop.

Sadly the article uses a poor example, writing a useless factorial function. I have never needed such a function in production code, and if I needed, I would write it using a loop. Using bad examples like this might create an impression that recursion is not useful in real code (which is wrong). It would be better if you have used an example that looks like real code and that would become less readable without recursion.

comment 4y ago · link · parent

1) The post has problems with math and the numbers are wrong

2) For fair comparison you should add memory used by daemons/services, otherwise I can say that gnome-shell uses only 200 Mb which is almost twice as low as your number

3) I am not sure if you can properly measure memory usage with Windows Task Manager. You need to account properly private, shared and swapped out pages for each process.

comment 4y ago · link · parent

Ignoring X server (or Wayland) is wrong because desktop environment can allocate memory in X server's process and it won't be accounted.
1
107108109
185