Better HN
topnewbestaskshowjobs
Log inSign up

devit

4,235 karma · joined Sep 10, 2015 (11y ago) · 1,525 submissions

Submissions

comment 8y ago · link · parent

Just run it in a separate process with a seccomp sandbox, using pipe/socket IPC with a timeout (if it's some anti-DoS/intrusion thing, just fail allowing the request, since it's going to have false negatives anyway).

The IPC cost should not be significant compared to the rest of the web server code.

Can also ask them to do the work and provide a small open source in-process shim that sets up and talks to the sandboxed process.

comment 8y ago · link · parent

Well, you could change Rust so that the names of types with interior mutability have to start with an "@" or something like that, and then it would be obvious, and could expose a trait to denote that (there is Sync and the internal Freeze, but they don't quite do that).

I think it hasn't been done because interior mutability is relatively rarely used, and being able to assert immutability in generic code is not actually that useful (and for things like hash map keys you'd need to implement Hash or other traits manually anyway, so you'll probably notice the issue).

In non-generic code, you have to call functions like "borrow()", etc. to access the internally mutable data, so you know it's mutable.

Regarding "fearless concurrency", the Sync trait ensures that, allowing "interior mutability" only if thread-safe (i.e. Mutex or Atomic).

Obviously you can have race conditions between modifications of different Mutex/Atomics, but that's an unavoidable fundamental problem: even transactional systems will have race conditions if you use two separate transactions where you should have used one, and single-threaded event based systems also have them if you "defer" part of the computation improperly.

comment 8y ago · link · parent

Obviously a language needs to be capable of expressing laziness (which requires closures and some mutability), but it being the default is the issue in Haskell, since basically everything returns a closure computing the value rather than the value itself, which is really weird and unexpected, and causes unintuitive (at best) memory usage.

As for implicit parallelization with no annotations at all, the main Haskell implementations don't seem to do it, so I guess it just doesn't work (the reasons probably being that there are penalties due to caches being CPU local and the cost of synchronizing threads that make automatic micro-parallelization much worse that explicit coarse-grained parallelization, unless the micro-parallelization is done in hardware by the CPU out-of-order logic).

And obviously a type system with controlled mutability like Rust's allows to express explicit parallelization just fine (in fact, writing a safe explicitly parallelized web browser in Servo was one of the main goals of it).

> What you really want is a static checker that only prevents shared, simultaneous mutability but admits everything else. The Rust borrow checker is an important step in that direction but it's not it.

Is there any example of a static checker that allows more expressive programs than Rust's while preserving the same guarantees? (and without requiring extra annotations like programmer-supplied proofs or using best-effort automatic theorem proving). Is that even possible?

comment 8y ago · link · parent

In Rust, if you have an & or Rc/Arc, you know that it's immutable, except for parts contained in Cell/RefCell/Atomic/Mutex.

If you have an &mut or owned mut variable, then you know that you can only mutate it through that name.

If you have a non-mut owned variable, then you know that only the Cell/RefCell/Atomic/Mutex parts can be mutated, and only through that name.

If a Rust program doesn't contain the words "mut", "unsafe", "Cell", "RefCell", "Mutex" or "Atomic[...]", then everything in it is immutable.

That gives the same guarantees as Haskell's immutability where desired, but it allows to actually make use of CPU capabilities like writing to memory, and express basic operations like assigning a value to a position in an array.

Or in other words, what you really want is a system that lets you mutate something as long as you are the only one with a reference to it, and then make it immutable and give it around, while also allowing you to "get it back" exclusively either with static checks (via lifetimes) or dynamic reference count checks.

Haskell's pure immutability system, while safe unlike Java's, is just a very restricted version of such a system, that is not powerful enough to write safe programs that are as efficient as C programs (since you can't modify memory), or express imperative code even when they are safe.

comment 8y ago · link · parent

My impression of Haskell is that the main issue is that laziness is simply wrong, since it causes space leaks that are hard to reason about, and seems generally less efficient than eagerness; furthermore, it seems rarely beneficial, so it seems more appropriate to explicitly request laziness rather than the opposite.

The next problem is that complete immutability is also wrong, because controlled mutable aliasing with linear types (like the system available in Rust) is what you really want since it's more general, efficient and expressive (allows mutable data structures), and complete immutability is just a special case of controlled mutable aliasing.

The third problem of Haskell is the weird syntax, that doesn't follow the common C/Java/JS or Python syntaxes for no good reason, making it hard to read and learn the language.

And if one were to change these things in Haskell, the result would essentially be Rust (or more precisely, a future version of Rust once all the missing abstractions like HKT, specialization, etc. are added), so I think that's what one should use instead.

comment 8y ago · link · parent

Python 3 is a case study on how you should never create a new version of a language implementation that can't load and interface with code written for the old version.

After almost 10 years, the old version is still in use, and the new version isn't even that much better.

comment 9y ago · link · parent

Rust is probably what you are looking for.

> a functional language

Has closures.

Has pattern matching.

Has algebraic data types (however variants can't have generic parameters not present on the data type itself, but you can use trait objects to do that).

Functions that don't take &mut parameters, & parameters with types with interior mutability and don't call functions that do I/O are pure (although they may not terminate and may abort).

> optional lazy constructs

"Automatic" lazy costructs are usually unnecessary and thus almost never used, but can be implemented as a library using macros.

Can also just use closures and call them explicitly.

> great polymorphism

Has trait/typeclass polymorphism with either monomorphization or dynamic dispatch.

Structures can't be inherited, but composition gives equivalent results and is the proper way to do it.

There have been several proposals for inheriting structures though, so maybe it will be available at some point, despite not being advisable.

> statically typed with inference

Yep.

> generics

Yup.

Not higher kinded, no constant integer parameters and not variadic yet, but those features should be available in the future.

> great concurrency story

Rust is the only popular language supporting safe concurrency without giving up the ability to share memory between threads.

> an efficient GC

It turns out that a GC is unnecessary, and that reference counting is enough, which is what Rust provides (although it's still relatively rarely used).

If you insist on a tracing GC, there are/have been several attempts to add it, and maybe there will be a mature one in the future.

In particular, there is a "rust-gc" crate, and Servo has a working integration with the SpiderMonkey GC, which I suppose should be possible for others to use with some work.

> compiles quickly

Work in progress (incremental compilation, more parallelization).

> self contained binaries

Yes (or optionally using shared libraries).

> simple and effective tooling which takes only seconds to setup

rustup can install the compiler and package manager in one line.

If you want an IDE, you'll have to install that too separately. Work in progress on improving IDE functionality and ease of use.

> giving you perfomance that equals java and can rival C

Performance is at least theoretically the same as C since the generated assembly code is conceptually the same (other than array bounds checking, which can be opted out from with unsafe code).

> low memory footprint

Same as C.

comment 9y ago · link · parent

Working at Mozilla on the Rust compiler would be the best possible fit skills-wise (other than going back to LLVM).

comment 10y ago · link · parent

Would it be too costly for Amazon to just employ people to review most or all of their products, and maybe even rebrand the best products under its own brand where the seller agrees?

It would dramatically increase the quality of their store and brand, and it benefits from economies of scale.

Assuming they pay $100 for an high quality review, then a $10 item would increase by only 1 cent if at least 10000 are sold, which seem reasonable conditions.

For categories with many very similar items, reviews should be cheaper since a standard review procedure could be designed and applied quickly, offsetting the lower sales per items.

comment 10y ago · link · parent

That's inaccurate.

You can do what you describe as long as you use Rust's reference counting support (Rc and Arc), which includes weak references that can be used for parent pointers, plus RefCell and Mutex for mutation.

To have an object "self-destruct", have it remove all reference counted pointers to itself.

You can pass an &Rc<Self> (or &Rc<RefCell<Self>> or &Arc<Mutex<Self>>) as the self parameter if you want to let an object create references to itself. If you want an object to be able to drop itself immediately in that case, use an Rc<Self> instead of an &Rc<Self>, and call drop(self) in the method (this also work if you are not using reference counting and just pass Self, of course).

You should try to not do this kind of thing though, because it adds overhead and the compiler cannot statically check that you are not leaking reference counted cycles or deadlocking on mutexes or refcells (which is not a Rust limitation, it's just impossible without having the programmer write a machine-checkable proof).

If you do it in C++ the compiler also cannot check whether you are referencing freed memory or incorrectly concurrently modifying the same object.

comment 10y ago · link · parent

It doesn't really break the encryption, as long as the password is strong enough to prevent brute forcing.

Relying on a weak password and a "trusted computing" mechanism like this one from Qualcomm to prevent an attacker with physical access from brute forcing it is not really advisable.

Using such a mechanism at all has downsides since it means that you lose the data if the mechanism or the entire device stops working, while otherwise you could simply move the SSD/flash/storage unit to a new identical device and have it just work as long as you type the correct password.

comment 10y ago · link · parent

These captchas are a great pain for Tor users, who are often presented with them on all websites protected by CloudFlare.

It would be greatly appreciated if the code used for the paper were released, even better if it's in the form of a Firefox extension and submitted to the Tor Browser maintainers for inclusion in the default install.

comment 10y ago · link · parent

Isn't any vesting for non-founding employees completely broken?

If the employee loses the stock when he's fired early, then the company has a huge incentive in firing him a day before he vests, and thus he should regard the vesting compensation as nonexistent.

If the employee retains the stock when he's fired early, then he can just get himself fired to ignore the vesting period, making the vesting pointless.

It seems that vesting can only work if the employee is so essential that the company would never fire him because the company would then be highly likely to fail, which should only apply for founders in a functional company.

comment 10y ago · link · parent

The actual issue is the fact that sending money to someone can result in untrusted code running in the middle of your code execution and even reentering it seems absurd.

Sending should always succeed immediately and if anything needs to be automatically triggered in response, the trigger should be executed asynchronously.

A great way to immediately see the problem is, for anyone with Rust experience, to think of this as a function taking an &mut self being somehow reentered without that &mut self being passed out by the function itself.

comment 10y ago · link · parent

It seems to me that Rust would be pretty much strictly better than this.

In particular Rust has similar syntax, seems to have all Reason's features plus the linear types and regions/borrowing that allow memory and concurrency safety while still being able to mutate memory and not being forced to use GC.

They are aware of Rust since they cite it in their page, so I wonder why they decided to create this instead of using Rust.

It would be nice if they explained this in the FAQ.

I guess it might be useful if you have an OCaml codebase to interface with but don't already know OCaml, but given the relative obscurity of OCaml that seems a pretty narrow use (and also Facebook isn't known to make extensive use of it, afaik).

comment 10y ago · link · parent

You can just redirect a port with SSH and then use Samba/CIFS or NFS if you are worried about sshfs.

comment 10y ago · link · parent

Can anyone explain how a chat-based interface can possibly be generally successful except briefly as a novelty?

Surely an UI with controls specific to the task at hand is much better than having the user guess what the bot responds to and what it can do?

In the restaurant use case, for instance, a QR code + text URL that points to a website where you can advertise the restaurant with whatever graphics and UI you want seems far better than some sort of text interface (which also requires them to be Kik users, know they can scan the code, etc.).

comment 10y ago · link · parent

The key principle is that the software should always correctly work at any point in the chain of commits, so you must squash commits that are "oops, fix X in previous commit".

Once that is satisfied, commits should be as small as possible, so that information about the grouping of changes is preserved.

comment 10y ago · link · parent

The really questionable thing CloudFlare seems to be doing is that they captcha traffic depending on the overall reputation of only the source IP rather than whether the source IP is attacking that specific site or even whether the site is under attack.

What they should do instead is this:

1. If the server is not overloaded, do not captcha any traffic at all

2. If the server starts being overloaded, only captcha traffic from IPs that have been detected as attacking THAT specific site

3. If the server is still overwhelmed, only then switch to captchaing all IPs with "bad reputation"

Most websites are probably almost never under attack, so this would make encountering CloudFlare captcha extremely rare in the wild while still providing DDOS protection.

They could even only do this for Tor exit nodes and other IPs that are known to be used by lots of people.

If a site is being DDOSsed a lot and the slower start up of this technique is a problem, then they can revert for those sites to the current behavior of using reputation.

comment 10y ago · link · parent

Yes, that's true.

Encrypting the data before hashing with a secret key solves this issue if applicable.

> You can't know that because you can't see into the future.

The "best cipher" is the single one you would have used if you had not decided to use a cipher cascade.

The idea is to make sure that your cascade is never worse than that single cipher.

comment 10y ago · link · parent

One the solutions is to start using algorithm cascades instead of single algorithms where performance doesn't matter.

If you are using 10 ciphers or 10 hash functions or 10 signature schemes, then you need 10 different breakthroughs before it all falls down.

There is really no reason to not do this unless performance is important, and a lot of times performance does not really matter.

NOTE: obviously you need to this properly and use a different key for each cipher, concatenate hashes, concatenate signatures and so on. Also, you should start encrypting with the best implemented ciphers, so that plaintext is not leaked if the worst ciphers happen to have timing/cache vulnerabilities.

comment 10y ago · link · parent

Does this mean that distributed transactions are not supported at all?

comment 10y ago · link · parent

Note that this is mostly caused by the fact that mobile game developers are courting such a distribution by making "pay-to-win" games where you can pay more to get advantages without limits.

While such a structure means that a game developer can earn 10k or more from a single player, it also makes the game worse for those who aren't willing to spend unlimited amounts of money and thus drives some of them away or causes them to decide to not spend any money at all.

If this is not desired, the simple solution is to have an "unlimited pass" that gets you access to all current and future IAP/DLC content that gives a game advantage for either a fixed one-time fee or a fixed subscription fee.

This is probably not often done because the game developers believe that it would be less profitable overall.

comment 10y ago · link · parent

I've been unable to find any clear description of the capabilities of Citus and competing solutions (postgres-x2 seems the other leader).

Which of these are supported:

1. Full PostgreSQL SQL language

2. All isolation levels including Serializable (in the sense that they actually provide the same guarantees as normal PostgreSQL)

3. Never losing any committed data on sub-majority failures (i.e. synchronous replication)

4. Ability to automatically distribute the data (i.e. sharding)

5. Ability to replicate the data instead or in addition to sharding

6. Transactionally-correct read scalability

7. Transactionally-correct write scalability where possible (i.e. multi-master replication)

8. Automatic configuration only requiring to specify some sort of "cluster identifier" the node belongs to

comment 10y ago · link · parent

Why not use a flat rate Spotify-like model?

Paying per article seems to have the big issue that you actually have to think whether you to want to pay or not and might feel cheated if the article is not as good (they offer refunds, but there must be a limit or catch or everyone would just refund everything).

comment 10y ago · link · parent

" UnnyWorld – A mobile League Of Legends clone: [...] While cloning popular games might not be prestigious, bringing the League Of Legends experience to mobile could be quite lucrative. "

Doesn't sound like the best advertising...

comment 10y ago · link · parent

Is AI right now useful as a way to provide value for small projects or startups? Any examples of that?

It feels like most examples of commercial AI usage are features (image search, automatic face tagging, etc.) that get added to existing products by large companies with access to large datasets and computing power.

comment 10y ago · link · parent

Wouldn't it have the wrong sender address?

Or are they actually forging it? (and somehow not getting put into spam due to SPF/DKIM failing)

comment 10y ago · link · parent

Huh?

A password hash could happen to be reversible, or could map lots of passwords to the same value.

1
414243
51