« first day (22 days earlier)      last day (328 days later) » 

1:02 AM
0
Q: What options are there for adding formal verification to a general purpose programming language?

Bruce AdamsSome languages support design by contract in the language itself. The absolute bare minimum for this is to define: pre-conditions (expects) post-conditions (ensures) & invariants These are often added as library primitives rather than as part of the language. Adding them to the language give...

 
1:25 AM
@Bbrk24 i think ml did it first and f# probably got it from there
 
 
2 hours later…
2:57 AM
Yeah but F# doing it explains how it got into the .NET ecosystem
 
ahh
yeah
 
3:34 AM
So Trilangle has a random number instruction, $
How the heck do I implement that in LLVM IR
that doesn't look fun
 
3:57 AM
Somehow, moving the static variables out of the function and into the top level makes it simpler?
 
i'd say yikes but it's fundamentally global state one way or another so i guess that kinda makes sense
 
Well querying std::random_device frequently is really inefficient, so typically you just use it to seed a PRNG
 
std::random_device uses hardware-backed randomness (if possible) and blocks if there's not enough entropy available
Even the sample code on cppreference says
++hist[dist(rd)]; // note: demo only: the performance of many
                  // implementations of random_device degrades sharply
                  // once the entropy pool is exhausted. For practical use
                  // random_device is generally only used to seed
                  // a PRNG such as mt19937
The length of the output varies considerably with the PRNG I use -- mt19937 is longer than minstd_rand, and ranlux24 is longer than that
And it seems like Godbolt's std::default_random_engine is std::minstd_rand0
 
4:19 AM
Reading from /dev/urandom might be easier to write but probably not nearly as performant as a PRNG
 
What if I use C rand()? Might have to call it twice since I think it only returns a 16-bit number, but
So the C standard only guarantees 15 bits but POSIX requires at least 32
 
lol
classic
 
4:36 AM
#if RAND_MAX >= 0x00ffffff
int32_t rnd24() {
    return (rand() << 8) >> 8;
}
#elif RAND_MAX >= 0xffff
// Three calls to rand() can supply two calls to rnd24()
int32_t rnd24() {
    static bool available = false;
    static int32_t next;

    if (available) {
        available = false;
        return next;
    }

    int results[] = { rand(), rand(), rand() };

    int64_t full = (((int64_t)results[0] & 0xffff) << 32)
        | (((int64_t)results[1] & 0xffff) << 16)
        | (results[2] & 0xffff);
perfect
I can/probably should remove that middle case :P
 
 
2 hours later…
6:46 AM
0
Q: What are differences between stack- and register-based virtual machine?

nchistovWhat are differences between stack- and register-based virtual machine? For example Python has stack-based virtual machine. But Lua has register-based vm. So, what are the differences?

 
 
5 hours later…
11:54 AM
I’m thinking about how Trilangle threads could be done in a compiled program
If I just follow @mousetail’s suggestion, model them as actual threads, and just track generation numbers, then a) every other IR instruction will have to be an atomic increment, which will be really slow; b) I/O will have to read all of them without hogging the locks.
 
12:36 PM
i might just end up not doing it. A round-robin, single-threaded interpreter will probably work better anyways
 
I suggested the other method to give you the freedom to rearange instructions
Round robin style forces executing them individually
including things like stack operations which are not really needed at all when JITed
 
3 messages moved from The Nineteenth Byte
 
1:17 PM
Pushing and popping are very fast, so the bulk of the time, I imagine, will be spent on atomic reads and increments.
 
Every thread has it's own stack though right? Why do you need the atomic reads?
 
1:35 PM
I/O needs to wait until that thread has the smallest generation number
 
True, I guess the speed difference depends on your proportion of IO instructions
 
We’re also considering thread joins I/O, because the order that two threads are joined is significant
And when a thread is killed, it has to remove itself from the generation table
 
True
But again how often does that happen? It might be a lot of barely any depending on the program which makes it hard to optimize
Each approach is in itself a huge challenge to code so you can't easily try both
 
Even a thread spawn has to add a new entry to the generation table
I can also do an easy optimization to scan the code for any threading operators and not output any of this nonsense if there are none
 
 
2 hours later…
3:56 PM
Man I'm on vacation and using my phone to write code sucks
I should get a lightweight thinkpad or something just so I don't have to use a phone keyboard to write code when I'm away from home for an extended period of time
 
I am extremely happy with my Thinkpad E14
I can pick it up by the corner with one hand, the carry case is pretty thin (not like a laptop case), and it has higher specs than my "gaming laptop" from about 6 years ago
The trackpad is also very responsive
 
@kaya3 I was also considering a thinkpad, can't go wrong with those, esp since I'm only gonna program on it
 
I got it for travelling, but it's also just nice to be able to sit on a comfortable chair with it
 
0
Q: What are the disadvantages of using SSA form?

SegganSSA form is an intermediate representation where all variables are assigned to exactly once. It greatly helps with a myriad of optimizations, such as constant folding, dead code elimination, and redundancy elimination. With these advantages, there must be some disadvantages to using it. What are ...

 
 
2 hours later…
6:26 PM
0
Q: What are the consequences of an unsound type system?

Bruce AdamsI was reminded in this answer (to my perhaps naive question https://proofassistants.stackexchange.com/questions/2225/what-is-needed-to-move-from-design-by-contract-to-using-a-proof-assistant) that the C++ type system is unsound. I take this to mean that you can in theory do evil things(tm) like: ...

 
 
1 hour later…
7:53 PM
0
Q: If size could be determined at compile time then why could size not be determined at preprocess time?

user16217248In C the sizeof() operator cannot be resolved in preprocessor conditions. If other operators such as + or - can be (so long as the operands are constants) then what is different about sizeof()? What technical limitations prevent sizeof() from being resolved at preprocess time while other operator...

 
8:52 PM
Why is stack allocation called alloca, anyways?
 

« first day (22 days earlier)      last day (328 days later) »