/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

prev:

Other urls found in this thread:

youtube.com/watch?v=KlPC3O1DVcg
twitter.com/NSFWRedditImage

templatestruct ECS_C{Pool pool;};templatestruct
Repository : ECS_C, Repository{
void
maintenance(){
for(auto i=ECS_C::pool.begin(); i!=ECS_C::pool.end(); ++i){
if(i->deallocate);
ECS_C::pool.remove(i);
}
Repository::maintenance();
}
};templatestruct Repository{virtual void maintenance(){};};

Friendly reminder that C is nearly 50 years old.

Don't do that, I'm trying to eat here.

what does this do

nobody knows

Maybe we should throw it a surprise party.

Some struct template holds a pool of type T. The variadic template allows for a tiered repository (?). A method called maintenance will remove elements marked for deallocation from the pool. Then the maintenance method is called on the next tier. Finally, a template specialization shadows the maintenance method to do nothing if T is void (which is also the default type provided in the repository template). Am I close?

I think I found a good idea for a project, a C++ to english-like nonsense converter.

>the absolute fucking state of sepples
In lisp it's just (create-repository).

I have an idea for a 2D video game that I'd like to make for Android/iOS.
I'm only good at python and I programmed the game to work on my computer.
I know very little about cross-platform development. How do I go from here? Can I publish the game the way I made it for mobile devices somehow, or should I start from scratch in some other language/environment?

Should I try and build it in Unity? Is Unity free if I want to make the game free?

Any good links for making/porting games into Android/iOS as easy as possible?

Kind of a stupid question, but does
int x;
for (int i = 0; i < 10; i++){
x = somefunc(i);
}
have less performance overhead than
for (int i = 0; i < 10; i++){
int x = somefunc(i);
}
or can I trust the compiler to optimize this anyway?

Spot on.

I'm new to programming. Which languages should I learn first? How can I learn? I'm currently trying python tho

it shouldn't make a difference on any sane compiler

Just roll with it, user.

>Can I publish the game the way I made it for mobile devices somehow, or should I start from scratch in some other language/environment?
Unless you used a framework that specifically supports mobile devices, you're gonna have to at least port it to such a Python framework, or start from scratch in something more suitable. Unity is probably more effort than it's worth for smallish 2D games.

Please help me senpaitachi.

I don't mind starting from scratch, it didn't take a long time, so it shouldn't take a long time to rewrite it.
Any suggestions as to whats the best language/framework to use?

>Any suggestions as to whats the best language/framework to use?
Frankly, they are all fucking awful, but if you're targeting mobile platforms, you might as well pick something native to them. I'd probably just go with Java and LibGDX.

Godot maybe. The language is litterally Python with a few exception.
If you really want to stick with Python there are a few librabries that can do what you want but I forgot the names.

doesn't mean you should do it though
1 is the superior option in any case

How do I import C libraries in Python?

>1 is the superior option in any case
Why on earth would that be better?
If you need to use 'x' outside the scope of the for loop, obviously you have to use the first, but the second one keeps your scope tighter.

>can I trust the compiler to optimize this anyway
never trust the compiler jew

You're all dumb.

for(int x, i=0; i

compound statements in for loops are ugly as fuck

>cares more about how his code looks than how well and concisely it expresses it's behavior

Are you a girl?

ugly code is by its nature bad at expressing its behavior

Now what if x and i are different types?

where's a good place a baby can go to to learn go, their "tour" is making my dumb head spin

also I have to learn it, I don't have a choice

what does dpt think of my kode :)
#include "std_lib_facilities.h"
int main()
{
cout > n;
cout

I'd be surprised if this compiles

:)

Learn assembly, numale scum.

>#include "std_lib_facilities.h"
Straight to trash

I'm just following the textbook you guys recommended for C++ :(

...

how do I dump my bios

>how do I dump my bios
Send her a relationship interrupt.

Is converting a language that stores data in absolute memory (ie. most regular languages) to a language that has relative memory (turing machine/brainfuck/etc) possible?
Like, I know both are turing complete, but is it possible in practice?
I thought about storing the current coordinate and just adding a lot of backtracking whenever you need get to the variable, but it kinda falls apart with loops.
Is there anything I can read on this topic?

You tell it nice and clear that you should brake up. It may give you a punch or two or torch your car, but hey!

this, java for mobile is bretty gud
(sadly)

You can find the relative position of any absolute cell to any other, so what's the problem?

holy shit just print screen or snip it

Please optimize it then

Are you telling us it's too difficult for you, user?

It is, I started learning C++ last week

Does JavaScript has anything similar to Python's generator?

will C ever recover?
>youtube.com/watch?v=KlPC3O1DVcg

ugly danish gnome

Clickbait title aside, he's right - C/C++ should've been merged into one

>C/C++ should've been merged into one
For what purpose? As it stands, C++ serves as a good containment language for brainlets and keeps them from polluting decent projects. Why would you want to ruin this?

Wrong. C++ should be the testbench for implementing everything and everything and becoming a clusterfuck because of it while C remains conservative, robust and clean, but without losing anything substantial.
If C11 introduced nothing from C++ but templates and constexpr, that would be perfect.

Wrong, C/C++/Lisp should've been merged into one

Wrong, Idris/Rust/Scheme should have been merged into one.

t. freelance fizzbuzzers

At least you admit it, newfriend.

What for? C++ has nearly no features needed by C. Templates are the only nice to have thing and those only became usable later.

If you merge every programming language in one, do you get the equivalent of the shit brown when you mix every color?

Is it possible to have a compile time counter in C or C++? More specifically I want the size of of a static array to be based on the amount of times a certain macro is called (or something similar, doesn't necessarily have to be a macro if its possible with templates or something similar).

>C++
C++ has constexpr for compiletime computations, not sure how you'd use it to determine how many times a macro has been called though.

> if (n=5) cout

Use __COUNTER__

I would if it was standard and could be used for more than one counters per program.

it's not supposed to be used for counting but as a way to get a unique number.

Writing in C is like giving rimjobs. You may derive pleasure from it, but you still just stuck your tongue in a dirty asshole.

Retards use C for things it isn't good for, and then act like the combination of their incompetence as programmers and the inappropriateness of their tool choice are the fault of the language.

What is C good for?

>What is C good for?
These days? Being a cross-platform assembly for writing highly optimized low-level code.

Kernels, drivers, bootloaders, firmware, libraries with a well-defined ABI, JIT compilers?

where did you guys start learning

No. You get a big, ugly, omnilanguge with no identity

learn lisp

I'm currently writing a bullet hell game engine in C++ and SDL2 and it's going pretty well so far, I'm just thinking of how I would implement sequences and events. I'm thinking of being able to write shit in a plain text file in this sort of fashion, I might have to do some changes:
GOTO main

winrar:
END-WATCH-FOR-SIG big-dude-name DEAD
CREATE_ENT score-pickup big-dude-name.x big-dude-name.y
END-SEQUENCE

main:
CREATE_ENT player 200 300
WAIT 5
CREATE_ENT some-enemy 0 0 enemy-name
MOVE enemy-name 200, 200 linear
WAIT 1.5
CREATE_ENT big-dude 64 64 big-dude-name

# means that if the the signal DEAD is sent by big-dude-name then
# whatever is in this block happens
START-WATCH-FOR-SIG big-dude-name DEAD
GOTO winrar
END

loop:
MOVE big-dude-name 340 64
WAIT-FOR-SIG big-dude-name NOT-MOVING
MOVE big-dude-name 64 64
GOTO loop

I would then be able to assemble it into some stack of instructions in a file that could be used by the game.
I know the goto's are ugly but it makes it a lot easier to implement, I could probably put in proper function calls if I really wanted to. Does anyone know any other ways of doing this sort of shit.

Guys tell me about ember, the good and bad

>C++
>I'm just thinking of how I would implement sequences and events
You're about to learn your first lesson about why C++ is a pile of trash and why all big studios use custom languages for everything they can get away with.

Wait, THIS isn't C++!!!!

Okay guys..
I got a question:
How do I add api to a python3 project without coding?

I know its cheating.

>coding

I watched some Python game tutorials (with PyGame) on Youtube. Iirc before that I checked some quick Python tutorial on the web that explained the basics. Then after writing small games with Python I moved to C++ and started making games with that. Not that I would use programming for anything useful though, I only do game """programming""".

wow reallllyy cool and useful insight

should I learn perl if I already know python?

The "useful insight" here is that maybe you shouldn't use a trash language in your next game project. Enjoy implementing your own slow, half-baked scripting language on top of C++ or fucking around with Lua bindings. At least calling the OpenGL function that uploads vertex data for your textured squares is going to be superbly efficient, so C++ was still the right choice.

nope. perl is dead.

Holy shit you're a fucking loser getting this mad over someone using C++

he's probably the same pajeet who was complaining that C++ doesn't have Java interfaces

idk there are always arseholes shitting up /dpt/ with their language wars that contribute nothing

>getting this butthurt about someone noting your language's inadequacy
What's wrong, sepples monkeys? Why don't you tell us how to accomplish what user wants elegantly within C++ itself?

You're too far gone, sorry user.

>you're right. i can't do it
Thanks for admitting it.

Sorry, I only program in Lisp.

You're seriously fucking embarrasing mate it's funny

i wish i could css good :

>you're right. i can't do it
You might as well stop at this point.

How to learn emacs lisp?

use emacs first

Im working on my engine in c with opengl and sdl2, so ill take you seriously.

i wouldnt want to create a script language for this but whatever.

0: make 1 big dude work through hard code first.
1: make a new big dude with new hard coded logic.
2: break each logic into small steps, re-use as much as possible.
3: ambiguate each logic to a list of thoe steps.
that list is now your scripting language.
so you just need to parse your script into a list of whatever steps in whatever order.

Any cute little girls in this thread?

...