/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1553756647418.jpg (401x500, 32K)

Other urls found in this thread:

hackaday.io/project/28042-phx8-homebrew-8bit-risc-cpu
en.wikipedia.org/wiki/Garbage_collection_(computer_science)#Reference_counting
khronos.org/opengl/wiki/Compute_Shader
docs.gl/gl4/glMemoryBarrier
twitter.com/SFWRedditImages

Nim is not the most powerful language

We already have a dpt, brainlet.

Nim isn't even a programming language.
Proof: GC

A pokemon map editor. Only does collisions atm, planning on adding more stuff.

Attached: 2019-04-04 03-06-44.webm (640x360, 354K)

Let's laugh at brainlets who can't C++.
I'll start:
AAAAAHHHHHAHAHAAHAHAHAHAHAHHAHAHAHAHAHA
HAHAHAHAHAHAAHHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAAHAHAHAHHAAHAHHAAHAHAHAHAAHAHAHAHAHAAA

Attached: xDDDDDDDDDDDDDDDDDDD.jpg (542x540, 17K)

Are you twelve or something? There is already a thread

"fuck off" is the only reply you're getting

No there isn't. There's only one /dpt/ thread up right now and it's this one.

I know C++. C++ is bad.

disclaimer, im a complete brainlet
how do these 8bit cpus work? Suppose I have some 8bit register A, and 4K memory, with two opcodes, LDA and STA (load and store).
LDA x

this one would just load byte x in A, Now I want to store the contents of A into some memory location.
STA y

how the fuck do I access more than 256 bytes of memory if y is just a byte?

You have to pick a particular CPU to answer that.
But a common technique is to glue together two 8 bit registers to make a 16 bit pointer register.

Why would I want to can anything that's OO

the 6502 MOS was the one I was thinking about

You can literally use any possible paradigm in C++

So it has a bunch of addressing modes, which I dont know what mean, but there is a table of opcodes here, does that mean LDA is actually a mnemonic for several opcodes?

Attached: lda6502.png (738x557, 33K)

>GC is bad

In that case, you can have an intermediate 16-bit value as an absolute memory address. It's just one cycle slower than a load/store from the zeropage with only a 8-bit argument, which is indeed the first 256 bytes of address space.

I this the official /dpt/?

Using C++s unwieldy smart pointers is garbage collection

Yes, that's right. Different forms of the LDA instruction will take different sequences of operands with different ways of accessing memory.
If you use the zero page form, which takes a single byte as an argument, the high byte is implicitly zeros.

that's not what garbage collection is

there is no official /dpt/
not exactly, you can't use e.g. smart pointers for an arbitrary graph

Attached: 1553756955077.png (1920x1080, 1.58M)

they collect garbage for you so why not

It's a garbage collection without a garbage collector. You might as well call `free` a form of garbage collection, there's nothing wrong with freeing resources. But having the performance and memory usage of your program compromised because you're too dumb to use a proper language, this is quite retarded.

>you can't use e.g. smart pointers for an arbitrary graph
yeah you can, just use weak pointers

I guess the bytes column there is how many bytes of code that instruction will require? Does that mean when the CPU reads the byte for the opcode and decides what to do it may treat the next byte as an operand or the next two bytes as an operand if its and LDA type instruction?

weak pointers aren't smart

now you don't have a gc. a gc maps out the reference graph at runtime to determine liveness. if you're doing it yourself it's not a gc

>I guess the bytes column there is how many bytes of code that instruction will require?
Yes.
>Does that mean when the CPU reads the byte for the opcode and decides what to do it may treat the next byte as an operand or the next two bytes as an operand if its and LDA type instruction?
Yes.

I hate webdev

Attached: 1526815179980.jpg (750x680, 95K)

we hate web dev too

damn that seems like it would make emulating instructions a lot more work

Yeah, RISCier CPUs are typically easier to emulate because the instructions are always the same length.

>a gc maps out the reference graph at runtime to determine liveness
a gc collects garbage
or if you want to be more specific, an automatic garbage collector
reference counting is a form of automatic garbage collection

does a risc-like 8bit cpu even exist?

If it's automatically collected then by definition it is not garbage.

// actually useful rust code
unsafe {

what the fuck are you talking about
GC is short for automatic garbage collector, it frees your garbage (memory you are no longer using) automatically instead of you having to do it yourself

8bit CPUs are quite "reduced" already, with limited addressing modes, most don't even have multiplication/division instructions. Besides, all the major 8bit ISAs were designed in the 70s, before the concept of RISC was formulated. It would be interesting to see an 8bit ISA designed from scratch with RISC in mind.

Garbage is defined as unreachable memory. If the memory never becomes unreachable it is not garbage. C++ only creates garbage if you leak memory. Automatic resource management does not collect garbage because it creates none by definition.

I really REALLY don't get why people are so obsessed with Garbage collectors tbqh.
Unironically, in all my years of coding, I never had problems with just deleting the things I allocated manually.
What the fuck is the big deal?
Are people really too fucking retarded for it?

>*leaks memory*
>*double frees*
>*tries to access freed memory*
> Are people really too fucking retarded for it?

Pointers pose the problem of ownership. It's not always clear who deletes the objects.

Smart pointers solve this problem.

I said automatic garbage collection not automatic resource management
You can determine when memory is unreachable using reference counting

The big deal with GC is usually people complaining about them making their code too slow

I know, but the post said deleting the objects. Deleting it manually causes problems, smart pointers do it automatically.

there is this
hackaday.io/project/28042-phx8-homebrew-8bit-risc-cpu

> Why do you need a safer language? Just don't make mistakes, duh. I, for one, never do.
How to tell a professional FizzBuzzer.

>>*leaks memory*
>>*double frees*
>>*tries to access freed memory*
So? All of those are easily fixed.

Of course, I mean you should use containers, and like constructors and destructors for it. But that is not the same as automatic garbage collection that will make your code slow at arbitrary points.d

Your initial premise is incorrect.
>reference counting is a form of automatic garbage collection
With reference counting no garbage is produced, thus it is not a garbage collector.

you have a counter for how many pointers are pointing to the object
when that hits zero, free the memory
are you dumb

Are you? You still don't appear to understand what garbage means.

unreachable memory
when there's nothing pointing to it, that memory is unreachable, so it's garbage
of course RC doesn't detect loops so it's not perfect compared to tracing, the upside it is has more deterministic performance

Is your point that it is deleted immediately before it becomes "trash"?
Because you do lose all refferences, the only difference to Java is that the Java gc will delete it non deterministically.

The memory owned by a smart pointer never becomes unreachable, so it is never garbage. If all memory resources are released deterministically there is by definition no garbage to collect.

glsl doesnt know pointer types, but are functions really all pass by value or are those references under the hood?

>The memory owned by a smart pointer never becomes unreachable, so it is never garbage
well yes because smart pointers are an abstraction built ontop of a language that gives you raw access to memory, it's still an automatic GC system

> If all memory resources are released deterministically there is by definition no garbage to collect.
Two things that have absolutely nothing to do with each other

how do you become a pro and get respect?
In my cs class I feel like such a brainlet, nobody respects me and its full of prideful people

Attached: 1548083178717.png (640x508, 348K)

they are pass by value, you shouldn't be passing around big pieces of data in shaders

git gud

They are fundamentally connected because if resources are released precisely when they stop being used they do not become garbage which must be collected.

Correct answer.

>prideful
Is that even a word?

fuck me. ancient paradigms right there

how many levels of autism are you on
If I throw a banana peel in the garbage as soon as I peel it the banana peel is still garbage

what reason would you have for using pointers in GLSL in the first place? all your big data should be passed in as uniforms/textures/whatever. If you think you need pointers I don't think you've grasped what shaders are supposed to do

bullshit. you dont want to access those opaque types 24/7 because of race conditions and the slowness of atomic access. and if you want to do something more complex in a computer shader you might want to use a couple functions

>prideful
>full of pride

Attached: prideful.jpg (458x355, 16K)

Garbage has a specific definition in the context of CS. So do garbage collection and automatic reference counting, and they are understood not to be intersecting categories.
Here's a funny thing about terminology: if you're the only one claiming they mean things other than the things they are universally understood to mean, you're incorrect.

Languages with reference counted GCs exist
Garbage doesn't have to linger for it to be considered garbage
the memory becomes unreachable and then it is freed
You're misunderstanding the terms

I'm not saying don't use functions, I'm saying you shouldn't be passing large data structures between them because your data structures should be in uniforms and textures
>race conditions
are you not doing graphics programming or am I misunderstanding the term? you don't have race conditions in shaders

garbage belongs in the trash
and the trash man picks up the trash and puts it in the garbage truck, collecting your garbage, then drives away.
when the garbage man arrives and leaves is not deterministic

You may as well consider a call stack a form of GC then.

sure, if you want
en.wikipedia.org/wiki/Garbage_collection_(computer_science)#Reference_counting

na boi, Im doing operations in a compute shader and thus Im not just reading but writing to buffers as well.

reference counting may be used to implement a garbage collector.

Trying to come up with a good 3d renderer design that is dump but still extendable.

well in graphics programming you don't read and write to a buffer at the same time, so race conditions aren't a thing, no idea how it works for what you're doing

khronos.org/opengl/wiki/Compute_Shader

what's 'dump'?

>well in graphics programming you don't read and write to a buffer at the same time,
this is wrong, gpu are now multi threaded.

docs.gl/gl4/glMemoryBarrier

I said you don't, not that you can't, there's no reason to be reading and writing from a buffer at the same time unless you're doing arbitrary computations

Anyone ever used Zig lang here?
I don't understand why the fuck it wont let me right shift.
pub fn RSA(u8 : op){
regA >>= op;
}

it keeps complaining that it wants an u3? but in the docs it says
a >> b
b must be comptime-known or have a type with log2 number of bits as a.
what the fuck? since when is right shifting out bits undefined behaviour?

just checking if this user is around: if you do, what did you mean by that? considering the sqtr of a number might not be an integer

why are you using a meme language

Im not for much longer. Jesus christ

how does everyone feel about the future introduction of metaclassses into c++

Just use Rust, m8.

I was just a second ago looking googling for a possible date when they come out.
It's great and will make a lot of things more efficient, I'm looking forward to it very much.

The committee didn't approve them tho, did it? It's just Sutter's wet dreams.

>c++

Attached: madoka_vaporwave.png (680x680, 687K)

possibly the worst way to introduce metaprogramming that isn't templates

I want to make webshit in PHP.
Core libsodium is a hard requirement, so PHP must be >= 7.2.
What OS should I install on the server?
My go-tos of Debian stable and CentOS 7 are both too old.

>madoka

Attached: 1509662542902.png (768x752, 88K)

That is not Madoka, Madoka likes C++

Attached: SadMadoka.gif (720x405, 969K)

>filename
hope this is bait, here's your (you)

that's yuno from sunshine sketch

how new are you that you're actually falling for the intentionally misnamed image file
it's also synthwave not vaporwave

Making a taskbar for my operating system. It was annoying how some window titles were too large for the taskbar buttons, so I wrote some code to collapse the part that doesn't fit into "..."
At first I was going to implement the taskbar internally in the window server but I figured it would be cooler to do it as a separate process. This forces me to add some interesting "remote management" capabilities to the server.

Attached: early_taskbar.png (1440x900, 455K)