139 karma · joined July 7, 2017
There's actually an active proposal for a standard library, but it is met with a lot of contempt from the JS community [0]
[0] https://github.com/tc39/proposal-javascript-standard-library...
Yeah, it was just a parody of the articles The Onion regularly releases regarding another topic and to be honest I didn't quite expect my post to take off the way it did.
I'm also sorry I posted it on Medium, which I personally dislike, but since Medium is frequented by many JS devs it seemed the ideal place to put that joke.
That is one of the most ridiculous statements I have ever heard.
Instead of listening directly to the event store for events you have another non-abstracting layer on top and listen to that.
A sensible architecture would have that layer be an abstraction layer for business use cases, so instead of listening to "user-created", "user-edited" and "user-deleted" events and rebuilding the user state in the consumer every time an event is fired, you'd have that layer expose a single user state stream. The rebuilding is handled entirely within the layer.
Many people skip that and just re-expose the "primitive" streams of the event store, because they read "don't expose your persistence layer" and skipped the important ", expose the business state layer instead" which usually comes right after that.
int main(int argc, char** argv) {
std::vector<std::string> strings{
"apple", "cAt", "cat", "Dog", "apple", "dog", "Cat",
"Apple", "dOg", "banana", "cat", "dog", "apple",
};
strings.erase(
std::remove_if(
std::begin(strings),
std::end(strings),
[seen = std::unordered_set<std::string>{}](std::string_view str) mutable {
std::string lower = "";
std::transform(std::begin(str), std::end(str), std::back_inserter(lower), ::tolower);
if (seen.find(lower) == std::end(seen)) {
seen.insert(lower);
return false;
}
return true;
}
),
std::end(strings)
);
for (auto& str : strings) {
std::cout << str << "\n";
};
}[1] https://github.com/tc39/proposal-javascript-standard-library...
Ever tried installing a local package via a file path? NPM just symlinks it into node_modules, causing issues because you suddenly have duplicated dependencies. Yarn does the same, btw.
I have given up any hope regarding npm/yarn acting sensible long ago.
That is, if you don't need to support IE (And I feel like we're finally in the phase where it slowly, but steadily dies off). Otherwise you can ponyfill it.
Such a library would only cover features which would be useful in JavaScript in general, not things which are tied to the web platform. (A good heuristic: if something would make sense on a web browser but not in node or on embedded devices or robots, it probably isn't in scope.)
For example, a function which takes a property path (in the form of an array of strings) and an object as parameters and returns the value at that path inside the object still needs overloads for every single tuple length.
type Key = string | number | symbol;
function get<T, K extends keyof T>(path: [K], obj: T): T[K];
function get<T, K1 extends keyof T, K2 extends keyof T[K1]>(path: [K1, K2], obj: T): T[K1][K2];
function get<T, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2]>(path: [K1, K2, K3], obj: T): T[K1][K2][K3];
function get<T, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3]>(path: [K1, K2, K3, K4], obj: T): T[K1][K2][K3][K4];
function get(path: Key[], obj: any) {
if (path.length === 0) {
return obj;
}
const key = path[0] as Key;
const rest = path.slice(1) as [Key];
return get(rest, obj[key]);
}
interface Foo {
foo: {
bar: {
baz: {
val: number;
}
}
}
}
declare const foo: Foo;
const num = get(["foo", "bar", "baz", "val"], foo);
In this case, num is implicitly typed as number, but if the path would be longer, you'd need to add more overloads.Are there any news regarding new, more environment friendly mining processes?
[1] https://www.wired.co.uk/article/lithium-batteries-environmen...
Just because they may be overused in Java doesn't mean people shouldn't use them at all in other languages.
> It was shown that wait times are required in the order 50–100 years for the remote handling recycling option and hundreds (Li4SiO4) to thousands (Eurofer) years for hands-on handling.
"Embrace, extend, extinguish" was one of Microsoft's key strategies.
https://en.wikipedia.org/wiki/Embrace,_extend,_and_extinguis...
Examples:
- Ben Deane - Using Types Effectively [0]
- Jason Turner - Rich Code for Tiny Computers: A Simple Commodore 64 Game in C++17 [1]
- Ben Deane & Jason Turner - constexpr ALL the Things! [2]
[0] https://www.youtube.com/watch?v=ojZbFIQSdl8