[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology

Name
Options
Comment
Verification
4chan Pass users can bypass this verification. [Learn More] [Login]
File
  • Please read the Rules and FAQ before posting.
  • You may highlight syntax and preserve whitespace by using [code] tags.

08/21/20New boards added: /vrpg/, /vmg/, /vst/ and /vm/
05/04/17New trial board added: /bant/ - International/Random
10/04/16New board for 4chan Pass users: /vip/ - Very Important Posts
[Hide] [Show All]


[Advertise on 4chan]


File: 1707860893850095.png (388 KB, 934x1000)
388 KB
388 KB PNG
What are you working on, /g/?

Previous thread: >>106922287
>>
File: 1760989216938900.png (1.3 MB, 1024x1024)
1.3 MB
1.3 MB PNG
>>106982750
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.
>>
>>106982750
I'm writing a JSON parser in C as a learning project. Tips, tricks, gotchas?
>>
>>106982875
Allow the use of a custom allocator to simplify cleanup.
>>
>>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?
>>
>>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
>>
>>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;
};
};
>>
>>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
>>
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.
>>
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.
>>
>>106982750
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
>>
>>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
>>
>>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
>>
I'm at that annoying point where I can pretty much only do boring projects, but any funs shit is too difficult.
>>
>>106984920
use case for fun shits?
>>
Light research and intuitioning a type inference algorithm
>>
>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
>>
>>106985917
the C intelligence agency
>>
>>106985917
define u32/i32 yourself and ignore int, long, char, size_t, uintptr_t, etc
>>
File: integers.png (109 KB, 1272x1024)
109 KB
109 KB PNG
>>106985917
>23 different data types for storing a number
If you only knew how bad things really are.
>>
>>106985917
C++ is a billion times worse, it's fucking dogshit meant to be undecipherable if anyone else but you read the code
>>
>>106984920
What would be fun? Some projects people consider fun are easier than the boring ones.
>>
>>106986448
>unsigned long long int
lmao is this for real?
>>
>>106986537
https://www.youtube.com/watch?v=6-1Ue0FFrHY
>>
>>106986448
in real life you only ever use char, int and size_t which you convert to int as soon as possible.
>>
>>106986537
You'd normally only write unsigned long long for that. Or uint64_t.
>>
>yes, this has been done
how do people get away with doing that?
>>
File: look-away-meme.jpg (47 KB, 640x423)
47 KB
47 KB JPG
>>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
>>
>>106987232
mental illness
>>
>>106987256
yeah. intrinsics are not for the faint of heart
>>
>>106987271
>5 function calls
oh my god dont hack me
>>
>>106987232
50 y/o boomer detected
>>
>>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
>>
>>106987284
why doe?
im not a zoomiezoomzoom but im not a boomer either
its just that my shit needs to go very fast
>>
File: rfogg.jpg (11 KB, 203x248)
11 KB
11 KB JPG
>>106987333
no I get it, fucking caches n shit, and keep the compiler on a leash
the compiler is a whore
>>
File: bump.png (1.1 MB, 1344x1010)
1.1 MB
1.1 MB PNG
>>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
>>
>>106987407 (cont)
(and gcc as compiler. other compilers have a different syntax or dont have the equivalent functionality at all)
>>
>>106982750
Making my own font in TempleOS
>>
File: saint-terry.jpg (52 KB, 612x612)
52 KB
52 KB JPG
>>106987526
baste templeOS enjoyer
>>
File: 1693992964102328.png (840 KB, 2782x3168)
840 KB
840 KB PNG
>>106982875
>>106983138
It's over
>>
File: carbon.png (347 KB, 2400x2398)
347 KB
347 KB PNG
Nice
>>
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.
>>
>>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
>>
>>106988552
Whatever compiler you're using, you must enable better instruction scheduling.

Dispatch for SIMD is pricy.
>>
>>106982750
>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.
>>
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.
>>
>>106988654
> no disruptive schizos

I'm the resident scizo of /dpt/, I'm just not namefagging.
>>
File: allen_bradley_plc_Scada.jpg (97 KB, 1200x800)
97 KB
97 KB JPG
Is PLC real programming?
>>
>>106982750
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.
>>
why does nobody do design by contract?
>>
File: 1760663572831546.gif (2.91 MB, 348x516)
2.91 MB
2.91 MB GIF
>>106988735
Look into Ralph Griswold. He wrote a deep dive into the SNOBOL4 compiler.
>>
>>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.
>>
>>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.
>>
>>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.
>>
>>106988784
What about in python?
>>
File: 1719134910934712.jpg (91 KB, 768x1024)
91 KB
91 KB JPG
>>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)
>>
>>106988654
>less disruptive schizos
I needed to get some work done. Sorry.
>>
>>106988605
No, you are doing it wrong, chud. I mean what about exponent notation?
>>
>>106987271
i love intrinsics they're fun to write with
t. C newfag
>>
>>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
>>
>>106988896
>>106988888
You're both wrong, Just fucking use OpenMP pragmas if you want vectorization.
>>
>>106988920
>just use the multicore tool if you want vectorisation
>>
>>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.
>>
>>106988924
OpenMP has pragmas for both retard.
>>
>just trust the compiler
>>
>>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
>>
i've vaguely heard of some schizo who is posting about vectorization/SIMD. is this that guy?
>>
>>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.
>>
>>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.
>>
>>106988605
>>106988964
>2am moment
forgot the picrel and to link the revised version
https://files.catbox.moe/es7s7u.c
>>
>>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
>>
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.
>>
>>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
>>
>>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.
>>
>>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
>>
>>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.
>>
>>106989064
poxil?
hwat dis?
>>
>>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
>>
File: jesus-laughing.png (1.36 MB, 1024x1024)
1.36 MB
1.36 MB PNG
>>106989059
> says TDB is le bad
> recommends Cooper&Turczon

Fucking kek.

Just read the Nora Sandler book anon.
>>
Is C a good enough gatekeeping language?
>>
>>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.
>>
>>106989050
yeah i only became aware of the concept recently
i think a lot of people use asserts and pydantic and stop there
>>
lisp with out-of-line assembly for maximal gatekeeping
>>
>>106989111
Lol, easiest language to write a compiler for.
>>
>>106988665
you still didnt post code for your EL implementation btw
>>
>>106989090
>>106989111
Structured Programming is the best Gatekeeper:

https://www.youtube.com/watch?v=SFv8Wm2HdNM
>>
>>106988665
Memoizing types. Very cool.
>>
>>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.
>>
>>106989171
ok
but then where did you get your figures from?
>>
>>106989178
What 'figures'? I'm confoos. I did not post any numbers.
>>
>>106982750
>What are you working on, /g/?
trying not to kms
>>
>>106989171
>EL
eisel lemire btw
>>
>>106989185
Do it. I died and I'm fine.
>>
>>106989194
I think you've mistaken me for another anon, anon.
>>
>>106989184
ah shit
wrong address, sry
intended for >>106988552

anooon
post code so i can play with it
>>
Grape Ape: please check for captcha validity before you upload the image.

Stupid.
>>
>>106989200
what processor works best in the afterlife
>>
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
>>
>>106989221
Surprisingly or not so surprisingly Apple's M2 feels like turbo mode without the fan on in excess.
>>
>>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.
>>
>>106988552
>>106989207
nvm, found it
>>
>>106989238
and the OS ? Ubuntu Satanic ?
>>
>>106989262
Awesome. I wonder if this would work on a C64 maxi with G-Pascal.
>>
>>106989288
It uses USDC Pascal. But all Pascals are the same really. I was not aware you could run compilers on C64.
>>
>>106988552
>>106989263
not nvm actually
post code
all i see is bits of code buried deep in bigger projects
>>
Is it possible to make a modded bf that's still simple but usable?
>>
>>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.
>>
>>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.
>>
>>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.
>>
>>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
>>
>>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.
>>
FALSE is gonna be the next CPP killer.
>>
>>106989480
XCPP is going to be the next CPP killer.

Oh, you meant C++.
>>
File: angry-emoji-long-hair-2.png (586 KB, 1024x1024)
586 KB
586 KB PNG
I'm so hungry but I have to wait until this sublabial pill dissolves.

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

Eww. I'm all for MTF, but FTM... My cousin is FTM, btw.
>>
>>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?
>>
>>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.
>>
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.
>>
File: truthnuke.png (148 KB, 610x341)
148 KB
148 KB PNG
>>
>>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.
>>
>>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?
>>
The LEAST passive-aggressive C++ talk:

https://www.youtube.com/watch?v=2KZgFiciOxY
>>
File: curry-chan.png (1.31 MB, 1024x1024)
1.31 MB
1.31 MB PNG
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.
>>
business idea : automatically rewrite python scripts in rust because rust is more gooder
>>
>>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.
>>
>>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.
>>
>>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.
>>
>>106991329
That sounds lame as fuck. I say just start vibe coding it and see what you come up with.
>>
File: squeeze.png (98 KB, 960x1044)
98 KB
98 KB PNG
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 :)
>>
>>106991378
You'll learn zilch by vibe coding.
>>
>>106990606
>The LEAST passive-aggressive C++ talk
It's a C talk. That's OK. I like C talks.
>>
>>106991406
He doesn't want to learn anything. He wants to get wrong answers now.
>>
>>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!
>>
>>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.
>>
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.
>>
>>106991392
good job anon
>>
>>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!
>>
>>106988768
we have regexes now, grandpa
>>
File: file.png (472 KB, 905x2105)
472 KB
472 KB PNG
>>106991576
https://web.archive.org/web/20250619132158/http://lambda-the-ultimate.org/node/3851
>>
File: angry-emoji-hat.png (346 KB, 1024x1024)
346 KB
346 KB PNG
>>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.
>>
>>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?
>>
>>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.
>>
>>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.
>>
>tfw when bypass rate limit with randomly generated string as user-agent

L M A O
M
A
O
>>
>>106992127
That is 'aggressive optimization'? Right?

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

Babe wake up the new Dylan Beattie talk just dropped.
>>
>>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
>>
>>106992207
interesting, which website?
>>
>>106992207
I once bypassed one by shuffling HTTP headers
>>
>>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.
>>
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.
>>
>>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.
>>
>>106993227
>stack bytecode or virtual register bytecode
*IR, really
>>
>>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.
>>
>>106991631
>we have regexes now, grandpa
but i dont want to parse HTML



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.