[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 318
Thread images: 39

File: daily programming thread2.webm (2MB, 600x338px) Image search: [Google]
daily programming thread2.webm
2MB, 600x338px
old thread: >>56028612

What are you working on, /g/?
>>
>>56033133
First for D
>>
File: 1399662065109.jpg (99KB, 500x669px) Image search: [Google]
1399662065109.jpg
99KB, 500x669px
Please help me with Java quickly

for(Walls walls: wall) {
scoreArray[i] = true;
}

I want to find the current number of the Walls array, and place that number into i.
So, if I'm on the 4th value of the Walls array, I want to set the 4th value of scoreArray to true.

I don't know how to change my foreach loop into a for loop, can someone write it for me?

I'm so stuck
>>
>>56033180
CHANGE MAJORS NOW
>>
>>56033133
kill yourself
>>
>>56033180
really?

for(int i = 0; i < walls.length; ++i) {
scoreArray[i] = true;
}
>>
I outgrew this general a long time ago, but I still come here to shitpost.

If your problem isn't literally fizzbuzz-tier, nobody replies to you.
>>
>>56024767 (Me)
>>56024831
the answer is similar to this:
http://stackoverflow.com/a/1572461
>>
How do I do that sexy code layout?
or something?
>>
>>56033434
read the sticky
>>
rcon = [[0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36],
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
]

what does this do
>>
>>56033200
>>56033227
for(Walls walls : wall) {
if(cam.position.y - (cam.viewportHeight/2) > walls.getPosTopBlock().y + walls.getTopBlock().getHeight()) {
walls.reposition(walls.getPosLeftWall().y + (WALL_COUNT * WALL_SPACING));

scoreArray[i] = true;
}
if(bubble.getPosition().y > walls.getPosLeftWall().y && scoreArray[i] == true) {
// Increases the score
score++;
scoreString = Integer.toString(score);
scoreArray[i] = false;


}
if(walls.collides(bubble.getBounds())) {
gsm.set(new PlayState(gsm));
break;
}
}


If I could get the i in scoreArray[i] to be the same as the value of the array Walls, I'd be fine. But I don't know how
>>
>>56033457
Defines a variable that's a list containing 4 lists of numbers.
>>
>>56033471
put this instead the first line
for(int i = 0; i < wall.length; ++i) {
Walls walls = wall[i];
>>
>>56033479
but what are these numbers?
what would they be used for
>>
>>56033471
>>56033504
or i'm not sure what you mean by
>get the i in scoreArray[i] to be the same as the value of the array Walls
>>
>>56033506
it's don knuth's hacking sequence of opcodes
>>
>>56033506
No one is a psychic medium here and won't be able to tell you without any context whatsoever, it's almost as if I posted a few random numbers like 5 1231 593252 252035 and asked you what are they used for. The only hint here is the variable name, which could be server authentication sequence? Although it wouldn't make much sense because the first list is simply multiples of 2 in hexadecimal notation.
>>
File: ewtryruf.jpg (72KB, 1235x487px) Image search: [Google]
ewtryruf.jpg
72KB, 1235x487px
>>56033504
Thank you anon
You know what I'm trying to do, but I'm not sure the syntax is 100%

see pic related
>>
>>56033544
>>56033547
https://github.com/Skycker/AES/blob/master/aes128.py
>>
>>56033600
ah, it's not a plain array, it's an Array object.

you can see in the documentation here:

https://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/Array.html

that you need to do wall.get(i) instead of wall[i]
>>
>>56033631
thank you so much
i actually love you
i've been crying for almost 90 minutes now
>>
File: Untitled.png (5KB, 615x89px) Image search: [Google]
Untitled.png
5KB, 615x89px
>>56033625
Gee, I wonder...
>>
>>56033691
bro i literally still have no clue explain it
so they're using these magic 0xGYPSY numbers for what
>>
>>56033778
looks like it's using rcon to precompute some scheduling. Kinda like how some CRC32 implementations use a table.
>>
>>56033778
https://en.wikipedia.org/wiki/Bitwise_operation#XOR
>>
>>56033853
>>56033855
but bros i literally still have no clue explain it
it looks like they're using these magic 0xGYPSY numbers for what
>>
>>56033917
How about you just fuck off.
>>
>>56033917
FOR FUCKING
HASHING
BECAUSE
ITS
A
CRYPTO
LIBRARY

can you kindly just fuck off back to /wdg?
>>
>>56033947
>>56033950
bros i am still shaking.
it looks like they're using these magic 0xGYPSY numbers for something shady
>>
Anons how can i insert data into mysql from file.
I have file hls, infile is:
1456893207286.webm
1456893239983.webm
1456893429952.webm
1456911883636.webm
1456912417621.webm
1456913173330.webm
1456919432270.webm

i tried
LOAD DATA LOCAL INFILE '/path/to/file/hls' INTO TABLE mytable

table has id and name
id primary key and autoincrement
name varchar and unique
>>
>>56034016
>>56034016
Ignore this, I'm retarded.
>>
>>56034016
Not working tried that too.
It inserts only one row
>>
Need some help measuring time time it takes to do something in a c++ program.


int start_s = clock();

//code to time

int stop_s = clock();
cout<<"time:"<<(stop_s-start_s)/double(CLOCKS_PER_SEC)*1000<<endl;

This always returns zero though, no matter how large the process is. (in this case, reading in from a file and sorting an array)

Maybe displaying milliseconds would show the time passed?
>>
ldr destination, source
str source, destination

Why would they do this?
>>
>>56034102
<chrono>
>>
>>56034102
see how its done in this example
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <string>
#include <cctype>
#include <chrono>
#include <thread>

int count_wrds(std::string s)
{
int numberOfWords = 0;

if (isalpha(s[0])) {
numberOfWords++;
}

for (size_t i = 1; i < s.length(); i++) {
if ((isalpha(s[i])) && (!isalpha(s[i - 1]))) {
numberOfWords++;
}
}

return numberOfWords;
}

void typing_speed()
{
std::cout << "Start typing: \n";

auto t1 = std::chrono::high_resolution_clock::now();

std::this_thread::sleep_for(std::chrono::seconds(1));
std::string sentence;
getline(std::cin, sentence);

auto t2 = std::chrono::high_resolution_clock::now();

double seconds = std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1).count() / 1000.f;


std::cout << "Typing speed: " << (count_wrds(sentence) / seconds) << " words per second\n \n";
}

void stats()
{
std::string sentence;

std::cout << "Start typing: \n";

auto t1 = std::chrono::high_resolution_clock::now();
std::getline(std::cin, sentence);
auto t2 = std::chrono::high_resolution_clock::now();

double seconds = std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1).count() / 1000.f;

std::cout << "Words per second: " << (count_wrds(sentence) / seconds) << "\n";
std::cout << "Words per minute: " << (count_wrds(sentence) / seconds) * 60 << "\n";
std::cout << "APM: " << (sentence.length() / seconds) * 60 << "\n";
}

int main()
{
stats();

return 0;
}
>>
>>56034176
>not steady_clock
kys
>>
>>56034184
xD
>>
>>56033969
You have to tell mysql where to insert the data, what you're doing will make it try to insert it into the ID column.

LOAD DATA LOCAL INFILE '/path/to/file/hls' INTO TABLE mytable
lines terminated by '\n'
(name);
>>
>>56034305
same as >>56034087
>>
>>56034460
then I don't know, just tested >>56034305 and it worked just fine.
>>
>>56033133
This is supposed to print something but it prints nothing.

#include <iostream>

class Test
{
char *member;

public:
Test()
{
std::cout << "Constructed." << std::endl;
member = new char[1024];
}

~Test()
{
std::cout << "Destructed." << std::endl;
delete[] member;
}
};

int main(int argc, const char **argv)
{
Test a();
{
Test b();
for(int i = 0; i < 10; ++i)
Test c();
}
}
>>
>>56034525
Test *b = new Test();
>>
File: Selection_004.png (39KB, 320x170px) Image search: [Google]
Selection_004.png
39KB, 320x170px
>>56034483
this is part of error from workbench
>pic
>>
>>56034571
Yes, it's trying to insert the webm names into the ID column, did you copy the whole code snippet from >>56034305, all 3 lines ?
>>
>>56034588
yes
>>
>>56034563
Shouldn't I get an error if I'm not declaring my shit correctly?

Also my destructor is never called now.
>>
>>56034628
No, because what you're doing is, as far as I know, the preferred way of doing things, that is, not using 'new', not really that familiar with C++ though.

And you don't need
member = new char[1024];

just do
char member[1024];
// instead of
char *member;
>>
>>56034588
I deleted id and everything is inserted.
My question is could i add id now and make it generate id by it self?
>>
>>56034680
Not quite sure what you mean, this is how I did it, starting with a clean table.

CREATE TABLE `test`.`webm` (
id int auto_increment primary key,
name varchar(256)
);


LOAD DATA LOCAL INFILE '/path/to/file/hls' INTO TABLE test.webm
lines terminated by '\n'
(name);
>>
>>56034678
Oh I get it the destructor is only called for objects on the heap duh.
>>
>>56034525
You have fallen victim to the *most vexing parse*.
Basically the compiler interprets the
Test a();
as a function declaration.
To prevent this, remove the parenthesis.
Test a;
>>
>>56034175
>>56034176

Thanks, I found what I need with chrono, but in my compiler I wasn't in c++11 for some reason and am having some trouble switching to it,

I run the command:
g++ -std=c++11 main.cpp -o main
but then if I a.out it does run the file with the new changes. And if i try to compile normally again with
g++ main.cpp
I get errors because my compiler still isn't in c++11
>>
Do checks have a place in C++ or is everything exceptions?
In C I used to make an error function and wrap it in a macro, would that be considered bad C++?
>>
>>56034775
Eh... the problem is?

You can't compile pre c++11 code without specifying the standard you're compiling against.
>>
>>56034743
I deleted table and created the same way as you and it worked.
Cant get what was problem
>>
fuck guys, I'm having trouble implementing a zipper for my data structure
data Filesystem a = Item a [Filesystem a]


any ideas?
>>
File: datta1.jpg (75KB, 1024x768px) Image search: [Google]
datta1.jpg
75KB, 1024x768px
>>56033471
>making games in Java
kys
>>
>>56034920
hello rêddit
>>
>>56034678
The char * there was to demonstrate how to use constructors/destructors to manage stuff like that.

>>56034753
No, it gets called for both heap and stack objects, in case of the stack objects it happens when they go out of the scope, in case of heap objects it happens when you call the delete operator.
>>
File: memes.gif (324KB, 604x364px) Image search: [Google]
memes.gif
324KB, 604x364px
ncurses is comfy
>>
>>56035322
How did you do that?
>>
>>56035322
is there ncurses for windows

like an actually recent and good one i mean
>>
>>56035358
Skipped physics classes in primary school? It's a basic position bounce & text display at the coord.
>>
>>56035594
Physics?
I never had that in school.
>>
>>56035594
ok we get that but we're talking about the non-linear printing of text in 2d space
>>
>>56035663
...
>>
File: heh.gif (239KB, 500x375px) Image search: [Google]
heh.gif
239KB, 500x375px
>>56035690
Skipped terminal printing classes in primary school?
>>
How do I get a job
>>
>>56035721
What? It's you who does not understand even though he included the keyword you're supposed to look for in his post.
>>
>>56034860
so make a new file,and then set the compiler to c++11? makes sense
>>
>>56035721
>terminal printing
He was using ncurses, which is different from that.
It uses termcap to get commands to draw things at arbitrary locations on the terminal. It isn't just printing out a whole bunch of lines over and over to simulate a frame.
>>
File: 1465586807125.png (319KB, 740x926px) Image search: [Google]
1465586807125.png
319KB, 740x926px
>>56035740
what have you coded?

/g/ bingo
>>
>>56033204
no u.
>>
File: 2016-08-11-192206_443x312_scrot.png (27KB, 443x312px) Image search: [Google]
2016-08-11-192206_443x312_scrot.png
27KB, 443x312px
>>56035663
That's the ncurses part, senpai.
>>
>>56035772
C and Non x86 cpu
>>
    float root = 0.0f;

float sqsr = x*x + y*y + z*z;

__asm__("sqrtss %1, %%xmm0;"
"movss %%xmm0, %0;"
:"=r"(root)
:"r"(sqsr)
:"%xmm0");

return root;


Can anyone help me why this isn't working? the error i get is

C:\Users\User\AppData\Local\Temp\cc5A0cab.s|199|Error: operand type mismatch for `sqrtss'|
>>
File: vape.jpg (4KB, 235x214px) Image search: [Google]
vape.jpg
4KB, 235x214px
> when you get a star
>>
>>56034860
Even after making whole new files im still not in c++11, how do you make sure you change your compiler settings?
>>
guys, I have no idea what the PatterGuards haskell pragmas does
any help?
>>
>>56035772
static public String rot13(String message){
String res = "";
for(char a:message.toLowerCase().toCharArray()){
res += (a>='a' && a<='z') ? (char) (((a -=84) % 26) + 97): a;
}
return res;
}

Has got to be the easiest bingo ive ever played.
>>
>>56035949
-XNoPatternGuards
disable pattern guards
>>
>>56033180
ignoring the fact that problem seems already resolved,

for(Walls walls: wall) {

should be
for(Wall wall: walls)

singular for a variable or field, plural for a collection

scoreArray[i] = true;

can be done with
scoreArray[walls.indexOf(wall)] = true;
>>
>>56033133
Is she a boy?
>>
If i compile something with this line of code:

g++ -std=c++0x main.cpp && .a.out

What would my Makefile have to look like to compile this? My Makefile currently looks like this:
CXX = g++
SRCS = main.cpp
HEADERS =
OBJS = main.o
output: ${OBJS} ${HEADERS}
${CXX} ${OBJS} -o outut
${OBJS}: ${SRCS}
${CXX} -c $(@:.o=.cpp)
clean: rm -f *.o output


semen
>>
changed my mind on if statements

providing you're using MultiWayIf
>>
File: 1466018566117.jpg (539KB, 1920x1080px) Image search: [Google]
1466018566117.jpg
539KB, 1920x1080px
Anyone here familiar with the eyeshot framework by devdept?
>>
>>56035921
A ... star?
>>
Man, we real ded

I'm in the process of learning some Haskell
>>
File: bingo.jpg (162KB, 646x851px) Image search: [Google]
bingo.jpg
162KB, 646x851px
>>56035772
This one was a bit easy imo.. Like do you really consider yourself a programmer if you don't get bingo here?
>>
>>56034779
Yeah it's considered bad C++ but exceptions are bad and tons of other things are 'bad C++' that are generally good. So don't worry about it unless you're being scrutinized by retards with power.
>>
>>56037668

also known as a shithub (you)
>>
File: comfy.png (82KB, 1183x628px) Image search: [Google]
comfy.png
82KB, 1183x628px
>>56037697
Ganbatte!
>>
I'm afraid to leave one programming job for another. Looking for comforting advice and stories. The one Id move to is literally doubling my pay, but I will miss a few of my coworkers. But Im working for so little money...
>>
File: 1551515154215215.jpg (19KB, 250x250px) Image search: [Google]
1551515154215215.jpg
19KB, 250x250px
>His programming language can't multiply a string.

print(100 * "YOUR PROGRAMMING LANGUAGE IS SHIT ")
>>
>>56037912
The * operator is clearly not mathematical multiplication in that case.
>>
>>56037912
What purpose would this serve?
You're multiplying a char pointer by 100,
>>
>>56037912
GHC/Haskell has Data.Semigroup with
stimes :: Integral b => b -> a -> a
mtimesDefault :: (Monoid a, Integral b) => b -> a -> a

>>56037964
Multiplication by a natural number is well defined for monoids (for non-zero it's well defined for semigroups)

It's not about semiring multiplication (i.e. a closed distributive operation), it's about repeated addition
>>
>>56037996
Monoids only have one operation and it's usually denoted by multiplication. Never will you see a * a = 2a in a monoid.
>>
>>56038019
When it's denoted by multiplication you represent the equivalent with exponentiation
Monoids don't always use *, a lot of times people use +
Normally you use the corresponding notation, i.e.

*/1/^
+/0/*

So if you use multiplication
a * a * a
is a^3
>>
>>56038055
And if it's a monoid and not a semigroup, a^0 is the (multiplicative) identity

Similarly for groups, you use negatives for negation

And obviously if you're using +/0/* notation
3n = n + n + n
0n = (identity)
>>
>>56038082
>multiplicative
Whoops, I should say monoidal, because for a monoid with one operation (which is all we care about in the context), there's no difference between multiplicative and additive, it's just notational, I think my point was you use a^0 in multiplicative notation
>>
File: gsl.png (2KB, 367x87px) Image search: [Google]
gsl.png
2KB, 367x87px
>>56037912

My meme language regretfully informs me that math operators cannot be used on strings.
>>
>>56038055
>a lot of times people use +
>a lot
Not in my formal language course.
>>
>>56038119
It depends what you're doing

If, for instance, you're taking the natural numbers under addition as a monoid, it makes a lot more sense to use addition
Similarly if you're adding natural numbers modulo N

Or if you're going to talk about something as a ring or semiring later
>>
>>56037912
main = putStrLn ("L" ++ "OL" * 10)
where (*) = (concat .) . flip replicate
>>
I got hired to use machine learning to replace some indians. literally. the dude that's paying said "I want to know if I can get rid of these indians"

they created the corpus that trains the algorithm that will replace them

is this how the chinese felt when the heavy industry left the US?
>>
>>56038192
Data.Monoid has
mconcat :: (Monoid a) => [a] -> a

(GHC) Data.Semigroup has
mtimesDefault :: (Monoid a, Integral b) => b -> a -> a
>>
>>56038243
Don't worry. Ideally in a few years everyone will be replaced by robots and everyone is just free to do whatever.
>>
>>56038273
>in a few years everyone will be replaced by robots
maybe
>and everyone is just free to do whatever
Nope
>>
>>56038287
You're saying communism will fail even when all production is taken care of?
>>
>>56038273
well these indians sure won't. I mean they have a shitty job, but at least they can feed their kids I guess
>>
>>56038315
They're software developers at an outsourcing company. The turnover rate is absolutely massive. It's not rare for people to move roles in single digit months. You're not making a difference.
>>
So I have this code here:

#include <iostream>
#include <GLFW/glfw3.h>

int main(int argc, char **argv)
{
if (!glfwInit())
return -1;

GLFWwindow *window;
window = glfwCreateWindow(640, 480, "opengl", NULL, NULL);

if (!window)
{
glfwTerminate();
return -1;
}

glfwMakeContextCurrent(window);

while (!glfwWindowShouldClose(window))
{
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
glfwPollEvents();
}

glfwTerminate();
}


But it's basically C, I want to C++ify it.
How do I do that? Objects? Exceptions?
Can somebody give an example please?
>>
>>56038243
I call bullshit.
>>
>>56038352
>I have this program, but I want to ruin it.
Why?
>>
>>56037708
do you have a github, so i can see your "bingo"?
>>
File: merry mfw.png (18KB, 78x77px) Image search: [Google]
merry mfw.png
18KB, 78x77px
>>56038352
what
>>
>>56038352
No need to shoehorn it into oop if it's such a small program.
>>
>>56038352
the code you posted is valid C and C++.

stop being retarded please
>>
>>56038367
>>56038382
>>56038386
>>56038391

guys...I think we were all baited
>>
>>56038399
Don't really care
>>
>>56038352
This is a setup for GLFW. A library which isn't OOP. Avoid C++ in that part. If you want to do something to C++'ify it do that between glClear and glfwSwapbuffers.

You should have your program in there.

If you really want to shoehorn OOP just make a class, have an init function where you do all the lines from the first line in main to the while loop. Then make a method "run" that contains the while loop. Instatiate the class in main and do run.
>>
>>56038428
but i want to impress some friends.

can't you transform that code to C++?
>>
>>56038428
make that class child of an interface class, and instantiate using a factory
>>
>>56034920

>making games

also
>that pic
>an infantile cartoon
>>
>>56038428
You can do OOP in C and that's exactly what GLFW is doing, although adding an other layer of OOP on top of it with sepples would be retarded.
>>
>>56038456
A window handle makes it OOP? I haven't really read the GLFW source but the interface is not OOP.
>>
>>56037990

string literals are const char[], fag
>>
how do I fold this data structure
data Tree a = Node a [Tree a]
>>
>>56038454
>infantile
>>
>>56038476
Abstraction is OOP.
>>
>>56038367
>>56038382
>>56038386
>>56038391
>>56038399
I've written graphics applications in C before and it was a real mess after a while.
I want to use C++ now, why is that so outrageous to you?
Surely there is a better way than just leaving it like this, maybe use smart pointers for the window handle?
Sheesh, I ask a simple question and everybody thinks I'm "baiting" them.
>>
>>56038352
const auto GLFW = [&](auto a) {
bool failed = !glfwInit();
if (!failed) {
a();
glfwTerminate();
}
return !failed;
}

const auto Window = [&](auto a, auto ... params) {
GLFWwindow *window = glfwCreateWindow(params...);
bool failed = (window == nullptr);
if (!failed) {
glfwMakeContextCurrent(window);
a(window);
}
return !failed;
}

const auto Render = [&](GLFWwindow *window, auto a){
glClear(GL_COLOR_BUFFER_BIT);
a();
glfwSwapBuffers(window);
}


...

int exitCode(bool b) { return b ? 0 : 1; }

int main() {
const auto run = [](GLFWwindow *window) {
while (!glfwWindowShouldClose(window)) {
Render(window, [](){ /*rendering code goes here*/ } );
glfwPollEvents();
}
}

return exitCode(GLFW(Window(run, 640, 480, "opengl", NULL, NULL)));
}

>>
>>56038530
are you a god?
>>
>>56038530
int exitCode(bool b) { return b ? 0 : 1; }

>CSGrad.jpg
>>
>>56038490
>%s/is/is one of the many characteristics of/
>>
>>56038492
the c++ part doesn't come in here, but in the actual development of your program. your graphical application will eventually have things on it (say cubes, spheres, walls). represent those using objects with a draw() routine, that makes an object draw itself, and each frame you just have to call the draw() routine for each object in your world

same with a step(timestep) routine if you want your stuff to move around
>>
>>56038530
This is good. Now it's hard to read. Just what C++ people expect. Can't have professional software without it looking like crap.
>>56038492
C++isms only make it worse.
>>56038490
No. OOP is OOP. Abstraction is abstraction. OOP is an abstraction.
>>56038543
Absolutely correct. It should be a member in a namespace, 0 and 1 should be namespaced static variables or the test should be done in a more explicit fashion with descriptive names.
>>
>>56038484
Either breadth first or depth first

If it helps you think, you can always do

instance Foldable a where
toList (Node v xs) = v : (toList <$> xs)
-- <$> is infix fmap
foldr f s tree = foldr f s (toList tree)


>>56038543
avoids implicit type casting, and is more readable
I know you could just do !b
>>
>>56038569
>OOP is an abstraction.
Well it encompasses more.. But you get me.
>>
>>56038570
wait, what, <*> and <$> are now in the prelude?
>>
>>56038530
>"Hey guys, I want to make this oop"
>FP-ish lambdas all over the code
Are you a retard?
>>
>>56038598
Yes.
>>
>>56038569
The main problem is C++ doesn't have anything like do notation and doesn't have custom operators

The second problem is it's awkward to manipulate variadic lists
You can't for instance do
(auto ... params, auto a)


The third problem is it's not auto&& and auto&& requires forwarding or moving everywhere

The fourth problem is defining functions as lambdas is much nicer than using primitive functions
>>
>>56038598
He wanted to make it more C++. Not OOP.
>>
>>56038598
FP is the new OOP

useful for some applications but memers will try to shoehorn it everywhere because it's cool and trendy
>>
>>56038598
>>I want to make this code OOP
Who said this?

Also if you do want OOP, it actually works out nicer with some things, for instance you could instead do

struct GLFW {
GLFW() { glfwInit(); }
~GLFW() { glfwTerminate(); }
}

struct Window {
Window() { ... create window and put it in variable }
~Window() { ... cleanup window }
window variable
}

int main() {
GLFW _glfw;
Window _window;
window = _window.glfwwindow;

/*code here*/
}
>>
>>56038570
>avoids implicit type casting
>Caring about typecasting integer types to larger integer types
>Has other implicit type casts in the code

>and is more readable
All it does is add stupid noise.
>>
>>56038660
>All it does is add stupid noise.
So?

job-security ftw
>>
>>56038654
>struct instead of class

why
>>
>>56038654
I say nicer, this doesn't have error handling, I just mean that OOP works nicer with the natural syntax

>>56038660
Where are the implicit casts?
If you mean casting TO a boolean, that I normally don't mind, sorry
>>
>>56038654
>>56038676
I say OOP, this is really just RAII
>>
>>56038676
>If you mean casting TO a boolean, that I normally don't mind, sorry
Yes I did mean that. With bool's semantics, it isn't that bad, but I really don't get why anybody would give a fuck about conversion to larger integer types. That shit happens all of the time, thanks to integer promotion.
>>
>>56038287
You'll have to work, just not quite as hard. People will be able to support themselves in ways which are seen as luxurious or wasteful before the robotic/AI revolution (like the humanities, or bullshit hipster feelgood startups). Just like math and science were luxurious studies of the rich before the industrial revolution, and textiles and metals were luxuries before the agricultural revolution.
>>
>>56038675
Why would he want a private constructor and destructor?
>>
>>56038730
>robotic/AI revolution
in 200 years maybe
>>
>>56038703
Wasn't the point in all of this to write more crappy code?
>>
>>56038594
I use GHC, I can't speak for normal Haskell
Foldable isn't even standard Haskell prelude
>>
>>56038287
>>56038730

Or, capitalist "you don't work, you don't eat" culture remains ascendant, the Bourgeois retain control, and the entire working population of the world dies of starvation and killing eachother over the scraps of what's left.

Fun!
>>
How can I tell the number of 1 bits of an integer's binary representation, without loops?
>>
>>56038761
actual, sci-fi-like AI? yeah, it could be 200 years, or more. we're not as close as some 'futurologists' like to predict

more utilitarian AIs like self driving cars and self serving checkouts? kinda like the ones that already exist? it won't be as apocaliptic as cgpgay made it seem in his meme video, but it's already happening
>>
>>56038809
GHC is Haskell at this point

HBC is a lost memory~
>>
File: 2016-08-12-002715_558x684_scrot.png (24KB, 558x684px) Image search: [Google]
2016-08-12-002715_558x684_scrot.png
24KB, 558x684px
>>56038809
weird
>>
>>56038829
Recursion
>>
>>56038845
that's just a shittier loop
>>
>>56038804
the idea is now rather than writing

bool function() {
bool failed = glfwInit();
... // non-boilerplate code
glfwTerminate();
return !failed;
}
you just write

GLFW([](){ ... })

or, much better, you write
void function() { ... }

then you call
GLFW(function)

and similarly for the window, except you write
void function(window) { ... }
and call
Window(function, windowparameters)


>>56038813
>capitalist "you don't work, you don't eat"
in other words, communism is either
"you don't work, you eat"
or
"you work, maybe you don't eat"
poetry

>>56038839
what's weird?
>>
>>56038859
It's not a loop though
>>
>>56038863
capitalism doesn't work, though
>>
File: 1266703306620.png (151KB, 500x376px) Image search: [Google]
1266703306620.png
151KB, 500x376px
Why is Gradle such a piece of shit? Why does Debian testing have a fuckold version that can't be used to build anything, and why is it literally impossible to build Gradle from source?
>>
>>56038881
op was probably looking for some clever bitwise operation straight out of the 70s
>>
>>56038829

https://graphics.stanford.edu/~seander/bithacks.html

Save that for other low level stuff, I learned a lot about bit twiddling from it.
>>
File: absolutely halal.jpg (12KB, 232x206px) Image search: [Google]
absolutely halal.jpg
12KB, 232x206px
>>56038932
>>
>>56038761
Well yeah, I'm not saying this is gonna happen overnight. It will take generations but we will get there. Or maybe we'll build all of this on the assumption that alternative energies will match the power current ones, fail to find these alternatives, and without the ability to power their tech the 5th or so generation of people who don't actually know how to do anything get cast into the stone age. It'll be like a species-wide sitcom.

>>56038813
Of course that will persist but I doubt it will be that extreme. The thing about easily producing goods is that individuals don't have to work as hard-- at whatever it is they're doing-- to avoid being homeless or dying of starvation. There will still be a concentration of wealth and plenty of high-crime areas sure but it won't be as much a struggle to survive. Within a population, comparative wealth is determined by how hard/well you work, but overall wealth and wellbeing is determined by what the sum of that work actually produces. And advances in technology will multiply that production enough that you might envy your neighbor, but at least you'll never have to live like your dirtfarming 2016 ancestors did, when manual labor was super common.
>>
>>56038813
Seems incredibly cynical. Given that there's pressure towards the left even now it seems unlikely.
>>
How would I go about writing a synthesizer?
>>
>>56038932
>Patented variation:
>r = (v ^ mask) - mask;
Well done america.
>>
>>56038892
if you are going to dev in ubuntu/debian, don't use packages from the repos (except for C/C++). either download/install manually, or install them from PPAs.
the repos will mess your shit, and you'll find lots of bugs
>>
>>56039044
> On August 13, 2006, Yuriy Kaminskiy told me that the patent is likely invalid because the method was published well before the patent was even filed, such as in How to Optimize for the Pentium Processor by Agner Fog, dated November, 9, 1996
>>
>>56037912
for (i = 0; i < 100; i++) {
puts("No you");
}
[/cpde]
>>
File: zhnnip.jpg (22KB, 201x200px) Image search: [Google]
zhnnip.jpg
22KB, 201x200px
>ctrl-f rust
>nothing

Let's get this shit going
>>
>>56039237
He said multiply strings, not multiply IO side effects
>>
File: a language you can't believe in.png (211KB, 638x592px) Image search: [Google]
a language you can't believe in.png
211KB, 638x592px
/Rust General/ - Embedded Edition

This is Rust General, embedded in /dpt/
All posts for rust general should quote this post so they can all be linked together


Don't know what Rust is?
No need to panic!!
https://doc.rust-lang.org/stable/book/
>>
>>56039283
I like Rust, but please don't. Just make a thread.
>>
File: 079567490005.jpg (107KB, 900x900px) Image search: [Google]
079567490005.jpg
107KB, 900x900px
>>56039249
>>56039283
>>56039320
squirt squirt squirt
>>
>>56039320
I'm trying to bring back the spirit of last year's /dpt/
>>
>>56039256
for (i = 0; i < 100; i++) {
a[i] = "Happy now faggot?";
}
>>
>>56038352

I suppose you make a window class.

instead of updating your shit in a while loop you give it an update() method. call this inside of your program's main loop.
>>
>>56039365
result isn't a string
>>
File: Routine_feb14[1].jpg (998KB, 1842x937px) Image search: [Google]
Routine_feb14[1].jpg
998KB, 1842x937px
hey /dpt/ I wanna write my own video game engine what do I need to know?
>>
>>56039650
You need to know that /dpt/ aren't fans of /v/
>>
>>56039650
1. Don't.
2. Seriously, don't do it. I'm begging you. For god's sake, don't throw your life away.
3. Fine, if you're gonna be stubborn about it, then write a specific game, not just a general purpose engine. That way you're only spending time on the features you need, not features that sound neat and that nobody will ever use. And wherever possible, build on existing graphics/input APIs (like SDL) and existing entity management frameworks. Find an existing library that implements an ECS (entity-component-system) architecture, and work within that to build your game. Figure out how to separate your display system from your physics system and your input system. Figure out how to separate your health system from all of the above.
4. If you ignore the above and write your own entity management code, there's no hope for you.
>>
>>56039650
Just use unreal engine lmfao
>>
>>56039761
>Find an existing library that implements an ECS (entity-component-system) architecture
links to some samples

hopefully none that use that godawful "manager" system
>>
File: dang.png (361KB, 1119x926px) Image search: [Google]
dang.png
361KB, 1119x926px
>>56035772
No bingo
>>
>>56039794
minimal deployed game size is fucking massive. No thanks

https://answers.unrealengine.com/questions/252073/size-of-the-duild-is-too-large.html
https://answers.unrealengine.com/questions/68812/best-way-to-make-your-build-size-lower.html
VM3779:1 https://answers.unrealengine.com/questions/144136/how-to-reduce-html5-package-size.html
VM3779:1 https://answers.unrealengine.com/questions/150470/package-size-for-c-blank-project-is-699mb.html
VM3779:1 https://answers.unrealengine.com/questions/102167/slate-taking-30mb-in-build-size-on-mobile.html
VM3779:1 https://answers.unrealengine.com/questions/105454/toooooooooooooo-large-file-size.html
VM3779:1 https://forums.unrealengine.com/showthread.php?55194-Bad-performance-and-huge-package
VM3779:1 https://forums.unrealengine.com/showthread.php?9179-Export-package-so-friends-can-test-your-game-terrible-experience
VM3779:1 https://answers.unrealengine.com/questions/70842/why-are-android-file-sizes-so-big.html
VM3779:1 https://forums.unrealengine.com/showthread.php?58334-How-to-optimize-the-apk-package-size
VM3779:1 https://forums.unrealengine.com/showthread.php?60629-Reduce-game-package-size-for-download-through-dropbox
VM3779:1 https://answers.unrealengine.com/questions/185365/reducing-size-of-windows-package.html
>>
>>56039848
>simple room
>724 megabytes

what the godfuck
>>
Hey guys, are How To Program 2nd Edition and SICP still relevant? Both use Scheme/Lisp, the former of which has become Racket now. I'm not a beginner programmer, I've been using Python for seven months now and reading into this book makes me feel like I'm wasting my time. It's offering astute abstract concepts, sure, but I'm not sure if any of this doesn't fall under the umbrella of common sense programming.

Kinda tl;dr: Should I be reading HTP,2E and SICP if I already know how to program in Python?
>>
>>56039841
>no functional code
why?
>>
File: bingo.png (384KB, 740x926px) Image search: [Google]
bingo.png
384KB, 740x926px
>>56035772
BINGO NIGGER
>>
>>56035772
i've done all except
1. code actively used by others
2. non-x86 cpus
3. contributed to foss
4. self-bootable code
5. cluster
>>
File: 1470343533729.jpg (45KB, 421x445px) Image search: [Google]
1470343533729.jpg
45KB, 421x445px
>>56039980
>i've done all except code actively used by others


never change /dpt/
>>
>>56039995
i went to college and after that i started working as a dba you cuck. i only code for myself ever since
>>
>>56040016
What the fucks the point then. Programming as a hobby is one of the most autistic things you can do.
>>
Is two-factor authentication a good idea or is it placebo for the customer?
>>
>>56039900
I haven't done anything except for Hello World and the Game Ai/Puzzle Solver
I've spent hours and hours learning code and feel like I've doen nothing with my time. I don't even know what to make. It seems that even creating something as simple as a graphical interface requires you to be knowledgeable of countless GUI modules. It's crazy, and a bit frustrating.
>>
>>56039761
Alright thanks, I'll heed your advice. I'm doing this to learn as much as I can so every little bit of info helps.
>>
>>56039804
Also interested in this.
I'm looking at a book made by the guys who made the ultima games. Seems like a good book so far but it's big on description and light on code.
>>
>>56037708
yep pretty easy, I've done most of this shit in a few months

I'd suggest some fields like:
- program while taking a shit
- skip meal/sleep because of programming
>>
>>56040035
you have a reading disability
>>
File: IveMadeALotOfShitButNoOneUsesIt.png (292KB, 740x926px) Image search: [Google]
IveMadeALotOfShitButNoOneUsesIt.png
292KB, 740x926px
>>56035772

Probably half of this or more was during my Bachelor's, some of it was during my Master's (i.e. the kernel code). A couple of things were on my own (bootable code)
>>
>>56039075
That that's even a concern is the real problem though. I could get that some larger set of code could have some legal aspects to it but 2 operations. That's really pushing the limit of what's even possible to feasibly legally have a patient for.
Like, you can't go below that.
>>
>>56034563
>needlessly allocating on the heap
Please fuck off.
>>
>>56038813
>capitalist "you don't work, you don't eat" culture
That's a socialist mantra, dumb commie.
https://en.wikipedia.org/wiki/He_who_does_not_work,_neither_shall_he_eat
>>
>>56040080
>>56039761
this is fucking awful advice written by an amateur
strict ECS is a meme, and
using an entity management framework is stupid (at that point you're not making your own engine and might aswell use unity)
>>
>>56034770
God I hate C++.
Someone please execute the committee immediately.
>>
>>56040144
>implying it fucking matters.
>>
>>56034770
Or just write Test() instead of declaring variables.
>>
>>56040109
>>56039841
Do you even know what functional code is? You probably did plenty of functional programming
>>
>>56040165
>own engine
>add ecs framework
>it's now like using unity
No anon come on that's not even close to true. Unity has an entire content pipeline and means of wrapping your code into their environment. Same with most engines. In fact it's probably what differentiates them from frameworks the most.
>>
>>56040189
if your game engine consists of third party graphics/audio frameworks and and an entity management framework, what exactly is it that you've programmed yourself?
>>
>>56040183
I presumed it was meant as 'writing functional code in a in a functional language'.
Pretty much anyone has written functional code otherwise obviously. By mistake at least.
>>
File: 1448118121269.png (404KB, 740x926px) Image search: [Google]
1448118121269.png
404KB, 740x926px
>>56035772
What do I win?
>>
>>56033180
NIGGA THAT AIN'T HOW YOU USE A FOREACH LOOP
>>
>>56040183
it says haskell, lisp, f#, etc.

so functional code in actual functional languages with functional datatypes

not using C# linq
>>
>all of these people who've only written dysfunctional code
>>
>>56040183
>functional code
ah thanks, some how did not cross it.
Still no bingo
>>
>>56037912

rubyist@Overmind:~$ irb
irb(main):001:0> 100 * "this shouldn't work"
TypeError: String can't be coerced into Fixnum
from (irb):1:in `*'
from (irb):1
from /usr/bin/irb:11:in `<main>'
irb(main):002:0> "this works" * 100
=> "this worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis worksthis works"
irb(main):003:0>


>>56040183

Yeah, but I struggle to think of anything non-trivial that I've done in a real pure functional style. Although now that I think of it, I had a discrete math class that used racket for its exercises, and the professor forbid us from using set! and such, so I guess I have.
>>
>>56040196
Depends on how complicated the engine is but you could have dynamic code reloading modules, asset loading system, input handling (which is not as trivial as bad-game programmers think), physics system (well arguably this could be a 'game' thing rather than an engine thing but yeah).

There's plenty to do.
But I agree that if you use audio/graphics frameworks and avoid messing with them completely you're rather limited in those departments.
>>
File: my_chart.png (355KB, 740x926px) Image search: [Google]
my_chart.png
355KB, 740x926px
I'm oddly balanced.
>>
>>56040215
well that bingo is retarded, Lisp is not a typical functional language anyway
>>
>>56040238
the meat of a game engine is the graphics system and the entity management system and possibly a script system, input handling IS easy and an asset/resource system is pretty easy aswell
>>
>>56040215
>lisp
(defun fib (n)
(prog (a b)
(setf a 0
b 1)
LOOP
(if (zerop n)
(return a))
(setf (values a b)
(values b (+ a b)))
(go LOOP)))

wow, so functional
>>
>>56040204
The shame of being a lonely nerd who fills in 4chan programming bingo charts.
>>
>>56040173
Please never touch a computer again.
>>
>>56040254
wow you can write OOP in F# too! With mutable and for loops!
>>
File: le jeez kasich.png (21KB, 394x252px) Image search: [Google]
le jeez kasich.png
21KB, 394x252px
>>56040267
>gotos
>OOP
>>
>>56040276
the argument about a functional language, not the code posted poltard
>>
>>56040253
Everything is pretty easy. The point of an engine is convenience for the user. That's why there's many of them.

Really if the idea you have of a game engine is just 'graphics, audio and ECS implemented' then maybe youre not thinking of a game engine?

The idea behind using frameworks for things is to excell in other areas obviously. So the inclusion of such things imply he's making cooler stuff elsewhere.

But I agree on some level that if he's building into something it becomes less of his own engine. As using frameworks can often shape your own code.
>>
>>56040254
pretty much, ignoramous made that bingo Lisp is not primarily a functional language, no where near actually there are no contructs that encourage functional style by the language designer. Well speaking of Common Lisp atleast

Why is Lisp clobbered together with functional languages in the first place, I wonder
>>
File: Stormweenie.jpg (67KB, 476x717px) Image search: [Google]
Stormweenie.jpg
67KB, 476x717px
>>56040276
>poltard not getting the point
typical.
>>
>>56040276
javascript is considered a OOP language.
That shit is gotos all over
>>
>>56040276
>>56040285
>>56040294
Oh god, they're going to derail the thread with /pol/ and anti-/pol/ shit again.
>>
>>56040276
How do people know this post is pol. Am I ignorant?
>>
>>56040292
a decent rendering system is about 50 times the size of an input handling system
and if you boil it down to a sentence, a game engine is basically a graphics, audio and entity management system (not neccessarily ECS)
most things above that are usually specific from game to game and not really 'engine' material
which is basically my point as if you're outsourcing all of those you're adding nothing significant of your own and might aswell use a premade game engine like unity
>>
>>56040313
Guess it's because it has a presidential candidate in the pic. People will react to just about anything to force /pol/ shit into the discussion.
>>
>>56034920
>The same language used to write one of the most iconic games today. Said game made hundreds of millions of dollars.
Found the retard
>>
>>56040300
wtf what was wrong with that post?
>>
>>56035772

Hmm not bad 6 squares left. I've never actually implemented a binary tree oddly enough it's also been prebuilt in a library. I do not know how I've managed to avoid reinventing the wheel on that one for so long.

non-x86 cpus I did think about doing some things on a raspberry pi but never went through with it. I also looked into snes / nes game hacking but never really did anything with it outside of a few cheats.
>>
File: bingo.png (332KB, 740x926px) Image search: [Google]
bingo.png
332KB, 740x926px
>>56040372

Inb4 I forget to post the image
>>
File: B_NG_.png (342KB, 729x917px) Image search: [Google]
B_NG_.png
342KB, 729x917px
>>56035772
Lonely R user here. Thinking of moving on to a more general language. Check means confidently done. Squiggle is more "technically" done. Each squiggle has its own caveat.

>>56040351
I forgot that R was, by nature, object-oriented so I added a little squiggle. This is maybe more of an indulgence then some other squiggles. Also autism.
>>
>>56040318
Well that depends on the scope of the audio and rendering stuff.

I certainly don't agree that it's 50 times smaller to have a good input handling system for a game engine. It has to be asynchronous, handle and abstract input in a way that allows for convenient access to both a very granular view of the input information and an abstracted set which would be for more casual use.

Sure, if all you're doing is a keyisdown function or whatever that's waaaaaaaay less than a 50th of a rendering system. Even if we think of a rather trivial system. But as a game engine it should be doing more.

And let's say he's using something like SFML. Is that really the interface you want for the user?

We're covering a rather big topic here and with game engines it's usually a balance between ease of use and flexibility. That he's using a graphics framework just means he put an upper bound on the flexibility (assuming no framework modifications in which case this argument becomes kinda pointless).

But anon wanted to learn to write a game engine. Not Opengl. I certainly think using a graphics framework would help him spend his time constructively.

And ECS has similar flexibility VS convenience concerns.
>>
>>56039464
So I've done this:

class programWindow
{
GLFWwindow *windowHandle;

public:
programWindow(GLFWwindow *rawWindowHandle) : windowHandle(rawWindowHandle)
{
std::cout << "Constructed" << std::endl;
}

~programWindow()
{
std::cout << "glfwTerminate()'ed ;)" << std::endl;
glfwTerminate();
}
};


But now I can't access my windowHandle because it's private.
Should I just make it public or is there another way?
>>
>>56035772
What does writing non-x86 code imply? Writing code with a non-x86 system in mind and making different decisions based on that or writing non-x86 platform specific code?
>>
>>56034920
>same language to make what is now an iconic game and said game made hundreds of millions of dollars.
Retard detected
>>
>>56040414
Have a get function for it or implement a wrapper for every interaction you want to do with the window handle.
That's the truly cancerous way.
>>
>>56040427
But I've heard bad things about getters and setters, wouldn't that make my class a quasi-class?
Is my class already a quasi-class?
>>
>>56040350
>>56040416
And those who have continued the development have severely degraded the performance of the product due to their use of the language:
https://m.reddit.com/r/programming/comments/2jsrif/optifine_dev_minecraft_18_has_so_many_performance/
>What happens when the game allocates 200 MB memory every second and discards them immediately?
>>
File: 1470743205649.jpg (136KB, 960x1280px) Image search: [Google]
1470743205649.jpg
136KB, 960x1280px
Quick! This girl is really jealous of your 2D waifu so much that she's going to hack her out of existence unless you manage to find three ways to make the program below to print 20 copies of the dash character '-' by changing/adding only one character:

int i, n=20; 
for (i=0; i < n; i--) {printf("-");};
>>
>>56040441
I'm not gonna try to do true OOP. Yes. Setters and getters are not a pure OOP construct. You should be sending messages to this window rather than accessing the variable directly.
>>
>>56040447
The language is C, by the way.
>>
>>56040447
Add 4 in int i=0 (so it says 40)

But my wife is real and can't be hacked out of existence so. Good luck with that jealous Korean girl.
>>
>>56040400

I really think you're overstating just what is necessary for a solid input system for a game.

You really can get away with just a stack of input events / mouse and joystick movement handled in a separate thread. The configuration and complexity is all on the user's end.
>>
>>56040469
>can get away
Well you can also get away with storing a translation, rotation and a texture reference to your sprite. Make a simple array which is looped over for drawing and call that your renderer.

It really isn't any different. Just writing the minimum possible engine is really easy yes. But let's not hold different standards for the different parts of the system. I find input very important and people like the fighting game community would easily get pissed as you if you're being lazy there.
>>
>>56040447

Change i-- to n--.

Praise me.
>>
>>56040447
adding ; after printf("-")
adding ; at the end
adding ; after n=20;
>>
just goin though the xmonad source code
why do some records have a bang before their types?
like in pic related
the only pragma within XMonad.Stackset is PatternGuards
btw
>>
>>56040491
Im pretty sure fighting games, like every other game, just grab the system input events at the start of the frame and send them to whatever other part of the game that needs them
it takes like a page of code
>>
>>56040540
it means it's strict
>>
>>56040549
I though only BangPatterns caused that
>>
>>56040491

Buffered input like I'm describing is very common in fighting games. As long as you're polling at a consistent fixed predictable rate (inputs polled / processed every y milliseconds) defined by the user.

I'm just saying in a generic engine anything overly complex will really risk being needlessly specialized and annoy the users more than help them.
>>
>>56040427
Actually it's fine I just absorbed all the code into my class and it werks pretty well.

#ifndef OPENGL_H
#define OPENGL_H
#include <iostream>
#include <GLFW/glfw3.h>

class programWindow
{
GLFWwindow *windowHandle;

public:
programWindow() :
windowHandle(glfwCreateWindow(
640,
480,
"OpenGL",
NULL,
NULL))
{
if (!windowHandle)
std::cout << "error XD" << std::endl;

glfwMakeContextCurrent(windowHandle);

std::cout << "Constructed" << std::endl;
}

~programWindow()
{
std::cout << "glfwTerminate()'ed ;)" << std::endl;
glfwTerminate();
}

void run()
{
while (!glfwWindowShouldClose(windowHandle))
{
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(windowHandle);
glfwPollEvents();
}
}
};
#endif /* OPENGL_H */


#include <iostream>
#include <GLFW/glfw3.h>
#include "opengl.h"

int main(int argc, char **argv)
{
if (!glfwInit())
return -1;

programWindow window;
window.run();
}
>>
>>56040556
https://wiki.haskell.org/Performance/Data_types#Strict_fields

dunno if it's standard or just GHC
there are a few deprecated language extensions though
>>
>>56039857
Anyone?
>>
>>56040543
What I described for a renderer is like a 20 line function, a static array of vertex, the basic opengl stuff you do to set things up. And an array of structs containing rotation, translation and a gluint. Very close to a page of code.
>i think fighting games
Some may do that. But even games like Braid do more complicated things. I doubt serious fighting games don't use sub-frame input handling.
>>
Im working on web based controller for mpd might add config editing later
>>
>>56040557
>I'm just saying
Well I'm confusing people then. I was arguing with someone who was thinking that there's not much more to do in an engine besides ECS, rendering and audio. Assuming those three are external to the engine code.

But I think there's potentially plenty.

And I agree that adding tons of stuff can be bad. But the reason there's a lot of engines is because of developer preferences.
>>
>>56040414
GLFWwindow& operator*() {
return *windowhandle;
}
GLFWwindow *operator->() {
return windowhandle;
}

And you can treat your instances like GLFWwindow pointers directly, if this style suits you. That's basically what smart pointers do and it's logical IMHO.
>>
Can someone explain to me "scripting".

Like "learn C++, and python to write scripts for your c++ program"

What the fuck does that mean?

Is writing in python not just continuing to program?

And also how the fuck does one work within the other?
>>
whats the easiest way to set up an opengl context.

Just the context and not actually a window. Like if I just wanted to render one frame of a glsl shader and get the pixels from it
>>
>>56040572
then you sample the input multiple times a frame, doesn't change the input handler complexity at all
it's also completely pointless to do it multiple times a frame because a frame is the smallest possible feedback unit the user has, jonathan blow is just an idealistic tryhard who doesn't understand practical code
Your example falls short because an input handling system for most games is about a page and even a basic rendering system in openGL for most games is like 20-50
>>
>>56040462
>>56040499

anyone got the third one?
>>
>>56040617
scripting is like a lighter, less close-to-the-metal form of programming. it's not really a formal definition. Engines are better suited to being made in C and C++ for speed of execution and reliability but gameplay logic is better off "scripted" in Python or Lua for speed of development and flexibility. They're both programming.
>>
Is there some sort of babby developer starter pack for >windows? Something that installs compilers and interpreters for the most common languages along with a good text editor and a debugger?
Or do I just have to download them all one by one as I need them?
>>
>>56040634
Visual Studio
>>
>>56040617
The idea is your C++ program has an interpreter, an interpreter is like an on-demand compiler and executer. You have an interface between the C++ and the interpreted scripts and the scripts can be changed without recompiling the C++ program
>>
>>56040634
Visual Studio Community Edition seems like it's just what you need.
>>
>>56040645
>>56040633

Thanks that helped somewhat
>>
>>56040645
Won't that be a vulnerability ripe for exploitation?

t. clueless about security fag
>>
>>56040661
generally you run the scripts in a sandbox, they can only call the functions that the base program provides them, they can't mess with the users system in any way (unless you provide the functions for it to do it)
>>
>>56040598

Well I'm the guy saying you're overstating what is necessary for a solid input system. It's generally going to be a very small percentage of your code in a game. Honestly, the bulk in most projects is Rendering, Physics, and Systems (Scripting, Save / Load, Dialog / menus, Scripting). In modern games I'd even go so far as to say the rendering system is the most important thing to get right. People just constantly circle jerk about graphics in this modern era. It's very sad and why I've been massively disappointed with a lot of modern games.
>>
>>56040649
>>56040641
Yea that looks pretty good thanks.
>>
>>56040598
stop assuming all entity management systems are ECS
>>
File: 2016-08-12-040548_111x30_scrot.png (480B, 111x30px) Image search: [Google]
2016-08-12-040548_111x30_scrot.png
480B, 111x30px
wtf, why not just make make an empty stack mean that there's nothing in the workspace
did he really have to make it a Maybe?
>>
>>56040696
Maybe he uses some some Maybe functions on it
>>
>>56040668
That makes sense.
>>
>>56040708
we'll see
hopefully it all comes tumbling down and finally make sense in my brain
>>
>>56040695
>>56040598
If you are creating your own game engine, why not use something low level like opengl and just do everything else by yourself. Thats where fun and learning opportunities lie. Creating your own ecs is great thing.
>>
>>56040617

Scripting is just programming using a scripting language. Personally, I define a scripting language as one wherein the source code and executable file are one and the same. That is, there is no ahead of time compilation to either machine code or bytecode.
>>
>>56040598
>I was arguing with someone who was thinking that there's not much more to do in an engine besides ECS, rendering and audio
I don't think that, those are just the biggest subsystems of a game engine (well audio isn't big, I'd say rendering, scripting and entity management) and if you outsource those you're not really making your own engine in the first place
>>
File: 1469643738953.png (541KB, 1280x720px) Image search: [Google]
1469643738953.png
541KB, 1280x720px
>>56040617
In general scripting is done in interpreted languages in contradistinction with compiled languages, although full-fledged programs can be written in scripting languages.
Languages like bash and perl are typically only used to write scripts, whereas python is typically used for full programs but is also an excellent language for writing scripts depending on the task at hand.
The difference between programming and scripting is not rigorously defined; the informal definition of scripting in my view is that pure scripting generally involves interfacing with the system from -above- the API level.
So in a programming language there is usually an API to interface with, such as the unix sockets API for network programming in C, but with a bash script one might simply invoke curl from within the script.
>>
Hey guys, are How To Program 2nd Edition and SICP still relevant? Both use Scheme/Lisp, the former of which has become Racket now. I'm not a beginner programmer, I've been using Python for seven months now and reading into this book makes me feel like I'm wasting my time. It's offering astute abstract concepts, sure, but I'm not sure if any of this doesn't fall under the umbrella of common sense programming.

Kinda tl;dr: Should I be reading HTP,2E and SICP if I already know how to program in Python?
>>
>>56040814
>>56040762
Thanks go to you two, as well!

Im off. Thanks to all that replied.
>>
>>56040857
Idea is to learn to program, not to learn to program in X. Once you learn to program language mostly doesnt matter unless its paradigm shift. Those books do teach programming so if you dont know to program, maybe?
>>
>how do i learn to program
isn't this literally like asking "how do i learn to swing hammer?"
>>
>>56040915
And answer,in case anybody is wondering, is: by swinging it.
>>
>>56040696
What does the maybe() construct do?
>>
>>56040931

It either contains a type or nothing. (Just something or Nothing generally)
>>
>>56040931
Its monad over type T
Maybe T can be T or Nothing

Its quite nifty, for.eg my function foo can maybe return error
Much better than doing std::throw_runtime_error in c++ xD
>>
NEW THREAD!

>>56040962
>>
>>56040696
I believe Stack can't be empty. It's a pointedlist I think.
>>
>>56040957
>>56040951
I can't think of a single use case where you'd want to maybe create a type or not.
>>
>>56040971
explane
>>56040974
it was made for possible error
for example
we wanna try to find something in a list
if we find it, we return just that item, or nothing
we have to return something in haskell, always, and Nothing is an acceptable value, thats why its useful
more formally
data Maybe a = Just a | Nothing
>>
>>56041009
yeah i don't understand your weird idioglossia at all
>>
>>56041017
fp is different
it wont make sense unless u try it
>>
>>56041017
class Maybe<T> {
Maybe<U> Map(Function<T,/*to*/ U>);
}

class Just<T> extends Maybe<T> {
T value;
Just(T x) { value = x; }
Maybe<U> Map(Function<T,/*to*/ U> f) {
return Just<U>( f(x) );
}
}
class Nothing<T> extends Maybe<T> {
Nothing() {}

Maybe<U> Map(Function<T,/*to*/ U>) {
return Nothing<U>();
}
}
>>
>>56041017
>>56041069

It's a container that has at most 1 element
i.e. it's either [] or [x]
Thread posts: 318
Thread images: 39


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.