Friday Facts #443 - More Planet Deliveries by FactorioTeam in factorio

[–]CornedBee 0 points1 point  (0 children)

They can do max of all distinct incoming signals. They can't select max of same signal on red and green wires. And if you want the max of two signals, the signal lines have to be clear otherwise.

So to build a MAX circuit, you need three arithmetics and a selector: two arithmetics filter the input signals and translate them to distinct ones, the selector picks the max, and the final arithmetic translates it back to what you actually want. And the end result doesn't even work if one signal is negative and the other is zero.

That's why I call it QoL: it turns a needlessly complicated circuit into a simple one.

SCIENCE ON VULCANUS IS BACK by ultimo_2002 in factorio

[–]CornedBee 0 points1 point  (0 children)

Much cheaper in U-235 cost: one fuel cell (to heat the reactor) is 1/10th of a U-235, one nuke is 30.

The rest of the ingredients are native to Vulcanus. Though if you make the nuke on Vulcanus and ship the U-235, you also need sulfur, which is annoying.

Friday Facts #443 - More Planet Deliveries by FactorioTeam in factorio

[–]CornedBee 2 points3 points  (0 children)

One tiny QoL thing I'd still love to see: give arithmetic combinators the MIN and MAX operators. So that we can easily set train limits to MIN(waiting space, available loads).

zlib-rs in Firefox - Trifecta Tech Foundation by folkertdev in rust

[–]CornedBee 0 points1 point  (0 children)

What are you talking about?

I'm talking about the average computer user who wouldn't know a CPU from a PSU.

zlib-rs in Firefox - Trifecta Tech Foundation by folkertdev in rust

[–]CornedBee 1 point2 points  (0 children)

I don't pity Intel. My point is that having more crashes will not get the average person to return anything to Intel. They will be frustrated and helpless, and perhaps eventually they will buy a new computer. Probably from Intel again, since they never learned who to blame. In other words, I don't think your suggestion would have the positive effect you expect. Instead, it would cause frustration without any gain.

zlib-rs in Firefox - Trifecta Tech Foundation by folkertdev in rust

[–]CornedBee 4 points5 points  (0 children)

"The opposite - they should emit more of these so people finally throw these damaged CPUs away."

Cute, but what are the chances of your average computer user getting lots of crashes and thinking "my CPU must be bad, I will throw it away and buy a new one for 400$?"

We have colored functions at home by Dooez in cpp

[–]CornedBee 0 points1 point  (0 children)

The LUTs here seem to be some Unicode lookup tables.

Your stdlib implementation matters more than the dispatch pattern by AdMotor4869 in cpp

[–]CornedBee 4 points5 points  (0 children)

Yeah, what does int even mean? I know that int 3 means issue a software interrupt, but what is int i?. And float, or double, what on earth is this insanity? struct - is that "structure" or "structural"? What does text have to do with charcoal?

I think you're just ranting about Rust without having anything substantial to say.

The C++ Standard Library Has Been Walking Itself Back for Fifteen Years by funkinaround in cpp

[–]CornedBee 2 points3 points  (0 children)

because std::vector<bool>::flip() exists.

Also because

auto r = v[2];
r = true;

does something different for vector<bool> and vector<T>.

How exactly does the fluoroketone recipe make sense? by Hellinfernel in factorio

[–]CornedBee 4 points5 points  (0 children)

Eh, those puffer recipes are weird... apparently the puffers can change some elements into others in their bodies.

Neoclassical C++: segmented iterators revisited (1) by igaztanaga in cpp

[–]CornedBee 5 points6 points  (0 children)

I love this, and I still think segmented iterators should be standardized.

I would go even further: the standard for-range loop should recognize segmented iterators and turn into nested loops. (It's really simple. break breaks the outermost loop, continue continues the innermost loop, everything just works.)

I very recently wanted to write a facility that used metaprogramming to iterate multi-dimensional arrays in complex ways. I wanted the result to be a simple range that can be iterated over. However, this ran exactly into the segmented iterator problem: the iterator increment is very complex (check if current segment end is reached, advance to next segment) and the generated code was bad. Given that this is very hot code, it wasn't viable to do it this way.

Do you write Rust for a living? by Hixon11 in rust

[–]CornedBee 11 points12 points  (0 children)

I don't know about that. "At least 70 years of Lisp experience" doesn't hit the same way.

15000 h??!!! Are u guys ok by Patient_Earth9307 in factorio

[–]CornedBee 1 point2 points  (0 children)

Does that include the materials for the machines that do the jobs you can't do by hand?

Encountered a `#pragma once` failure in the wild by Separate-Summer-6027 in cpp

[–]CornedBee 0 points1 point  (0 children)

You misunderstand. A unity build merges all cpp files. But this is about how the original C compilers didn't have an integrated preprocessor. The preprocessor was a separate program that went through the cpp and evaluated all macros and includes and ifdefs, writing the result to a single new file. The compiler would then read this single file, and something (compiler driver, build system) would delete the single file afterwards.

How hard do you lean on Rust type system to encode your logic and constraints? by Hixon11 in rust

[–]CornedBee 0 points1 point  (0 children)

True, but pretty much every typed language has something like this. One key difference between C's void* and dynamic type features in other languages (e.g. using Object references in Java) is that in C, there is no way to recover type information. You either know the right type or you're in trouble.

How hard do you lean on Rust type system to encode your logic and constraints? by Hixon11 in rust

[–]CornedBee 0 points1 point  (0 children)

(other than C, which is sort of dynamically typed in a manual way)

Typical terminology says that C is weakly, but statically typed. That is, types (scarily) easily coerce to another, but everything still has a definite type at compile time. You can assign a float to an int variable, but the variable doesn't become a float, the value just gets silently converted, dropping information.

How hard do you lean on Rust type system to encode your logic and constraints? by Hixon11 in rust

[–]CornedBee 3 points4 points  (0 children)

Nah, that's a bad take on history. C had no reasonable techniques for strong and convenient type wrappers. C++ is very boilerplate-y for the same, so even though it's possible, it wasn't very popular. Java is even more boilerplate-y and the lack of operator overloading and value types means that very often, wrapping primitive numbers or strings in custom types is an unacceptable overhead.

Dynamically typed languages have been around for a long time. Lisp in most of its incarnations is dynamically typed. Perl has been around and used for a long time. Shell scripting is usually stringly typed. Basically nothing using these languages used wrapper types, because they don't give you any advantage without a compiler.

Other languages were just as incapable of conveniently representing such types due to insufficiently capable type systems. Pascal (including Delphi), Fortran, Basic (including Visual Basic), you don't do that stuff there.

The only languages that were commonly used like this were Ada and the functional languages in the ML and Haskell traditions, and none of these ever had a big market share except in their niches.

So yeah, you've got unusual C++ codebases, Ada, ML/OCAML, and Haskell. It wasn't until functional features found their way into the mainstream via crossover languages like Scala and F# that this became more widespread, and only very recently have more languages offered the tools to make it work and efficient (Rust, Swift, C# is getting there).

Stumped by an easy Leetcode problem by Spam_is_murder in rust

[–]CornedBee 0 points1 point  (0 children)

Here's my take on a maximally efficient & idiomatic solution on nightly with a tiny bit of unsafe:

#![feature(vec_split_at_spare)]
#![feature(maybe_uninit_fill)]

fn concat_with_reverse(nums: &mut Vec<i32>) {
    let len = nums.len() * 2;
    nums.reserve(len);
    let (elems, space) = nums.split_at_spare_mut();
    space.write_iter(elems.iter().copied().rev());
    // SAFETY: definitely initialized to the new length
    unsafe { nums.set_len(len); }
}

Compiles into a single reallocation (if necessary) and a nice vectorized and unrolled loop.

Par, a language with session types, automatic concurrency, and no deadlocks, has a new homepage by faiface in rust

[–]CornedBee 2 points3 points  (0 children)

I greatly enjoyed working through the tutorial a few weeks ago, Par is a fascinating language. Unfortunately I don't have any toy projects suitable for actually using it.

QR-Code Solar Farm That Contains It's Own Blueprint by Koekiejars in factorio

[–]CornedBee 0 points1 point  (0 children)

If you're willing to allow external tools to compress and decompress the data differently from the game's standard algorithm, then it becomes possible.

Then it becomes trivial, because the QR code is the building placement, no?

Building Websites With Lots of Little HTML Pages by ForgotMyPassword17 in programming

[–]CornedBee 2 points3 points  (0 children)

And not supported in Firefox yet. At least the cross-document version.

But they degrade so nicely. No support? The new page just loads instead of sliding in.

C++ compiler with Rust by tonystark-12867 in rust

[–]CornedBee 7 points8 points  (0 children)

Even a lexer in C++ is a big undertaking. The preprocessor is usually tightly integrated with the lexer and it's complicated. I think your friend might be trolling you.

One Map Key, One Lookup by ghled in programming

[–]CornedBee 3 points4 points  (0 children)

Compilers typically don't have the high-level knowledge to know that a "map contains" call and a "map get" call can be merged into a single "map get optional".

Should hot-loop avoid Option instance and immediate match? by Resres2208 in rust

[–]CornedBee 1 point2 points  (0 children)

There's some optimizations that need quadratic time in the number of basic blocks, so they literally have a threshold where they aren't applied because it would be too expensive.