Better HN
topnewbestaskshowjobs
Log inSign up

GrumpySloth

4,901 karma · joined Sep 13, 2020 (6y ago) · 1,641 submissions

Submissions

comment 4y ago · link · parent

What does ":" do in this?

  : "${BASH_LOADABLE_PATH:=/usr/lib/bash}"

comment 4y ago · link · parent

The GUI is made with Electron.

comment 4y ago · link · parent

Then you're using a definition of vector, not used in any mathematics course.

> you can construct a vector space out of a set of non-vectors (such as matrices)

A vector is by definition no more and no less than an element of a vector space. Vectors are defined by vector spaces, not the other way around.

If you have a vector space whose elements are matrices, then those matrices are vectors. And they will be written in coefficients in a given base as tuples.

> out of operations other than vector addition and scalar multiplication

You don't "build vectors out of operations like vector addition and scalar multiplication", as in: you don't choose them. You choose the field and dimension, and those operations (vector addition and scalar multiplication) are a consequence.

> you can use vectors for purposes other than constructing vector spaces, also without involving either of those operations

Again, you don't construct vector spaces out of vectors - there are no vectors without vector spaces. And there are no vector spaces without those operations. But yes, you can use vectors from a given vector space in a greater capacity than just as vectors.

An example, which shows the futility of looking at vectors as just tuples: a real number is a vector in the vector space of real numbers over the field of rational numbers.

comment 4y ago · link · parent

Also, the unfortunate associative containers and std::regex.

comment 4y ago · link · parent

Go authors put out a good post explaining the problem with C syntax and contrasting it with Pascal/Go/Rust syntax: <https://go.dev/blog/declaration-syntax>

comment 4y ago · link · parent

2. I'm not sure I understand you here. A vector is defined by those operations. A set without those operations, even if it has the same elements, is not a set of vectors anymore. I don't understand your remark about sets here. The correspondence is necessary, because those operations on vectors are induced from the operations of the relevant field of scalars. The operation of adding vectors of bank numbers would be induced from the operation of adding bank numbers, if there was any such thing. The operation of multiplying vectors by scalars (bank numbers in this case) would need to be induced from the operation of multiplication of bank numbers, if there was any such thing. Anyway, I think you got hung up on the example, when the point is you can have std::vectors of types for which those operations don't make any sense. Now, imagining that perhaps there hypothetically might exist some definitions of those operations, just to convince oneself that std::vector is a vector is really stretching it, and I'm not even sure at this point if you're not trolling.

Anyway, as another commenter pointed out, Stepanov himself, who gave this container its name, said that it has nothing to do with vectors, and he wouldn't name it vector, if he could correct this mistake.

comment 4y ago · link · parent

It's not. Vectors can be added together and multiplied by scalars. That they are often represented as tuples of coefficients is just notation, doesn't matter for the notion of vectors, and vice versa: a tuple is not necessarily a vector.

1. std::vector doesn't have a fixed dimensionality, as would a mathematical vector. A fixed-length array actually makes more sense as a vector.

2. It doesn't provide the operations of addition and multiplication by scalars out-of-the-box (though you can whip up your own). Moreover, in general those operations wouldn't make sense for the elements which can be stored in a std::vector. E.g. neither multiplying bank account numbers by scalars, nor adding two bank account numbers make any sense. It would be good if you modelled them with types which don't allow those operations. Yet storing them in a std::vector makes perfect sense. But std::vector (or tuple) of bank account numbers is not a vector.

comment 4y ago · link · parent

Actually, I've never known it existed. You're the one who reminded me now. :)

comment 4y ago · link · parent

> FWIW, ArrayList is a List, backed by Arrays.

You probably know that, but just to clarify: it's backed by a single array, reallocated repeatedly, just like std::vector in C++ (although growth factors are different, I think).

Just "List" probably risks that some people will jump to the conclusion that it's a linked list. I'd probably prefer the full "ArrayList". Although personally I'd use something like "DynArray"/"DynamicArray".

comment 4y ago · link · parent

Java: ArrayList

Zig: ArrayList

GLib: GArray

Objective-C: NSMutableArray

comment 4y ago · link · parent

It's std::vector that was weirdly named. In plenty of codebases "Vector", particularly gamedev and scientific, will mean the mathematical object with that name.

Other languages don't need to replicate this mistake.

comment 4y ago · link · parent

There are some instances of it in the stdlib, e.g. <https://pkg.go.dev/html/template@go1.18.4#Must>

I'd guess with generics we can expect a generic "Must" to replace them.

comment 4y ago · link · parent

My favourite feature of mpv is small but neat: going frame-by-frame forwards and backwards with the keys "." and ",". VLC can step forwards, but not backwards, which frustrated me a fair bit, because I like first stepping really fast forwards to go into the general vicinity of the frame I wanted to catch, necessarily overshooting the target a bit and then backing off a bit and narrowing down the frame with greater precision. VLC didn't allow me to do that, overshooting meant I needed to do the whole thing all over again; but mpv got me covered.

comment 4y ago · link · parent

I don't remember where I got the number, but a quick look at Wikipedia finds some claims that Free Germania used to have 70% forest area. I think I've also heard similar numbers in some museums given for Poland in Middle Ages. Can't find it now though.

Sweden and Finland today have ~70%. 30% is the number for most of Europe today, and it's usually considered low, among the people I know. So it seems that Iceland historically already had very little forestation.

comment 4y ago · link · parent

From the title, I expected they were sounding an alarm that they are losing forests. It appears the opposite is happening. Really bewildering, given how just a couple centuries ago for most European countries having less than 70%+ forest coverage would be an oddity.

comment 4y ago · link · parent

Oh, got it. I got confused, because the Haskell snippet is written in a point-free, not applicative style.

comment 4y ago · link · parent

> The given Haskell example doesn't support their claim that

>> This is shorter than the equivalent in an applicative language, because we have to name the input argument, that is only used once.*

Are you saying that in your eyes the Common Lisp and Haskell snippets are equally terse? To me the Haskell snippet looks a lot shorter and easier to read. Counting tokens also supports that judgement.

comment 4y ago · link · parent

> Bethesda has such a reputation for releasing ambitious-but-buggy games

As far as I know, I've only played one game by Bethesda - Doom Eternal. It was also the only game I haven't found a single bug in. I'm more used to Ubisoft games, which are chronically buggy. Doom Eternal was a whole other level for me.

comment 4y ago · link · parent

Rust isn't any less "free" than Debian. If you forked Debian, you also would need to change the name, due to the trademark.

comment 4y ago · link · parent

Scotland

5.46 million people, 6.83 million sheep.

comment 4y ago · link · parent

> In ML syntax, you don't know how many arguments a function will take, because of currying, and it's a (useful) feature, not a bug.

Currying doesn't change the picture here from the situation in, let's say, C. If it wasn't for "infixr", there would only be one way to parenthesise an expression. Just like in C, you could apply a function of N arguments to N+2 arguments, and the function call would get interpreted by the compiler as function application to N+2 arguments. It's just that there would be a type error, but gramatically, there is no ambiguity about which symbols are used as called functions, and which as arguments to the functions (and to which functions)... as long as you don't use "infixr". Same with a function of N+2 arguments getting N arguments. At some point you get a type error probably, because you're going to get a function, where you expected a non-function; but the type system doesn't influence the building of AST (in this place at least). Looking at the source you know how many arguments are getting applied to what, without even knowing the definitions of functions, as long as you don't play with infix functions.

To make an example, again ignoring infix stuff, given "a b c d e", I know to read the whole expression as application of function a to arguments b, c, d, e. To be even more literal, SML doesn't have multiple-argument functions, all functions take one argument, and I can write it as "((((a b) c) d) e)". Unlike in concatenative languages, the function application doesn't suddenly stop in the middle of this expression, just because a takes fewer arguments than it was given, e.g. this expression can never be interpreted as "((a b) c) (d e)", even if it made more sense from the point of view of types of a, b, c, d, e.

But when you do add infix syntax, then yeah, there is ambiguity, and now AST building is driven by the symbol table a bit.

comment 4y ago · link · parent

If b is declared to be infix by default, then it will be an application of function b to arguments a and c though. So you need to know the symbol table anyway it seems.

comment 4y ago · link · parent

> But this is true for ML syntax too, isn't it? And ML-likes are widely considered to be readable.

I don't see how that's true for ML. Could you give an example showing the ambiguity?

Edit: I think I can see how the presence of infix syntax may cause that. As in: when you see "a b c" it will read differently based on whether "b" is a function that's declared to be infix by default. Yeah, I think infix notation is a mistake. The more I think about syntax, the more appeal I see in S-expressions.

comment 4y ago · link · parent

And now I want to see a broadway play narrated by David Attenborough.

comment 4y ago · link · parent

I associate it more with Perl. A quick search reveals Perl to be older than PHP by 7 years, so I'd guess it's a Perl idiom borrowed by PHP.

comment 4y ago · link · parent

I don't understand Piped. It's marketed as a faster frontend for YouTube, but more often than not, for me it's actually a lot slower (buffering-wise) than normal YouTube, gives me lower video quality and I end up switching from it[1] to normal YouTube to make the experience bearable.

[1]: Nitter replaces YouTube links with Piped links, so I end up on Piped partly involuntarily.

comment 4y ago · link · parent

You can opt into lexical scope for a script by starting it with:

  ;; -*- mode: Emacs-Lisp; lexical-binding: t; -*-
You can then opt into dynamic scope for single variables, when it makes sense:

  (defvar variable)
1
313233
55