/dpt/ - Daily Programming Thread

Old thread: What are you working on Sup Forums?

Other urls found in this thread:

youtube.com/watch?v=QIIje6g8M50
libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/Pools.html
r-5.org/files/books/computers/algo-list/game-development/James_Van_Verth_Lars_Bishop-Essential_Mathematics-EN.pdf
twitter.com/NSFWRedditImage

First for D

/Java/

4th for making every class a singleton

What you listening to /dpt/?

youtube.com/watch?v=QIIje6g8M50

and everything static

Why did somebody create an alternative syntax for x86 assembly that makes it look like m68k assembly?

Who did?

I need a new text editor. Looking at vim, neovim, and atom. Any recommendations for those or something else?

Why would you make a singleton if you can only have one of something rather than just writing the equivalent inline?

Deviating from the manufacturer specifications is stupid. Whoever would do something like that should feel stupid.

I'm learning go for backend development, and I was wondering if there was an easy way to split a string in a template? If this sounds retarded please let me know.

AT&T

you dont use singleton. it's bad practice.

I just want to know how anybody can possibly justify it to themselves.

They want global variables but they want to pretend that they don't.

ELI5: What is the decorator pattern?

>Posts frog
>ELI5
>>>/reddit/

>inline

That's not even a certified pattern, you pleb. Come back when you're at 3 patterns per 500 LOC minimum.

A buzzword for composition and implementing the interface of whatever you're composing with.

who certifies patters?

what does programming have to do with anime?

They need to be published in a meme book.
Really, don't fall for the """Design pattern""" or OOP shit.
It's a terrible way to design programs.

(You)

Doesn't the GoF book even say that the patterns are more for reading and communicating about code and not tools for writing it?

so what are you proposing instead of oop? you cant make everything functional. what a clusterfuck

>OOP shit
what a retard

Sorry, I don't know what an interface is. I only program in JavaScript.

Procedural programming, taking opportunities to write pure functions when you can.

"""Design patterns""" are really just a way to get over the shortcoming in Java.
They're stupidly overcomplicated and overengineered for what they try to solve.

Basically, like says. Functional is a refinement/spin on procedural so you can "mix" them as much as you want really.

>"""Design patterns""" are really just a way to get over the shortcoming in programmers.
fixed that for you

Javafag is here.

Eclipse you gaylord

>Eclipse
Jesus christ, get a load of this faggot.

He wants a text editor, not a garbage IDE

learning C
the first exercise where you're not given an example code and you have to write it all yourself
immediately forgot everything i've tried to memorize up to this point

"write a program that uses one printf() call to print your first name and last name on one line, uses a second printf() call to print your first and last names on two separate lines, and uses a pair of printf() calls to print your first and last names on one line. the output should look like this (but using your name):


firstname lastname

firstname

lastname

firstname lastname"

I can of course repeat the same thing that's been in every example practice up to this point, but I just feel stupid that I can't plug it into this new example like I really learned it. am I on the right path? This is my first time using [code /code] so i hope I don't mess it up

#include stdio

int main(void)

{

char firstname[20];
char lastname[20];

printf("%firstname, %lastname\n" firstname, lastname);

printf("%firstname\n" firstname);
printf("%lastname\n" lastname);

}

>Procedural programming
isn't that obvious? everyone should see that when he thinks for 5 minutes about his code

>start learning
>starting to understand things
>stop trying because i dont know what to do with my understanding of the language

i literally need homework and project based shit to teach me. I have no imagination and everyone just says "build something."

nigga if i could just "build something" id build a tree so i can hang myself from this shit

emacs
eclipse isn't a fucking text editor

I have to re-instantiate this class every 30 seconds or so.

I have decided to move a lot of the instantiation in pic related to another class, and have that class only be called when the program is started.

Does anyone see a problem in this?
I am new to Java, and don't know if I am overlooking anything.

Imagine being so much of hipster that you think using tried and tested design patterns to organise your code is a bad thing.

An interface is basically just a type, tbqhwyl. Though interfaces (again, types) in OOP languages typically can't include fields due to dynamic dispatch.

>tried and tested
Nice meme. Is there any concrete evidence that they work or just empty promises and following the leader?

>#include stdio
#include
>char firstname[20];
>char lastname[20];
You want to initialise them with something.
char firstname[20] = "Christopher";
char lastname[20] = "Poole";

In terms of the printf calls, you're on the right track.

More of a /sqt/ but how do I make a JavaFX that copies text from one field to another?

VS Code

So you need project ideas?
Make a game. Pong. Text adventure. Whatever.

(You)

>#include stdio

Emacs.
Neovim is OK if you are comfortable with using that control scheme
Vim is pretty old and doesn't have the modularity of addons that Neovim does (although Emacs completely destroys here)
Atom has the plugin architecture like Emacs, but it is pretty bloated (can't run through SSH is a deal breaker for me).

>something with game
>called every 30 seconds
>a whole tsunamis of new
friendo...

>tried and tested
"""Design patterns""" and OOPs are literally the definition of cargo cult programming.

You mean split a string inside your template markup?

It's called per new level of my game, but the first few levels are only a few seconds long. So the 1 second of loading is too much.

I will post the class it once it is fixed

Why are Javatards so shit at programming?

>he doesn't use VSC instead of shitty gentoo editors

re-use your shit. only ever call new if there is no way around it.

best language for a beginner?

tried Python 2.7 and 3. People tell me not to use either of them. Hate installing shit too.

Try implementing Conway's Game of Life in more than three dimensions (changing the rules to account for added space) and make a detector for new shapes. Compile these shapes, study them a bit, and post about it on here.

It is a project I always wanted to do, but I'm preoccupied with other projects at the moment. If you make a git repo, I would totally help with some of the work.

they are the only one actually doing something beyond fizzbuzzing

Because I'm new and self taught ):

Learning on a need to know basis. Currently I have lag, so I am fixing it, and then in the future I won't make the same mistake.

Will do senpai

>gentoo editors
what did he mean by this

I hope you are using libgdx

what did you mean by this

C

x86 assembly
get the basics down first then move onto C or lisp

its best practice to use libgdx if you want to make games for android?

Who are you quoting?

>I hope you are using libgdx
i am indeed

wewlad

you are from norway, aren't you?

What's the easiest way to forward ports through UPnP?

@58114406
see
@58114339

what else do you want to use? java needs some serious work done to make it useful for real time applications. *cough garbage collector cough*

libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/Pools.html

So I'm moving all of my instantiation to another class which will only be called once.

I am adding a bunch of this.thing = inst.thing;
Is this okay? I will have a list of maybe 20 items long

England

is this a troll

Racket

With the router interface?

Somebody has to have their ports forwarded, whether it's a master server for hole-punching or at least one client in the network.

Should i explore the deepest corners of Racket?

thanks, it turns out I was making it more complicated than it had to be. I didn't have to write something to call a char and insert it, I just had to have it printf names the way it wanted using \n
I mean I still didn't get it to work right with the "char name = name" things, but hopefully once I learn more I can rewrite it like that and have it work

>failed math in highschool
where do i start if im bad at math

i always wanted to create software. yes videogames played a huge roll in it but i never went around telling people i want to make videogames.

hell making videogames would just be a bonus.

from the beginning

Through a program's interface (C++). What packets need to be sent to add a forwarding rule?

You can't, unless the machine's (the one the program is running on) router has an API or something.

You should have a solid understanding of algebra and discrete mathematics.
If you want to get into graphics (needed for games), you need to know linear algebra.
Calculus can be useful sometimes, but is not needed in general.

There are other branches of mathematics needed for niche areas of programming, but don't worry about it, unless you are looking to get into those niche areas.

Is there some way to interact with javascript on a webpage without actually rendering a browser or anything?

I'm trying to build a web scraping tool but the bits I want to scrape are now behind a javascript click action. If I can somehow interact with the page to activate that, then scrap the resulting html, I'd be set.

Can a const qualified variable in C be changed at all after it has its initial value?
Like can hardware change the value it already has?.

No, most compilers change const to a constant at runtime and optimize the variable away (like a macro but with type checking)

Just a word of advice: C is not a language that should be learned in an ide. Install MinGW/GCC and use the text editor of your choosing (Notepad++ is good) to write your code.


Working with a compiler will help you greatly.

whelp, currently I have 0 experience in programming, and am currently deciding if I want to read Kochan's Programming in C (third edition) or Kernighan and Ritchie's The C Programming Language (ANSI C) (Second Edition)

which would you go with, Sup Forums?

The C Programming Language (ANSI). The best way to learn a language is by learning from the people that created it.

You can learn C online in two weeks without either of those books. C++ is what you really need some resources for (at least if you want to learn it all).

read this
r-5.org/files/books/computers/algo-list/game-development/James_Van_Verth_Lars_Bishop-Essential_Mathematics-EN.pdf

afterwards work through cormen and you are good to go

>Can a const qualified variable in C be changed at all after it has its initial value?
It depends.
You can have a pointer to a const object that COULD change.
int my_fn(const int *a, int *b)
{
*b = 10;
return *a == 10;
}
and is called with
int a = 0;
my_fn(&a, &a);
But if you just have some non-pointer variable you made const, no.

>Like can hardware change the value it already has?
What you're describing is a 'volatile' variable. Yes, a 'volatile const' variable can change.
volatile const int *some_address = (int *)0xDEADBEEF;

This mentality is what creates bad programmers. Learning the syntax is VERY different from learning the language.

really? the couple books I've been reading suggested an ide. I've got dev-c++ but I will go install those and try them out.
already have notepad++ but haven't actually used it yet
thanks again

slime like repl with scala in emacs possible? Yes/No?

it doesn't sound like he's going to take to clrs

K&R is not a book catered towards beginners.
It glosses over programming fundamentals very quickly.

IDEs often hide the compilation process from you, and as a result, any time you need to do anything remotely interesting, you're going to become incredibly confused. Same if you have to switch into a different IDE.

"Optimize" is a buzzword, if we don't use as much resources as we can there will never be hardware progress!

>IDEs are good for beginners
IDEs are terrible for beginners.
They train people to become reliant on a single set of tools.