[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 / qa] [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


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


Over a day without one? dead board.

What are you working on, /g/hosts?
>>
Previous thread
>>103475299
>>
>>103521394
Nothing much right now. Mending some leaking pipes instead.
>>
advent of code
working through the fast.ai tutorials. just managed to get the colab notebooks working on my device yesterday
>>
I updated my Macbook and now SDL/MoltenVK is broken.

When I run the game I'm working on I get these SDL errors when trying to load Vulkan and create a window respectively
>No dynamic Vulkan support in current SDL video driver (cocoa)
>Vulkan support is either not configured in SDL or not available in current SDL video driver (cocoa) or platform

I suspect it's an SDL problem because vkcube and vkcubeapp run fine, but it does appear to be an SDL problem that specifically pertains to Vulkan.

tbqh after spending most of the day searching for information online and tinkering without any luck I think I'm going to just do nothing for a while and see if any of my libraries get updated.

I'm also not going to update macOS very quickly in the future.
>>
>>103521394
picked up a gentle introduction to common lisp again after 5 months hiatus.
Also advent of code
Im paused on personal projects but would love to program something like tetris or other small games in lisp / any project in lisp, since its such an interesting language but I still have a long way to go before I can do that
>>
File: 1729178322624464.jpg (62 KB, 959x916)
62 KB
62 KB JPG
I'm trying to work on building a suite of microservices/utilities that can be deployed on either home servers or cloud environments in order to utilize the fact that I have and use a lot of different devices that could all play a part of a personal distributed network.

Sounds cool, right? Instead I waste my time shitposting on /g/. FML.
>>
Im on the final stretch of Writing an Interpreter in Go.
Was using this book to learn go and looking for other go books / resources if anyone has reccs
>>
>>103522575
these are all on my read list

Learn Go With Tests (web book, what im currently going through now)
Let's Go
Let's Go Further
Learn Concurrent Programming with Go
Distributed Services with Go
Cloud Native Go
The Go Programming Language
gRPC Microservices in Go
>>
>>103522624
additionally there's Build Your Own Database and Build an Orchestrator From Scratch
>>
>>103522624
>>103522633
Let's Go and the Database book look great.
Thank you
>>
still sitting on advent of chode day 9. not really perplexed by it, just gotta get it done and I'm lazy
>>
>>103522138
Chances are those microservices already exist
>>
File: code.png (39 KB, 361x878)
39 KB
39 KB PNG
The C64 Forth I like has a screen editor limited to 39 columns. The Forth itself supports long lines but it's a fun autistic limitation to be creative inside of, even though I mostly develop outside of the C64 emulator now anyway.

I've probably written the fun parts of the beginning of a tetris a half dozen times in as many languages over the years so I'm not confident I'll progress any further, but hey it's fun.
>>
File: 55839907.png (11 KB, 307x462)
11 KB
11 KB PNG
Is it possible to hook into my discord program so I can grab my mute status?
>>
File: includeos.png (144 KB, 995x627)
144 KB
144 KB PNG
What do we think of this?
>>
Nothing at the moment but the next project will probably the a push notification module that I can use within my scripts and running services so I can get updates from my server on my phone.

I also have a termius on my phone which allows for launching/relaunching scripts via shortcuts and I need to finish setting that up.
>>
>>103521394
I've been benchmarking my new rig and home server, transitioning away from cloud.

I'm also getting up to date with Python 3.13
>>
>>103524452
That's cool, but the point is for me to learn how to build things, not how to download things off of Github. I already have that part taken care of.
>>
oh I was about to make a new thread
my project is a secret, but it's going to be grand I'm getting started on it now.

do you ever do UI mockups? would you use CSP for them or what? I have Rnote too and I'm going to try using it for that first
I tried figma for a bit but I don't have the patience
>>
File: Komi_holding_Compilers.jpg (1.15 MB, 1920x1003)
1.15 MB
1.15 MB JPG
>>103522056
that's very unfortunate
>>
>>103527537
Depends on what I'm mocking up. I'm personally fond of just whipping something up with Flask or Blazor and using simple anchors between pages for the demo states, but that only saves time if you're doing something web based anyway
>>
>>103521394
>dpt not in title
you fucking idiot
>>
>>103527718
300 second captcha fried my brain, it is true
>>
>>103527715
oh, cute idea
I think this is going to be an SPA but maybe it would be worth it just to mock it up that way and "collapse" it later
>>
>>103527779
Abuse the shit out of iframes to collapse any multi page into a SPA
>>
>>103527812
oh baby, bring me back to 2008
>>
What's the best way to make a GUI front end in python? I want to make an image gallery which I could use in a few projects, but I don't really ideas of how to do it.
>>
>>103528002
You can use PyQt5 for a good looking robust UI
You can use tkinter if you just want something that works and is simple
>>
>>103524468
I only just now tried to compile and test some of this and it's going remarkably smoothly.
>>
File: code.png (10 KB, 384x546)
10 KB
10 KB PNG
>>103528579
>>
>>103528641
>>103528579
very inscrutable. is that a finished tetris game?
>>
>>103529536
derive, as the comment says, calculates 4 block positions from a piece origin, rotation count, shape index triple. pt@ pt! dt@ dt! move piece triples and derived block positions into and out of in-memory tables. Just basic stuff. Essentially structure assignment through the stack.

The second pair of screenshots is just moving characters and color codes into memory, again not much substance there yet. I'm currently writing the filled lines mark-sweep. It's maybe 8 lines of code. Forth is fun.
>>
>>103521394
I'm making a game of Video Poker in Python
>>
File: abstractIdeasMan.png (57 KB, 463x372)
57 KB
57 KB PNG
>>103521394
>What are you working on, /g/hosts?
Boredom. Posted this over in /gedg/:

Making an 8-bit game for every letter in the alphabet. ex:
Asteroids
Breakout
Centipede
Defender
etc. (huehuehue)

Think of it as a year long Advent of Code in my free time. Trips chooses between:
Monogame
Raylib w/ C
Defold, yeah I know it's an engine.
>>
>>103527537
I never do UI mockups because I'm all function over form
>>
>>103524468
>The C64 Forth I like has a screen editor limited to 39 columns.
I've been working on my own text editor in Forth on and off for years and never liked any of my implementations. It's one of those things that are very easy to implement but have so many fine details that require you to make tradeoffs.
>line editor
Easy to implement with low amount of code but shit to actually use. Adding undo/redo support is trivial.
>block editor
Trivial to implement but shit to actually use due to inherent limitations.
>screen editor with line editor as backend
It's basically VI but don't like VI or VIM.
>screen editor with buffer gap
Pretty good but implementing syntax highlighting / find and other commands without moving the gap is shit. Performance for large files will be bad if you move the gap to create a contiguous region. Adding undo/redo is more complicated unless you just consider every change to the buffer a command, which is a shit implementation.
>screen editor with other more complicated data structures (ropes, piece table, ...)
Too complicated if you want to keep it minimal.

I'm not too surprised that most Forths just ship a block editor, even though they completely suck to use.
I've been looking for a way to implement a text editor that I would actually want to use and maintain but haven't found it yet.
>>
>>103521394
aoc
>>
>>103529873
The developer of that Forth doesn't like short names as much as me, the screen editor he ships is under 700 lines and compiles to about 4.5K. It's basically vi. It's alright and I made do with it for a while.

https://github.com/jkotlinski/durexforth/blob/master/forth/v.fs
>>
File: code.png (97 KB, 1077x829)
97 KB
97 KB PNG
`sweep` took me a LOT of thinking, but it's probably correct. A bit of a test. The well painting overwrites the test code I put into the interpreter but
>$12 3 4 derive ... lock
>$45 0 6 derive ... lock
>1 4 sweep
Puts two pieces and deleted one line from the second one. Again it basically just worked.
>>
I just realized sweep does erase the offscreen blocks so if I ever get around to player control clearing lines also erases walls lel. Easy fix, just got to move and reuse a line of code.
>>
I'm only doing coding as a hobby, so I have no formal education in any of it, but I was wondering, when writing tests, I get how you test backend stuff, but how do you test rendering/UI stuff? Or do you just create a test environment with most UI elements and then visually confirm it looks as expected?
>>
>>103527537
>do you ever do UI mockups?
I don't. I generally create all the backend stuff and then slap a UI on top of I have to or feel like it.
As a result all my programs with a UI look like utter dog shit. Functional, bit hideous.
>>
File: empty lines.png (3 KB, 238x73)
3 KB
3 KB PNG
Removed all empty lines from my code.
>>
>>103521394
Plesk decided to start charging a subscription so I'm taking this opportunity to learn how to set up websites by hand. It's not really hard, it's just a lot of little steps that Plesk handles with a button click.
I'm also playing around with PHP, I used it at my job a long time ago and I forgot how comfy it is. Super easy to write in, especially as a solo dev.
>>
>>103531023
35% of my code is empty lines
>>
>>103530932
hire an army of pajeets to test your UI elements
>>
I just put extra bounds checking in the hit detection. Dealing with offscreen wall blocks was a ton of trouble.

\ drain all rows or scrub i thru i+u.
: th ( i-a) 16* well + ;
: drain ( -) well /well 0 fill ;
: scrub ( iu-) dup 16* ( #del ) >r
2dup + 24 swap - 16* ( #move ) >r
( iu) over + th swap th r> move
24 th r@ - r> 0 fill ;

\ find and count filled rows to scrub.
: full? ( i-f) -1 swap th 10 bounds do
i c@ 0= if 1+ leave then loop ;
: scan ( -iu) 23 0 24 0 do i full?
if swap i min swap 1+ then loop ;

: h- ( bf-f) swap dup 15 and 9 < if dup
/well u< if well + c@ then then or ;
: hit? ( bbbb-f) 0 h- h- h- h- ;
: l- ( bc-c) tuck swap well + c! ;
: lock ( bbbbc-) l- l- l- l- drop ;
3 hides h- l- th
>>
>>103530956
If a UI design doesn't fit on the back of an envelope, it'll be horrendous. Industrial control UIs are the worst.
>>
Is it okay to make a function that is just an IF/ELSE statement? Or do you always in-line that?
>inb4 "it depends"
>>
>>103531903
It's okay, but you should really consider if it's used enough to be worth it in my opinion.
If you think about it, stuff like the abs() function In a dynamically typed language like python is just that. A simple if statement that multiplies the value with -1 if it's negative.
>>
>>103531997
I'm a noob and I don't like it when indents deeper than 3 levels, so I feel tempted to make a function out of anything that goes beyond that
It's really dumb in that case isn't it
>>
>>103531837
>>103532081
Rule of thumb is if you're gonna use it more than once, put it in a function. If you're not, just leave it. To many people get psyched out by the YandereDev endless nested IF statement posts and think that nesting too many statements is bad form, and it's not, as long as you're not repeating yourself and aren't being stupid.
If you have a lot of branching logic I'd rather be able to trace it all in one big nested IF statement than having to chase down a bunch of methods that do nothing but keep branching out more and more.
>>
>>103532127
Thanks, I'll keep this in mind
>>
Do branch predictors get nuked by dynamic library calls from different processes?
>>
>>103532237
^
That's a good question.
>>
>>103532237
might be able to benchmark branch predictor misses and find out?
>>
>>103521394
write a c compiler from scratch. Arena allocator sucks hard
>>
I want to write a TUI that supports unicode, however certain features require me to know exact width of string before it will be displayed on any terminal emulator that might be used, how am I supposed to know that?
>>
File: file.jpg (326 KB, 1300x731)
326 KB
326 KB JPG
Working on a virtual memorial website.

Can't seem to figure out how to do a scrolling wall of text for the background. Want to do a wall of names that scrolls from right to left, perhaps with a line-by-line cascading effect so they aren't all moving as one big block. Want them to loop back around, too.
>>
>>103537098
And yes I am new to coding anything even webshit
>>
>>103537098
Check out the examples on this page. What you're describing is either a direct example of one of them or can be done by combining some of the effects.
https://blog.hubspot.com/website/scrolling-text-css
>>
>>103537098
Here's another example
https://codepen.io/ciprian/pen/xxmomZR
>>
>>103537435
>>103537447
Cheers man
>>
>>103531524
If anyone is interested, here's how I'd translate those the first 5 functions into more typical C. 46 lines versus just 13. And that's with the autistic column count restriction. Denser code is better IMO. Less jumping around when you're trying to read.

int times_16(int n); // not shown in my post, gives n << 4

char *nth_row(int irow) {
return times_16(irow) + well;
}

void well_drain(void) {
memset(well, size_well, 0);
}

void well_scrub(int irow, int ucount) {
int ndel = times_16(ucount);
int nmove = times_16(23 - (irow + ucount)); // *
memmove(nth_row(irow), nth_row(irow + ucount), nmove);
memset(nth_row(24) - ndel, ndel, 0);
}
// * note my previous post mistakenly has
// `24 swap -` instead of the correct 23.

// C needs help returning more than one value.
struct i2 { int a, b; };
struct p2 { char *a, *b; };
struct p2 bounds(char *, int); // library function

int row_is_full(int irow) {
int result = -1;
struct p2 bnds = bounds(nth_row(irow), 10);
for (char *i = bnds.b; i < bnds.a; i++) {
if (!*i) {
result++;
break;
}
}
return result;
}

struct i2 well_scan(void) {
struct i2 result = {23, 0};
for (int i = 0; i < 24; i++) {
if (row_is_full(i)) {
i2.a = (is.a < i ? i2.a : i);
i2.b++;
}
}
return result;
}
>>
>>103521394
Im searching for a good beginner portfolio project
I dont want to put games i made for fun on a job application.
>>
I am looking to run a game client and server using lua I wish to protect the server and client from malformed data and buffer overflows, and malicious code insertion. What's the best way to go about this?
Strictly force it to a format/ validate that it meets the format?
Check the range of numbers and the length of strings?

If I'm using a socket and lua, and I control the length of the incoming packets message, remove all special characters... Am I looking for a library or something to handle this for me? Sorry for knowing so little, I don't even know what I don't know.
I suppose I'll also need rate limiting.

So I'm picturing the following:
TCP/SSL tunnel.
Client asks the server for the socket.
Server sends a computational challenge.
Client sends back the correct formatted response (or socket closes)
Client sends it's user data to the server, it must be strictly formatted.
Server checks formatting and drops the packet/ connection if it doesn't closely match what is expected.
Server checks for the number of messages from the client and closes if the rate is too high.
>>
>>103538336
Depending on what frameworks/languages you used, games can be plenty impressive.
>>
>>103538372
i used raylib but nothing more impressive that a half baked tetris clone
>>
>>103538411
a working tetris is more imperssive than a registry dumper
>>
>>103538431
Well, C64 Forth thing still has a ways to go, but I don't really care too much. I'll probably stop when it's no longer fun.
>>
>>103538336
What kind of job projects do you want? Which industries?
>>
>>103538500
Looking at the job postings they arent too specific what they want, either its webshit, writing device drivers or "C#" There are some hydro energy openings so I might make a desktop app that displays powerplant resources, temparatures, health and other stats. Thoughts? I'd try to not make it too ambitious as i am a beginner.
>>
>>103538797
they want you to ask x10 less money while writing x10 more code x10 faster
>>
>>103521394
>Louise Bourgoin in the op
basé
>>
Kotlin / Android exam tomorrow that will seal my fate
wish me luck fellas
>>
File: 1626291085950.jpg (83 KB, 1280x721)
83 KB
83 KB JPG
>>103538797
I wasn't asking what the job posts want, I asked what do YOU want. Let your projects have some sort of narrative that show you're not just a drone but also that you know how to build tools with good UI or that are practical to a particular group of people that is in an industry you care about or just have an affinity towards.

I know nothing at all about you so it's hard to even point you in the right direction
>>
what are some interesting memory models that just werk and make things simpler?
I know ABI/OS conventions dictate who should maintain register states between caller/callee/return boundaries and I want to find a similar concept for memory ownership and passing around addresses/refs where pre-made assumptions clear the way of much headache and leeks.
>>
gave up on trying to set up haskell language server for my advent of code project (award)
>>
Have I just wasted 4 years of my life working in COBOL?
>>
>>103540159
its so simple to set up though?
>>
>>103540288
Not if you you're planning to be an admin for a bank. Then you're sitting pretty.
>>
File: 1708781996257852.png (51 KB, 892x459)
51 KB
51 KB PNG
>need to find critical path of a sparse matrix's graph
>great, let me use networkx
>is_dag = false due to self cycles
i can't figure this shit out im about to blow my brains out. how do i prevent self cycles there is no graph types with no cycles
>>
File: Screenshot.png (16 KB, 582x577)
16 KB
16 KB PNG
Got all the way through implementing MOV before realizing that immediate mode MOV is completely pointless and stupid, since you would rather just DAT the bytes directly, without the overhead of the copying subroutine. At least it always feels nice to delete unused code and simplify things.
Anyway, here's a contrived example with the MOV that remains.
1       $0000            use C64-LABELS
2 $0000 use PETSCII-CASE
3 $0801 01 08 prg C64
3 $0801 0B 08 01
3 $0804 00 9E 32
3 $0807 30 36 37
3 $080A 00 11 08
3 $080D 02 00 80
3 $0810 00 00 00
5 $0813 A2 00 BD mov @DST @SRC:14:x
5 $0816 2E 08 9D
5 $0819 3C 08 E8
5 $081C E0 0E D0
5 $081F F5
7 $0820 A2 00 ldx #0
8 $0822 BD 3C 08 lda @DST,x
9 $0825 F0 06 beq > rts
10 $0827 20 D2 FF jsr @CHROUT
11 $082A E8 inx
12 $082B D0 F5 bne < lda
14 $082D 60 rts
16 $082E @SRC
17 $082E 68 45 4C dat "Hello, world!\$00"
17 $0831 4C 4F 2C
17 $0834 20 57 4F
17 $0837 52 4C 44
17 $083A 21 00
19 $083C @DST
>>
>>103543273
Despite messing with durexforth a lot, I haven't used actually used cbm basic very much. I'm guessing $801 thru $812 is the usual SYS command to jump to machine code, and $813 thru $81F is a MOV command you added to BASIC? I see the addresses at $816 and $819, and it looks like the 14 is at $81D, but iiuc BASIC stores literals as text characters so I'm probably missing something.
>>
Oh wait now I see the first five bytes at $813 are the same as those at $820, so MOV compiles itself into machine cod--- wait no MOV is a metacommand for your assembler! I see now.
>>
File: sdl.webm (609 KB, 720x406)
609 KB
609 KB WEBM
>>103521394
fuck you for not putting dpt in title

I am not sure if I love or hate embedded linux/yocto.
I don't even understand it at all and only copy paste shit to get le libraries, but now I have SDL2 working on my custom LED matrix running on some shitty proprietary risc-v + fpga development board. Holy fuck.
I already have an SNES-Controller driver too.
Now just gotta actually learn sdl2 and make gaymes

what a fucking journey.
>>
File: kodewithkarlie-1.png (141 KB, 928x593)
141 KB
141 KB PNG
>>103543784
Things to do or to consider:
- try to access directfb device to make screen drawing easier and separate from sdl2 app
- maybe implement a chip8 emulator
- attach snes controller again

ok bye
>>
>>103543695
>>103543720
I think you're getting it now!
A C64 program stored on disk includes a two-byte header indicating its start location, often $0801, the default start of BASIC.
PRG C64
outputs these bytes, but they do not advance the PC, which is why they're listed separately there. The remaining bytes output by
PRG C64
are a BASIC program that translates to
1 SYS2067
2 END

Everything at $0813 and beyond is machine code that's along for the ride. As you realized, MOV is translated into a memory copy subroutine, presumably saving you from having to type all that out.
>>
>>103543890
I just happened to be messing with durexforth, here's its BASIC header. Looks like it's 6 bytes shorter because its doesn't bother with and END statement.

My not-yet-tetris uses the expression `-8 and` and I was testing whether it was worth putting it in machine code since I could skip loading a literal and doing the MSB.
>>
>>103538431
>a working tetris is more imperssive than a registry dumper
Kek
>>
>>103543970
I'm surprised there's apparently no risk of the BASIC interpreter running past the SYS, there must be something I'm not aware of that stops it from doing so.
>>
>>103544074
I believe a statement is a two-byte pointer to next statement, a two-byte parsed line number, then the statement terminated by 0. The END statement is mostly used to end a program early, such as within an IF statement. Programs end normally at the last statement, which has a 0 as its link.

>>103543970
You can see here the link 080b, the line number 000a (10), the SYS statement 9e, and the address as the characters 32 30 36 31 "2061", then the zero to end the SYS statement and the program terminator 0000 followed by the durexforth code.
>>
Also DurexForth never returns to BASIC. It unloads the BASIC ROM and reuses its half of zeropage for its datastack.
>>
Here, I just added a compile-time MOV, macro to DurexForth. Fun times. It takes two addresses and a length and compiles five instructions HERE.
>>
File: file.png (209 KB, 1068x603)
209 KB
209 KB PNG
>programming
how do you handle the fact that all of you are redundant?
>>
>>103544644
smartest ai user
>>
>>103544644
Nice. AI can build hello worlds.
When it's able to debug network errors across 2 systems let me know.
>>
File: cmp.png (67 KB, 815x735)
67 KB
67 KB PNG
>>103544123
Good to know, I removed the END statement and now my BASIC header looks like that one, just a different line number. You saved me those 6 bytes.
>>103544560
Neat!
Here's a multi-byte CMP macro, although this one could definitely use an immediate mode version too.
>>
Storing numbers as characters that need parsed at runtime sure was a decision to make. I know CBM BASIC is based on Microsoft BASIC, is this literally Gates' fault?
>>
I’m using C++ at my daily job. I would like to expand my skills. I’m hesitating hesitant improving my C++ knowledge by learning more about the language and becoming some kind of expert on it despite the multiple warts and needless complexity. The alternative is learning Rust and dropping this prehistoric language because learning the ins and out of C++ will surely feel like a waste of time right? I feel like I know enough of C++ to be productive.
>>
>>103522056
I'm sorry to hear that. But I have to ask, did you update macOS, or did you upgrade it? Two very different, potentially environment-breaking things.

By the way, I also updated macOS just recently, and it broke tab-completion of makefiles in the terminal? I don't even know where to go to report this. It looks like Apple is going the way of Microsoft.
>>
Not a whole lot. I was thinking about writing a memory relocation program
>>
>>103545315
Yes, upgrade to rust, and same applies to 4chan, it's worse than reddit because people can call you what you are - a retarded nigger tranny. Go back.
>>
>>103544644
So why did it omit the whole database thing? My employer can just fire me now because it can do everything, right?
>>
>>103544644
>ai is a rust tranny
grim
>>
Here's some of the reasons I don't use rust:
>The userbase is insufferable
>Only one compiler ecosystem (gcc frontend is still a WIP and probably will be forever)
>borrow checker filters me
>the syntax
>afaik it's not usable with official SDKs for certain platforms (game consoles), but idk since i don't have such an SDK (yet)
>>
programming outside of tutorials and courses is so fun bros. i hated programming a year ago when i learned because i didnt do anything other than follow tutorials and courses, but now im working on an actual project and its much more fun.
>>
File: python_oqs_openssl.png (14 KB, 381x220)
14 KB
14 KB PNG
>>103521394
>What are you working on, /g/hosts?
https://github.com/ran-sama/postquantum-mlkem768x25519-openssl-debian

Post quantum key exchange works easily on old Debian linux boxen with just Python to wrap OpenSSL.
I'm just running stock libs, 1 text file for the entire server and the OQS provider that you can compile whilst brewing coffee.
Are we cool yet, hackers?
>>
>>103548577
I feel that.
Another great feeling is when a new framework or library I'm trying out is intuitive enough/has good enough documentation that I can just figure it out by experimenting and actually doing stuff with it instead of having to look up some shitty tutorial.
>>
Still haven't added anything but it's a clean looking test.

>dtab dd \ make a table to store 4 coords
>$c3 2 5 \ row 12 col 3, rotation 2, shape 5 (T)
>derive \ convert to 4 coords
>dd gt! \ convert to screen coords and store
>dd dt@ 5 color dpaint \ put color codes on screen

>-1 0 4 derive dd dt! \ get coords for an S piece on bottom row
>dd dt@ 4 color lock \ store the S piece in the well
>wpaint \ redraw the whole well
I did have to cursor back up and rerun the two piece calculations to put them back on screen.

Still no interactivity, still doing a lot of thinking.
>>
File: 1723662442300997.jpg (353 KB, 1919x2145)
353 KB
353 KB JPG
>>
File: mik.gif (244 KB, 240x240)
244 KB
244 KB GIF
Does anyone have good resources on how floating point comparisons work at the logic gate level? I am seeing that many architectures produce C, V, N, and Z flags just for floats and will even have their own flag registers. I would like to know how that all works in better detail
>>
>>103550414
I don't have any actual resource, but if you think about it, for positive numbers (ie. sign bit is 0), a comparison between two 32-bit floats would be an identical operation to a comparison between two 32-bit integers.
The only real difference would be for negative numbers because of how the sign bit works between IEEE standard floats and two's-complement integers.
I imagine all a flag for dealing with floats would do for comparisons would be to reverse the result for greater-than/less-thans when the sign bit is flipped.
>>
>>103521394
>>
>>103521394
>dead board
i haven't been here for a couple of months
wanted to come back a bunch of times but the retarded 15 minute captcha stopped me. not gonna wait that long to shitpost
>>
>>103552852
glowies won
>>
>>103552884
I guess only people who never clean their cookies post here?
I always used to post from incognito
>>
>>103551344
other than nan/inf/signed zeros, don't you also need to consider denormalised floats?
>>
File: 294px-Iggy_Death_OVA.gif (203 KB, 294x225)
203 KB
203 KB GIF
Want to learn vulkan and try learning rust (again; tried before and fell off every time) after seeing some rust code in /aocg/ for intcode and getting inspired, so I thought I'd kill two birds with one stone and make some sort of interpreter or emulator in rust that uses vulkan. Problem is -- what should I do? I considered PSX but that might be too complex for a 7-day project. Maybe something like Chip-8 or a real-world 8-bit or 16-bit computer but I feel like I wouldn't exactly be using vulkan properly if I did something that doesn't do 3D.
>>
>>103543273
What does the first column mean, btw? It seems to be counting instructions, but goes up by 2 for some metainstructions?
>>
File: mov.png (26 KB, 320x400)
26 KB
26 KB PNG
>>103555314
Line number in the assembly source code.
>>
>>103554167
bump
>>
Do you ever prototype shit?
>>
What are some projects I could do in 1-4 months that involve using a 3D graphics API like vulkan (that aren't games -- I'm waiting for the "right time" to get started on a game project)
>>
Tried testing something involving using libc in the cursed crab language
https://rust.godbolt.org/z/zx5fcbnEj
I hate how, although rust *allows* you to use the much faster libc functions instead of their bloaty core/std libraries, it makes the code look gross, especially the
"Sum: %d\n\0".as_ptr() as *const i8

I'm not sure how to wrap rust functions around libc shit, particularly ones like printf that use varargs (rust doesn't support varargs outside of "extern c" functions)
>>
>>103556438
new algorithms
>>
File: 1668907081758312.jpg (63 KB, 800x576)
63 KB
63 KB JPG
>Hmm I think I've got the hang of this functional programming thing thanks to ocaml
>I'll try Haskell again!
>Immediately get filtered by function composition shit
>It's been 3 hours and I still can't figure out the arcane combination of functions I need to invoke, in what order to get the fucking types to work properly.
Holy shit. I just wanted to read a text file, split it into a list of strings, then print it back out again. I didn't even write the fucking separateBy function, because I was apparently too retarded for that too.

Am I genuinely fucking stupid?

import Data.List (unfoldr)

separateBy :: Eq a => a -> [a] -> [[a]]
separateBy chr = unfoldr sep where
sep [] = Nothing
sep l = Just (fmap (drop 1) (break (== chr) l))

printAllLines :: [String] -> IO ()
printAllLines ls =
head (map putStrLn ls)

main :: IO ()
main =
let filePath = "dat/4" in
let fileContents = readFile filePath in
let ls = fmap (separateBy '\n') fileContents in
printAllLines ls
>>
made this, it was handy to concatenate parts of a big video. the end part was corrupted so I extracted most of the old parts, and redownloaded the end
int main(int argc, char **argv)
{
size_t count;

if (argc < 3) {
die("cat count FILE*");
}

count = atol(argv[1]);

for (int i=2; i < argc; i++) {
int fd = open(argv[i], O_RDONLY);
if (fd < 0)
die("open '%s'", argv[i]);
close(fd);
}

for (int i=2; i < argc; i++) {

if (count > 0) {
int fd = open(argv[i], O_RDONLY);
if (fd < 0)
die("open '%s'", argv[i]);

ssize_t bytes = sendfile(1, fd, NULL, count);
if (bytes < 0)
die("sendfile '%s'", argv[i]);

count -= bytes;

close(fd);
}
}

return 0;
}
>>
>>103557227
fileContents isn't a list of strings, it's a program (IO [String]).

fmap stuffs a function onto a program, so ls is again, not a list of strings but a program. printAllLines is declared to take a list [String], not a program (IO [String]), so just put another fmap before it in main. Or:

putLines = putStr . unlines
main = putLines . separateBy '\n' =<< readFile "dat/4"


If you want you can map putStrLn over a list of strings, but then you'll have a list of programs, you can sequence them into one big program sequence_ :: [IO a] -> IO ().
>>
>>103557227
This is one of the main stumbling blocks for people learning Haskell (one of very few pure functional programming languages). I would recommend using do blocks to achieve this initially, then working out how >>= etc work. >>= is the main operator you're missing when defining main (since if you merely used fmap printAllLines ls, you would get IO (IO ())).
main = do
let filePath = "dat/4"
let fileContents = readFile filePath
ls <- fmap (separateBy '\n') fileContents
printAllLines ls

Note that 1) the "in" isn't needed in a do block for lets and 2) <- is used (implemented with >>= and a lambda). From the perspective of the programmer this looks like running the effect, binding the IO [String] to ls :: [String], but the do block obliges you to then return IO something. (You can use "return" or "pure" to turn an A into an IO A, but you can't do the reverse.)
You can also use it in place of the earlier fmap:
main = do
let filePath = "dat/4"
fileContents <- readFile filePath
let ls = separateBy '\n' fileContents
printAllLines ls

Another bug in your program is printAllLines. When you use map putStrLn, what you are doing is turning every element into the list into a printing action. You are not actually running any of those printing actions - in fact you can see the goal of a Haskell program as to compose all the actions into the final main definition, never truly escaping IO. What you want to do here is either define it recursively and use >>= (or >> which is defined in terms of it) or use any of: sequence, sequenceA, traverse, mapM.
>>
how many of you tried to find this thread searching for /dpt/?
OP is a fucking faggot and I'm tempted to create a new thread because that's probably why this thread is deader than fuck and has lasted for days now
>>
>>103557227
>>103557849
Also, are you the one who couldn't get haskell language server (HLS) set up? Because I would really recommend using it. Personally I use ghcup to install a compatible set of GHC, cabal and hls (but not ghc 9.12.1 yet which released just yesterday), and create a project with cabal init.
Type information on hover is super useful for understanding what is going on as a beginner. A feature that works well with this is typed holes (_ as an expression, not a pattern, usually for code you have yet to write). One current downside of HLS is you need to restart the server to update package dependencies or modules (but not every time you modify a file).
Feel free to ask questions in /dpt/, I am free over Christmas to answer them and /dpt/ is dead lately anyway.
>>
>>103558035
Back when /dpt/ wasn't permanently dead that is exactly what we would have done, in fact someone made such a thread (the only way I found this one is a link in that one) and it so happens to have died. Would have been better to have moved to that one.
>>
File: 1733926595593407.png (223 KB, 485x558)
223 KB
223 KB PNG
>>103557849
This is a very helpful writeup anon, thank you. It's a rather unfortunate consequence of functional purity that IO has to work this way. This entire time I've been thinking of IO/State as special type wrappers that the compiler knows to handle differently (eg don't just erase them because they return nothing). The idea of them acting as composed programs at a type-level makes sense... sort of. I guess the mechanics of the STGM are weird enough that I should have suspected there was more to them.

I completely forgot do blocks existed and had special rules. As well as the <- operator. Damn this language is huge.
>>
>>103558046
Not me, I got my ghcup setup working 12 months ago when I last tried to fight this dragon. I'm nice and comfy with my bloated vscode setup yelling at my misconceptions in real-time.

If I have any questions I'll post 'em. Thanks for offering to help, you're very kind. I can only imagine how silly these problems look.
>>
>>103558046
Actually I do have one more question:
separateBy :: Eq a => a -> [a] -> [[a]]
separateBy chr = unfoldr sep where

The function signature and my general understanding leads me to believe that there's some kind of currying thing going on here? Is that right? Not sure where else sep could come from.
>>
>>103558067
<- is part of a do block so i don't normally think about it as an operator (at least not in the sense + or >>= are operators), you can call it bind since that's what >>= is called
(do x <- e; f x) is syntax for (e >>= \x -> f x)
(do e1; e2) is syntax for (e1 >> e2), which is equivalent to (e1 >>= \_ -> e2.)
IO A is a procedure that returns an A (if it doesn't throw or run forever), and it is a first class value. The most important thing to understand is you do not *really* run these at any point. You build them up until you've built the whole program that you assign to main. This is the exact same idea as e.g. functions calling other functions in C, but it applies consistently throughout all expressions in Haskell - evaluating expressions does not cause side effects.
let x = getLine
is not like x := getLine() in an imperative language, it is like
x := function () { return getLine(); }
in an imperative language.
Now you can imagine x <- getLine or (getLine >>= \x -> ...) is like x := getLine() in an imperative language, but in the same "local" sense as a statement in a function definition, i.e. you're still ultimately defining a larger procedure.
a := function () {
x := getLine()
... do something with x
}
If you want to create a new procedure that just returns a value, you can use "pure" or "return" (named to be similar to C) which is just a regular function (A -> IO A).
confirm :: IO Bool
-- confirm = getLine >>= \x -> return (x == "Y")
confirm = do
x <- getLine
return (x == "Y")

There is no general (IO A -> A), aside from unsafe compiler primitives.
>>103558273
sep is defined by the where block, which is kind of like a backwards let
let bindings in expression
expression where bindings
You can't use where everywhere unlike let, it has to go in certain places for grammar reasons (I can't recall exactly where, but the right hand side of = is an example)
>>
>>103558273
Sep is the local function defined on the next line. A where clause is like a let expression, except that it scopes over an entire equation (including any guards)

name = expr where { names }
name = let { names } in expr

name1 | test1 = expr1
| test2 = expr2
where { names }
-- this can't be expressed with a let


>some kind of currying thing going on here?
Yes, the definition is equivalent to:
separateBy chr string = unfoldr sep string where { sep = ... }
>>
>>103558303
I guess you could do this:
name1 = let { names } in
case () of
() | test1 -> expr1
| test2 -> expr2
>>
>>103558317
there's an extension MultiWayIf you can use that lets you write
if | guard1
| guard2
| ...

I never use it though
>>
>>103558067
>It's a rather unfortunate consequence of functional purity that IO has to work this way
It's an extremely unfortunate consequence of most languages that I have to worry whether a "function" might cause side effects in all cases, everywhere, forever.

I like not having to care.
>>
>>103558303
>>103558317
>>103558334
The main upshot is that grammatically, `where` is a part of definition syntax and not expression syntax, so this is a syntax error:
name = (expr where { defs })
>>
>>103558035
I did too, I thought that /dpt/ was dead for a full 2 days and it was finally the end
>>
>>103521394
How the fuck do you even detect properly that a device (/dev/input/eventN) is a keyboard on linux? some keyboards are reported as both keyboards and mice and some mice are reported as both mice and keyboards and even have support for buttons such as "A" even if there isn't such a button on the mouse.
>>
>>103558351
sure, it just makes the initial hurdle of learning harder, since interaction with the program in any manner is a side effect.
wouldn't be so bad if ghc let you statically include a file as a list of bytes or chars at compile time.
>>
>>103561898
There is an extension TemplateHaskell that can do this using template haskell is a bit advanced
https://hackage.haskell.org/package/file-embed-0.0.16.0/docs/Data-FileEmbed.html
You could test stuff out in ghci though, if you have a cabal project use "cabal repl" instead. It lets you do side effects at the top level of the interpreter using <-
>>
>>103521394
Is there a point where LEA instruction becomes slower than several sequential math instructions due to it being encoded much wider plus decoding+exec latency?
>>
>>103562394
>There is an extension TemplateHaskell that can do this using template haskell is a bit advanced
I'll maybe look into it after I master IO/State monads. I did eventually want to try Liquid Haskell, so I'm not terribly shy of eventually getting into the deep end of things.
>It lets you do side effects at the top level of the interpreter using <-
Oh that's pretty neat actually. Is it an extension cabal adds to ghci, or is it just part of ghci in general?
I remember abandoning the REPL last time I tried to learn Haskell because of one or two things that ghci doesn't let you do. I even dug up HUGS, because it didn't have those restrictions, but ended up dropping it again because of Haskell98 lacking a ton of shit (do notation, if-then-else) and also many bits of Haskell code relying on ghc extensions.
>>
>>103563838
It's just part of ghci, cabal repl just loads the right packages/flags if you're using a cabal project. What couldn't you do in the repl?
Incidentally GHC is basically the de-facto haskell compiler and HUGS is dead, so most people rely on GHC extensions often (so much so there are no standards GHC2021, GHC2024)



[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.