Better HN
topnewbestaskshowjobs
Log inSign up

GrumpySloth

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

Submissions

comment 5y ago · link · parent

This could be useful for writing lexers. Although I typically need to interleave some "decoding" with proper lexing (like decoding escape sequences in strings, universal character names in identifiers etc.), which would make it harder, when you want to do it in a single pass.

comment 5y ago · link · parent

Your comment doesn't reply to anything in mine. I haven't written anything about hamburger menus, things looking lean, chrome or gestures.

The only thing my comment was about is the practice of imagining non-computer-expert people to be mindless zombies who don't know basic stuff. Cmd+C, Cmd+V, and Cmd+R are one of the most popular shortcuts in computers, known by people who aren't computer experts. Just because something is done with the keyboard, doesn't mean it's some l33t knowledge exclusive to "power users". But computer professionals often talk about "casual users" as stupid, probably to feel better about themselves, because they know all that oh-so-advanced-hard stuff.

So yes, just like a "copy" button would be a waste of space, when Cmd+C is so widespread, a "refresh" button is similar in that regard.

Apple would be the last company to optimize for power users.

comment 5y ago · link · parent

Stop patronizing casual users. Cmd+R isn't rocket science, just like Cmd+C. Casual users aren't monkeys.

comment 5y ago · link · parent

What is "it" that would bash into your leg? The door? Are your toddlers strong enough to ram closed door with enough force for it to bash into your leg?

comment 5y ago · link · parent

It includes JS. See section "8. JavaScript-based interaction". I guess the idea is that just as you can control cookies both via HTTP headers and JS, you will be able to request consent both via HTTP headers and JS.

comment 5y ago · link · parent

The primary reason to use a stable/long term distribution is to avoid updates which break my workflow, not to avoid security holes. For Debian the most visible example of that is that in Debian Stable default repos you only have Firefox ESR, which helps avoid a lot of pain for the user. There are other examples, but nothing breaks my workflow as much as new Firefox releases.

comment 5y ago · link · parent

I thought forking referred to what's happening to the process tree, similar to what forking means in chess.

comment 5y ago · link · parent

It is useful educationally. People aren't born experts.

It's also a breath of fresh air in an industry whose practitioners can't distinguish technology from magic.

comment 5y ago · link · parent

There was a thread[1] a couple months ago where I discovered a method to get one's IP address relying only on DNS:

  nslookup myip.opendns.com resolver1.opendns.com
I love it.

[1]: <https://news.ycombinator.com/item?id=26634476>

comment 5y ago · link · parent

I've been observing a lot of repeated submissions lately (repetitions of things which were already on the front page several days earlier). When I point them out in the comments, nothing happens to the submission. It's a bit boring. The FAQ discourages reposts. Has something changed in this regard?

comment 5y ago · link · parent

The article doesn't argue that ECS is a good fit for everything. It argues that it is a better fit than OOP for some of the things OOP was intended for. And that it's a broader theme, where OOP is usually not the right tool for the job, even when it was originally intended to solve that particular job.

comment 5y ago · link · parent

Thanks. That makes sense. The "in parallel" certainly threw me off.

Although in the article the author at some point switches from lists to vectors, which changes the whole task, and allows for a more efficient implementation (even if it's an answer to a different question).

comment 5y ago · link · parent

What do you mean by "traverse them in parallel"? You want to find the medians of the two lists independently and then somehow combine them? How?

comment 5y ago · link · parent

To me that's one of the grossest things ever.

comment 5y ago · link · parent

When I'm at home, I wash my behind after using the toilet. At work that's impossible. Not looking forward to getting back to the office.

comment 5y ago · link · parent

Same here. Self-hosted Jenkins pulling from self-hosted repos seems to be the standard in the companies I worked for and their partners/customers.

comment 5y ago · link · parent

Pole here. I only drink when I go out with someone, or have a party. Mostly wine, once a couple years vodka. Occasionally, when I have company during lunch, we drink one glass of wine to it. Oftentimes though, when I invite someone over, we don't drink alcohol, I make lemonade or tea. Lemonade with matcha and ice cubes is a great replacement. Maybe more places should offer lemonade?

PS. It's not uncommon for me to drink 3 glasses of wine a year. Although recently I've been more social, so it's been 1-2 glasses of wine every 1-2 weeks. I don't go out of my way to drink alcohol, but I also don't avoid it.

comment 5y ago · link · parent

Soundcloud and Spotify don't have any video.

comment 5y ago · link · parent

> the alternative is something where the docs go to some centralized SaaS that store everything including your signature for an unknown period of time.

No. The alternative is using a desktop application, which offers a superior UX in every way.

I don't get what's so bad about installing applications. It's painless. Browsing the web on the other hand is painful.

comment 5y ago · link · parent

> When X is 2, you have one of the most important functions in the family of functions that display exponential growth. It is the one in which the exponent is 0.

This is technically correct, but also purely academic. If I called the function f(X) = 5 in an analysis exam "exponential", then I would be laughed out of this exam, and for a good reason.

> This is really weird phrasing, since you're on much stronger ground saying "not growth" [arguable] than you are "not exponential" [flat wrong].

"not A" implies "not (A and B)". That's all I meant.

comment 5y ago · link · parent

When X is 2, then 2 people replace 2 in theory, so there is no growth. In practice, some of those children will die early, so 2 is actually a minor reduction, not growth, forget about exponential.

comment 5y ago · link · parent

Agreed. Looks like black magic to me.

comment 5y ago · link · parent

- https://matklad.github.io/

- https://danluu.com/

- https://raphlinus.github.io/

- https://rosenzweig.io/

- https://flak.tedunangst.com/

- https://ciechanow.ski/

comment 5y ago · link · parent

This is another place where it's context-sensitive. To make everyone happy, I could rephrase my claim to "C preprocessor grammar is context-sensitive". This has practical implications for e.g. what gets substituted where by the preprocessor. And in my claim this context-sensitivity means that we get different sequences of tokens in different places for the same input. Your example shows that we get different ASTs for the same input but different type information, although we still get the same sequence of tokens. Getting a different sequence of tokens is much more confusing to me than getting a different AST (or maybe I just got used to that with a life of experience with C++).

But generally I disagree that preprocessor is separate from C for the following reasons:

1. It is specified by the C standard.

2. Different C compilers implement it differently, just like they implement other parts of C differently.

3. There is some truth in the claim that it is a separate text transformation, but here I also do not agree entirely, because the C standard doesn't say that the preprocessor outputs text. It says that it outputs tokens and those tokens are then converted to tokens of C proper[1]. It is also clear that this model of "text transformation" is also not entirely what happens in real world compilers, because if it did we wouldn't get good backtraces for tokens that went out of the preprocessor after substitution. Maybe GCC serializes it to text at some point, but clearly it gets more information out of it than what a naive interpretation of the phrase "text transformation" would suggest.

[1]: Translation phase 7 of the C11 standard:

> Each preprocessing token is converted into a token.

comment 5y ago · link · parent

Its only reason for existence is that if-s in C are statements and not expressions. But an if and a ternary expression do the same thing. Making two different constructs to do one thing doesn't sound all that simple to me. And the standard has special treatment for parsing ternary expressions. It basically says that in any "a ? b : c" pretend that "b" is surrounded with parens, so that it's effectively "a ? ( b ) : c". Because specifying a grammar that has clear precedence was too hard.

comment 5y ago · link · parent

That's a good example, but of a different thing. My examples show that the input is lexed differently based on what part of AST is being produced at a given point. Your example shows that input is parsed into different ASTs based on information from the type system. I.e my examples show that in C the lexer can't be separated from the parser, and your example shows that the parser can't be separated from the type system.

comment 5y ago · link · parent

My last paragraph addresses that.

comment 5y ago · link · parent

> You seem to be talking about the preprocessor, not C itself, and I'm not sure that anything you say about it is true (the preprocessor is complicated).

The preprocessor is part of the language. Both in literal sense and in real-world. All C programs use the preprocessor. You need to deal with it. Also, the grammar of the preprocessor is intertwined with C proper due to "#if" directives. The expression on the right hand side of an "#if" is parsed according to the grammar of C proper.

> I'm not sure that anything you say about it is true (the preprocessor is complicated).

You can run the examples under compilers and verify. Also, the part about it being context-sensitive (with regard to tokenization in #include directives vs everywhere else) is explicitly noted in the standard. Nothing controversial here.

> Certainly, your first example won't compile without warnings for any sensible GCC options.

Compiles just fine without any warnings with GCC with options -Wall -Wextra.

comment 5y ago · link · parent

C syntax isn't simple. Unlike most modern languages, which have a context-free grammar, it has a context-sensitive grammar. You can see it in the following example:

  #define a stdio
  
  #define header <a.h> // five tokens: <, a, ., h, > (otherwise preprocessor wouldn't substitue "a")
  
  #include header // one token after substitution: <stdio.h>
  
  int main() {
      struct {
          int h;
      } stdio;
      a.h = 0;
      printf("%d\n", stdio.h);
  }
What happened here is:

1. In #include directives a thing like <stdio.h> is one token; everywhere else (including other preprocessor directives) it is five tokens;

2. But an #include directive can have multiple tokens on the right hand side of "#include" before macro substitution. After macro substitution the strings are lexed again - into ONE token.

3. In main() "a.h" is substituted with "stdio.h" - this time it's THREE tokens.

(Oh, and writing "#include <a.h>" will produce an error, because here we have a single token <a.h>, so no "a" to be substituted, and normally there is no "a.h" header file in include path.)

So the same string gets lexed into a different number of tokens in different places; and that happens even after it got lexed first into the same number of tokens before macro substitution.

Now have an example of a C file that compiles with GCC, but not with Clang:

  #define CMPS x /*
                    */ <y>
  
  #define ALMOST_SHIFT<CMPS
  
  #define FWD_FST(x, y) x
  
  #define CONCAT(x, y) x ## y
  
  #define x
  # /*
       LOL
       */ define y stdio.h
  
  #include CMPS
  
  #undef x
  #undef y
  
  #include FWD_FST(<stdint.h>, y)
  
  // btw. comma is a valid character in a header name. but this will work anyway,
  // because lexing in C works in mysterious ways
  #include CONCAT(<std,def.h>)
  
  int main() {
      int x = 0;
      int y = 0;
      int z = 0;
      printf("%d\n", CMPS z);
      // printf("%d\n", z<ALMOST_SHIFT); // doesn't compile
      // but the rest works fine...
  }
So clearly the C syntax isn't simple. It's so not simple, that compiler writers can't agree on what exactly it is.

(I've been writing such programs for the purpose of using them as edgecases to test my C compiler.)

Then of course you have the type declaration fiasco: <https://blog.golang.org/declaration-syntax>

Then there if of course the awful ternary operator.

Oh, and I almost forgot: spaces are insignificant... unless you're in a "#define" directive. Talk about language consistency...

Those things not only make life hard for compiler writers, but also for language users, because, I don't know about you, but when I write a program the smallest unit that I use to think about its source code is the token. When I can't easily predict tokenization, then something went really wrong. Same with other syntax complications. Guy Steele once said that when he designs a language he verifies that its grammar is LL(1) with a parser generator, which helps make sure that it's not only easy to write the parser and that parsing can be very efficient, but also that it's easy to understand by humans. C fails here big time.

comment 5y ago · link · parent

Your comment triggers my OCD in 2-3 different ways:

1. First you start numbering with 1.

2. Then you start numbering with 0.

3. You provide links for all but the first element in the list, which, combined with my first 2 points, results in a juxtaposition of "2" and "0", suggesting to my subconscious that I missed something.

Well done.

1
464748
55