4,235 karma · joined Sep 10, 2015 (11y ago) · 1,525 submissions
comment 5y ago · link · parent
Depending on option, the args can be pointers to structure.
comment 5y ago · link · parent
I think that would make it pretty much impossible to cheat assuming the tournament organizers don't collude with players.
While the described setup is expensive, just playing naked with a metal detector check in a physically isolated place through the described computer system is probably enough and reasonably cheap.
comment 5y ago · link · parent
comment 5y ago · link · parent
Since Rust has an actual type system, decent programmers usually produce code that works correctly the first time it successfully compiles, so running and testing it is not so important.
If you still need to run many code snippets frequently, create a command line tool with an option parser (e.g. clap in Rust), and create a subcommand for each "code snippet" and you can then invoke them from the command line along with whatever options you need.
You can also use debuggers or add eprintln! calls in existing codebases.
If you are just learning the language and want to test simple examples you can also use online playgrounds like https://play.rust-lang.org
comment 5y ago · link · parent
That seems quite unlikely given the lack of syntax for lifetimes. It's still in theory possible to infer them, but that would result in API instability and hard to decipher error messages.
Can you for instance have a function that given a reference to an hash table and a reference to a key returns a reference to the value corresponding to a key equal to the given one? (this requires the return value lifetime to be the same as the hash table lifetime, while the search key lifetime is unrelated)
Can you refactor code that takes multiple parameters by reference to taking by value a single structure including those parameters as fields with independent lifetimes?
comment 5y ago · link · parent
But that's just bad for running general purpose software that can require more memory than available locally since it means you have to do memory cache management in software which is going to be much slower than letting the hardware do it.
comment 5y ago · link · parent
Gaining memory safety at no cost is the whole point of rewriting in Rust, since it dramatically changes the behavior of the resulting program (it no longer has memory-related bugs and vulnerabilities).
The other languages might have slight benefits over C, but they either also have drawbacks (with makes them unsuitable) or the benefits are not worth a rewrite.
comment 5y ago · link · parent
This makes the societal superorganism very effective at exploiting the planet's resources by conditioning human beings to serve it; that conditioning is also the root cause of all human suffering, which is an invitation to consider whether one wants to identify with society.
comment 5y ago · link · parent
But in general, every command would generate an "undo record" with information to undo it.
In case of the brightness/contrast change you can do that by undoing in the naive way and then storing the difference between the "naively undone" image and the origignal version, compressed, in the undo record.
In general the undo record will only be large if you lose a lot of information, and then there won't be as much information left to lose and thus the next undo records won't be able to be so large, so overall the total size of the compressed current image and undo record will amortize and be in the range of the size of the original image plus the command description.
For example, once you turn the image fully grey, then all per-pixel transformations will be either be reversible or the undo record will compress to the effect on one pixel since it's the same for all the image.
This doesn't hold however if you also have operations that create information (e.g. something that draws a pseudorandom image with you then adjust contrast on, resulting in a pseudorandom undo record that you can't compress with standard techniques): in that case I think reexecuting the command history is the only space-efficient solution that doesn't require coding for the specific application.
comment 5y ago · link · parent
This would not work, for instance, in an image editor with an "adjust brightness/contrast" command since that changes the whole image.
It's also inefficient since you need to examine the whole state to generate the diffs, so in general it's not a great solution.
comment 5y ago · link · parent
Assuming you have an hardware DMA ring buffer for I/O that is directly mapped in userspace, the only thing that is really needed is to write the operation type, size, disk position and memory position to the ring buffer, update the buffer position and check for flush, doable in around 8 CISC instructions (plus the slowpath), so around 100x inefficient.
Without the direct mapped ring buffer and with a filesystem, you need a kernel to translate from uring to the hardware ring buffer, and here it still seems around 10x inefficient as around 100 instructions should be enough to do the translation (assuming pages already mapped in the IOMMU, that you have the file block map in cache, and that the whole system is architected to maximize the efficiency of this operation).
comment 5y ago · link · parent
The summary is that you should use esbuild (or swc/spack when ready) for new projects and probably switch existing ones as well if feasible.
It's possible that the Parcel 2 version they used is not the released one, so maybe it improved.
comment 5y ago · link · parent
In that case, you might be (temporarily) better off adding some very powerful and addictive thoughts or feelings to cover up the depressive ones; I think this might be in fact one of the main uses of social media and videogames.
comment 5y ago · link · parent
I tried the QuietOn Sleep, but they didn't seem any better than foam earplugs (and possibly a scam - i.e. lacking any ANC at all).
Anyone knows about any such things?
comment 5y ago · link · parent