[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: 329
Thread images: 26

File: abstraction.png (1MB, 1200x1198px) Image search: [Google]
abstraction.png
1MB, 1200x1198px
What are you working on, /g/?


Previous Thread: >>57333561
>>
>>57339284
We must go smaller, there has to be a way.
>>
>>57339289
just coded my first rock paper scissors. new to programming so it's literally babbys first program.
>>
>tfw drowning in (You)s
>>
>>57339310
You can shave off two characters by removing a set of extraneous parentheses

d=q=>document.querySelector(q);d("#p"+localStorage["4chan-track-g-"+d("[name=res]").value].match(/(\d+)":1}/)[1]+" input").checked=1;d("#delform").submit()
>>
>>57339337
Actually we can probably just do
d=document.querySelector;d("#p"+localStorage["4chan-track-g-"+d("[name=res]").value].match(/(\d+)":1}/)[1]+" input").checked=1;d("#delform").submit()

For another 6 character savings
>>
>>57339365
Run all but the .submit() part and it throws an error:
>TypeError: 'querySelector' called on an object that does not implement interface Document.
>>
>>57339365
>Uncaught TypeError: Illegal invocation
>>
>>57339372
Huh, weird
>>
File: 1467570941060.jpg (517KB, 1521x1076px) Image search: [Google]
1467570941060.jpg
517KB, 1521x1076px
>>57339401
Javascript has types?
>>
Can I use Haskell do make vidja?
>>
>>57339441
Haskell is pure, how dare you imagine defiling it like that
>>
>>57339437
dynamically typed =/= untyped
>>
>>57339337
Come on men, almost at 150.

Put your thinking caps on and optimize the shit out of this.
>>
File: shot0033.jpg (310KB, 1920x1080px) Image search: [Google]
shot0033.jpg
310KB, 1920x1080px
daisuki~

Don't be shy to ask anything to your favorite programming literate!

>>57339441
Probably but both carmack and sweeney dropped the idea.

>>57339437
javascript always had types.

>>57338675
https://en.wikipedia.org/wiki/Symbolic_artificial_intelligence

http://norvig.com/paip-preface.html
Note that lisp has been replaced by python since then.
https://news.ycombinator.com/item?id=1803815

>>57339314
Share the code source, please.

>>57339289
Please use an anime image next time.
>>
>>57339461
they're so weak they may as well not exist
>>
>>57339441
Yes.
http://blog.chucklefish.org/wayward-tide-technical-details/
>>
>>57339474
but
if (op.image.isAnime == true)
will happen!
>>
>>57339441
>>57339481
That said, it's probably better to learn Haskell and apply the ideas in a different language, like Rust. Rust shares a lot of similarities with Haskell, and it even has affine types which are just as good or even better at controlling side effects than monads.
>>
>>57339437
Yes actually, it turns out when you make explicit use of them you get pretty optimised code and an interesting target language, hence asm.js
https://www.destroyallsoftware.com/talks/the-birth-and-death-of-javascript
>>
>>57339473
It'd be easier to find the anon that said 150 and lynch him so everybody forgets and we can say 160.
>>
>>57339498
>affine types
>better at controlling side effects than monads
No

>rust
>worth using
No
>>
File: le.gif (471KB, 288x216px) Image search: [Google]
le.gif
471KB, 288x216px
>>57339489
shouldn't you use the isX notation only with a method and not with a variable?

>>57339476
it's actually because they do exist that JavaScript can be this ""weak"".
>>
File: 1470435347349.png (171KB, 966x903px) Image search: [Google]
1470435347349.png
171KB, 966x903px
Why do standard library developers think this shit is acceptable?
>>
>>57339489
== true
>>
>>57339525
Just look at all the gymnastics required for decent resource safety with monads. That particular case is actually what inspired algebraic effects since a monad stack is so damn bad at it.

Meanwhile, it's extremely natural with a substructural type system.
>>
>>57339533
>>57337250
>>
>>57339539
everything in the std must start with __ to avoid conflicts.
>>
>>57339548
>all the gymnastics required for decent resource safety with monads
I'm not seeing them.

Affine types don't achieve what monads do, and only serve to make less features first class.
>>
>>57339489
>>57339553
>tfw you started a meme

I'm so proud of myself
>>
How do you match the end of line character in PCRE? I want a character class to contain the end of the string, but the expression probably won't be at the end of the string so I can't use [class]?$.
>>
>>57339558
>avoid conflicts
With fucking what? these are just local/private variables.
They are local fucking variables, a conflict is impossible.
>>
>>57339558
That's shitty design.
>>
I want to have an array of structs inside a struct and I want to be able to realloc it. So:
struct faggot{
int x;
};

struct people{
struct faggot ** ops; //pointer to array of faggots
};

struct people *4channers;
4channers->ops=malloc(sizeof(struct faggot *)); //pointer to the array
*4channers->ops=malloc(10*sizeof(struct faggot)); //the array

//later
4channers->ops=realloc(4channers->ops, 20*sizeof(struct faggot)); //don't mind the lack of error checking

Is this correct? Am I doing something wrong here or is there a problem somewhere else, because im getting a segm fault after i go to access the "x" in this example after a realloc.
Don't mind minor syntax errors i just wrote it in the reply box.
>>
>>57339314
import random 

count = 0
comp_count = 0
rules = ('''choose 1 for rock
choose 2 for paper
choose 3 for scissors''')
list = (1, 2, 3)
print (rules)

while True:
user_choice = input('user selection: ')
user_choice = int(user_choice)
comp_choice = random.choice(list)

if user_choice == 1:
if comp_choice == 2:
print('computer wins paper beats rock')
comp_count += 1
print('computer has won ', comp_count, '/', '3')
elif comp_choice == 3:
print('you win rock beats scissors')
count += 1
print('you have won ', count, '/', '3')
else:
print('tie')

if user_choice == 2:
if comp_choice == 1:
print('you win paper beats rock')
comp_count += 1
print('computer has won ', comp_count, '/', '3')
elif comp_choice == 3:
print('you lose scissors beats paper')
count += 1
print('you have won ', count, '/', '3')
else:
print('tie')





if comp_count == 2:
print('computer won 2/3')
break
elif count == 2:
print('player has won 2/3')
break
else:
continue



well it's almost finished. I feel lik ethis could be made into one of them cs grad memes.
>>
>>57339607
For "fairness" and lack of entropy you should have the computer decide before the player.
>>
>>57339602
>4channers->ops=realloc(4channers->ops, 20*sizeof(struct faggot)); //don't mind the lack of error checking

that was supposed to be
*4channers->ops=realloc(*4channers->ops, 20*sizeof(struct faggot)); //don't mind the lack of error checking
>>
>>57339337
Wow guys we did it, we got it under 160 characters!
>>
>>57339602
You don't need pointer to pointer. Everything else is fine.
>>
>>57339639
Too bad we can't tweet it.
>>
>>57339570
>I'm not seeing them.
http://okmij.org/ftp/Haskell/regions.html
okmij.org/ftp/Haskell/extensible/more.pdf (the part about regions)

>Affine types don't achieve what monads do, and only serve to make less features first class.
Monads are for more than controlling side effects. We've gone over this a million times. Substructural types are better than monads at controlling side effects only; they have nothing to do with the abstraction aspect.
>>
>>57339639
smaller
>>
>>57339663
>all side effects are IO
we've been over this a million times
>>
>>57339670
DELETE THIS

with this compact less than 160 character piece of code
>>
>>57339675
Yes, actually. Using e.g. Either as a monad can't have side effects since it's just an abstraction over pure code.
>>
>>57339693
So I guess IO isn't a side effect then
>>
>>57339707
What?
>>
File: 1477905651683.jpg (63KB, 480x721px) Image search: [Google]
1477905651683.jpg
63KB, 480x721px
Is PHP worth learning anymore or should I just go full pajeet mode with java or c#?
>>
File: nn.jpg (298KB, 531x717px) Image search: [Google]
nn.jpg
298KB, 531x717px
>>57339489
>== true
>>
>>57339722
i try to know as little PHP as possible. it rots the brain. sometimes you have to use it though, but in those cases i just learn it for a little while and then try to forget
>>
>>57339722
Somebody will say it's worse than Perl, Python, or Ruby backends.
>>
>>57339533
>shouldn't you use the isX notation only with a method and not with a variable?
Why?
>>
>>57339722
http://hacklang.org/
>>
>>57339730
why is she so smug
>>
>>57339754
Probably because it's "live" when it determines it.
Seems fine if using for data constructs/APIs.

Everybody has preferences for naming.
>>
>>57339764
if you were an anime girl you'd be smug
>>
Good if (day.time.isAfternoon() == true) to you.
>>
File: umaruwh.jpg (305KB, 1920x1080px) Image search: [Google]
umaruwh.jpg
305KB, 1920x1080px
>>57339754
IIRC, this convention was introduced by Java; You are supposed to ask a question to the object which is not really the case if you read a variable. It also make easier to avoid conflict with the inner variable.

class Foo
{
bool open;

public bool isOpen() { return open;}
}
>>
>>57339837
I'm surprised Java didn't just roll with "isOpen" and "getIsOpen" which would be a hell of a lot more consistent.
>>
>>57339837
Would you agree then
(...isOpen() == true)
is fucking retarded then?

It asks the same question twice. Or more so it asks the question then "REALLY?".
>>
>>57339865
maybe he works at NASA and that's part of their coding safety standards so he did it automatically
>>
>>57339754
>>57339837
>>57339855
>>57339865
And you should also think about interfaces where you can't define any variables.
>>
>>57339489
> == true

Bb.. bbbba...Ba-aka.
== true
is not kawaii. It's kowai.

Though I think it's appropriate for Halloween.
>>
>>57339865
isIsOpenTrue
>>
S-senpai... I code from there!
>>
>>57339855
you should not think about the underlying data, remember oop is about data abstraction, but only about the purpose of the message.

getX is when you need something
isX is when you need an answer by yes or no.

it's either isOpen or getOpen() but not getIsOpen
>>
>>57339927
Is it a problem to have a field isOpen and a method isOpen?

C#, unsurprisingly, doesn't have this problem because it has properties instead of getters/setters.
>>
>>57339872
source? Besides "I/my (related person) works for NASA :^)"
>>
File: polite code.png (6KB, 308x223px) Image search: [Google]
polite code.png
6KB, 308x223px
>all these rudeposters
>>
>>57339969
i do work at nasa though

we use cinnameg
>>
>>57339969
Not him but some languages might auto cast things to compare them to booleans then you're left with unexpected behavior.

Granted at that point you deserve it since you weren't checking the type you're comparing and clearly let something else reach that point.
>>
>>57339941
properties are against the principles of oop. never rely on them. pure evil.
>>
>>57340006
>properties are against the principles of oop
I'll make sure to start using them immediately
>>
>>57340006
>properties are against the principles of oop
Even better, but how the fuck are you coming to that conclusion in the first place? They're just better getters and setters.
>>
File: 1340509167565_animgif.gif (744KB, 245x300px) Image search: [Google]
1340509167565_animgif.gif
744KB, 245x300px
>>57339289

Someone explain the OP pic? I guess I mean, can someone explain what it means by abstraction and what the last panel is?
>>
>>57339993
The example should use === then to make it clear.

Dynamically typed languages are still retarded.
>>
>>57339872
NASA's requirements are retarded, and everyone besides the dedicated programmers doesn't give two shits.
>>
>>57339941
Sounds like just a naming convention issue, call the private field _isOpen or similar depending on your convention for private field names.
>>
>>57340029
probably an OOP monstrosity of extensions
>>
>>57340068
>>57339337
delete this
>>
#include <stdio.h>
#define x_initial 0
#define y_initial 1

double approx_e(double delta_x) {

double y = y_initial;

for (double x = x_initial; x < 1; x += delta_x) {
y += y * delta_x;
}
return y;
}


int main() {
double delta_x;
printf("Choose delta_x for e approximation: ");
scanf("%lf", &delta_x);
printf("e approximation for delta_X=%lf is: %lf", delta_x, approx_e(delta_x));

return 0;
}


Ai em veri gud mathemater xP
>>
>>57340029
Abstraction means generalizing over certain details so that code can be reused in different contexts.

The last panel is a bunch of random Haskell that isn't all abstraction-related, and out of that entire thing zygohistomorphic prepromorphism is the only example of abstraction gone too far.
>>
>>57340087
>isn't at all abstraction related
>>
>>57340087
so it's like creating classes of things basically?
>>
>>57340068
u r veri bed et koad teg tho cx
>>
>>57340105
whai de buli, aim kyut gorl :(
>>
>>57340095
>inserting the word "at"
Sneaky sausage.

>>57340104
Sort of. Classes generalize over how the thing is used, although that's kind of how things are by default. So classes don't really add any abstraction except when you're doing e.g. subtype polymorphism.
>>
>>57339337
Managed to shave off 1 character.

d=q=>document.querySelector(q);d("#p"+localStorage["4chan-track-g-"+d("[name$=o]").value].match(/(\d+)":1}/)[1]+" input").checked=1;d("#delform").submit()


4 more to go.
>>
>comonads allow you to define either duplicate or extend or both
>monads only allow you to define >>=
FFS Haskell
>>
Hi guys simple question here. Look at this simple program that counts words in a sentence.
// Function to determine if a character is alphabetic

#include <stdio.h>
#include <stdbool.h>
bool alphabetic (const char c)
{
if ( (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') )
return true;
else
return false;
}
/* Function to count the number of words in a string */
int countWords (const char string[])
{
int i, wordCount = 0;
bool lookingForWord = true, alphabetic (const char c);
for ( i = 0; string[i] != '\0'; ++i )
if ( alphabetic(string[i]) )
{
if ( lookingForWord )
{
++wordCount;
lookingForWord = false;
}
}
else
lookingForWord = true;
return wordCount;
}
int main (void)
{
const char text1[] = "Well, here goes.";
const char text2[] = "And here we go... again.";
int countWords (const char string[]);
printf ("%s - words = %i\n", text1, countWords (text1));
printf ("%s - words = %i\n", text2, countWords (text2));
return 0;
}
10 0672326663 CH10 6/10/04 2:05 PM Page 211
Program 10.7 Output
Well, here goes. - words = 3
And here we go... again. - words = 5
>>
>>57340068
>>57340084
#define x_initial 0
#define y_initial 1

wtf???

Also that's a horrible way to approximate e. All you have to do is remember it
2.718281828459045
That was my password for a while.
>>
>>57340174
>not less than 160 characters
Are you even trying?
>>
>>57340174
>
if ( alphabetic(string[i]) == true )

fixed that for you
>>
>>57340174
>>57340194
>>57340201

Forgot to ask the question lmfao. My question is about this for loop:
for ( i = 0; string[i] != '\0'; ++i )
if ( alphabetic(string[i]) )
{
if ( lookingForWord )
{
++wordCount;
lookingForWord = false;
}
}
else
lookingForWord = true;

Why does the function only count the first letter only? I understand that it turns into false after the first letter, but does that mean that it stays false through out the end of the word until someting OTHER than a letter appears? If so, why?
>>
>>57340212
:thinking:
>>
Can I do programming on Windows?
>>
>>57340277
painfully
>>
>>57340212
for (i = 0; string[i] != '\0'; ++i) {
if (alphabetic(string[i])) {
/* ... */
} else {
lookingForWord = true;
}
}


It stays false because the statement
lookingForWord = true;
can only be reached if alphabetic(string[i]) == false, a.k.a. "something OTHER than a letter appears".
>>
Can I do programming in Assembly?
>>
>>57340277
>>57340319
It would be extremely painful
>>
>>57340293
So let me get this straight, boolean expressions (at least this one) could be thought of as a "switch" that you can turn on and off? That's more or less the behaviour of
 lookingForWord 
here. First is on aka "true", then we turn it off after we find an alphabetical letter, and then turns back on after we find a non-alphabetical letter.
>>
>>57340184
it's not cheap on resources but I find it to be pretty cool. can always recalculate it and dump the value somewhere.
>>
>>57340006
Hahaha

What the fuck
>>
>>57340337
but "recalculate" I meant "calculate it before-hand".
>>
>>57340326
For me?
>>
>>57340006
Don't let transgenders know about properties.

They'll say the objects were born with the wrong ones.
>>
>>57340166
Here you go, anon. 145 characters.

d=q=>document.querySelector(q);d("#p"+localStorage["4chan-track-g-"+d("[name$=o]").value].substr(4, 8)+" input").checked=1;d("#delform").submit()


It will need updating when post numbers reach the 100 millions. but that's a long long way off.
>>
>>57340347
#define x_initial 0
has literally the same effect as
const int x_initial = 0;
>>
>>57340389
but does it really matter?
>>
>>57340336
>boolean expressions
lookingForWord is a boolean variable. Variables hold values, expressions are values or evaluate to a value.
bool isBig             =  size > 10
^ boolean variable ^ boolean expression


That's literally what a Boolean value is, either true or false, 1 or 0, on or off.
>>
https://blog.rstudio.org/2016/11/01/announcing-rstudio-v1-0/

seems like there's a lot of new stuff
>>
>>57340382
>not future proofed
tsk tsk
>>
>>57340212
Go away and never come back.

>>57340362

In general. There is very little reason to do so either. Unless you want to deal with stinking ABIs and shit and you absolutely NEED to deal with Assembly, just stick with an higher language.

Trust me - I know what I am speaking of.
>>
Is it possible to join these sed statements? maybe wrong thread but yall use linux anyway

$ sensors | sed -n 's/^temp1:\([\t\ ]*\)\([^(]*\).*$/\2/p' | sed '3!d'
>>
>>57340277
Yes.

The majority of programmers use Windows.

Most tools are available on any OS, but Visual Studio is currently WIndows-only. This only really matters if you're using C#, F#, C++, C, or Visual Basic, though.

Before anyone spergs out, I'm not saying Windows is a better OS, I'm merely noting that the majority of programmers (and users) use Windows, so nearly all tools are ported or made for it.
>>
File: 1470926161060.jpg (256KB, 1155x703px) Image search: [Google]
1470926161060.jpg
256KB, 1155x703px
Is it true that crossdressing makes you a better programmer?

I need to know before I buy this.
>>
>>57340460
w-where does the cat tail go?
>>
>>57340460
>You bought this item
>>
File: umarusfs.jpg (115KB, 1280x720px) Image search: [Google]
umarusfs.jpg
115KB, 1280x720px
>>57340015
>>57340022
>>57340343
>>57340377
oop is about abstracting the data behind a procedural/functional interface (the operations) but properties actually abstract operations behind virtual data. it's a huge step backward from the philosophy of object orientation and should be considered harmful by any oop theorist.
>>
>These are IDEs, folks, meant for professional programmers. A good programmer should be able to get up to speed quickly enough with either IDE, and eventually become comfortable in it.

Text-editor fags confirmed for hamstringing themselves, or bad programmers.
>>
>>57340443
Oh fuck off! Everyone started somewhere. I don't care how dumb my questions are, as long as I want to make sure I understand everything. So instead of talking shit to people who are trying to learn, you should encourage them.

>>57340420
Thanks mate, I will keep that in mind.
>>
>>57340460
It just makes you shine more, leading people into believing that you know what you are talking off when you actually don't.

If you want to become better, just read more books or articles. Or watch some programming talks on YT. Like this one:
>https://www.youtube.com/watch?v=FnGCDLhaxKU&t=1h32m10s
>>
>>57340460
>Is it true
Redundant, just use "Does crossdressing make you a better programmer?"
>>
>>57340488
real programming requires more thought and theory than braindead boilterplate typing, sandeep.
>>
>>57340500
>If I asked you if crossdressing would make me a better programmer, would you answer yes?
>>
>>57340460
Somehow, the brightest programmer I know is a crossdresser, and the second best is a furry, so sure go for it, just fuck your shit right up
>>
>>57340483
What's the fucking difference between:
T getFoo()
void setFoo(T)

and
T Foo { get; set; }
>>
how come dpt has always so many dubs compared to other generals?
>>
>>57340382
>substr(4, 8)
You had one job.

Seems it's also select the first user post, when it should be last.
>>
>>57340494
>Oh fuck off!
No u.
Your problem is not the stupidity of your question, but the absolute lack of format in your code. No indention, no block around your loop, and you actually think that people would read this shit?

Go away and never come back!
>>
>>57340511
>tfw crossdressing furry
>>
>>57340459
>using an IDE for C
>>
rob pike doesn't use an ide
checkmate
>>
>>57340511
The brightest programmer I know is a depressed alcoholic who does not give two shits about crossdressing. There are people, and then there are people.
>>
File: no you.webm (199KB, 1898x972px) Image search: [Google]
no you.webm
199KB, 1898x972px
>>57340504
>>
>>57340494
>>57340523
This

Even if you are completely new, you should still be considerate of the people reading your question.

Formatting code is the easiest thing you can do. Why not take a couple seconds to format it before making a post?
>>
>>57340459
I use C, C++, SQL, Python

Though I haven't found any environment setup on Linux/UNIX that compares to Visual Studio.

Visual Studio has:
fast, correct syntax highlighting, completion, and error catching.
easy way to document code
Supports the above four languages in 2015 version
Lots of code/binary profiling tools
>>
>>57340523
>Your problem is not the stupidity of your question, but the absolute lack of format in your code. No indention, no block around your loop, and you actually think that people would read this shit?

See? If you had said this at the beginning, I would have been like "Oh shit, he is right, I gotta work on my formatting" and boom, I learn something important.

Btw, it is perfectly formatted on my end, somehow, 4chan text's box always fucks up the format of my codes. I need to work on that. Anyways, I will stay here forever, and you will like it!
>>
>>57340567
Die in a fire.
>>
>>57340405
Yes because preprocessor statements effect absolutely everything
Lets say you have such arrangement

//calce.hpp
#define x_initial 0
/*
code
*/

//math.hpp
#include <calce.hpp>
/*
code
*/

//main.cpp
#include <math.hpp>

int main()
{
//code
x_initial = 0;
}

After preprocessing is done, you'd get an error about not being able to define numeric constants or something.

There is only two legitimately good uses for #define that I've found. One
//main.cpp
#include <iostream>
using namespace std;

#define DEBUGGING

int main()
{
//code
#ifdef
cout << some_variable << endl;
#endif
}


Two (from the doom source code)
#define R ((8*PLAYERRADIUS)/7)
mline_t player_arrow[] = {
{ { -R+R/8, 0 }, { R, 0 } }, // -----
{ { R, 0 }, { R-R/2, R/4 } }, // ----->
{ { R, 0 }, { R-R/2, -R/4 } },
{ { -R+R/8, 0 }, { -R-R/8, R/4 } }, // >---->
{ { -R+R/8, 0 }, { -R-R/8, -R/4 } },
{ { -R+3*R/8, 0 }, { -R+R/8, R/4 } }, // >>--->
{ { -R+3*R/8, 0 }, { -R+R/8, -R/4 } }
};
#undef R

And that had pages upon pages of that type of code.
>>
>>57340564
>using
>an
>IDE
>for
>C

You need Jesus
>>
>>57340578
>
    #ifdef DEBUGGING

Fixed
>>
>>57340539
and?
>>
>>57340576
No u!
>>
>>57340389
c or c++?
>>57340389
>has literally the same effect as
no.
>>
>>57340578
There are others as well: initializing array objects with constant sizes for strings whose length you want to have determined at compile time.

Or generally initializers for objects. Like a macro that creates a timespec object for you. There ARE many use cases for macros, but as with goto beginners cannot estimate when to use them and when not to. So they tell beginners not to use them instead of teaching them when to use them.

Reminds me of the Jedi in Star Wars. "You must not use the dark side!" - "Why?" - "Because you mustn't!"
>>
>>57340590
IDE's with VCS make it easier to manage projects with +50,000 lines of code or +100 file. I also have build scripts and helper scripts, too.

Something you would not understand, anon~~~~
>>
>>57340567
It's probably because you use tabs, if you use spaces instead it will look proper across all editors instead of a mess.
>>
>>57340389
t. Pajeet who barely knows the basics of C#
>>
>>57340640
I manage a project with 37+ KLOC. And VS is absolutely atrocious for that task.
>>
>>57340649
Oh cool! I will take that into consideration next time I copy and paste my code. Thanks anon.
>>
>GTK
>GIMP Toolkit
>GNU Image Manipulation Program Toolkit
>GNU Is Not Unix Image Manipulation Program Toolkit
>GNU Is Not Unix Is Not Unix Image Manipulation Program Toolkit
>GNU Is Not Unix Is Not Unix Is Not Unix Image Manipulation Program Toolkit
>>
>>57340673
What did you use senpai? Eclipse?
>>
>>57340695
>GTK
>not GTK+
>>
>>57340695
Why is this allowed?
>>
File: 1455694587020.jpg (12KB, 300x250px) Image search: [Google]
1455694587020.jpg
12KB, 300x250px
>>57340706
VS <=> Visual Studio
>>
>>57340763
Well obviously.
>>
>>57340695
Richard M. Stallman (PhD) is a lisper( ̄ー ̄ )
>>
>>57340635
>There are others as well: initializing array objects with constant sizes for strings whose length you want to have determined at compile time.
Better used as a const

>Or generally initializers for objects
This is also a good idea for macros

>>57340633
>>57340652
Test it out then, fuckers.

To use his code, this is what I did.
#define x_initial 0
#define y_initial 1

double approx_e(double delta_x) {
// const double x_initial = 0;
// const double y_initial = 1;

double y = y_initial;

for (double x = x_initial; x < 1; x += delta_x) {
y += y * delta_x;
}
return y;
}

Compile with
g++ -O2 -S main.cpp
, move main.s to preprocessor.s, uncomment the const and delete the #define. Compile again.

Now can we all guess what happens after
 diff main.s preprocessor.s 

I think I can guess. Hint: It's fucking nothing
>>
>>57340821
We are talking about static global string lists in objects.
>>
How is the life of a programmer? Is it stressful? Will you have time for other hobbies(music, gym, etc). I am trying to become one, and I do enjoy programming, just wanna know are the lives of you guys who do this for a living.
>>
>>57339750
Perl is on its way out and I can't say that I'll miss it
>>
>>57340821
one is handled by the preprocessor while the another one is handled by the compiler. already that make them having different effects.
>>
>>57340821
>Test it out then, fuckers.
Fuck off.

>#define x_initial 0
>has literally the same effect as
>const int x_initial = 0;

huehuehue wew lad spicy dank meme i tell you what
>>
>>57340836
Right, and it can be better suited with a const.

>>57340843
Right, which is why const is recommended because you won't fall for simple errors like >>57340578

>>57340871
Legitimately not an argument
>>
>>57340840
If you enjoy programming, don't become a programmer.
>>
>>57340894
recommended for c++, maybe, but not for C.
>>
>>57340906
If you enjoy football, don't become a football.
>>
>>57340578
Neither of those uses are necessary
>>
>>57340906
Oh boy, so does that mean that I will end up hating programming if I become a programmer? Should I aim for a software developer instead? I am quite interested in your reasoning tho, so please, elaborate.
>>
File: markus-notch-persson.jpg (151KB, 1280x720px) Image search: [Google]
markus-notch-persson.jpg
151KB, 1280x720px
>>57340840
read the story of notch, he's probably the most successful game programmer and my hero.
>>
class foo {
private:
int val;
public:
foo(std::vector<foo*> &fooContainer, int x) : val(x) {
fooContainer.push_back(this);
}
void PrintThis() { std::cout << "This foo class instance\n"; }

};



What's wrong with this code?
>>
It's not C#.
>>
>>57340982
he hated what the corporate machine did to his personal project
>>
>>57339607
why not generalize it instead of breaking it to all the cases.

Something like this for example, 0 is tie, 1 is user, 2 is computer
#!/usr/bin/env perl
use feature qw(say);

my ($a, $b) = ($ARGV[0], int rand 3);

for my $z (($a, $b)) {
if ($z == 0) {
say "Rock";
} elsif ($z == 1) {
say "Paper";
} else {
say "Scissors";
}
}

say (($a-$b)%3)
>>
>>57340974
software developer vs programmer, is there really a difference?
>>
>>57340982
>loves java
>>
>>57340982
Your hero ripped off Infiniminer using a shitty language.
>>
>>57340913
Show proof.

Write any sort of basic function in C, in one case use #define, in the other case, use const, and compare the assembly.

>>57340967
Writing in C++ is not necessary. Writing in C isn't necessary. Hell, neither is Assembly.

The point is to write legible code.
>>
>>57340894
>Right, and it can be better suited with a const.

... what?

#if defined(MY_GCC)
# define strlen_constant(string) (((sizeof(string) / sizeof((string)[0])) - 1) + \
sizeof(typeof(int[1 - 2 * !! __builtin_types_compatible_p(typeof(string),typeof(&string[0]))])) * 0)
#else
# define strlen_constant(string) (((sizeof(string) / sizeof((string)[0])) - 1))
#endif
#define STRING_CONSTANT(string,type) (string),strlen_constant(string)

NOEXPORT const string_t mime_strings_desc[] =
{
{STRING_CONSTANT("Unrecognizable/generic file")},
{STRING_CONSTANT("3D Crossword Plugin")},
{STRING_CONSTANT("3GP")},
{STRING_CONSTANT("3GP2")},
/*...*/
};


And you want to do that without macros? You're insane.
>>
>>57339592
macros
Since template code has to go in headers should would break if someone did:
#define n "fuck you std"
#include <random>
>>
File: trump_alien_proof.png (276KB, 1440x1813px) Image search: [Google]
trump_alien_proof.png
276KB, 1440x1813px
Has someone made a neural network that can guess IQ based on the way people talk?
>>
File: n.png (150KB, 587x855px) Image search: [Google]
n.png
150KB, 587x855px
>>57341027
>>57341026
there a lot of difference between minecraft and infiniminer.
>>
>>57340983
1. Capitalize class names.
2. Put public before private.
3. The constructor doesn't make sense.
>>
>>57340982
So what I understood from that story was. Make a game that appeals to autistic kids, proceed to become a billionaire.
>>
>>57341037
>const auto R = ...;
>const bool debugging = false;
>>
>>57340677
Do not listen to him. This will ruin formatting of your code. Tabs > spaces.
>>
>>57340974
I once loved programming. Then I learned how to do it on a professional level. And ever since I cannot feel the magic for programming like I did once.

If you want to keep feeling the magic, don't become a pro.
>>
File: umaruwp.jpg (112KB, 1920x1080px) Image search: [Google]
umaruwp.jpg
112KB, 1920x1080px
>>57341037
>Write any sort of basic function in C, in one case use #define, in the other case, use const, and compare the assembly.
no need to talk about assembly which is an implementation detail.

Try to compile this in _standard_ C.

#include <stdio.h>

const unsigned int LENGTH = 10;

char string[LENGTH];

int main()
{
printf("%zu\n", sizeof(string));
}
>>
>>57341063
Java is a fucking general purpose programming language. It is not a screw.
>>
>>57340677
nononononono use tabs for everything other than Ascii art
>>
>>57341090
B-but, how do I make money from something that I love?
>>
Working programming for a year definitely fucked it up for me as a hobby, but the good news is after a break (while finishing college) I'm enjoying it again
>>
>>57340649
>>57340677
>>57341087
Tabs for indentation, spaces for alignment.
>>
>>57341087
>>57341142
Lol! Ok, I will still be part of the tab masterrace!
>>
>>57341063
Who the hell is this idiot, Java is one of the most noobish languages
>>
>>57341145
Do something that you don't like to begin with. You'll hate it, but at least it won't perverse something you love.
>>
>>57341157
>Tabs for indentation
>>
>>57341169
Yes?
>>
>>57341162
Nice, good for you
>>57341157 is true too
>>
>>57341120
>two space indent
>new line after function declaration
Hamster worshiper degenerates mass suicide quick please
>>
>>57341163
you wish every night to be as successful as this idiot.

http://www.eurogamer.net/articles/2014-12-19-minecraft-creator-notch-just-bought-the-most-expensive-house-ever-in-beverly-hills-for-usd70m
>>
>>57341058
Yeah and they trained it on /g/
Guess how that turned out
>>
>>57341157
This is the cancer killing /g/
>>
>>57341183
>you wish every night to be as successful as this idiot
i'm pretty sure he's killing himself with drugs to medicate his depression, so no

if nothing else he's addicted to twitter in an unhealthy way
>>
>>57341183
Holy shit this guy thinks capitalism is some kind of ranking where the most useful human beings grind to the top.
How wrong could this be...
>>
>>57341058
>implement flesch kinkaid reading level
>wire to content material by author NOTE: twitter is a bad choice; brevity is intentional when your characters are that limited
>????
>PROFIT
>>
>>57341145
Start pimping him/her
>>
>>57341183
Good for him, he might be an extremely talented game develop but it doesn't seem like he knows much about Programming
>>
>>57341183
Notch is lucky he hit an autistic/underage niche that doesn't care about how buggy and slow the game is.

And Minecraft is only de facto moddable because it uses an interpreted/JIT language - the game itself has almost zero support.
>>
>>57341243
I don't think you know very much about programming.
>>
>>57341244
>Notch is lucky he hit an autistic/underage niche that doesn't care about how buggy and slow the game is.

As long as it runs with 60 FPS I don't really care.
There are reasons to abandon Java for performance reasons, but games are not really one.
>>
>>57341259
I don't think you know very much.
>>
>>57341259
Might be true, but it seems like at the very least, I know more than him.
>>
>>57341183
Okay seriously, how did this guy get away with ripping off Infiniminer? Its like he literally copy pasted everything from one language to another. How did he get away with it?
>>
File: Minecraft_Win10_Beta_-10.png (729KB, 1000x533px) Image search: [Google]
Minecraft_Win10_Beta_-10.png
729KB, 1000x533px
>>57341263
Don't you find it a bit disconcerting that a game that looks like this struggles to run at 60 FPS on a fairly powerful computer?

Meanwhile I can max out D44M and it runs better than fucking Minecraft.
>>
>>57341045
>* 0
>>
>>57341263
If only it was written in C++.
Minetest was a proof of concept C++ clone of minecraft and it runs buttery smooth 60fps on even the shittiest toaster systems.

Even the microsoft ports written in C# run smoother.
>>
File: !1S.jpg (41KB, 500x371px) Image search: [Google]
!1S.jpg
41KB, 500x371px
One more question about tree traversal:

How could I check if one tree's pre-order traversal gives the same sequence as another tree's post-order traversal? And how would I do that without going over O(n) complexity?

I was just going to make it where it checks if tree a's pre-order corresponds to tree b's post-order, and if not check the other way around, but that would be O(n^2), right?
>>
>>57341275
Says you.
>>
>>57341288
>struggles to run at 60 FPS on a fairly powerful computer
In what way?

I haven't played Minecraft in years, but it ran at insanely high FPSs until someone did something crazy like turn the entire world into torches all at the same time.
>this kills the server
>>
>>57341157
>>57341087

No, what the fuck? Enjoy your ugly diffs.
>>
>>57341288
>Don't you find it a bit disconcerting that a game that looks like this struggles to run at 60 FPS on a fairly powerful computer?

I never had it struggle for 60 FPS on my box. And it's not a fairly new one - iCore 7, 8 GiB RAM, GTX 850M.
>>
>>57341299
>Even the microsoft ports written in C#
Wait, what?

Have they released source?
>>
>>57341306
I don't think.
>>
>>57341305
traversing it both ways is still O(n)
>>
>>57341297
If you don't understand what the code does, don't comment on it.
It's a safeguard to make sure I don't pass pointers instead of arrays to the macro.
>>
>>57341288
This is the power of Javaâ„¢ at full force!

Witness it!
>>
Even if Java is performant enough for your use case it's still a really shitty language to use. Boggles the mind how anybody could stand to use Java of their own volition.
>>
>>57341345
What is >Hadoop
>>
>>57341323
Of course not.
MC for consoles and MC pocket edition are written in C#.
The original PC version written in Java and none of them have ever been open sourced.

Notch planned to open source it, but then the money rolled in.
>>
Can you port C++/CLI to linux?
>>
>>57341305
no, that would be 2*O(n), i.e. just O(n), because you're running an O(n) algorithm twice. it's still O(n) if you run it a constant number of times

the right way to do this is probably to write a preorder iterator, and a postorder iterator, and then compare the streams element-wise. then flip the iterators and do it the other way
>>
>>57341263
>There are reasons to abandon Java for performance reasons, but games are not really one.
Stop the world GC isn't a problem for video games? Reality seems to disagree with you, which is why you never see Java used for AAA games
>>
>>57341310
I suppose the nominal FPS might have stayed high but it stutters like shit during chunk loading.

>>57341319
That is a pretty fucking powerful machine for a game that looks like Minecraft.
>>
>>57341338
>If you don't understand what the code does, don't comment on it.

that's mostly because C preprocessor is a one giant ugly hack
>>
>>57341310
Singleplayer always runs like ass.
>>
>>57341305
Use a hash
>>
Should I start learning web dev stuff with a MVC framework or should I just start super basic?

What is babbies first web dev stuff
>>
>>57341327
>>57341369
Oh, cool, thanks.
>>
>>57341370
I am no advocate of Java. I only say I don't care what you do in your game as long as I don't notice how badly it's programmed.

Once I do - and I had that a lot with Skyrim - you can be sure I'll rant about it a LOT.

>>57341376
You think so? I never considered it that powerful desu.
>>
>>57341380
C preprocessor is quite barebones, that's why some macros look the way they do, but all they're doing is blind text replacement.
Since macros don't expand recursively, you need to add intermediary macros every time you want to expand more than once for non-trivial expansions.
>>
tired of people in my computer science program whining during lectures about how e.g. turing reductions aren't used in real life. this 30 year old dude taking an undergraduate course won't shut up. he literally wants the university to teach classes in OOP only, because that's what's used in "the real world". he also wants entire classes on teaching how to use a single language. and the majority of people agree with him as he interrupts the professors to opine
>>
>>57341380
Again, you want to do it without macros? Then I again will tell you you're insane.
>>
>>57341394
MVC and PHP are massively fucked clusterfucks. IMO learn some webforms for easy stuff, then move to C# MVC

learn PHP if you wanna feel the pain
>>
>>57341413
i'd just rather not have to use c at all
>>
>>57341408
also he sucks off the software development professor because he's so eager to learn about how to write code. literally cannot stand this dude
>>
>>57341376
>>57341382
But what are you comparing it to?

The scale and mechanics of the world around you in that game are nothing like that of a corridor shooter.

In a modern AAA game, there aren't really that many 'things' on the screen at any given time. Those things are often highly detailed with many triangles and other rendering effects, for which graphics cards are optimzed to render.

In Minecraft, you're talking tens of thousands of entities that have their own state and potential behaviors, as well as effects on entities around them.

At some point, you have to balance memory usage to store all of these, CPU power to calculate the behaviors, and unfortunately the GPU gets underutilized because of the nature of the game as a real-time simulation of many entities, rather than calculations of visual on surfaces.

There aren't many similar games out there, any many that try really do fail to hold 20 FPS on a modern, mid-high tier setup.
>>
>>57341431
C is extremely simple and straightforward.
>>
>>57341408
i minored in law and all the MBAs at the law school would opine to me about how our CS program was shit because it didn't teach "app programming"
>>
>>57341446
>tens of thousands
Each chunk is 65,536 blocks.

Many chunks are loaded and active at once, many many moreso if it's a server.

You're looking for HUNDREDS of thousands, and even millions on a small server.
>>
>>57341431
Well, as I said, if you want to make sure you are dealing with a non-retarded compiler, doing it like that is the safest and also the fastest way to deal with mass-object-initialization.

And maybe it's ugly. But that's C. C actually takes "pay for what you use" seriously, unlike C++ (sometimes).
>>
>>57341446
>In Minecraft, you're talking tens of thousands of entities that have their own state and potential behaviors, as well as effects on entities around them.
Most blocks do nothing. Most everything else just walks around randomly and maybe moves towards you.

You're making an even stronger case against Java here, by the way, because simulating lots of entities is something that benefits hugely from contiguous memory. Oops, nearly everything in Java is heap-allocated and can only be used by reference!
>>
https://vimeo.com/189525997

rubyfags, everyone
>>
>>57341468
>In multiplayer mode, a grid with a default radius of 10 (for a total of 21x21 or 441 chunks) is loaded around each player and sent to the player by default

Even in singleplayer, the default setting lends to nearly 30 million blocks loaded and active.
>>
>>57341449
>C is extremely simple and straightforward
>check out this ad-hoc array/pointer type guard based on unstructured text interpolation
there's nothing wrong with a low-level language, but in many cases C offers bad solutions to real problems
>>
>>57341408
I had a guy like that in my algorithms class. He would get in C vs Java flamewars with another autist. And he'd interrupt the professor to talk about how this related to his job experience writing embedded C code. The most disturbing part of this is these people were masters students. Some people just have no self awareness and feel like they need to be the smartest guy in the room. At least in this class everyone else gave this guy the stank eye and he was just too autistic to realize everyone hated him. I'm sorry for you ;_;
>>
>>57341363
>MC for consoles
Even PlayStation?
>>
>>57341449
THIS
H
I
SIMPLE

>>57341493
I hate the fact idiots like you exist. kys
>>
>>57341479
Why hasn't something similar been built in something like C?

By the way, I'm not necessarily trying to make a case for Java, but anons are claiming that Minecraft "runs like ass", without any point of comparison for something similar written in other languages.
>>
>>57341513
>I hate the fact idiots like you exist. kys
>t. "I have never used C in my life, but I know more about it than any one else."
This is the average /g/ poster.
>>
>>57341505
Interesting. I hope you thought about posting that on Facebook to collect more sweet karma you fucking faggot.

>Oh look this guy is smarter than us, bully him!
>>
>>57341540
http://www.minetest.net/
It was already mentioned ITT.
>>
>>57341417
Yeah, a friend recommended MVCs, but that would mean having to learn HTML, SQL, whatever language the framework is in and JS. Seemed a bit overwhelming.
>>
>>57341491
30 million entities is not actually a big number if they're well-structured

like yeah, if you blow a kB on a stationary cube then that's huge, but realistically we're looking at a pointer to a static template. even with some markup flags we're looking at most at tens of bytes. for 30 million objects that will clock in under a gigabyte.

of course if you heap allocate everything then you're slapping 24B+ of metadata on everything and easily doubling your footprint or worse. i'm being loose and fast with the numbers here but that's entirely my point -- the numbers matter, the language matters and efficiency matters. you can't just throw around "million scale" because it's not actually a big number in many contexts
>>
>>57341493
That's the problem of the framework, not the language.
>>
>>57341544
At least, I know that I'm the only sentient being on earth. NPCs should know their place.
>>
>>57341550
What makes you think he is smart? Maybe I was unclear. Everyone in the class was a masters student with the exception of me (which was an anomaly cause I couldn't get into the ugrad section). He was one of the least bright students, he was just very loud and full of himself.
>>
googled "game" source code.

get github
>TODO: make private

jesus
>>
File: 1455768432030.jpg (171KB, 650x560px) Image search: [Google]
1455768432030.jpg
171KB, 650x560px
>>57341603
Now we are seeing levels of autism that shouldn't even be possible.
>>
>>57341592
>30 million entities is not actually a big number
In the context of comparison to a AAA corridor shooter, it certainly is.

That's the only reason I brought it up; an anon wondered why Doom 4 runs better on his machine.
>>
>>57341631
I don't think you're real.
>>
>>57341219
>i'm pretty sure he's killing himself with drugs to medicate his depression, so no
his dad was actually a drug addict and killed himself with a firearm.
>>
>>57341636
Do you really consider the "entities" in Minecraft (mostly static blocks by your count) to be equivalent to the "entities" in D44M?
>>
>>57341310
Try optifine
>>
>>57341630
What's the problem, anon?
>>
>>57341045
Why do people put C macro keywords like NOEXPORT at the start of a function declaration like this?
>>
>>57341664
No, not at all.

That's the point.

There's an insane amount of them (in the context of video games), and gaming hardware is made for the latter, not the former.
>>
>>57341686
>C macro keywords
>macro keywords
>>
>>57341690
Actually, hardware is made to do the same thing many, many times. So you'd think Minecraft would have a leg up. But it doesn't, because Java makes it so that the computer doesn't "know" it's doing the same thing many, many times due to non-contiguous memory, dynamic dispatch, etc.
>>
File: 1455812710177.jpg (41KB, 447x400px) Image search: [Google]
1455812710177.jpg
41KB, 447x400px
>>57341657
It's OK. A long time ago I was 14 too.
>>
>>57341690
>>57341710
The same simple & straightforward thing many, many times, mind you.
>>
>>57341715
Prove that you're not a philosophical zombie then.
>>
>>57341715
I hope you die soon, anon.
>>
>>57341686
Because there can be different linkages between different compilers. cl.exe on Windows for example generates different names depending on whether the object was declared statically or dynamically. And on Windows, to hide symbols from showing up in the binary, we use "static".

GCC on the other hand uses
__attribute__((visibility("internal"))
to hide symbols.
>>
File: 1399979012357.jpg (6KB, 189x251px) Image search: [Google]
1399979012357.jpg
6KB, 189x251px
>tfw FINALLY manage to snag an internship somehow

PRAISE ALL*H
>>
>>57341764
static is the standard way.
>>
File: 1455795870432.jpg (65KB, 331x382px) Image search: [Google]
1455795870432.jpg
65KB, 331x382px
>>57341749
No.

>>57341756

Pic related.
>>
>>57341764
JUST USE STATIC
IT'S IN THE STANDARD
>>
>>57341780
... which, IIRC, does not work on GCC. Some symbols still showed up, which I didn't want to.

So I did it like that, and it worked. Maybe it was a bug, maybe they already fixed it. I don't care. With this macro it takes me less than a minute to adapt my entire code to it.
>>
>>57341828
>no dubs of truth
I rest my case here.
>>
>>57341810
static does work, it's used a lot by linux and cpython.
>>
>>57341810
>I don't care to make my code simpler
Guys, this is why earth is shit.
>>
>>57341856
var a = "";

if (op.image.isAnime() == true) {
a = "faggot"
} else {
a = "cool guy"
}
>>
>>57341844
And I tell you, it didn't.
I had internal functions that were not supposed to be exported outside the module, and they were still exported. As I said, it could have been a bug with the version I compiled with. I don't know. But this worked for me when static wouldn't, and with NOEXPORT I could change to static if I ever felt like it.
>>
>>57341856
>simpler
Ah, good, you are a retard. I will stop talking to you now, as it is a waste of my fucking time.
>>
>>57341883
dude, shut up, you r a fucking liar. i know because i used myself static in my projects. fucking normies.
>>
>>57341882
var a = op.image.isAnime() ? "faggot" : "cool guy"
>>
>>57341882
return ["normal guy", "autistic intelligence"][nnet.test(op.image)];

Bad taste, anon.
>>
>>57341900
I'm not the one you think you're talking too but w/e. Kys.
>>
can someone post haskell like rust code?
I wanna see if its true or you guys are just talking shit.
>>
File: 1459101225661.png (323KB, 584x717px) Image search: [Google]
1459101225661.png
323KB, 584x717px
>>57341882
>var
>>
>>57341636
>30 million entities is not actually a big number
Only a shit programmer would actually record all the states of the 30 million entities in memory.
>>
>>57341882
>== true
>>
>>57341947
It doesn't work like that. There is no magic number. Depends on what you are doing.
>>
Why are y'all so combative when it sounds like none of you know anything about programming anyway
>>
>>57341970
>>>r/eddit cancer
>>
>>57341970
not everyone is stupid as you.
>>
>>57341970
Welcome to /dpt/.

Most employed or competent programmers generally don't stay unless they're already ingrained into 4chan as a whole.
>>
>>57341970
You didn't see a bunch of autists compress and optimize a bit of javascript code to delete their posts?
>>
>>57341988
>>57342000
Nigga I've got a job programming. I get paid. Idgaf about what you guys think of me, I just think it's funny seeing autists sling shit at each other
>>
>>57341970
i have tried to spread programming literacy for some times now but i must admit that i have underestimated the burden.
>>
>>57341936
They're both functional and they both are quite concerned with controlling side effects. That said, I don't think "Haskell-like Rust code" is a thing. Haskell also makes heavy use of HKTs which Rust doesn't have.
>>
>>57342026
>autists sling shit at each other
I saw a TED Talk about the FOSS community and says it's better than hugbox developer communities where you flat out call somebody's code shit and one up them constantly.

Forces you to get good or be the minority.

Now if you'll excuse me I need to make CalleAPTCHA to compete with Google.
>>
>>57342026
Good thing for you pajeet. I suppose you have a wife and kids too? If that's the case you kill them before killing yourself.
>>
>>57342052
New Thread

>>57342052
New Thread

>>57342052
New Thread

>>57342052
New Thread

>>57342052
New Thread
>>
>>57342063
than you
>>
>>57341690
this is pure porkometrics. the number only means something if it's contextualized and "video games" is not a coherent context. we might as well talk about how many floating point numbers Doom 4 is crunching, it's totally meaningless

when we try to give some context to the entities in minecraft we see there's no very good reason for them to be big, but they could easily become big if e.g. the data's structure is mismanaged, which is exactly why no one would normally choose Java for a project like this
>>
>>57342059
FOSS people tend to know their shit and be rationally blunt. /g/ tends to not know anything and call people fags as damage control. There's a difference there.
>>
>>57342181
>faggot detected
>>
>>57342200
my code may be gay but it's still straighter than your code
>>
>>57342633
Did you just assume my code's gender?
>>
This is really basic, but is there a way to just make an array longer in C every time I need to add a new element, or do I need to use a linked list for something like that?
>>
>>57342655
You should consider posting in the new thread:
>>57342052

And yes, you need to. Unless you are allocating more elements than you need to, which is a smart move on some machines because of paging. But that's a long and tedious story, and I am not going to explain it in a dying thread.
>>
>>57342655
Yes you can make an array longer but reallocating memory is expensive so instead of making it 1 bigger it's better to multiply the previous capacity by 1.5 or 2. You need to manually perform this reallocation when it hits capacity using http://en.cppreference.com/w/c/memory/realloc . That's basically how c++'s vector works, or Java's ArrayList.
>>
>>57339489
>==true
>not .equals(Boolean.TRUE)
>>
Can I get an explained example of loop summing in Java with with for and while loops. I'm struggling with this concept.
>>
>>57343082
assuming you have an arraylist of ints called nums:
int sum = 0;
for (int i=0; i<nums.size(); ++i) {
sum += nums[i];
}

int sum = 0;
int i = 0;
while (i < sum.size()) {
sum += nums[i];
++i;
}
>>
>>57343082
i'm not going to explain because i'm too lazy senpai baka lmao
Thread posts: 329
Thread images: 26


[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.