← Home ← Back to /g/

Thread 106982750

236 posts 108 images /g/
Anonymous No.106982750 [Report] >>106982794 >>106982875 >>106983440 >>106987526 >>106988654 >>106988735 >>106989185 >>106994120 >>106996111
/dpt/ - Daily Programming Thread
What are you working on, /g/?

Previous thread: >>106922287
Doctor Eli Selig No.106982794 [Report] >>106993497
>>106982750 (OP)
I am trying to turn Szudzik's Elegand Pairing Function into a compressor. I do not know if it will actually be possible, but that is what I am attempting.
Anonymous No.106982875 [Report] >>106983045 >>106983059 >>106983156 >>106983540 >>106987854
>>106982750 (OP)
I'm writing a JSON parser in C as a learning project. Tips, tricks, gotchas?
Anonymous No.106983045 [Report] >>106983100
>>106982875
Allow the use of a custom allocator to simplify cleanup.
Anonymous No.106983059 [Report] >>106983138
>>106982875
It's simple but if it's your first parser you have little things to figure you, so get started.
Have you figured out you will pass the parser state to functions? What will the parser function return? The type of the json tree?
Anonymous No.106983100 [Report]
>>106983045
I like to write functions that take a custom allocators as parameter but there are functions where I know you'll never want to use an allocator other than uan arena/stack allocator so I'll make the function take an arena instead. Parsers fall in that category
Anonymous No.106983138 [Report] >>106987854
>>106983059
It's half done already, there's a json_parse function that takes a const char* (raw JSON), a struct json_value * (result), and a char ** (where the parser stopped) that returns 0 on success and an error code on failure. It's not recursive, I push the next struct json_value * to be written to on a stack and pop when it's done. Here's the JSON struct:
struct json_string {
size_t length;
char *bytes;
};

struct json_array {
size_t length;
struct json_value *elements;
};

struct json_object {
size_t length;
struct json_string *names;
struct json_value *values;
};

struct json_value {
enum {
JSON_NULL = 1,
JSON_TRUE,
JSON_FALSE,
JSON_NUMBER,
JSON_NUMERIC_STRING,
JSON_STRING,
JSON_ARRAY,
JSON_OBJECT
} type;
union {
long long number_value;
struct json_string string_value;
struct json_array array_value;
struct json_object object_value;
};
};
Anonymous No.106983156 [Report]
>>106982875
>Tips, tricks, gotchas?
actually use it for some application - don't write a program that parses a JSON and does nothing with it
even something trivial. and if it's meant to be a generic parser - at least a few different trivial applications

only by actually having the thing being used for something you'll be able to discover shortcomings, design flaws and areas for improvement. having an actual use case also helps in keeping motivation up to continue working on it
Anonymous No.106983348 [Report]
Finally my fast cfr showdown evaluation seems to work, it took so much time. Hopefully I won't discover a new bug, I'm so tired.
Anonymous No.106983424 [Report]
ChatGPT can be really handy at telling me how does kubernetes work and how to manage related services, but it can't edit bash scripts for shit. It's actually pretty funny how it can handhold me through debugging some really complex shit but as soon as it has to fiddle around with ("${@:2:V-1}") it shits itself, repeats same snippet of code over and over while claiming it changed it and simply just fake command output to match what is requested.
Anonymous No.106983440 [Report] >>106983487 >>106983540
>>106982750 (OP)
made this shitty program
It sorts numbers in bogosort and insertion sort at the same time and the first to complete kills the other

void *insertionSort(void *arg){
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
I = 1;
sortArgs *args = (sortArgs *)arg;
int *data = args->array;
int size = args->size;

for(int i=1;i<size;++i){
pthread_testcancel();
if(I==2) pthread_exit(NULL);
int j = i - 1;
int k = data[i];
while(j>=0 && data[j] > k){
data[j+1] = data[j];
j--;
}
data[j+1] = k;
usleep(10000);
}
printf(" ");
for(int i=0;i<size;++i){

printf(" %d", data[i]);
}
printf("Sorted\n");
I = 2;
return NULL;
}

void *bogoSort(void *arg){
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
I = 1;
sortArgs *args = (sortArgs *)arg;
int *data = args->array;
int size = args->size;
int n = 0;
while(!sorted(data, size)){
pthread_testcancel();
if(I==2) pthread_exit(NULL);
printf("ups, not sorted, shuffling again\n");
shuffle(data, size);
usleep(10000);
}
for(int i=0;i<size;++i){
printf(" %d", data[i]);
}
I = 2;
return NULL;
}

int main(){
srand(time(NULL));

sortArgs args = {sort1, sizeof(sort1) / sizeof(*sort1)};
sortArgs args1 = {sort2, sizeof(sort2) / sizeof(*sort2)};
pthread_create(&threads[0], NULL, bogoSort, &args);
pthread_create(&threads[1], NULL, insertionSort, &args1);

for(int i;i<2;i++){
pthread_join(threads[i], NULL);
}
printf("\n");
return 0;
}
|
I think my code is just bad ngl
Anonymous No.106983487 [Report] >>106983540
>>106983440
Forgot to mention I just started learning to code and algorithms like 8 months ago so if you have any challenges or resources it will help me
Anonymous No.106983540 [Report]
>>106983440
>think my code is just bad ngl
no, that's just C, and the kind of goalless program

>>106983487
now try making a wild gunman-style typing game:
start a random and hidden countdown timer, flash DRAW! (or HEY SHITASS! or whatever) along with some word randomly selected from a bank of words
then have one thread where you type the word, and another running a timer for that word
if you type the word correctly before the timer runs out, you win
if the timer runs out or you type it incorrectly, you lose

then make the word bank stored in a JSON file, and hook up with this anon >>106982875 to use his JSON parser to parse the word bank into your program
Anonymous No.106984920 [Report] >>106984980 >>106986475
I'm at that annoying point where I can pretty much only do boring projects, but any funs shit is too difficult.
Anonymous No.106984980 [Report]
>>106984920
use case for fun shits?
Anonymous No.106985792 [Report]
Light research and intuitioning a type inference algorithm
Anonymous No.106985917 [Report] >>106985972 >>106986406 >>106986448 >>106986465
>try to get into C
>there are 23 different data types for storing a number
>all the names are weird abbreviations
>10 different compilers each with 4 versions
who came up with that shit
Anonymous No.106985972 [Report]
>>106985917
the C intelligence agency
Anonymous No.106986406 [Report]
>>106985917
define u32/i32 yourself and ignore int, long, char, size_t, uintptr_t, etc
Anonymous No.106986448 [Report] >>106986537 >>106986863
>>106985917
>23 different data types for storing a number
If you only knew how bad things really are.
Anonymous No.106986465 [Report]
>>106985917
C++ is a billion times worse, it's fucking dogshit meant to be undecipherable if anyone else but you read the code
Anonymous No.106986475 [Report]
>>106984920
What would be fun? Some projects people consider fun are easier than the boring ones.
Anonymous No.106986537 [Report] >>106986793 >>106987143
>>106986448
>unsigned long long int
lmao is this for real?
Anonymous No.106986793 [Report]
>>106986537
https://www.youtube.com/watch?v=6-1Ue0FFrHY
Anonymous No.106986863 [Report] >>106987232
>>106986448
in real life you only ever use char, int and size_t which you convert to int as soon as possible.
Anonymous No.106987143 [Report]
>>106986537
You'd normally only write unsigned long long for that. Or uint64_t.
Anonymous No.106987184 [Report]
>yes, this has been done
how do people get away with doing that?
Anonymous No.106987232 [Report] >>106987256 >>106987284
>>106986863
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"


union atoi_vector_128;
typedef union atoi_vector_128 u_vector_128;

__attribute__((aligned(16))) union atoi_vector_128
{
__m128i v_128i;
__m128 v_128;
float floats[4];
int ints[4];
char chars[16];
unsigned char uchars[16];
};

union atoi_vector_256;
typedef union atoi_vector_256 u_vector_256;

__attribute__((aligned(32))) union atoi_vector_256
{
__m256i v_256i;
__m256 v_256;
__m128i v_128i[2];
__m128 v_128[2];
float floats[8];
int ints[8];
char chars[32];
unsigned char uchars[32];
};

__attribute__((aligned(32))) struct s_vector_atoi_period
{
u_vector_256 vec;
int period;
};

#pragma GCC diagnostic pop
Anonymous No.106987256 [Report] >>106987271
>>106987232
mental illness
Anonymous No.106987271 [Report] >>106987277 >>106988896
>>106987256
yeah. intrinsics are not for the faint of heart
Anonymous No.106987277 [Report] >>106987294
>>106987271
>5 function calls
oh my god dont hack me
Anonymous No.106987284 [Report] >>106987333
>>106987232
50 y/o boomer detected
Anonymous No.106987294 [Report]
>>106987277
actually 0
it all gets inlined
its all macros

the rabbit hole is a bottomless pit
save yourself while you can
<picrel is how your memory gets populated, in case your brain wasnt hurting enough
Anonymous No.106987333 [Report] >>106987363 >>106988552
>>106987284
why doe?
im not a zoomiezoomzoom but im not a boomer either
its just that my shit needs to go very fast
Anonymous No.106987363 [Report] >>106987407
>>106987333
no I get it, fucking caches n shit, and keep the compiler on a leash
the compiler is a whore
Anonymous No.106987407 [Report] >>106987473 >>106988552
>>106987363
yeah and a slightly dyslexic one
but if you make things easy for it, it can accomplish wonders
heres the full code if anyone wants to have a look
https://files.catbox.moe/cvikfz.c
you need to use -mavx2 and -mbmi flags to compile it
https://files.catbox.moe/cvikfz.c
Anonymous No.106987473 [Report]
>>106987407 (cont)
(and gcc as compiler. other compilers have a different syntax or dont have the equivalent functionality at all)
Anonymous No.106987526 [Report] >>106987695
>>106982750 (OP)
Making my own font in TempleOS
Anonymous No.106987695 [Report]
>>106987526
baste templeOS enjoyer
Anonymous No.106987854 [Report] >>106990372
>>106982875
>>106983138
It's over
Anonymous No.106988077 [Report]
Nice
Anonymous No.106988290 [Report] >>106989787
I've been considering implementation of a subset of R7RS in JS, but as language that you can embed inside the browser. Like BiwaScheme. I call these languages "Browser-embedded" languages.

<script type="text/braqiette">
(define foo 'bar)
(display "homosex")
</script>


Given I'm a systems guy and I rarely, if ever, coincide with ECMAScript, I decided to generate a whole-ass book, with 48 chapters and four appendices, using Sonnet 4.5. I fed it loads and loads of books.

Here's the book, it's just out of the press:

https://chubak.neocities.org/emblang-dossier

It discusses implementation of five languages, three universal, and two domain-specific:

1. Braquette -> R7RS Scheme
2. Muneshine -> Lua-like language
3. jSML -> ML-like language
4. GWizz -> Graph DSL
5. Amb3r -> Circuit simulator

Yes, I fed it books on electronics simulation too (Farid Najm's book, and 4 others).

This is one of the best books I've generated with Sonnet 4.5.

I used the same context to generate this book, that I used to generate this one:

https://chubak.neocities.org/ecmascript-dossier

This is a full reference for JS, for systemfags like me.

It is hallucinating, for example, it says "I spent two years building a language called FlowJS". I'm not sure why it's doing that, but it's kinda cute lol. I think, that's because I told him "I want some personality in the book, be more like Nystrom, than Seidl". So to add personality to the book, it's taken some mescalin.
Anonymous No.106988552 [Report] >>106988605 >>106988964 >>106989207 >>106989263 >>106989306 >>106989408
>>106987333
>>106987407
What makes you think using SIMD would be faster?

Non SIMD, using eisel-lemire algorithm:
main : hngh
main : tally : 0.031250000000000000000000
main : control : 0.031250000000000000000000

real 0m22,513s
user 0m22,465s
sys 0m0,000s


Your SIMD code:
main : hngh
main : tally : 0.031250000000000000000000
main : control : 0.031250000000000000000000

real 0m38,642s
user 0m38,498s
sys 0m0,000s
Anonymous No.106988605 [Report] >>106988888 >>106988964 >>106988995
>>106988552
Whatever compiler you're using, you must enable better instruction scheduling.

Dispatch for SIMD is pricy.
Anonymous No.106988654 [Report] >>106988676 >>106988848
>>106982750 (OP)
>US government shuts down
>/dpt/ posting rate cut in half
>/dpt/ becomes more civil
>less disruptive schizos
>no anti-maidposts
>no childish trolling
>no retards using tranny as every other word when describing something
I hope this shutdown lasts one million years.
Anonymous No.106988665 [Report] >>106988843 >>106989149 >>106989166
I just learned about a nifty optimization, that will help a lot when I'm implementing Diyrbal. This is what SpiderMonkey and V8 both do.

So, imagine, the programmer makes several objects of the same 'shape':

let foo1 = { 'a': 1, 'b': 2 };
and foo2 = {'a' 11, 'b': 12};
and foo3 = {'a': 1444, 'b': 22.2};


So, the interpreter creates a 'hidden object cache', some sort of 'stencil' for the object, so it won't have to regenerate the structure over and over.
Anonymous No.106988676 [Report]
>>106988654
> no disruptive schizos

I'm the resident scizo of /dpt/, I'm just not namefagging.
Anonymous No.106988719 [Report]
Is PLC real programming?
Anonymous No.106988735 [Report] >>106988768 >>106988770
>>106982750 (OP)
What's the best book/resource to learn about compilers and assembly? The dragon book is notorious but hacker news doesn't like it. I came across this https://github.com/IUCompilerCourse/Essentials-of-Compilation/ a while ago, I read that this one is good but I forget where I got it from.
Anonymous No.106988745 [Report] >>106988784
why does nobody do design by contract?
Anonymous No.106988768 [Report] >>106988796 >>106991631
>>106988735
Look into Ralph Griswold. He wrote a deep dive into the SNOBOL4 compiler.
Anonymous No.106988770 [Report] >>106989059
>>106988735
Thorson Ball's books (he's got one on compilers, one on interpreters) is the best ones for beginners. If you want a more advanced, yet, less 'theoretic' book, grab Nora Sandler's books.

CCDev is kinda theory-heavy. You're kinda wrong about The Dragon Book. Yes, cringe people who call themselves 'hackers' really like it. But TDB is the perfect blend of theory and practice.

Nora Sandler's book is extremely light on the theory, and if you just wanna make a compiler, Thorson Ball and Nora Sandler's books are your poison.
Anonymous No.106988784 [Report] >>106988833
>>106988745
In the backend, contracts turn into constraints that need to be solved, via dynamic programming, or decision trees, etc. So they make the compile time extremely longer.
Anonymous No.106988796 [Report]
>>106988768
I fucking love ancient compiler books. How did this slip out of my radar.

I like ancient OS books as well. e.g. Lion's Commentary on Unix.
Anonymous No.106988833 [Report] >>106988906
>>106988784
What about in python?
Anonymous No.106988843 [Report] >>106988906
>>106988665
You might be interested in *ML {a=1, b=2}, (a, b), and {1=1, 2=2} are synonyms (the last case being a numeric record selector)
Anonymous No.106988848 [Report]
>>106988654
>less disruptive schizos
I needed to get some work done. Sorry.
Anonymous No.106988888 [Report] >>106988920
>>106988605
No, you are doing it wrong, chud. I mean what about exponent notation?
Anonymous No.106988896 [Report] >>106988920
>>106987271
i love intrinsics they're fun to write with
t. C newfag
Anonymous No.106988906 [Report] >>106988936 >>106989077
>>106988833
Python has contracts? I was not aware of it. I think Python has gradual typing, and retards call them contracts.

If you wanna know a real contract system, look at Racket's or D's.

You could add contracts to Python, like this:

@requires(a == 12 && c == 15)
@encures(Contract.returns == 12)
def foo(a, b):
....



But that would still require solving the constraints. The simplest, and the slowers way of solving logical constrains is via dynamic programming, like it's a chess AI.

>>106988843
Yeah, in the world of Algebraic Datatypes, these are 'product' types. I implemented ASDL two years ago, and it uses ADTs to generate an AST:
https://github.com/Chubek/ZephyrASDL
Anonymous No.106988920 [Report] >>106988924
>>106988896
>>106988888
You're both wrong, Just fucking use OpenMP pragmas if you want vectorization.
Anonymous No.106988924 [Report] >>106988944
>>106988920
>just use the multicore tool if you want vectorisation
Anonymous No.106988936 [Report] >>106988970
>>106988906
There's some libraries for contracts (icontract is the one that i came across) and apparently a deferred PEP (316) to incorporate them into the docstrings from way back in 2002. I actually just learned about this but that was my general idea.
Anonymous No.106988944 [Report]
>>106988924
OpenMP has pragmas for both retard.
Anonymous No.106988962 [Report]
>just trust the compiler
Anonymous No.106988964 [Report] >>106988990 >>106988995
>>106988552
>>106988605
>What makes you think using SIMD would be faster?
parallelism.
im fairly certain that a parallelized EL algo would blow a linear implementation out of the water
especially-
>By combining the significand and precomputed tables, we can compute the nearest floating-point number using as few as one or two 64-bit multiplications.
simd multiplication is pretty fast. the gains from running multiple ops at once outweigh the latency.

and things are actually closer than what the first results might indicate
in the version you tested i had a quite important opti disabled- for debugging reasons.
the fallthrough in my switch pattern fallthrough
also- the EL algo has blindspots and in some cases has to fallback on a less efficient algo
when my algo was ran in the worst case scenario for it
heres the revised version if you wanna check it
also i would like to have a look at your code for the EL algo
im not gonna ask you to benchmark the algos actually thoroughly
Anonymous No.106988968 [Report]
i've vaguely heard of some schizo who is posting about vectorization/SIMD. is this that guy?
Anonymous No.106988970 [Report] >>106989022
>>106988936
Strong typing or contracts = long compile times.


This is the Faustian bargain every language developer makes.

If you are making a compiler, and your IL is typed (like my WIP PoxIL) and it has several passes of typed IL after typed IL, what you get is Rust, where compile time is eternal.

This is unacceptable for an scripting language. That's why languages like Ruby uses 'duck' typing.
Anonymous No.106988990 [Report] >>106989029
>>106988964
“Concurrency is about dealing with lots of things at once. Parallelism is about doing lots of things at once.” – Rob Pike

Fuck parallelism. Concurrency rules.
Anonymous No.106988995 [Report]
>>106988605
>>106988964
>2am moment
forgot the picrel and to link the revised version
https://files.catbox.moe/es7s7u.c
Anonymous No.106989022 [Report] >>106989050
>>106988970
I've just been fucking around with something very similar to PEP 316 and it caught some corner case bugs in my code which only occurred in maybe 0.03% of inputs. The overhead in most functions was about 8% and right now i only run it during development to catch these bugs. I'm not seeing the downside.
Sure i could add a bunch of asserts and made the code ugly but this method allows me to just control it with env variables and a single decorator + docstrings formatting
Anonymous No.106989025 [Report] >>106992073
Gadies and lentlemen, someone has asked me to present them with my ongoing FOSS projects, they might either fund them, or hire me to work for them and let me continue working on them at their behest.

I've been working on it for several days:

https://github.com/Chubek/chubek/blob/master/chubak-intro.odp

If you can opine on it, please do.
Anonymous No.106989029 [Report] >>106989064
>>106988990
eh, you can work on a gpu and then you get the power of both
some stuff has to be dealt with linearly though
Anonymous No.106989050 [Report] >>106989102
>>106989022
Well duh. Contracts are great, when you can afford it, that is.

I think people don't use them mostly because they're unaware of it, or asserts take care of their needs.

I originally was introduced to contracts via Racket. It's one of the strong suites of the language.
Anonymous No.106989059 [Report] >>106989082
>>106988770
So I should just pick up the dragon book then and forget the other one I had linked. I found the link where HN is complaining about it, I can't really provide any input since I'm new to the topic: https://news.ycombinator.com/item?id=14487961
Anonymous No.106989064 [Report] >>106989069
>>106989029
My PoxIL will support all GPU programming frameworks. I know parallelism is good, but I personally have no use for them in PLT.

I remember some schizo had made a long blogpost about bringing the GPU into Haskell. That was a fun read.
Anonymous No.106989069 [Report]
>>106989064
poxil?
hwat dis?
Anonymous No.106989077 [Report] >>106989097
>>106988906
In basic.asdl the Add and Sub constructors share the same shape, so you could imagine them sharing an allocator for (int * ints) with an additional type parameter
Anonymous No.106989082 [Report]
>>106989059
> says TDB is le bad
> recommends Cooper&Turczon

Fucking kek.

Just read the Nora Sandler book anon.
Anonymous No.106989090 [Report] >>106989156
Is C a good enough gatekeeping language?
Anonymous No.106989097 [Report]
>>106989077
Great idea man. Thanks. I was kinda retarded when I made it. It has a very bad bug in the generated code. Plus, the linked lists make everything come out in the inverse.

I gotta go back to it one day and fix/optimize.

Funny thing is, I just mentioned how V8 and SpiderMonkey do the same thing with JS.
Anonymous No.106989102 [Report]
>>106989050
yeah i only became aware of the concept recently
i think a lot of people use asserts and pydantic and stop there
Anonymous No.106989111 [Report] >>106989136 >>106989156
lisp with out-of-line assembly for maximal gatekeeping
Anonymous No.106989136 [Report]
>>106989111
Lol, easiest language to write a compiler for.
Anonymous No.106989149 [Report] >>106989171
>>106988665
you still didnt post code for your EL implementation btw
Anonymous No.106989156 [Report]
>>106989090
>>106989111
Structured Programming is the best Gatekeeper:

https://www.youtube.com/watch?v=SFv8Wm2HdNM
Anonymous No.106989166 [Report]
>>106988665
Memoizing types. Very cool.
Anonymous No.106989171 [Report] >>106989178 >>106989194
>>106989149
What is that? I haven't written a single line of code in about 1.5 months. Been mostly reading AI-generated books.

In about an hour, I'll start working on Braquette, a browser-embedded Lisp.
Anonymous No.106989178 [Report] >>106989184
>>106989171
ok
but then where did you get your figures from?
Anonymous No.106989184 [Report] >>106989207
>>106989178
What 'figures'? I'm confoos. I did not post any numbers.
Anonymous No.106989185 [Report] >>106989200
>>106982750 (OP)
>What are you working on, /g/?
trying not to kms
Anonymous No.106989194 [Report] >>106989206
>>106989171
>EL
eisel lemire btw
Anonymous No.106989200 [Report] >>106989221
>>106989185
Do it. I died and I'm fine.
Anonymous No.106989206 [Report]
>>106989194
I think you've mistaken me for another anon, anon.
Anonymous No.106989207 [Report] >>106989263
>>106989184
ah shit
wrong address, sry
intended for >>106988552

anooon
post code so i can play with it
Anonymous No.106989214 [Report]
Grape Ape: please check for captcha validity before you upload the image.

Stupid.
Anonymous No.106989221 [Report] >>106989238
>>106989200
what processor works best in the afterlife
Anonymous No.106989234 [Report] >>106989262
Here's a proof-of-concept text adventure game engine written in Python. If you can figure out how to use it, you could make a proper game (I think).
https://files.catbox.moe/1g7nii.py
Anonymous No.106989238 [Report] >>106989281
>>106989221
Surprisingly or not so surprisingly Apple's M2 feels like turbo mode without the fan on in excess.
Anonymous No.106989262 [Report] >>106989288
>>106989234
This is a classic text on making adventure games with Pascal:

https://github.com/Chubek/chubek/blob/master/programming-adventure-game-in-pascal.pdf

These days, you gotta get your ECS on if you wanna make games.
Anonymous No.106989263 [Report] >>106989306
>>106988552
>>106989207
nvm, found it
Anonymous No.106989281 [Report]
>>106989238
and the OS ? Ubuntu Satanic ?
Anonymous No.106989288 [Report] >>106989301
>>106989262
Awesome. I wonder if this would work on a C64 maxi with G-Pascal.
Anonymous No.106989301 [Report] >>106989330
>>106989288
It uses USDC Pascal. But all Pascals are the same really. I was not aware you could run compilers on C64.
Anonymous No.106989306 [Report] >>106989408 >>106998387
>>106988552
>>106989263
not nvm actually
post code
all i see is bits of code buried deep in bigger projects
Anonymous No.106989322 [Report]
Is it possible to make a modded bf that's still simple but usable?
Anonymous No.106989330 [Report] >>106989373
>>106989301
>I was not aware you could run compilers on C64
A lot of compilers were written for C64 including some C compilers but it is a huge pain at least without multiple drives and/or a RAM disk. Some compilers work in emulation and others seems to just glitch out. I suspect it has something to do with inaccurate disk emulation. I think I got G-Pascal to work but not any C compilers.
Anonymous No.106989373 [Report] >>106989398
>>106989330
Use Clang with LLVM's 6502 backend, or cc6502. I don't think writing code on C64 is a very nice experience. Burger wrote all her C64 games on an IBM PC, AFAIK.
Anonymous No.106989398 [Report] >>106989479
>>106989373
>Use Clang with LLVM's 6502 backend, or cc6502. I don't think writing code on C64 is a very nice experience. Burger wrote all her C64 games on an IBM PC, AFAIK.
I'm already playing around with CC65. Coding on a C64 Maxi sounded fun on paper but got tiresome pretty quick. I kind of wish I had just gotten a real C64 instead because I think most of the issues I run into are due to emulation.
Anonymous No.106989408 [Report] >>106998387
>>106988552
>>106989306
and also its supposed to yield a double
instead of a float

i think ima call bullshit on this one until proof to the contrary
Anonymous No.106989479 [Report]
>>106989398
My uncle had a C64, when I was 5. He treated it as a gaming console. I think most people considered all these 80s micros to be for gaming, rather than an actual compooter.

My mom says, her cousin bought a C64 the year it came out. The first time I saw a PC was on his brother's desk. I have a vague memory of walking towards a desk with a beige IBM PC on it at my aunt's home, then looking out the window, and seeing someone come into the front yard (he happens to be my uncle, btw, consanguineous marriage was the norm here until the generation before me got into this whole eugenics thing, yes, not wanting to bang your cousin is eugenics). His other brother had an IBM PC too. Of course these were probably clones.
Anonymous No.106989480 [Report] >>106989494
FALSE is gonna be the next CPP killer.
Anonymous No.106989494 [Report]
>>106989480
XCPP is going to be the next CPP killer.

Oh, you meant C++.
Anonymous No.106989687 [Report] >>106989764
I'm so hungry but I have to wait until this sublabial pill dissolves.

No it's not Estrogen you scum.
Anonymous No.106989764 [Report] >>106989785
>>106989687
it's test I'm ftm
Anonymous No.106989777 [Report]
I never relied on tests this much, but they are needed. There is so many places where things can go wrong.
Anonymous No.106989785 [Report]
>>106989764
> FTM

Eww. I'm all for MTF, but FTM... My cousin is FTM, btw.
Anonymous No.106989787 [Report] >>106989835
>>106988290
I wanna try something like this for my own Forth compiler. Did you just start a claude chat on their and give it all the book pdfs or do you use the API with a bunch of tools to get it on the right track?
Anonymous No.106989835 [Report]
>>106989787
I use this aggregator to access most LLMs (GPT, Claude, Gemini, etc): gapgpt.app.

It's no use to you of course, so try to find a similar aggregator.

Problem is, they only allow me to upload 5 files at once. So what I do is, I collect the PDFs in one directory in my home directory, and do this with Fish:

set -l ncat 0
set -l nprod 1

for f in *.pdf
set -l booknm "~/my-aggregated-books-part-$nprod.txt"
echo "==LITERATURE BEGIN==" >> ~/$booknm
pdftotext $f - >> ~/$booknm
echo "==LITERATUR END==" >> ~/$booknm
set ncat (math $ncat + 1)
if test (math $ncat % 120) -eq 0
set nprod (math $nprod + 1)
end
end


Alternatively, you could use `split(1)`.

split -b 50MB all-the-pdfs-as-one-text-file.txt


I like my method better. `split(1)` gives you less control.

For DJVU files (which many of Forth books are in) you can use `djvutxt(1)`. Make a function in Fish called `ebook2txt` that checks for both. I will do that myself, I don't know why I haven't already.

I'm currently generating a 64-chaper book on Unix systems programming. I'm using GPT Pro this time.
Anonymous No.106989867 [Report]
Oh, btw, ask for the table of contents, then when you are asking it to generate, say, chapter 2, do:

Now, give me "Chapter #2: Why the Nazis were Right".


So, after a chunk of chapters have been generated, you can Ctrl+f "Chapter #2", copy it, and paste it like so:

xclip -selection clipboard -o > ch-02.md


Then, convert all the Markdown files to HTML with Pandoc.
Anonymous No.106990073 [Report] >>106990141 >>106994298
Anonymous No.106990141 [Report]
>>106990073
lol OCaml has been operating on this for ages. OOP in OCaml is abstracted away by FP.

Look up "Sheaves" in category theory. They are kinda like classes.
Anonymous No.106990372 [Report]
>>106987854
Great resource anon, thanks. Mine passes all the n_/y_ ones. It's hard to decide what to do with the i_* though, should I bother rejecting overlongs, noncharacters and lone surrogates?
Anonymous No.106990606 [Report] >>106991424
The LEAST passive-aggressive C++ talk:

https://www.youtube.com/watch?v=2KZgFiciOxY
Anonymous No.106990845 [Report]
https://www.youtube.com/watch?v=w0sz5WbS5AM

Man, I love Matt Godbolt. I joined his server to show off my crappy generic preprocessor (https://github.com/Chubek/Ekipp), and he thought it's a real compiler, and asked me if I want to add it to the website.

I can't wait until I make a compiler, to add it to CE.
Anonymous No.106991120 [Report] >>106991260
business idea : automatically rewrite python scripts in rust because rust is more gooder
Anonymous No.106991260 [Report] >>106991288 >>106991540
>>106991120
The first issue we run at is, Python's numbers are bignum by default. So you either have to do recursive memoization to keep the count on the size of integers and floats assigned to a variable, and see if bignum is used, and make a use a Rust bignum library to assign them to (or use Python's own bignum via bindings) -- otherwise, assign a machine integer size to them. And even that requires a lot of memoization. Python's gradual typing does not help here.

Plus, what about the Python API and FFI. People use Python mostly because of its strong interoperability with C. We could use a binding (I used Python's C bindings for Rust, for a project I was actually paid for --- one of the last projects I did for pay, 2 years ago -_-), but that solves nothing.

There's already Python -> C translators. Nuitka and Cython. Nuitka is more about the compilation, Cython focuses on libraries.

So there's no value added here. Go for it if you want, but you cannot utilize Rust's typing system via automatic source-to-source compilation.

If you wanna try it yourself, I recommend using ANTLR4 to handle the parsing. Nuitka is actually a paid compiler (at least, it has a paid tier) but C is not a typesafe language, Rust is --- and you'll have to dig yourself out of so many ditches to compile Python to Rust.

What would be useful is implementing Python in Rust. I'm doing a JVM implementation in Rust (called YASJVM, Yet Another Safe JVM) and I've already done a lot of research. I'm also implementing Awk in Rust. There is market for implementing interpreted scripting languages in Rust. Interoperability is a big issue here. I haven't yet managed to find the best way to bring JNI to YASJVM.
Anonymous No.106991288 [Report] >>106991329
>>106991260
Do it with AI. Have AI generate validation tests and transform the python into rust, then check the output with the validation tests. Feed the result of the tests back into the AI and have it rewrite it until the tests pass. Simple.
Anonymous No.106991329 [Report] >>106991378
>>106991288
That's not a half-bad idea. There's a lot of papers on source-to-source translation with LLMs. Go to Google Scholar and search see what academics have already found out.

Remember that PLT is a field rife with theory. My advice to you is, seek your answers in academic books and papers, and not blogposts. If you don't have the time to read papers and books, have AI summarize it for you, or write a book on it after you've fed the literature to it.

If you are going to rely on a blogpost, make sure it's sourced. A blogpost won't get too many traction, unless it has citations, or is a hallucinatory acid trip. I mentioned the "Use GPU power to solve type constrains in Haskell" post. That was one post on PLT that got a lot of traction.

I recommend wetting your toes with something simple first. Like a browser-embedded language. I generated a 48-chapter book on them with Sonnet 4.5:

https://chubak.neocities.org/emblang-dossier

It discusses creating 5 browser-embedded languages, I posted it above, but I've improved the template I use to generate the HTML with.
Anonymous No.106991378 [Report] >>106991406
>>106991329
That sounds lame as fuck. I say just start vibe coding it and see what you come up with.
Anonymous No.106991392 [Report] >>106991574
i just finished exercise 2-4 and 2-5 from the K&R C programming language book. im a beginner and i find working through this textbook quite relaxing. using my brain. no ai.

it might be quadratic time complexity but it came from my own brain :)
Anonymous No.106991406 [Report] >>106991505
>>106991378
You'll learn zilch by vibe coding.
Anonymous No.106991424 [Report]
>>106990606
>The LEAST passive-aggressive C++ talk
It's a C talk. That's OK. I like C talks.
Anonymous No.106991505 [Report] >>106991545
>>106991406
He doesn't want to learn anything. He wants to get wrong answers now.
Anonymous No.106991540 [Report] >>106991576
>>106991260
>The first issue we run at is, Python's numbers are bignum by default.
That is dealable-with if you're cunning, but Python's worse than that. Python's numbers are subclassable. If you get given a number as an argument (like you do when you call a function or method) then you can't actually work out at compile time what the damn thing will do when you add it.
Worse, there are Python libraries in the standard Python distribution that make use of this. You cannot ignore it. (Damn you, enum!)
Python's the worst possible language to write a compiler for, or at least to write one that makes a material difference to performance. Fuck you, Guido!
Anonymous No.106991545 [Report]
>>106991505
Generating webshit code with LLMs makes sense. Even then, I cannot seem to be able to generate a workable template for my books. But something that's oughta learn you stuff? It's stupid.
Anonymous No.106991550 [Report]
Found out that the reason why my iced toy app was lagging so hard after loading preview imgs into state was that I was loading the bytes, when I should have instead done the decoding within my fetch function and then store the Vec<Handle> and load the preview imgs from that. It runs super quick and seamless now.
Anonymous No.106991574 [Report]
>>106991392
good job anon
Anonymous No.106991576 [Report] >>106991769
>>106991540
But JIT works for Python. I know CPython does not do JIT for some reason, buy PyPy has managed to achieve it with metatracing.

In metatracing JIT, another language takes care of tracing for you. In regular tracing JIT, you have to keep the total number of loops so you can see if the trace is hot or notl

CPython authors are stupid. At JIT already!
Anonymous No.106991631 [Report] >>106993289 >>106993517
>>106988768
we have regexes now, grandpa
Anonymous No.106991769 [Report] >>106992021
>>106991576
https://web.archive.org/web/20250619132158/http://lambda-the-ultimate.org/node/3851
Anonymous No.106992021 [Report] >>106992127
>>106991769
Metatracing is a great solution. This guy is just describing what metatracing is, and says it's "le bad", for not being a perf-tracing JIT like LuaJIT.

Who cares if it's 'complex'. Handing the tracing off to another interpreter is better than Anton Ertl's solution of the "Code-Copying JIT". Metatracing takes care of the code being portable. In vanilla tracing JIT, you either have to use an IL like LLVM, or do Copying JIT.

I don't see myself knowledgable enough to opine on such matters. But this is 4chidori and I can say whatever I want.
Anonymous No.106992073 [Report] >>106992203
>>106989025
>so desperate to find a job that she's posting portfolio on 4chin
grim
job market in burgerland must be really tough now, huh?
Anonymous No.106992127 [Report] >>106992241
>>106992021
The point is the big wins kick in when you manage to unbox things like integers and floats, and can nail down exactly what the operations really are. That's REALLY hard to do with Python, where the basic operations of the virtual machine model are things like "look up method with this name", not "add two numbers", and fixing that is hard because the fact that operations can be arbitrarily overridden is fairly widely used in real Python code (notably many libraries; most language users have no idea of the shitshow going on).
One way forward would be to compile two code paths, one under optimistic type assumptions, and the other under pessimistic ones, and to pick at runtime which to do based on the real value types presented: if you're given all standard values (the common case!) then you get the faster code path. You can use similar approaches to reduce the cost of bignums under the assumption that most code doesn't really need them; until you get an overflow (or start with big values) you can choose cheap operations.
Anonymous No.106992203 [Report]
>>106992073
I'm a dude, and I'm Iranian.

Also, I wanted people to opine on my presentation. Read the post carefully. Someone wants to 'probably' fund my FOSS projects, and they've asked me to put together a presentation.
Anonymous No.106992207 [Report] >>106992372 >>106992513
>tfw when bypass rate limit with randomly generated string as user-agent

L M A O
M
A
O
Anonymous No.106992241 [Report] >>106992364
>>106992127
That is 'aggressive optimization'? Right?

If not, what is 'aggressive optimization'? Everyone has a different answer. I think it's a buzzword.
Anonymous No.106992273 [Report]
https://www.youtube.com/watch?v=J9ZKxsPpRFk

Babe wake up the new Dylan Beattie talk just dropped.
Anonymous No.106992364 [Report] >>106992550
>>106992241
'aggressive optimization' doesn't refer to any specific optimization
it's an expression used by programmers when (some) optimizing compilers were unreliable
it's also incorrectly assuming that optimizing compilers are not required to strictly preserve the semantics of the program
Anonymous No.106992372 [Report]
>>106992207
interesting, which website?
Anonymous No.106992513 [Report]
>>106992207
I once bypassed one by shuffling HTTP headers
Anonymous No.106992550 [Report]
>>106992364
I was actually thinking about optimizations keeping semantics intact this morning.

"Optimization level flags are created for a reason, chud".

Not to mention customizable optimization profiles.

It does not make sense for a program aimed at string processing to heavily rely on, say, something arcane like polyhedral analysis.
Anonymous No.106992682 [Report] >>106993227
Making a Lisp (MAL) in VanillaJS is so liberating, compared to C.

I always tell people 'prototype in a scripting language first'. But I myself never follow this advice.

Prototyping in VanillaJS has the benefit of the browser's JS engine being extremely forgiving.

JS is a very sweet language. I don't understand why I never made anything with it.

I did not know you could pull the custom <script> tag trick. You could make a whole C -> WASM compiler in JS, provided you create your own WAT -> WASM assembler.
Anonymous No.106993227 [Report] >>106993242 >>106993283
>>106992682
It's very nice to implement algorithms in a scripting language first, maybe even some of the parser when designing and refining the sytnax but I think it's a waste of time to implement entirely the language in the scripting language first.

For example, when learning how to transform the AST into stack bytecode or virtual register bytecode, you need to know how to deal with unary and binary operators, assignment, loads, store, function calls, control flow, but you don't need to implement every kind of operation. It's even more true for type checking/inference.
You're also free to use directly write nested data structure or use s-expression parser instead of the full parser of the language.
Anonymous No.106993242 [Report]
>>106993227
>stack bytecode or virtual register bytecode
*IR, really
Anonymous No.106993283 [Report]
>>106993227
One way to 'justify' implementation of languages in scripting languages is simply 'performative coding'.

Like this: https://www-labs.iro.umontreal.ca/~feeley/papers/YvonFeeleyVMIL21.pdf

Or, browser-embedded languages. Like BiwaScheme.


I have to admit that, programming languages are never good for 'learning'. Scripting languages make it fun, because you know that nobody is expecting the program to be at its A-game. Right?

In one of the manpages for Awk, I read that they've built an assembler for an 8-bit micro in it. I think making an assembler for say, 6502, in Awk or Ruby or Python, or Tcl, will prime you for making an actual assembler.
Anonymous No.106993289 [Report] >>106993566
>>106991631
>we have regexes now, grandpa
but i dont want to parse HTML
Doctor Eli Selig No.106993497 [Report] >>106999510
>>106982794
I can now convert a number into an S-Expression with the unpairing portion of Szudzik's Pairing Function and convert the S-Expression back into a number using pairing.

I don't think this can become a compressor, but it is interesting to see.
Anonymous No.106993517 [Report] >>106993566 >>106993569
>>106991631
The pattern matching system in SNOBOL4 is more powerful than regex.
Anonymous No.106993566 [Report] >>106993977
>>106993517
more powerful than your grandpa regexes, yes, but less powerful than perl regexes
>>106993289
you would if the "regex" was compiled at compile time to efficient native code
Anonymous No.106993569 [Report] >>106993746 >>106993977 >>106995384
>>106993517
The best language for string processing is "Summer", by Paul Klint:


https://github.com/Chubek/chubek/blob/master/klint-summer-book.pdf

It has a construct called "match". It has control flow constructs specifically for scanning strings:

try <id1 , ... , idn> patt1, ... pattn until patt0 yrt


The `match` construct can be found in Icon. The rest of Klint's wonderfully absurd design is lost to the ages.

You're free to implement Summer. I might. Except, Klint uses Summer itself to specify the semantics of Summer... nah thanks.
Anonymous No.106993746 [Report] >>106993834
>>106993569
>It has a construct called "match". It has control flow constructs specifically for scanning strings:
how is it better than say, a regex or PEG parser for matching substrings?
Anonymous No.106993834 [Report] >>106993955
>>106993746
From what I understand, it uses function calls instead of symbolic patterns. So if you wanna match `/foo(w+)/` you'd do `lit("foo"), repeat(alpha())`. Take this with a grain of salt, though, the prose of that book is terse, and I'm an EFL speaker.
Anonymous No.106993955 [Report] >>106993988 >>106994732
>>106993834
So then it's not better, it's simply the same thing as regex.substitute but with a different syntax, and with function patterns if I understand.
Anonymous No.106993977 [Report] >>106993988 >>106995408
>>106993566
>t. doesn't know how matchers work in SNOBOL4

>>106993569
Thank you for telling me, but the PDF appears to be broken?
Anonymous No.106993988 [Report] >>106994732
>>106993955
I think there's more to it. Read the PDF.

>>106993977
You can download it from Z-Lib or Anna's Archive.

ISBN 3-540-16041-8 Springer-Verlag Berlin Heidelberg New York TokyoISBN 0-387-16041-8 Springer-Verlag New York Heidelberg Berlin Tokyo
[/code[
Anonymous No.106994120 [Report] >>106994192
>>106982750 (OP)
I made TempleOS Clock Widget with Custom Font

https://gitgud.io/ZekeRedgrave/ZEKEHC/-/tree/master/Sample/TempleOS%20Clock%20Widget?ref_type=heads
Anonymous No.106994192 [Report] >>106994210
>>106994120
I wish I was autistic enough to make crappy software for a dead schizo's shitty OS, but then again, my mom only took 13 Acetaminophen tablets whilst she was pregnant with me.

Does HolyC even optimize the code? In anyway?
Anonymous No.106994210 [Report] >>106994252
>>106994192
its already optimized into flat assembly after compile
Anonymous No.106994252 [Report] >>106994309
>>106994210
Is the bar that low that the sheer act of compiling into assembly is considered optimization.

I mean, does it do any controlflow analysis and stuff like that, or does it just shit-slop unoptimized assembly into a binary.

What is the ABI here? Does it have a fixed ABI?

I don't mean to stop you from doing what you like. But I, personally, don't approve of making software for such obscure thing. You will learn shit, and nobody uses that crap so what's the point.

I'm being extremely hypocritical here. Do what you love. Don't listen to me.
Anonymous No.106994298 [Report]
>>106990073
which part of OOP do they mean?
the only OOP part of lambda calculus is the return value of tail call, which you can consider a state
Anonymous No.106994309 [Report]
>>106994252
>What is the ABI here? Does it have a fixed ABI?
not existed

>does it do any controlflow analysis and stuff like that
its called D() and Dm()

>But I, personally, don't approve of making software for such obscure thing. You will learn shit, and nobody uses that crap so what's the point.
the old can still do the trick even on how new is the present
Anonymous No.106994732 [Report] >>106994867 >>106995408
>>106993988
This book is wonderful, thank you.

>>106993955
It has a better syntax, because instead of bolting stuff on top of regex to make up for the shortcomings of regex, it was designed for purpose. It is far more readable and easier to use.
Anonymous No.106994752 [Report]
https://github.com/TallGirlVanessa
Anonymous No.106994832 [Report] >>106999768
>group project at school
>break out into roles to make a real app
>pick backend and volunteer to basically be devops to help since I have some irl experience
>super excited for this
>team members kept suggesting fundamental design changes to the original concept
>database person drops
>I'm basically doing backend, database, and devops now
this is how I must have made senior devs feel as a junior dev
Anonymous No.106994867 [Report] >>106998160
>>106994732
If you're up for collaboration on implementing Summer (as long as I get to choose the name, and I choose Midsommar, jk we'll choose a good name later), contact me. My Discord is in my Github frontpage.
Anonymous No.106995265 [Report] >>106995384
PLT Knowledge Tidbit of the Day:

When the semantic analyzer of a compiler handles 'generics' (e.g. `fn foo<T>(a: T)`), the act is called "Monomorphization".
Anonymous No.106995384 [Report] >>106995440 >>106996052
>>106993569
this control structure is probably just a library function in Haskell
>>106995265
not even true except in specific cases
Anonymous No.106995408 [Report]
>>106993977
>>t. doesn't know how matchers work in SNOBOL4
Do you? I've used SNOBOL4 a bit and matched JSON with it so I know what it can do, it's less expressive than perl regexes.
>>106994732
>It has a better syntax,
It's subjective and I disagree. The implicit concatenation, the pipe for the altnernation, the quantifiers and their respective precedence is amazing, hard to beat how good it is.
The biggest deficiency in the syntax of regex is that literal are not quoted but apart from that it's not so bad. The '(?.. )' groups are not used often, except for '(?: )' so it's ok.

>It is far more readable and easier to use.
No it's not, it's ambiguous as fuck which is especially problematic for a tool that matches/parses strings.

"repeat" for example.
Does it makes (0 or more times) or (1 or more times)?
Does it backtrack when subsequent patterns fail? If so, does it matches greedily or lazily?
Anonymous No.106995440 [Report] >>106995604 >>106995623
>>106995384
What is it called then? I'm not deflecting I'm genuinely interested to know. If I am to hopefully lang a job in PLT (which as been my dream for 2 years now) I gotta know all the terminology.

I'm generating a book on op/den/ax semantics rn. I must train myself to read the notation.
Anonymous No.106995604 [Report] >>106995623 >>106995897
>>106995440
so first thing, even though C++ has templates and idk about Rust but I assume it's mostly similar, that compile by basically compiling the code multiple times for each set of arguments, other languages just have generic functions/types that are compiled once and work regardless (e.g. they only reference types through same sized pointers, only call methods through interfaces, etc etc)
personally I don't like calling the former generics, I think the latter fits the bill for generics, and the former are better called templates (because it gives you the impression of that static restriction on the arguments - compiler has to spit out a fixed version)
in any case the latter ones don't get "monomorphised" except as an optimisation basically equivalent to inlining/argument specialisation - they remain parametrically polymorphic (not the same as OOP polymorphism)
Anonymous No.106995623 [Report]
>>106995440
>>106995604
also read TAPL and ATAPL, learn Haskell (it's a good example of a language very different from most imperative languages) or even something like Agda/Idris
Anonymous No.106995897 [Report] >>106995908
>>106995604
>parametrically polymorphic
so that's what *parametric* polymorphism mean...
Anonymous No.106995908 [Report]
>>106995897
yes
https://en.wikipedia.org/wiki/System_F
Anonymous No.106996052 [Report] >>106996067
>>106995384
>not even true except in specific cases
>In programming languages, monomorphization is a compile-time process where polymorphic functions are replaced by many monomorphic functions for each unique instantiation.
https://en.wikipedia.org/wiki/Monomorphization
Anonymous No.106996067 [Report]
>>106996052
>Apples are fruits
>Fruits are apples
Anonymous No.106996111 [Report] >>106996121 >>106996140 >>106996187 >>106996408 >>106996420 >>106996490 >>106996509 >>106996550
>>106982750 (OP)
I'm struggling with Recursion, is it joever for me? I can usually figure out what the base case would be but figuring out the recursive call is where I get lost
Anonymous No.106996121 [Report]
>>106996111
such as? it's not really any different from a loop
>initial situation
>how situation changes each iteration
Anonymous No.106996140 [Report]
>>106996111
Draw a tree
Anonymous No.106996187 [Report]
>>106996111
start with a function that recursively walk over a tree and prints each element. pre-order, in-order, post-order is your choice
Anonymous No.106996408 [Report]
>>106996111
Recursion uses a STACK, learn the STACK data structure.
Anonymous No.106996420 [Report] >>106996490
>>106996111
Actually forget programming languages, start with logic gates and 16-bit assembly.
nandgame.com
Anonymous No.106996490 [Report]
>>106996111
>>106996420
dont listen to him.
starting with high level languages always creates codemonkeys

no, learn quantum superposition first, then build up from there
Anonymous No.106996509 [Report] >>106996550
>>106996111
You should probably learn lambda calculus then read The SICP.
Anonymous No.106996550 [Report] >>106996581 >>106996626
>>106996111
>>106996509
shills never sleep
if were talking more seriously
writing a fibonacci in rec. did it for me
representing whats happening graphically could be the actual winning move
Anonymous No.106996581 [Report] >>106996608
>>106996550
>representing whats happening graphically could be the actual winning move
I think this might be what I need. I've been using PyTutor to visualize what is going on
Anonymous No.106996608 [Report] >>106996636
>>106996581
i used pen and paper
isnt using an additional utility- additional cognitive burden?
esp. at the learning stage
Anonymous No.106996626 [Report] >>106996664
>>106996550
What am I shilling for? Learning how to program?
Anonymous No.106996636 [Report] >>106996682
>>106996608
>additional utility- additional cognitive burden
I honestly have no idea what that means anon ;-;
Anonymous No.106996664 [Report] >>106996690
>>106996626
lisp is worthless for that
its a novelty language
everything else- in other words, what youre actually gonna be using - functions based on different principles

its not even asm, lisp is gonna do worse than waste the beginner's time, its gonna teach em anti-patterns
shilling sicp is like spawncamping noobs, kek
Anonymous No.106996675 [Report] >>106996788
for c++ is there anything wrong with doing it like this if i want a const enum option to return a 3 digit array (its for a motor driver setting selection and theres not really a pattern with the returned sequences), on godbolt it compiles to pretty much what i want:
constexpr std::array<unsigned int,3> setting(somenum enum){
switch (enum) {
case someenum::1:
return {1,0,1};
case someenum::2:
return {0,1,1};
}
}

sorry for the semi-pseudocode you get what i mean
Anonymous No.106996682 [Report]
>>106996636
learning two things at once ;)
i always fallback on pen + paper because i dont need to engage my brain to make use of it
Anonymous No.106996690 [Report] >>106996717 >>106996821
>>106996664
I think you need to reread my post because you seem to have misunderstood it.
Anonymous No.106996717 [Report]
>>106996690
idk maybe i have. you sounded serious
Anonymous No.106996788 [Report] >>106996821 >>106997270
>>106996675
if it were c you could just do this
int jump_turth_whatever_table[$your_literal_enum_size]{..., 0x00010001, 0x00000101, ...};


and use it like this
return jump_turth_whatever_table[$enum];


i mean, afaik this passes in c++ but maybe theres some arcane reason it actualy doesnt
Anonymous No.106996821 [Report] >>106997270
>>106996690
>>106996788 cont
if it needs to be specifically 3 char elements, or whatever else you can also do 2d arrays
declare em globally, init upon declaration and you have yourself a jump table
Anonymous No.106996883 [Report]
...or whatever its caleld
Anonymous No.106997270 [Report] >>106997361 >>106997397
>>106996788
>>106996821
thank you i like that 2d array solution but they compile to pretty much the same so i think ill stick with what i wrote since its a bit more readable desu and dosent initialize a variable, ill see if i can do it with one int if the pins are on the same io port though
Anonymous No.106997361 [Report] >>106997397
>>106997270
>but they compile to pretty much the same
>more readable
fair point
>ill see if i can do it with one int if the pins are on the same io port though
its a neat package, init?
also by comparing the whole int you can cut on conditionals and iterations
Anonymous No.106997397 [Report]
>>106997270
>>106997361 cont
unions might be a clean way to access the individual bits
but youre writing for an architecture im not familiar with
and the ub-ness of certain operations involving unions is subject to debate
maybe its something to keep in mind
im not sure of the exact status of unions in c++
but in c some types of access are technically ub even though deterministic, supported by most compilers for x86
Anonymous No.106997408 [Report]
>the individual bits
*bytes
eh, close enough
Anonymous No.106997477 [Report] >>106997520
My prospective employer/patron is coming to our house to see my presentation on my projects.
Anonymous No.106997520 [Report] >>106997588
>>106997477
baste. good luck
Anonymous No.106997564 [Report]
Rolling for project
Anonymous No.106997588 [Report]
>>106997520
Thanks anon. Let's knock on wood 3 times so I won't get the 'evil eye'. I lost my onyx pendent.
Anonymous No.106998160 [Report]
>>106994867
How about MaidSummer?
Anonymous No.106998387 [Report] >>106998415 >>106998449 >>106998536
>>106989408
>>106989306
Ping, are you there bro?
Anonymous No.106998413 [Report]
ml syntax is so comfy that its making me actively cynical about programming languages in the algol family. anyone else know this feel?
Anonymous No.106998415 [Report]
>>106998387
im here
you got some code for me, bro?
Anonymous No.106998449 [Report]
>>106998387
i need my lines, bro
im seeing shadow people again...
Anonymous No.106998536 [Report] >>106998580
>>106998387
otherwise i still fiddled with the code since then
i think i can still make it faster by manually inlining everything (i fucked up the force inlines)
but im not eniterly sure i wanna deal with register pressure considerations
or rewriting it to be pointer based
i might, at a certain point, but not immediately

i just need a hard benchmark to check against
and to see what types of behaviour the EL algo has, because it varies wildly from what i devined from the papers

and catbox.moe is down atm
any idea where to share code?
Anonymous No.106998580 [Report] >>106998675 >>106998782
>>106998536
I'm using this implementation of EL. https://github.com/Jpn666/ctoolbox/blob/master/src/str2flt.c
If you want to use it make sure to compile that library using --buildtype=release to get better performance.
Anonymous No.106998675 [Report] >>106998782
>>106998580
1000 thanks anon
i know theres some (glaring) inefficiencies in my code, i am curious how far i could push it, and how it compares with an exemplary implementation
('bc it is, even my thing is only ~40-60 cycles, with the EL algo still faster than that. i estimated by ~25% now, but im gonna check properly, now i have the code)
Anonymous No.106998782 [Report] >>106999028
>>106998580
>>106998675
btw
i tought about the cost of simd today
and i went after what i thought was one of the larger performance hogs of the code
to see if the horizontal addition of 4 floats wouldnt be faster than the variety of intrinsics that i use in lieu of that

turns out that simple modification increased execution time by fukken 30%
and i still wrote it with the parentheses and shit to make sure the compiler will understand a way to compute that with optimal dependency (for ilp reasons)
nah.
changing from the spaghetti into human readable form increased the runtime by 30%
from 21s/1B iterations to 27.7. (i assume 3gigs speed bc ryzen 3600 that gives 60 cycles. not 40. indulge me im baked)
Anonymous No.106998906 [Report]
also curious fact:
fastest scenario for me runs in 19 secs
and thats half the memory ops
so im probably bumping my head against the latencies of simd
i already have a suspect in my code
the fukken additional blocks
but it think if i remove everything i can be using more than 16 vector registers at certain points and that means offloading shit to the stack
which is gonna tank performance i think
its 60 cycles. 4 cycles for a read and 4 cycles for a write and thats 13% of the runtime of added latency which may or may not be optimized away by the cpu
but then the compiler might/should do a better job at linking everything together

im not gonna code it today, but i think my intern tier use of blocks makes my stuff way slower than it should be
possibly fences which prevent out of order, which in turn influences latencies
certainly the fact that i pass everything through eax, which happens because i trusted a very bad source- everything is passed by value
although that may be because i force the behaviour with my blocks
Anonymous No.106999028 [Report] >>106999165 >>106999224
>>106998782
>to see if the horizontal addition of 4 floats wouldnt be faster
I did the same for the multiplication of a 4x4 matrix by a vector, in row order. Using it made the function a lot of shorter.
Anonymous No.106999165 [Report] >>106999224
>>106999028
yeah, simd can be very handy
its a vector wide operation. instead of loops theres one line.
err, maybe a couple when you factor in the load operation
i experimented with unions and alignments and these seem to be faster than certain load ops though
Anonymous No.106999224 [Report]
>>106999028
>>106999165
more precisely
something like this:
__attribute__((aligned(32))) union atoi_vector_256
{
__m256i v_256i;
__m256 v_256;
__m128i v_128i[2];
__m128 v_128[2];
float floats[8];
int ints[8];
char chars[32];
unsigned char uchars[32];
};


and then instead of calling this:
_mm256_extractf128_ps(target, 1);


one does this:
target.v_128i[1];


didnt double check
but it seems to be faster
Anonymous No.106999246 [Report]
>target.v_128i[1]
target.v_128[1], actually
Anonymous No.106999278 [Report]
cont of cont
i think its because of the opacity of a type now that i gave it a fink
an __m256 is not guaranteed to be the equivalent to 2 __m128's
the compiler cant make that assumption
so it emits an instruction
this should be a macro into union
if the m256 is 32 byte aligned than its halves are 16 byte aligned, kinda by definition
Anonymous No.106999440 [Report]
So, a university-educated, respectable business owner and family man, has traveled half across the country to meet me, in the room, where I masturbate and cry to sleep, so he can hire me, a SWE dropout, for one of the most complex jobs in the industry, and yet, I feel empty inside, and I don't feel validated at all. I feel like garbage.
Anonymous No.106999510 [Report]
>>106993497
What am I reading?
Anonymous No.106999768 [Report]
>>106994832
You made me remember when I had to do a Java shit group project and all the Next.js tards were scared of doing endpoints and it was up to me to make endpoints for every fucking delusion they had.
>bro make an endpoint to get all customers
>bro make an endpoint to get all the trucks with customers
THE CUSTOMERS CAME WITH THE TRUCK IDS RETARDS JUST ASK THE TRUCK ENDPOINT FOR THE TRUCKS WITH THE IDS YOU GOT
Anonymous No.106999847 [Report] >>106999884 >>106999892
c problem. I'm passing in a file pointer to a function that loops a bunch of times, with each loop it's fwrite'ing data to an opened file, or at least it should.

i continuously get segfaults if i pass the opened file pointer to the function, gdb indicates something to do with __vprintf_internal. program otherwise works fine if i fopen the file within the called function instead of passing it to the function.

checking that the file exists and is writable before the procedure in the function works fine too.

any ideas?
Anonymous No.106999884 [Report]
>>106999847
post code
Anonymous No.106999892 [Report]
>>106999847
It's hard to tell without looking at the code. Are you using fprintf? Maybe one of the parameters to fprintf is wrong.