/dpt/ - Daily Programming Thread

Last: What are you working on, Any Forums?

Attached: 1662158604375509.png (285x313, 227.69K)

input management library for game development

learning java from C:
classes = struct definition
new = struct declaration
objects = struct instance
methods = functions calls of structs
this = this struct specifically

did i miss anything?

Attached: 1658452745991973.jpg (660x495, 138.14K)

trying to learn java that way will be harder than going in with a blank slate mentality. java is not C.

"new" isn't just struct declaration, it's more like a malloc. when you declare a struct like
mystruct foo;
you're allocating it on the heap, while a
new MyClass();
is allocating it on the heap and returning a pointer, more like
MyClass* foo = malloc(sizeof(MyClass));

new also allocates memory, so it's more like malloc

>you're allocating it on the heap, while a
on the stack*, not the heap. sorry

Do you anons put your real name in the license file for the projects you contribute to or your own projects? Apparently you're supposed to put your full name there.

Java mostly allocates on the heap. Only primitives get allocated on the stack and if you're lucky enough to hit some hotspot optimizations that allocate small classes used in a loop on the stack.

yes I know. you can even declare primitives on the heap using the boxed versions.

now why would someone be learning java in 2022, that's the question...

I don't respect or utilize copyrights. There are so many ways to shit on people that use your code if you don't like them doing that.

Ty anons

How does this IDE know what i'm going to do, is set and get methods common in java? i'm doing questions from a textbook

it even suggests it when i type "s" rather than "set"

i wish this book explained java the version and other books explained C, talking about idioms and how the compiler works and what is and isnt undefined behaviour.

it feels very superficial compared to the book on C

I'm making Snake in C, with the board being on the terminal and you just use the command line.

I've only been programming for 4 months but I'm getting the hang of it.

A question for people that do this for a job. How the fuck do you guys program for 8 hours a day? I can only manage 2-3 before my mind starts to wander. I have to intermix programming with long walks and downtime to get it done.

Attached: 1662335152257915.jpg (474x744, 52.2K)

forgot pic sorry

but also is this common for OO languages to gloss over things like how new works and memory allocation and all that?

Attached: wtf.png (1142x944, 57.59K)

Using Java and its ecosystem is like not being bothered by using your cheeto fingers to touch your couch, controller, laptop, etc.
You give up on the notion of clean and simple code to embrace shitting on the streets because you get work done that way.

intellij is one of the last few ultra-specialized IDEs like that. it knows java and suggests common patterns

and yes getters/setters are super common but they tend to be overused because some time in the past someone said "you should use getters and setters for everything"

like, if you have a private field with a getter that just returns the field and a setter that just sets the field, just make it public. getters and setters should only be used if you need additional logic, checking, or if you'll only have one of the two. otherwise just make the field public.

class = struct with extra data which makes them impossible to pack in a way that's cache coherent
object = safe struct*(no arithmetic)
methods = class instance functions
static methods = class type functions
this = struct self pointer
new = malloc but without having to manually specify size & alignment

ty user i will do so

Someone who embraces Java and THE bloat IDE inhaled so much copium he started suggesting breaking basic OOP mantra.
What a sight. I'd much rather stick to the usual "but there is a 3rd party patch" which is so bad that it either introduces a code preprocessing step or runtime reflection and code injection of getter/setter.

God dammit, do you ever have one of those days where you hit every single stupid error like making a typo, flipflopping the order of arguments, off by one, etc., and every time it's in a place that forces a full rebuild, such that something that should have taken 30 seconds ends up taking close to an hour because you end up shitposting on Any Forums every time you have to rebuild and continue shitposting for 10 minutes or so whenever the build finishes, only to run it and find another dumb mistake that forces another rebuild? Because I've had like 3 of these days in a row.

Attached: konachang_frustrated_that_wood_is_so_hard.jpg (850x1062, 173.97K)

1. you can still take walks and have downtime
2. you spend as much time in meetings, gathering requirements, hunting down bugs, creating documentation, etc. as you do programming

I think at this point people just got so used to seeing "object.getThing()" over "object.thing" that people add getters just to make it look like they expect.

>Someone who embraces Java and THE bloat IDE inhaled so much copium he started suggesting breaking basic OOP mantra.
I've worked in the OOP mines but I'm a free negro now. if I ever need to work with the JVM again I'll be using clojure or kotlin. but I hope I never do