Better HN
topnewbestaskshowjobs
Log inSign up

codebje

1,356 karma · joined Jun 19, 2017 (9y ago) · 591 submissions

Submissions

comment 1y ago · link · parent

It’s a confusing (and confused) article. The parts on type systems are expressing IMO a fair observation that dependent types are weird and hard, but without any sense of understanding what they are or what they can do that might justify their cost.

The parts on compile time execution are the better parts of the article, IMO. There’s food for thought here. The author might enjoy reading up on partial evaluation.

Then, fulfilling Greenspun’s 10th, the article reinvents Lisp macros.

comment 1y ago · link · parent

If someone cold calls me and asks me to verify myself, I refuse.

If it’s an expected call or they give me a good reason to, I’ll call their listed contact number back.

So far I have not missed out on anything of consequence by refusing to identify myself to someone who initiated contact with me.

comment 1y ago · link · parent

They’re all double the last dimension plus two, without skipping any in that sequence - but that offers no insight into why it wouldn’t hold for 254.

comment 1y ago · link · parent

No, but they do (did?) have a vast ocean of Perl, and I did know a hacker or two who got hired to work there on it.

comment 1y ago · link · parent

I once updated a little shy of 1mloc of Perl 5.8 code to run on Perl 5.32 (ish). There were, overall, remarkably few issues that cropped up. One of these issues (that showed itself a few times) was more or less exactly this: the iteration order through a hash is not defined. It has never been defined, but in Perl 5.8 it was consistent: for the same insertion order of the same set of keys, a hash would always iterate in the same way. In a later Perl it was deliberately randomised, not just once, but on every iteration through the hash.

It turned out there a few places that had assumed a predictable - not just stable, but deterministic - hash key iteration order. Mostly this showed up as tests that failed 50% of the time, which suggested to me a rough measure of how annoying an error is to track down is inversely correlated with how often the error appears in tests.

(Other issues were mostly due to the fact that Perl 5 is all but abandoned by its former community: a few CPAN modules are just gone, some are so far out of date that they can't be coerced to still work with other modules that have been updated over time. )

comment 1y ago · link · parent

It's probably https://www.good-display.com/product/440.html which is also 1mil refresh cycles and a fast refresh time of 1.5sec - around 185 hours of screen updates, so ~3 months of 5hrs a day typing or a few years of e-reader style usage.

I can't really see a device like this getting used super heavily every day, so expecting it to still be usable from time to time for a few years seems reasonable to me.

comment 1y ago · link · parent

The main advantage of recursive descent parsing is readability. Forget the machinery of the parser, which is (a) trivial enough that AI will generate correctly it for you with next to no prompting, and (b) widely available in libraries anyway. The win is writing a parser that reads like the grammar it implements, which means changes to your grammar are easy to apply to your parser.

Regexes are effectively write-only. If you change the grammar parsed by a regex, you're probably going to discard the regex and make a new one.

comment 1y ago · link · parent

Here's one paper covering the derivation of a typed functional LALR(1) parser in which derivations are given explicitly in symbolic language, while proofs are just prose claims that an inductive proof is similar to the derivation:

    https://scholar.google.com/scholar?&q=Hinze%2C%20R.%2C%20Paterson%2C%20R.%3A%20Derivation%20of%20a%20typed%20functional%20LR%20parser%20%282003%29
Here's one for the semantics of the Cedille functional language core in which proofs are given as key components in symbolic language with prose to to tie them together; all theorems, lemmas, etc are given symbolically.

    https://arxiv.org/abs/1806.04709
And here's one introducing dependent intersection types (as used in Cedille) which references formal machine-checked proofs and only provides a sketch of the proof result in prose:

   https://doi.org/10.1109/LICS.2003.1210048
(For the latter, actually finding the machine checked proof might be tricky: I didn't see it overtly cited and I didn't go looking).

comment 1y ago · link · parent

My experience in reading computer science papers is almost exactly the opposite of yours: theorems are almost always written in formal symbolic language. Proofs vary more, from brief prose sketching a simple proof to critical components of proofs given symbolically with prose tying it together.

(Uncommonly, some papers - mostly those related to type theory - go so far as to reference hundreds of lines of machine verified symbolic proofs.)

comment 1y ago · link · parent

I love your Overcooked mod.

comment 1y ago · link · parent

Haskell has a type system that lets these things be directly useful in ways they cannot be in many other languages.

You can't, in Java, declare anything like "class Foo<F<T> extends Functor<T>>", or use a similar generic annotation on a method: you can't have an unapplied type-level function as an argument to another type-level function.

These things get a name in Haskell because they can be directly used as useful abstractions in their own right. And perhaps because Haskell remains very close to PL research.

comment 1y ago · link · parent

I am not yet sure whether it's a third mistake to think that it's particularly relevant to understand monads (and friends) outside of a language with (a) the higher-kinded types necessary to actually use them, and (b) a type system that is inconsistent in the face of effects without monads.

I waver between a belief that developers with curiosity about computer science topics will, over time, be quantitatively better developers, and the notion that these are niche topics with limited relevancy.

After all, it's very clear that the Java standard library design committee understands what monads are and where they're useful, since the library is littered with the things, but there's vast numbers of developers out there making effective use of futures, collections, optionals, and streams, building their own intuitions about what "flatMap" means you can get away with, all without reading any monad tutorials.

comment 1y ago · link · parent

One source for confusion around lists is that the list monad is often used to model non-determinism, rather than just "many things". If you're thinking about non-determinism, a list is akin to a container of one item when you don't precisely know which item it is, but do know it's one of zero or more candidates.

The most widely recognised example, IMO, would be monadic parser combinators. "A parser for a thing, is a function from a string, to a list of pairs of strings and things."

comment 1y ago · link · parent

The measurable brightness of the LED is a straightforward sum of the times it's on and the times it's off. Shift the ratio so it's off more than it's on and it gets dimmer.

The "fully bright" part is a consequence of human vision. Your brain is making sense of limited, noisy information coming from your eyes. A flickering light appears brighter than the light in steady state, lots of still images shown in rapid succession look like they're moving, as far as you can tell you can perceive the full range of colour out of the corner of your eyes, and the dress could be either colour.

comment 1y ago · link · parent

I am convinced of it, as an Australian.

Commercial interests have been assaulting truth since before I was born, nearly half a century ago. The methods for doing so have steadily improved. Social media briefly hindered it, before being co-opted thoroughly to advance it.

Even where the truth hasn't been completely buried, finding what's true and what's spewed from the firehose of bullshit is a time consuming and difficult task, one that definitely doesn't scale to very many of life's decisions at all.

Culminating this trend is the rise of the extreme right across the globe. This is tightly linked to politically motivated disinformation coupled with whatever the techniques are that are forming closed mind cult-like behaviours.

Maybe it's not an assault on truth - maybe truth is just collateral damage - but I don't think I could even pose it as a question to ask if you could convince me these things are not happening.

comment 1y ago · link · parent

How far we've come from the Arab Spring.

comment 1y ago · link · parent

Bold assumption that AR glasses won’t just be a way to deliver more targeted advertising.

comment 1y ago · link · parent

That’s the best service provider, by Amazon’s criteria.

comment 1y ago · link · parent

That was a well written and easily approachable blog post on what I found to be an interesting topic. Aside from the topic itself, I think I also learned a bit about structuring technical articles.

comment 1y ago · link · parent

This is something that weighs on my mind a lot. Industry norm is to use 3rd party dependencies, and it's impractical to carefully vet direct dependencies let alone transitive dependencies. The article spits out a big list of reasons to worry about this, but in the end, the possible solutions aren't all that great.

I have no answers: just questions that haunt me, from time to time.

comment 1y ago · link · parent

Yes - it's pretty opaque to trace through, but you can see in `valid` that for a given move history, a "good" test is performed on each instruction in the assembly listing - a full pass. This is invoked, asymptotically at least, once per jump per level of the search tree explored in `bigotimes`. Each level 'i' of the search tree has a history of `i` jumps decided to be short or near and branches 'n-i' times; both of those average out to n/2, so the tree searches n^2 nodes with each node doing 'n' iterations over the list of instructions to check all jumps are valid, so the total running time is O(n^3).

(With some modifications to the code as shown, anyway: `lookup` is linear but used in such a way it can be replaced with a constant vector index, instruction lists can be compressed to just jumps & labels with byte counts following, avoiding the duplicate invocations of `p` in `arginf`, etc).

I'd be dubious that there's an algorithm to find the true minimum in less than cubic time, but there's plenty of "good enough" approaches: most branches will be definitely short or definitely not; jumps backwards can be resolved when encountered; jumps forward can be written long and replaced with a short jump plus no-op padding when the target is encountered within short jump distance.

comment 1y ago · link · parent

Quite a long way away. They have different jobs to do: an LR parser for code is trying to produce an abstract syntax tree a compiler (or static analyser) that represents the structured program expressed in source. An LLM for code is trying to extract intent, code style, and other useful factors for generating more code that "belongs" with the rest. The former really wants valid source, the latter will accept any text and do its best; text that expresses intent tends to work better, so code with single letter variable names or obfuscated methods will make LLMs struggle, but compile fine, while pseudo-code explaining the intended outcome in prose will help get good code produced, but not compile at all.

An LR parser will produce a parse tree, showing how the given token stream satisfies the parser's grammar - or an error, if the token stream doesn't satisfy the grammar. Your typical parser algorithm is deterministic, even if the grammar it matches isn't, so you'd expect to get the same parse tree for the same token stream, every time. By and large LR parsers (as described in TFA) are shift/reduce parsers: there's a bunch of states, and in each state the next token in the input stream determines if the state shifts (pushes the token onto a term stack and moves to the next input token) and jumps to another state, or reduces (pops a number of terms off the term stack and replaces them with the term being reduced to) and goes back to a prior state. TFA talks about the situation where more than one shift or reduce action is possible for a given state and input token.

An LLM uses embeddings. AFAIK the current state of the art algorithm (method, perhaps?) for this is still transformers with attention: roughly speaking, each token in the input gets projected into an embedding vector, a query vector, and a key vector; attention means that for each token, all other tokens with a key vector near to their query vector have their embedding alter the query token's embedding, allowing for context to have an impact. Multiple layers of attention can run one after another, eventually producing a final set of token values. Different embedding models use different means to pick one of those values (eg, pick the last one in the input sequence, if your query/key vectors tend to push information 'forwards' to following tokens), and that's your whole input's embedding. Neural nets can be deterministic, but those used for embedding rarely are: the values produced by repeated runs over the same input will (or should) always be pretty close, but generally won't be exactly the same.

comment 1y ago · link · parent

What would competitiveness of AI have to do with whether a confidentiality clause in a commercial license is enough for an enterprise or not?

A source code hosting service has direct access to the "secret sauce" of a company built around proprietary software. A customer relationship management service has direct access to the "secret sauce" of a company built around sales and customer relations. A document management service has direct access to the "secret sauce" of a company built around confidential documents. A cloud hosting provider has direct access to the "secret sauce" of a company built around a database.

Everything's SaaS. Everyone's confidential and critical data is aggregated in some big provider's system. Except for a few paranoid (sensible? rational?) holdouts who aren't competitive as a result.

comment 1y ago · link · parent

The same way responsible enterprise class companies rely on "trust us bro" EULAs for financial systems, customer databases, payroll, and all the other systems it would be very expensive and error prone to build custom for every business.

comment 1y ago · link · parent

That's just a semantic game. It's a product. Services are products. Bank loans are products. Devices sold for narrower end goals than general purpose computing are still products. Cable TV boxes are products.

For enterprise IT, it's got some potential. Devices users can't muck with facilitate standard operating environments, hot desks, and similar practices that are already user hostile. In that setting, there's no big deal here. It's even got the chance to be less awfully intrusive than existing SOE software.

It's also, IMO, a bit of a leveraging of a monopoly position to crowd out those SOE vendors. Microsoft's the only one who can make this device; anyone else is stuck at best making a browser-only thin client and hoping 365 works well on it for long enough to recoup R&D costs and make bank on top. Not a fan of SOE vendors, but not a fan of monopoly control either.

comment 1y ago · link · parent

It looks like the compiler would need to determine it can inline E twice before it can perform a constant case fold on the "if h == 1" expression, right? It's 'obvious' if you understand what E does, but that's not a program transform. Unless I'm very mistaken, this is two steps: inline E twice, then constant case fold (or constant "if" fold, if you aren't translating all the "if"s to "case"s).

If E were a different expression, perhaps "E h = let F i = if z == i + h then 7 else 8 in if y then F 1 else F 2", then the inlining choice (made twice, here) would be very poor - F would be inlined four times all up, and since "z" is a free variable here there's no constant case/if to fold, and everything would wind up worse.

The ANF transforms should look something like:

    let
      a0 = if x then 1 else 2
      E h = if h == 1 then 2 else 3
    in
      E a0
Departing from my previous analysis, I'd say that the next obvious step is the inlining of the now-only-called-once E:

    let
      a0 = if x then 1 else 2
    in
      if a0 == 1 then 2 else 3
But (either here or earler) that's not ANF, the "a0 == 1" isn't a simple constant or variable:

    let
      a0 = if x then 1 else 2
      a1 = a0 == 1
    in
      if a1 then 2 else 3
Let's take the time to rewrite all those conditionals and such as case statements:

    let
      a0 = case x of { True -> 1; False -> 2 }
      a1 = case a0 of { 1 -> True; _ -> False }
    in
      case a1 of { True -> 2; False -> 3 }
Now we can inline a0 into a1, since it's only called once:

    let
      a1 = case (case x of { True -> 1; False -> 2 }) of
               { 1 -> True; _ -> False }
    in
      case a1 of { True -> 2; False -> 3 }
A case-of-case transform applies to a1:

    let
      a1 = case x of
             True -> case 1 of { 1 -> True ; _ -> False }
             False -> case 2 of { 1 -> True ; _ -> False }
    in
      case a1 of { True -> 2; False -> 3 }
Two case of constant transforms on a1 apply:

    let
      a1 = case x of { True -> True ; False -> False }
    in
      case a1 of { True -> 2; False -> 3 }
a1 can be inlined and case-of-case once again applied:

    case x of
        True -> case True of { True -> 2; False -> 3 }
        False -> case False of { True -> 2; False -> 3}
Case-of-constant again leaves us with just:

    case x of { True -> 2; False -> 3 }
And that's our desired outcome. We took some risks doing case-of-case because of the duplicated outer case, but that can be dealt with using join points for the expressions that get duplicated; a bit more long winded but the same end result here due to the case-of-constant transform eliminating the duplicate immediately each time, followed by an inlining of an expression evaluated only once.

comment 1y ago · link · parent

Last I looked, join points hadn't made it into GHC Core directly - do you know if the ideas in the join points paper were introduced to (mainline) GHC in the end?

edit: it looks like there's distinct Core join points now, never mind!

comment 1y ago · link · parent

The ANF form is amenable to rewriting the “if” outside the “let”.

    if x then
      let a0 = a in E a0
    else
      let a0 = b in E a0
If a and b are simple variables or constants the new “let”s will be eliminated by ANF.

What happens to E isn’t so straightforward. In your example, though, it’s a small expression tree and would just be duplicated inline with the same obvious constant reductions available.

If it’s ‘large’ (heuristically) it might instead be assigned to a “let” binding outside the “if”, to avoid duplicating a large block of code.

CPS should be making that same determination on E.

comment 1y ago · link · parent

ANF transform will rewrite that to “let a0 = if x then an else b in E a0”.

This isn’t identical to floating the call to E inside the “if”, obviously, but would have (within predictable boundaries) the same performance. If this code went through LLVM to produce machine code I suspect it would wind up identical as LLVM will likely rewrite the duplicated call to be outside the “if”.

comment 1y ago · link · parent

If your continuation has no state to hold your recursion should already be tail called.

If it does have state, it’s probably a stack allocated closure…

1
8910
20