[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y / ] [Home]
4chanarchives logo

/dpt/ - Daily Programming Thread


Thread replies: 318
Thread images: 42

File: NO_FILE_GIVEN (93KB, 486x500px)
NO_FILE_GIVEN
93KB, 486x500px
old thread: >>51741895

What are you working on, /g/?
>>
>>51748143
C!
>>
File: 1448263215242.jpg (63KB, 600x338px) Image search: [Google] [Yandex] [Bing]
1448263215242.jpg
63KB, 600x338px
>people keep telling me i'm dumb and my struct function pointers should go in a vtable instead
I feel like I got trolled.
vtables in C are an unmaintainable pile of rubbish.
>>
>>51748225
>wahh it's too complicated I just want to make OOP happen in C, not even OOP just the idea of member functions
I remember being 2 months into knowing C
>>
Are linked lists just a meme?
>>
>>51748252
It's a beginner concept to get students able to think about data structures, but it serves no other purpose.
>>
>>51748238
What is wrong with putting function pointers in your structs?
How much fucking memory could a void pointer take up anyway?
>>
>>51748278
It's not the memory that's the problem. It's just literally pointless and horribly ugly.
If you want member functions so badly, use C++. Please.
>>
File: 1445277014687.png (430KB, 811x599px) Image search: [Google] [Yandex] [Bing]
1445277014687.png
430KB, 811x599px
>>51748252
cons cells are life.
>>
>>51748225
Just use C++ you wasteman.
>>
>>51748278
What is the point? What are you trying to do that can't be achieved with a regular function? I guarantee you what you're doing is neither efficient nor reasonable.
>>
Real new thread. Report and ignore tranny threads.

>>51748322
>>
Real new thread: >>51748322
>>
>>51748340
He can have polymorphism, actually.

#include <stdio.h>
#include <ctype.h>

struct animal {
char * name;
void (*voice)(Animal *this);
void (*action)(Animal *this);
};
typedef struct animal Animal;

void bark(Animal *this);
void bite(Animal *this);
void meow(Animal *this);
void jump(Animal *this);

int main(int argc, char **argv) {
Animal dog = {"Spot", bark, bite};
Animal cat = {"Mittens", meow, jump};

dog.voice(&dog);
cat.action(&cat);
dog.action(&dog);
cat.voice(&cat);

return 0;
}

void bark(Animal *this) {
printf("%s: Bark!\n", this->name);
}

void bite(Animal *this) {
printf("%s bites!\n", this->name);
}

void meow(Animal *this) {
printf("%s: Meow!\n", this->name);
}

void jump(Animal *this) {
printf("%s jumps!\n", this->name);
}
>>
>>51748292
>>51748335
>>51748340
WHY DO FUNCTION POINTERS EVEN EXIST
>>
>>51748394
One reason is that you can implement virtual functions. Just not in the horrible way that you're doing it.
>>
>>51748386
Completely useless. Show me a real-world example instead of your aritifical OOP-concocted fantasies.

It would be better to have a switch on, say, the voice function, with a case for each unique animal.
>>
>>51748394
>learns about function pointers
>first idea: implement member functions
This was exactly me a couple years ago too dude.
Function pointers allow you to reference a function for many applications, like if you have an array of ints and you want to map a function to each one.



void map(int *array, int n, void (*fun)(int *a)) {
for (int i = 0; i < n; i++) {
fun(array + i);
}
}

void increment(int *a) {
*a++;
}

void decrement(int *a) {
*a--;
}

void print_num(int *a) {
printf("%d ", *a);
}

int main(int argc, char **argv) {
int array[4] = {1, 2, 3, 4};

map(array, 4, increment);
map(array, 4, printnum);
map(array, 4, decrement);
map(array, 4, printnum);

return 0;
}
>>
>>51748394
because assembly
because of how computers work
>>
>>51748462
Oh I know, that's actually the exact shit I did when I was at his stage. I wrote that one file and was done with it.
>>
op should burn in hell
>>
>>51748270
>but it serves no other purpose.

Lol
>>
everyone report OP for being subhuman
>>
>>51748530
>implying that wasn't just a basic example to illustrate a point
>implying pseudo member functions serve a purpose
Mapping functions is a huge tool. Anyone that thinks faking member functions in C is stupid will tell you that.
>>
>>51748544
What is this incoherent rambling supposed to mean?
>>
File: pos.png (38KB, 1130x847px) Image search: [Google] [Yandex] [Bing]
pos.png
38KB, 1130x847px
How do I make something like this, minus the confidence part? It's javafx, so Radiobutton and TableView, right? How do I disable the radiobutton and load data into TableView?
>>
File: wheeeeee.gif (499KB, 300x250px) Image search: [Google] [Yandex] [Bing]
wheeeeee.gif
499KB, 300x250px
>>51748586
it means nobody here knows C or writes anything of value and everyone is just throwing shit because they don't know any better
>>
>>51748586
Let me help.
"Mapping functions" is a huge tool. Anyone that thinks "faking member functions in C is stupid" will tell you that.
>>
>>51748602
dunno
>>
>>51748602
Nvm figured it out
>>
Real new thread: >>51748322

Report and ignore trap threads, especially ones forcibly posted before the bump limit such as this one.
>>
>>51748642
you're not me
>>
>>51748643
>trap
are you stupid?
>>
>>51748602
>>51748631
>>51748642
>>51748647
Me
>>
>>51748252
No. Although "pure" linked lists (cons cells) are probably less common than the case where a structure contains both the data and a link to the next item in the chain.
>>
>>51748650
>himegoto
google it
>>
>2 threads because one faggot couldn't wait till bump limit and yet another faggot couldn't just deal with it and had to make a second thread because he literally sucks dicks
One day this will stop
>>
>>51748742
You're the problem here, kid. Delete your shitty thread and stop crying.
>>
>>51748742
good luck with that. the day the trap faggot finally gives up, two more will take his place.
>>
fuck trannies, we don't want them
>>
>>51748700
Looks like a fun read, picked up
thanks guy
>>
>>51748754
>implying this is my thread
>implying I'm happy with either of them
>>
>>51748770
The other thread is yours, Everyone knows it.
>>
>python
DEPRECATED! Use Venture instead.
>scheme
DEPRECATED! Use Church instead.
>clojure
DEPRECATED! Use Anglican instead.
>C
DEPRECATED! Use probabilistic-C instead.
>C#
DEPRECATED! Use Infer.net instead.
>>
>>51748762
>we

?
>>
>>51748797
the /g/dpt/
>>
>>51748143
Hey /dpt/.
I have a program in mind that I want to create. I'm still severely inexperienced at coding however.So I want to ask you guys what language It has to be written in.

most of the program works already on Excel. it's fairly simple actually. I just need to apply a very thorough GUI. how would I go about doing that? what language would I be coding in? what should I learn?
>>
no trannies belong to programming. deal with it
>>
>>51748860
describe what you wan to do
>>
>>51748860
java/C#
>>
>>51748860
VBA
>>
File: 1429667391238.png (265KB, 637x477px) Image search: [Google] [Yandex] [Bing]
1429667391238.png
265KB, 637x477px
Daily reminder PHP has outlasted Python, Ruby, Lua and Groovy.
>>
>>51748143
>What are you working on, /g/?
Messing around with Rust, match statements are pretty cool.

use std::env::args;

fn main() {
let i: u64 = match args().nth(1) {
None => panic!("No arguments given"),
Some(value) => match value.parse() {
Ok(n) => n,
Err(_) => panic!("Invalid argument"),
}
};

println!("\n{} has {} Collatz steps.", i, collatz(i));
}

fn collatz(n: u64) -> u64 {
print!("{} ", n);
match n {
0 => panic!("Invalid value"),
1 => 0,
_ => match n & 1 {
0 => { 1 + collatz(n/2) },
1 => { 1 + collatz(n*3+1) },
_ => unreachable!(),
},
}
}
>>
>>51748882
I dont know how to properly explain it.
Mostly, it will just be adding values together. Something like a log to keep stuff in.
For example the very basic form of it that I have in excel, has me running all around the file copying certain boxes and special pasting (adding) them to others. I want so simplify that a lot.
Think a few prompts and a small list of things that is always stored.and then a log that the user updates every day.
>>
People don't actually program for FUN, do they?
>>
>>51748954
no but the results can be fun
>>
>>51748954
Of course they do.
>people don't actually play music for FUN, do they?
This is how stupid you sound.
>>
>>51748974
if you know a way to get the same quality result with less effort, you will do it that way. you don't program for the sake of putting effort into programming itself
>>
File: 1448457441953-3.jpg (119KB, 1080x1080px) Image search: [Google] [Yandex] [Bing]
1448457441953-3.jpg
119KB, 1080x1080px
>>51748947
Rust is seriously fucking disgusting. I couldn't even imagine programming in Rust for fun, which is pretty much all it's good for.
>>
>>51749004
Nah. Some people use C.
>>
>>51749005
The irony of calling something disgusting while posting a picture of a white girl.
>>
>>51749022
Alright Jamal
>>
>>51749018
for some applications, like embedded and kernel dev, C is the best trade-off between performance, portability and developer time.
>>
File: lain-is-a-bear.jpg (48KB, 1008x720px) Image search: [Google] [Yandex] [Bing]
lain-is-a-bear.jpg
48KB, 1008x720px
>>51749022
Rush and white girls are disgusting.
>>
File: 1444748701765-1.jpg (378KB, 2592x1944px) Image search: [Google] [Yandex] [Bing]
1444748701765-1.jpg
378KB, 2592x1944px
>>51749022
Subhuman please go.
>>
File: 1431929892325.jpg (311KB, 800x1202px) Image search: [Google] [Yandex] [Bing]
1431929892325.jpg
311KB, 800x1202px
>>51749044
>>51749062
White girls never stood a chance.
>>
>>51749047
I never did anything that C is good for and I wrote purely in it for a while. It was a great deal of fun.
>>
>>51749004
So I take it you only write enterprise quality java?

Yeah, nobody programs for fun.
Nobody writes music for fun.
Nobody paints for fun.
It's all a means to an end just to make money.
You're pathetic.
>>
File: 1448870372218.gif (3MB, 550x309px) Image search: [Google] [Yandex] [Bing]
1448870372218.gif
3MB, 550x309px
>Java can't pass primitives by reference
>>
>>51749099
Then just make it an object.
>>
>>51749070
>thick knees
>weak hips, ass and thighs
>no tits
>brown nips
ok weeb
>>
>>51749142
Would NOT bang amirite?
>>
>>51749059
YOU LEAVE GEDDY LEE OUT OF THIS
>>
File: 1446962972638.gif (479KB, 320x240px) Image search: [Google] [Yandex] [Bing]
1446962972638.gif
479KB, 320x240px
>>51749113
>need to make an object just to pass "primitives" by reference
>>
File: 1444748701766-4.jpg (4MB, 4288x2848px) Image search: [Google] [Yandex] [Bing]
1444748701766-4.jpg
4MB, 4288x2848px
>>51749070
Asians have good culture and are generally slim, but having to look at some Asian alien face when you wake up next to her in the morning and looking at your fucking alien kids' faces is not worth it. White women are the most beautiful.
>>
>>51749142
>weak ass
abort

pic related desu
>>
>>51749156
If this is a problem to you then it's a classic case of user error. You can always switch language (and make sure that one has what you need before using it)
>>
>>51749094
there are plenty of times when writing/maintaining code is simply not fun. do you want to spend years on making a very crappy painting if you could achieve the same quality painting in a week? it would have to be an extremely good painting or else you will have wasted years of your time, just masturbating with your shitty painting process.
>>
>>51749169
>fake tits
>>
>>51749168
Agree about the alien part, but white girls are so soulless.
Pacific islander and hispanic master race.
>>
>>51749168
Pic unrelated?
>>
>>51749156
Boxed types are for your purpose, unboxed primitives are not.
>>
File: 1386792647769.jpg (56KB, 408x383px) Image search: [Google] [Yandex] [Bing]
1386792647769.jpg
56KB, 408x383px
>>51749168
>white women
>the most beautiful
>>
>>51749169
i was talking about asians. murrican "white" girls tend to have thick knees but otherwise they're alright in terms of physical attributes
>>
>>51748860
What do you want it to do exactly and in what context will it be used?
>>
>>51749169
weak shop
>>
Is there anything better than gradually refining a program until it's perfect?

>tfw you start with questionable data structures
>poorly named functions
>confused flow
>redundant variables

Like taking a scalpel to a tumor, excise the ugly and leave only what's beautiful and necessary.
>>
>>51749099
it's on purpose, it's much more elegant that way. if you really want to do it because you suck at programming then use a boxed primitive or use a different language.
>>
>>51749214
Ah the mythical "perfect program"
>>
>>51749177
>you will have wasted years of your time, just masturbating with your shitty painting process.

Why are you even in this thread?
>>
File: 1449069094557-1.jpg (319KB, 2560x1707px) Image search: [Google] [Yandex] [Bing]
1449069094557-1.jpg
319KB, 2560x1707px
>>51749183
I actually am dating a light-skinned hispanic girl. They are good too.

>>51749196
That's an American.
>>
File: 1428462828977.png (73KB, 360x403px) Image search: [Google] [Yandex] [Bing]
1428462828977.png
73KB, 360x403px
public enum OS{ Windows, OSX, UNIX  }
public static OS env;
public static String defaultRoot;
public static String rootPath;
public static String[] runtimeArgs;
private final Image Icon =
new Image(getClass().getResourceAsStream("/16x16/apps/disk-usage-analyzer.png"));
private final ImageView graphic =
new ImageView(new Image(getClass().getResourceAsStream("/96x96/apps/disk-usage-analyzer.png")));


@Override
public void start(Stage stage) throws Exception {
rootPath = null;
if(env == OS.UNIX){
Dialog popup = getDialog();
Optional<Pair<Pair<String, String>, Pair<String, String>>> result ;
result= popup.showAndWait();
if(!result.isPresent())
System.exit(1);
else
result.ifPresent(runArgs -> {
runtimeArgs[0] = runArgs.getKey().getKey();
runtimeArgs[1] = runArgs.getKey().getValue();
runtimeArgs[2] = runArgs.getValue().getKey();
runtimeArgs[3] = runArgs.getValue().getValue();
}
);
}
File file = openDialog.chooseDirectory(stage, defaultRoot);
if(file != null)
rootPath = file.getAbsolutePath();
FXMLLoader loader = new FXMLLoader();


Parent root = loader.load(getClass().getResource("JDUA.fxml"));

Scene scene = new Scene(root);
stage.setTitle("JDUA");
stage.getIcons().add(Icon);
stage.setScene(scene);
stage.setOnCloseRequest(e ->{
treeMap.destroy();
Platform.exit();
});
stage.show();
}
>>
>>51749209
I just googled hot latina or some shit. I don't like that girl's face but I meant more to reference the race, oh well.

>>51749227
Same though.
>>
>>51748143

>this trapfaggot is still posting threads.
Wow, that's dedication.
>>
>>51749249
>I just googled hot latina or some shit.

This is the caliber of people we're dealing with here. People who get their porn from Google images.
>>
>>51749207
Think of something like myfitnesspal . i dont know if youve heard about it. anyway its a diet tracking program read the second post i made few posts below my first one.

the user will have a list which will be saved in the program, with foods and stuff, and he will be able to update a daily log by taking from that list. basically i want prompts like "Add X amount of Y in Z Day"
>>
File: lelastar.jpg (10KB, 213x319px) Image search: [Google] [Yandex] [Bing]
lelastar.jpg
10KB, 213x319px
>>51749258
>porn
We're pretty much just talking about our racial preference. I was just grabbing an image since that's what we've been using, but okay.
>>
>>51749284
use java
>>
>mods delete the real /dpt/, leaving this false trapfaggotry up
Wow.
>>
File: 1436514829711.png (301KB, 641x720px) Image search: [Google] [Yandex] [Bing]
1436514829711.png
301KB, 641x720px
>>51749357
#Rekt
>>
>>51749357
at least they could have deleted it before it became an established thread ffs

>>51749320
if it's just codemonkey stuff you can decide to not give much of a shit and just do whatever works. if it's for a more quality-critical application then you should be willing to allocate a lot of time to making good decisions so that you get a higher quality product and so that you'll spend less time refactoring the code in the future. as you get more experience you will have already encountered similar situations before and then you will already have an idea of the best way to do things.
>>
Should I post what I'm working on here or should I wait till later?

I was trying to post in dpt and then it vanished.
>>
>>51749381
read the OP
>>
>>51749381
this thread will be fine until it reaches the bump limit (310 replies)
>>
>>51749357
>>51749367
>>51749370
they deleted OP's trap fag pic so it's fine lel
>>
>>51749385
>>51749387
Oh, I know how threads work.

Just reading up a bit seemed to show people in a circlejerk about a tripfag and the thread may get deleted because of butthurt about something.
>>
>>51749396
MODS == GODS;
>>
>>51749396
You lost squirt.
>>
>>51749407
i was unaware that i was in a competition
>>
>>51749405
warning: expression `false' unused
>>
>>51749403
the gods have spoken. this thread will remain but without OP's fag pic
>>
>file deleted
What was the OP pic?
>>
They deleted it and the other thread so you guys would stop shitposting about it, if you can't figure that out.
>>
# python
containers = ["MP4", "MKV"]
resolutions = [["720p"], ["1080p", "2160p"]]

formats = {
c: [r for r in r_list]
for c in containers
for r_list in resolutions
}


I was aiming for something like this:
{"MP4": ["720"], "MKV": ["1080p", "2160p"]}


But instead got this:
{"MP4": ["1080p", "2160p"], "MKV": ["1080p", "2160p"]}


Any help fixing the dictionary comprehension?
>>
>>51749489
Watch, soon enough anime will get it's own global rule ban because it upsets anti-anime autists too much just like ponies derailed entire threads back in 2010.
>>
>>51749396
Creator of the other thread here, I couldn't ask for anything more. Now, if only they'll enforce Rule 6 for all /dpt/ OPs.
>>
>>51749498
Try this.

dict(zip(containers, resolutions))
>>
>>51749439
himegoto
>>
>>51749532
formats = dict(zip(containers, resolutions))
>>
I work every day this week, so I haven't the chance to really sit down and work on this, but.

I came across this: http://www.gamedev.net/topic/597954-luac-keeping-the-index-of-a-functiontable-after-calling-lua-getglobal-so-next-time-not-needed/#entry4787713

and something called SWIG

Are these both ways to possibly fill what is not working?

The last thing that I remember talking to you about was that since self was coming back as nil from the registry, to try some other methods.

I'll check this thread in the morning for a reply.
>>
>>51749535
whats wrong with himegoto
>>
>>51749532
Amazing. Thank you very much.
>>
>>51749550
it's part of the trap/tranny/crossdressing troll. maybe not too bad in and of itself but it's as "bad" as the troll can get away with without a guaranteed thread deletion. and this thread was posted before the old one hit 300 so it wasn't legit at all. it was posted early so that OP could force his trap pic.
>>
File: bingo.png (319KB, 740x926px) Image search: [Google] [Yandex] [Bing]
bingo.png
319KB, 740x926px
Late night bingo time.
>>
File: rangeindicator.png (2KB, 345x351px) Image search: [Google] [Yandex] [Bing]
rangeindicator.png
2KB, 345x351px
How do I allocate an array of squares of uniform dimensions given only a range from origin?

Pic related. Given an integer, I highlight the nearest surrounding squares.

I'm doing it manually thus far, because I'm an idiot that can't into using sin functions in for loops. I'm using sdl2 and SDL_RenderDrawRects() if anyone cares.
>>
File: rangeindicator.gif (5KB, 345x351px) Image search: [Google] [Yandex] [Bing]
rangeindicator.gif
5KB, 345x351px
>>51749597
Whoops. Wrong picture. Animated.
>>
>>51749581
>it's part of the trap/tranny/crossdressing troll
I don't really care so long as he posts anime because anime /dpts/ are the best /dpts/.
>>
what the fuck can you do with a singleboard computer to learn. all the projects people talk about are dumb gimmicks.
>>
>>51749597
if you want a brute-force way of doing it, which could still have good enough performance for what you're doing, is to start with a square with a length of (2n + 1) and then compare the distance to each individual square inside the larger square. you can check the square of the distance like n^2 <= x^2 + y^2 or something like that
>>
File: nobingo.png (365KB, 740x926px) Image search: [Google] [Yandex] [Bing]
nobingo.png
365KB, 740x926px
>>51749585
>>
>>51749644
x^2 + y^2 <=n^2
>>
>>51749642
Embedded programming stuff.
Stuff that would be too expensive to deploy with a regular computer like you're used to.
Imagine a tiny circuit that does nothing but blink a LED when a photosensitive diode is exposed to light.
That sort of thing.

Too bad most mainstream boards prevent you from learning anything useful by abstracting all the microcontroller stuff away and replacing it with a disgusting library.
>>
>>51749679
>abstracting all the microcontroller stuff away and replacing it with a disgusting library
Arduinos. Not even once
>>
>>51749324
ok ty
>>
File: bingo.png (325KB, 740x926px) Image search: [Google] [Yandex] [Bing]
bingo.png
325KB, 740x926px
>>51749585
>>
>>51749713
Noice.
>>
>>51749698
I bought an arduino leonardo clone once, and the godawful arduino ide put me off.
Is there any way to use it without using their disgusting libraries or even their disgusting IDE?
>>
>>51749644
not sure what shape you're aiming for, but
vec2 M = abs(p - origin); M.x + M.y < n
(checks if point p is inside the radius)
might work for you as well
>>
>>51748462
quake 3
>>
File: image.jpg (181KB, 708x914px) Image search: [Google] [Yandex] [Bing]
image.jpg
181KB, 708x914px
>>51749585
>>
>>51749644
>>51749664
What I'm actually doing is stepping from origin and spiraling outward north->west->south->east->(2)north->northwest->west->southwest...etc

Maybe I shouldn't have said anything about sin. Just seemed like it was the correct way to proceed assigning x,y coordinates in sequence.
>>
File: code-bingo.png (300KB, 740x926px) Image search: [Google] [Yandex] [Bing]
code-bingo.png
300KB, 740x926px
>>51749585
>>
You're writing C and you need to return a pair of arrays.

Do you return an int**, or do you write a custom struct and return that?
>>
File: bong.jpg (166KB, 740x926px) Image search: [Google] [Yandex] [Bing]
bong.jpg
166KB, 740x926px
>>51749766
struct if you do it a lot
>>
>>51749766
Make the user supply their own pair of arrays.
Preferably a struct.
>>
>>51749761
doing it like a spiral like you describe could work very well if you want larger ranges to be diamond shaped rather than rounded like a circle. if you have very large ranges it could be more cache-friendly to iterate through a bounded square rather than hopping back and forth like with the spiral
>>
how much do devs in india make?
>>
>>51749736
>what shape
It's just 10x10 squares that expand outward from the center square. It'll always be a diamond.

In reality, the ranges will never be greater than like 10 so I could just assign every square by hand. It always
origin-x (+/-) j*10, origin-y (+/-) j*10

and I seem to be having a brainfart.
>>
>>51749812
It doesn't matter; you can't pay them enough to use a toilet.
>>
>>51749802
The shape is equal to the move radius and diagonal movement isn't allowed. So moving to the square to your northeast would require two steps. The range indicator expands according to that limitation.
>>
>>51748143
>>51747548
>Still need JavaScript to do anything with forms
>>
>>51749943
web devs are the worst
>>
>random name generators
vs
>loading a possible names list
>>
>want to do a quick test of my own spline class
>want to compare it against:
http://grepcode.com/file/repo1.maven.org/maven2/org.apache.commons/commons-math3/3.5/org/apache/commons/math3/analysis/polynomials/PolynomialSplineFunction.java
http://grepcode.com/file/repo1.maven.org/maven2/org.apache.commons/commons-math3/3.5/org/apache/commons/math3/analysis/polynomials/PolynomialFunction.java

holy shit am i blind or how do i get a polynomial spline function when given knot points and values? i could have sworn there was a method called "interpolate". wtf??
>>
>>51750118
all you're doing is loading a dictionary and randomly picking strings
>>
>>51749812
less than minimum wage compared to someone in a developed country
>>
>>51750130
i forgot about SplineInterpolator. at least i haven't gone completely insane
>>
>>51749227
masha?
>>
Got a friend who wants me to do some webshit for him over the winter break. He's paying, and the task seems simple enough (literally a clone of a game played in /b/ threads that's going to be heavily centered around the chat), so I guess... time to be doing a ton more Ruby programming.
>>
>>51750366
have you made games before?
it might seem easy because creating the actual game logic is pretty easy, but theres a LOT of shit around it that needs to be done, especially if you want animations, GUI and content in general
>>
File: bingo.png (341KB, 740x926px) Image search: [Google] [Yandex] [Bing]
bingo.png
341KB, 740x926px
>>51750424

I have done some game development before, making a scrolling shooter game. What I'm working on, however, has a very minimalist set of rules, and won't require much in the way of graphics changes except for flood filling part of a map. This is a strategy game kind of like Risk, except structured heavily around diplomacy.

Also, kek at this bingo board. Most of this I've done in class assignments... tfw no top center though.
>>
>>51750366
Why not NodeJS?
>>
>>51750484

Because I know Ruby better than I know JS, and I also know this thing isn't going to get more than a few hundred users on at any given time.
>>
>>51750484
kill you'reself
>>
>>51750497
K. Personally, I would invest some time in NodeJS. Shit's really handy when doing projects like you mentioned.
>>51750517
I'm fine. Waiting for christmas.
>>
>>51749713

I love how I'm the only one with top center. It makes me feel like I've almost done something with my life.
>>
>today's adventofcode challenge
What a fucking joke, yesterday's was much harder
>>
>>51750595
What's the challenge?
>>
>>51750557

Grad school really does put a stint in one's career. Although I've been debating whether or not to get a PhD, I do not plan to do so without having spent at least 10-15 years in the industry (as a number of my professors seem to have done). But I am going to focus on getting this master's degree, as I do know of a few job opportunities for me that are opened up because of it.

Also, just realized I can technically check off functional programming. Had to do a lot of racket code for a class on "functional programming and discrete mathematics"... which was mostly the latter, although we did end up writing a bit of code to do things like identifying injections and other logic-related crap.
>>
>>51750615
--- Day 8: Matchsticks ---

Space on the sleigh is limited this year, and so Santa will be bringing his list as a digital copy. He needs to know how much space it will take up when stored.

It is common in many programming languages to provide a way to escape special characters in strings. For example, C, JavaScript, Perl, Python, and even PHP handle special characters in very similar ways.

However, it is important to realize the difference between the number of characters in the code representation of the string literal and the number of characters in the in-memory string itself.

For example:

"" is 2 characters of code (the two double quotes), but the string contains zero characters.
"abc" is 5 characters of code, but 3 characters in the string data.
"aaa\"aaa" is 10 characters of code, but the string itself contains six "a" characters and a single, escaped quote character, for a total of 7 characters in the string data.
"\x27" is 6 characters of code, but the string itself contains just one - an apostrophe ('), escaped using hexadecimal notation.
Santa's list is a file that contains many double-quoted string literals, one on each line. The only escape sequences used are \\ (which represents a single backslash), \" (which represents a lone double-quote character), and \x plus two hexadecimal characters (which represents a single character with that ASCII code).

Disregarding the whitespace in the file, what is the number of characters of code for string literals minus the number of characters in memory for the values of the strings in total for the entire file?

For example, given the four strings above, the total number of characters of string code (2 + 5 + 10 + 6 = 23) minus the total number of characters in memory for string values (0 + 3 + 7 + 1 = 11) is 23 - 11 = 12.

haven't seen the 2nd challenge, but they're never usually much harder than the 1st, just a little further tinkering
>>
after spending some time on webdev how hard is it to move to other more rigorous kinds of software dev? I mean employers won't take you seriously right?
>>
>>51750667
its different from webshit, but you should be fine
employers dont care as long as you're applying to a company with a HR department, because they dont know shit anyway
>>
>>51750550

It's really unnecessary for me to go learn multiple web frameworks when I don't plan to make a career out of web development. Ruby+Sinatra does pretty much everything I need.
>>
>>51750664
what a horribly formulated question for such a retardedly simple task
>>
>>51750692
I thought Ruby has died long ago.
>>
>>51748613
You're a huge tool
>>
>>51750737

It still sees some use today, but it's no longer "hip".

Personally, I don't care about what's hip. I care about what I can effectively wield. For me, where performance is less relevant, Ruby tends to fulfill that role. I tend to use it for pretty much anything that other people would use Python for. Mainly because I'm pretty meh at Python, but have memorized a shit ton of the odd string and array methods Ruby has for manipulating crap.

>>51748608

>nobody here knows C
You wanna go, mate?
>>
>>51750842
>You wanna go, mate?
Nah, i'd rather just filter you.
>>
>>51749193
But boxed types are immutable.
>>
>when you have one giant source file and know eventually you'll need to start cleaning it and separating out classes
>but that would slow down getting stuff working and start the spiral of refactoring and eventually dropping the project
I'm sure by even an intermediate coder's standards it's still a negligible amount of code, but having 6 class prototypes and definitions sandwiching my main is beginning to eat at me.
>>
>>51750980
maybe you shouldn't write shit code in the first place senpai
>>
>>51750842
Fair enough. I'd rather pick Python for the same reason as you.
I know the BBC uses Ruby for testing purposes, so it's not completely dead yet.
>>
Fuck AoC Day 8, I'm not sure why my solution doesn't work anymore and the challenge seems so simple compared to something like Day 7 that I didn't have any problems with, ugh.
>>
>>51750990
But writing good code implies I'm a good coder, domo.
>>
OP here, going to bed.
See you guys in 116 posts!
>>
>>51751261
fucking hell the captcha for reporting is literally impossible. fuck off stupid fag troll
>>
File: attencopper.png (505B, 86x21px) Image search: [Google] [Yandex] [Bing]
attencopper.png
505B, 86x21px
2 weeks to finish chess in javafx

so far i can select a piece, the game knows the type and color, and it's target

did out the game logic yesterday, the checkmate/check looks like it will be a real nightmare but it's all there in pseudocode anyway
>>
where do I find good projects that accept commits or contributors that I can throw on my resume?
>>
>>51751594
Logic as in chess AI?
>>
Apologies for being an absolute fucking retard, but I'm trying to do a foreach loop in C# for each value on a list, but I want to omit a result with a certain value, how do I do that?
>>
>>51751767
And yes I realise I could do an if value = [omitted value] { do nothing } but i was wondering if there was a better way to do it than that.
>>
File: pf.webm (1MB, 853x480px) Image search: [Google] [Yandex] [Bing]
pf.webm
1MB, 853x480px
Ask your beloved programming literate anything.
>>
File: 1418867137457.gif (542KB, 311x283px) Image search: [Google] [Yandex] [Bing]
1418867137457.gif
542KB, 311x283px
>>51751661

just the logic for a chess move, i had something like
// Pseudo
IF PLAYER x
CCHECK; (check for check)
SELECT ONLY x PIECES, SELECT TARGET
IF SELECT is (PIECE TYPE)
RUN PIECETYPE.move(SELECT, TARGET, BOARD)
IF MOVE == VALID
CHANGE BOARD;
CCHECK;
RETURN BOARD, CCHECK;
CHECK WINNER; CHECK STALEMATE

// CCHECK
FOR EACH ENEMY PIECE
CHECK IF MOVE TARGET == KING RETURNS TRUE;
CHECK = TRUE; ELSE CHECK FALSE;

IF CHECK == TRUE
// Check for checkmate
IF EVERY PIECE MOVE
RETURNS CHECK == TRUE
WINNER = 1 or 2 // work it out here
ELSE
SELECT PIECE, SELECT TARGET UNTIL CHECK == FALSE
// alternative is player concedes

IF MOVE == VALID
DO MOVE
CHANGE PLAYER

Tbh it was just something I threw together yesterday as a guideline for when I start doing the move code
>>
>>51750208
my version seems to have much better accuracy for my use case and at least as good accuracy in other cases. fuck yeah
>>
Again, packet dissection and Ethernet frame differentiation.
I wrote a prototype for a dissector in a separate project and now I'm going to integrate it in the main project.
Pretty much the only reason to also implement 802.2 LLC/SNAP is (R)STP.
For the dissector, I want to generate properties, so I only have to define the structure once.
I got some hate for generating classes before, but I still think it's the best way to do it, or at least using metaclasses.
The only issue I still have is reading bitstrings. I don't want to use a library, but there doesn't seem to be a lot written about it.
I'd like some hints on that. I'm using Python.
>>
File: 1345891784347.png (4KB, 205x223px) Image search: [Google] [Yandex] [Bing]
1345891784347.png
4KB, 205x223px
>>51748143
Is there a way to call functions (that use members from my base class) in a derived class from the base class? God, this is such a clusterfuck.
>>
>>51752260
you mean this?
class derived: public base
{
void potato() { base::potato(); }
};
>>
>>51752260
C++? Yes, sure.
>>
>>51752260
class Foo {
void foo() {
if(this instanceof Bar) {
((Bar) this).bar();
}
}
}
class Bar extends Foo {
void bar() {
System.out.println("neat");
}
}
>>
>>51752290
I think he means something like this:
#include <cstdio>

struct Master
{
virtual void dicks()
{
printf("hello\n");
}

void something()
{
// You can also call Master::dicks() here to explicitly invoke the method from base
dicks();
}
};

struct Slave: public Master
{
void dicks()
{
// Same deal here
printf("world\n");
}
};

int main(int, const char **)
{
Slave slave{};
slave.something();
return 0;
}
>>
>>51752290
>>51752291
>>51752308
>>51752315
I must be retarded since I can't figure this shit out.
Main.cpp------------------------
#include "Base.h"

int main() {
Base base;
Derived derived;
base.test();
return 0;
}
Base.h--------------------------
#pragma once

class Base {
protected:
int interestingThing1;
int interestingThing2;
public:
Base() = default;
void test();
};
Base.cpp------------------------
#include "Base.h"
#include "Derived.h"

void Base::test() {
interestingThing1 = 5;
interestingThing2 = 7;
doStuff(); // error: 'doStuff' was not declared in this scope
this->doStuff(); // error: 'class Base' has no member named 'doStuff'
Derived::doStuff(); // error: cannot call member function 'void Derived::doStuff()' without object
}
Derived.h-----------------------
#pragma once
#include "Base.h"

class Derived : public Base {
protected:
void doStuff();
public:
Derived() = default;
};
Derived.cpp---------------------
#include "Derived.h"
#include <iostream>

void Derived::doStuff() {
std::cout << interestingThing1 + interestingThing2;
}
>>
File: Screenshot_1.png (43KB, 675x722px) Image search: [Google] [Yandex] [Bing]
Screenshot_1.png
43KB, 675x722px
whats wrong with my program?
>>
>>51752531
It's not working?
>>
>>51752563
no, idle wont run it.
>>
>>51752531
lower case while dummy
>>
>>51752569
You make absolutely not sense.
Do you poo in loo?
>>
>>51752576
im such a fucking moron. thank you.[spoiler][/spoiler]
>>
Is there a good subreddid that discusses writing programming languages (both interpreted and compiled but preferably more focus on the former)?
>>
>>51752704
The best subreddit for you is the suicide assistance subreddit.
>>
>>51752006
If you were using a probabilistic programming language, you'd already be done.
>>
>no submissive cock sleeve traps again

Why even bother?
>>
>>51752876
go annoy someone else where
>>
How do you design a class which can take const char* directly, std::istream or a filename as a constructor?

MyClass(const char* data);
MyClass(std::istream& data);
MyClass(const char* filename);
>>
>>51751767
Well a for each loop is intrinsically purely iterative. That means that it doesn't even keep track of the count. It just manages to traverse the "array of elements". I say "array" because it could be an enumeration process.
Iterators like the for each loop were made before they even had the "for int" loops like you see today. Back then they were called simply iterators, though.

Sorry I couldn't help you, btw. Maybe you could try to do something like...use a ternary operator that assigns on a conditional basis. If you set the condition to one explicit thing you could make sure that the assignment was only valued against the "omitted" value. This might prompt the compiler to optimize the process as an and process and streamline the array through a omission principle that simply inserts the odd man out at top of the stack and then flushes buffer upon fail.
>>
>>51752886

Newfag detected.
>>
>>51752962
traps stay in lgbt
why not
>>
>>51752908
have your class wrap a buffer of data and then just make your constructors into different ways of loading that data?
whats the problem?
>>
>>51752975

Still a newfag
>>
>>51752979
The problem is, if you pass a const char*, how does the constructor know if its a filename it needs to read to get the data or actual data?
>>
>>51752949
I figured it out anyways, I just used an if statement within the foreach loop, worked to my advantage, because I did want to do something with the value I wanted to omit.
>>
>>51752983
you have to be a newfag to not like traps?
>>
>>51753016

No you just don't know that cross-dressing helps programming skill. Havwnt you seen the old dpts
>>
>>51753051
you'r cancer
>>
>>51752425
I can help walk you through these logic errors if you're still around. This kind of reminds me of the jump between visual basic, as it was in high school where the professor has all the code defined for you, and Java. I think I can help you.
>>
>>51753072

>Newfag calling me cancer
>cant spell you're
>>
>>51753083
I'm still here but I might get off soon as it's pretty late. I've thought about it more and it seems I like I'm a total retard and could just put the methods from the derived class in the base class but then I'd just end up with a gigantic clusterfuck class.
>>
Program yourself some brains faggets
>>
>>51753101
i'm not newfag
>>
>>51753010
Good to hear.

You can still use ternary operators that way, btw. On condition fail it allows you run an expression and since it's limited to one is optimized through a variety of means appropriated to the syntax value. Instead of Giving you a narrowing clause, it branches out.

Food for thought. Happy coding!
>>
>>51753115

>a
>>
>>51753009
const* char only supplies a pointer to a string from a dynamic location. If you pass it as such you will need to handle it as such. If you make the const* char pointer a const pointer to an array of a specified size then you can both let the constructor and future coder that's reading your code know that you are passing a filename.

The program can't know anything you haven't helped it "learn".
>>
Hey guys, do you happen to know about any C# books for a beginner?
>>
>>51753190
check
>>51737163
>>
>>51753111
You are right to be thinking along those lines but it seems to me that you might just be fatigued. I don't say this to be snarky or "smarter" than you, I'm simply meaning that you are placing a class that doesn't exist yet in a class that it turns into, so to speak.

base->derived
derived -/->base

and while derived can make calls to functions within its own base class, meaning that while you can call the point to the class that you extend with your derived class, you can't loop forward in time and back to your base class from the derived stand point.

Also, the this pointer in the classes is intrinsic. You don't need to declare it. And don't forget to define your classes in the .cpp file if you've already declared them in your base class.

Let me know if that makes sense of if I'm coming off as a fucking prick. It's late for me too but I like how much effort you've put into that project there to just let you give up on it before I've extended a helping hand.
>>
>>51753115
Dude, you're arguing with a mod. Who cares, ignore her autism.

You got any code you need help with or are your feelings just hurt? I'm here to help.
>>
>>51753227
dont' forget to declare your functions in the .cpp file, I mean. Not the classes. I guess declaring the classes stands to reason but I don't mean to come off as pedanctic. Let's leave that to the computers.
>>
File: 1448760534865.jpg (69KB, 590x750px) Image search: [Google] [Yandex] [Bing]
1448760534865.jpg
69KB, 590x750px
>>51753208
Will do. Thanks, anon.
>>
>>51753101
>>cant spell you're
>calls someone a newfag
>>
>>51753167
What? I know what a const char pointer is anon.
This is a design question.

struct MyString {
std::string data;
MyString(const char* data) : data(data) {}
MyString(conat char* file) {
ifstream stream(file);
stream >> data;
}
};


How do you distinguish from a file and raw data passed to the constructor?
>>
File: checker.jpg (42KB, 540x420px) Image search: [Google] [Yandex] [Bing]
checker.jpg
42KB, 540x420px
Best functional lang?
>>
File: 4322.jpg (197KB, 840x422px) Image search: [Google] [Yandex] [Bing]
4322.jpg
197KB, 840x422px
Consider the following code:


# include <cstdlib>
# include <iostream>
# include <cmath>

using namespace std;

double Arithmetic_Progression(int n, double a, double l);

/* */
int main(int argc, char** argv)
{
double a;
double l;
int n;
double r;
double q;

n = 5;
a = 1;
l = 10;

cout << "\n";
cout << " Sum of the Arithmetic Progression:\n";
cout << " C++ version\n";
cout << "\n";
cout << "The sum of the Arithmetic Progression of first term:" << a << "\n";
cout << "last term:"<< l << " and " << n << " terms is:\n"<<
cout << Arithmetic_Progression(n,a,l);

return 0;
}

double Arithmetic_Progression(int n, double a, double l)
{
return (a + l)*n/2;
}



The code above is returning me 0x804a04427.5. What gives? In return for your help, a pic of a pineapple pizza .
>>
>>51753227
Yeah, I think I've figured it out. I can do what I'm looking for with a non-instantiable friend class composed of static methods. (at least I hope, I'm going to bed after all this thought)
>>
>>51753355
#include <iostream>
int main() { std::cout << std::cout << 27.5; }

Shortest program that highlights your problem.
Next time figure it out yourself.
>>
Anyone here got any good ideas on a good basis for a grammar model search mechanism? I want to steer clear of the common moralities and empowerment speeches you see in games. Instead I want to focus on the growth process as the means. So, like how you can use particular skills to gain information or opportunities in the Bioware games, instead of getting more loot or instead of making it easier, you learn something about the NPC in the near future or you gain experience towards that one particular's more "hidden" stats.

I know this sounds weird but it almost reminds me of the whole "liked" stat you find in RPGs like Mass Effect and Star Ocean. Except that instead of making you better at getting laid, you can create paralells between how you want your character to grow ( and devote yourself to a hard to train skill at the cost of convincing this particular person you are extending an olive branch ) or micromanage the PC<>NPC relationship to completely change the story for you. I actually intend on making a fully randomized story with branching clauses and all that good stuff but first I need to manage a character that doesn't run on purely inherent biological cycles. No morality, no the journey is the way, no loot fests ( though there is loot ), not god mode 25% of the way into the game. I'd spend more time on this part of it but the fighting system is actually going to be very much in depth. I just don't know how to do both things without making the NPC->PC interactions all about sating immediate desires.

It's a kind of post-apocalyptic/cyberpunk games along the lines of maybe the Diamond Age by Neal Stephenson but with a slight emphasis on the seemingly meaningless changes that can come about from simply not having the opportunity presented to you in the current play through. Heavily inspired by nethack but not emphasizing the mechanics so much as it will all mostly be running from a command line interface that pretty much is you "logging in" to the "matrix?"
>>
>>51753467
>>/ideaguygeneral/
>>
>>51753355
Look closely at this line:
cout << "last term:"<< l << " and " << n << " terms is:\n"<<
>>
>>51752425
looks like you want CRTP, look it up
>>
>>51753446
Why should I figure out myself if you can spoonfeed me?

>>51753516
Thanks for the help, I realized that I used the second << on the second to last cout. Now the program is working good.

Still, I was expecting some kind of breaking segmentation fault that pointed the exact line where it was happening. I guess Python and Java spoiled me a bit.
>>
>>51753533
>Still, I was expecting some kind of breaking segmentation fault that pointed the exact line where it was happening. I guess Python and Java spoiled me a bit.
Usually you'll get that but streams work through black magic and fuck everything up.
>>
>>51753353
Allocation size. Like I said, you can make the parameter, i.e. const char (*data)[ 100 ], then you can't readily expect it to be file data as the OS limit for files is nowhere near 100 characters but the filename limit is.
>>
File: 8a0mptg.png (367KB, 898x475px) Image search: [Google] [Yandex] [Bing]
8a0mptg.png
367KB, 898x475px
>>51753561

redditor invented a programming language
>>
>>51753353
what exactly is the problem using something like this?
struct MyString {
std::string data;
MyString(unsigned char* data, unsigned int size)
{
data.reserve(size);
memcpy(&data[0], data, size);
}
MyString(const std::string& filename) : MyString(std::ifstream(filename)){}
MyString(std::istream& stream)
//Read data here
};
>>
>>51753564
>>51753587
No, data isn't binary, its ascii null terminated.
You don't pass a size to a null terminated c-style-string.
This means constructor signature is the same for both cases.
>>
>>51753496
I just recently got a book on genetic programming for language but I don't have time to do that, look for more work, spend time with my son and come up with things for us to do, write out item lists and plot out the balance system for the fighting engine. I figure someone with enough time working with word dictionaries might have some insight on the matter. I had a friend working on this with me but he's always busy with his hairy faced girlfriend.
>>
>>51753597
Enjoy your JavaScript then. Your design parameters are exactly the reason why you pass an expected limit to the size in your parameter listing. The signature doesn't necessarily "change", the memory that is allocated is more forcibly ascii null terminated.

Your autism is showing. I'll laeve you to it. If you come on here to ask people for help and then deny it on the basis of some imaginary top down design implementation then you fail to see the point of the study.
>>
>>51753597
>declares a, l, n
>assigns n, a, l

ISHYGDDT
>>
>>51753699
>Enjoy your JavaScript then.
What does js have to do with anything?

>Your design parameters are exactly the reason why you pass an expected limit to the size in your parameter listing.
I don't store the data, i pass it on to another library which expects a null terminated c-string.
If i passed a const char* pointer with a size, i would have to copy the data, add a null terminator, and only then pass it on.

>The signature doesn't necessarily "change", the memory that is allocated is more forcibly ascii null terminated.
If you pass a size, the expectation isn't a null terminated string, the expectation is raw binary data.
>>
New Haskell article out:

>>51753751
>>
>>51753800
No one cares.
>>
>>51748472
those increment and decrement functions don't do anything, you muppet
>>
>>51753790
>>51753790
Could you do us the favor and close that penis head brendan frasier thread?
>>
>>51753814
Are you the guy who keeps telling me "No one cares. Kill yourself?"
>>
>>51753354
Common Lisp and Erlang.
>>
>>51753842
He's definitely not the only one who would rather you kill yourself.
>>
>>51753832
Just replace them with modA( int ) and modB( int )
>>
>>51753842
Nope, but let's go with that.
>>
>>51749099
>java can't pass anything by reference
ftfy
>>
>>51753842
Don't worry about her. She's probably one of the mods come here from fit to spread disinformation. You really don't know how far people have been going in this term of election. I know it sounds unrelated but it isn't.

I'm probably going to get banned in a bit under some false premise.
>>
>>51749782
>Make the user supply
>Make
b-but muh freedoms
>>
>>51753925
C is all about caller responsibility. It's not as safe, but it's how you get efficiency.
>>
>>51753843
>common lisp
>functional
ishyggy
>>
>>51753855
webfag detected
>>
>>51753941
>implying the callee doesn't have responsibilities
m8...
>>
>>51753997
Of course they do. But to write idiomatic and fast C code, which is why you should be using C in the first place, the caller must be allowed to control things like allocation.
>>
>>51753981
I just noticed that it was for a map too. I couldn't imagine he'd only implement increment functions if he was going to simply a manner to randomly call the functions...

Using a switch case he'd have a better output time than incrementing through the list from such a high level operation. Creating an interface would knock out both the construction phase and the directing phase in the design.

Is it like women's day or gay gay or something? All these work arounds for legitimacy points but it seems someone is failing to see that they're just opening up more access points for someone to squeeze information out of.
>>
>>51748472
Uhhh not that you're gay or feminine or anything. But it seems completely unlike you're learning and rather just applying something by force, the way a lot of the current feminism and gay rights movements are pushing right now.

Also, yeah, I don't think those incremement and decrement functions are doing anything.
>>
>>51753981
Kind of blind and, honestly, reading through the constructs on here sometimes gives me a headache. Appreciate the correction, though. But I'm not exactly a "webfag". I just don't hide behind the details as if people can't just outright tell a bold lie from a superiority complex.
>>
File: 1449168919306.jpg (31KB, 353x353px) Image search: [Google] [Yandex] [Bing]
1449168919306.jpg
31KB, 353x353px
>>51754096
>>51754131
>>
Working on big fat CSV convert via sqlite in python. Has 70 headers exact, maybe 20-24k entries.
Currently have this and getting syntax error from col1
 import csv, sqlite3
conn = sqlite3.connect('cust.db')
c = conn.cursor()


def make_database():
c.execute('CREATE TABLE IF NOT EXISTS ctable ('col1 VARCHAR


Any ideas why that col1 would throw a syntax error?
>>
>>51754312
i think the syntax highlighting shows you
>>
>>51754312
I think I get it now.
""" needs to go right before create table and after I establish what headers Ill be using
so
c.execute("""CREATE TABLE IF NOT EXISTS example(header0 VARCHAR, header1)""") 
>>
Night, you guys. Morning for those of you in the Americas.

I'll hopefully be back in a few hours to shit post.

Yeah, I know. I don't really care, though. DPT is awesome to me.
>>
Right now a basic webapp in django for handling inventory, point of sales, and some accoutning info.

Next try developing an app for a better loyalty rewards program.
>>
how one can really acquire programming literacy ?
>>
>>51753586
nice programming language ahmed
>>
In C++, can you pass a class member to std::function within current class? For instance:
struct SomeFunc
{
void foo()
{
baz(bar);
}

bool bar(int a)
{
return true;
}

bool baz(const std::function<void(int)> &func)
{
return func(5);
}
};
>>
>>51754442
>func returns void
>baz returns bool
>return func(5);
>>
>First time learning programming
>Learn Python at school when younger, too easy for me
>Try to learn something harder
>Start to read about C so I can later make the transition to C++
>Start to make C excercises
>Reach excercise 10ish
>Start to get overwhelmed, my head hurts
>go to sleep
>Never touch it again

How do I stop this, /dpt/? How do I become a programmer and stop my body and brain from being such a fucking faggot to me?
>>
>>51754701
Learn Go.
>>
>>51754701
Forget Python completely.
Even if you go from knowing Python to knowing nothing, it is better.
>>
Hope do you find the motivation to work on personal projects while doing programming as a job? I feel like all I ever do anymore is write glue code and unit tests.
>>
>>51754750

I already pretty much forgot everything about Python, I only remember it being a piece of shit.
>>
>>51754442
say you fixed what >>51754553 pointed out
you'd still need to either
>use std::bind to bind 'bar' to 'this'
>instead of passing bar pass a lambda that captures 'this' and calls bar

second version is much more readable and preferred
>>
Our entire team just switched from C to Java so I get to rewrite a bunch of bullshit.

It's about as fun and rewarding as it sounds.
>>
>>51754787
template <typename T>
class memberInvoke
{
memberInvoke(T& x) : closed(&x) {}
template <S, T ...>
decltype(auto) operator()(S&& fn, T&&... args)
{
return fn(closed, args...);
}
T* closed;
}
>>
>>51754817
Good to hear you guys are growing up.
>>
>>51754821
some_class y;
memberInvoke<decltype(y)> closure(y);
auto some_result = closure(some_class::some_function, arg1, arg2, arg3);

something like that (needs specialising for void)
>>
>>51754821
>>51754844
that's 99.9% of what std::bind is/does
why go through the trouble and reimplement it?
>>
>>51754817
should have switched to Go instead
>>
>>51754817
If you have a large codebase, C++ might make a lot more sense than Java. You could have a much smoother transition, and all the existing code will still work as you migrate.

Then again, you might end up with really shitty C-style C++ if the team is all C programmers.
>>
>>51754817
At least anything involving strings will be much less painful now
>>
>>51754821
Literally reinventing the lambda/std::bind.
>>
>>51754860
>>51754878

it's specifically for member functions

you could make a free function so that it's
member(y)(some_class::some_function, args)
and not
[&](){ return fn(&y,args...); }


std bind is shit btw
>>
>>51754904
or even better,
member(y, some_class::some_function)(args)
>>
>>51754701
Listen to your body and move on to something else.
>>
File: side-project.jpg (89KB, 627x960px) Image search: [Google] [Yandex] [Bing]
side-project.jpg
89KB, 627x960px
>>51754772
>I feel like all I ever do anymore is write glue code and unit tests.
Maybe by designing a project from scratch? Maybe by working in a different area from your job? Let's say you work in something related to distributed systems, your personal project could be about AI, writing a compiler for an existing or new language.
Just do something different
>>
>>51754701
i'm sorry to tell you this but it seems as though python has ruined you for life
>>
In Java, if I have a list with strings and I attempt to add another string at an index that already has one, what happens? Does the old one get deleted, or does the list expand, or what?
>>
>>51754701
>>51754750
>>51754981
>tfw you fell for the talking snake
>>
>>51755013
It replaces the string at the index, so the old one gets removed
>>
>Easy to use. Ruby was designed by Yukihiro Matsumoto (often just called "Matz") in 1995. Matz set out to design a language that emphasized human needs over those of the computer, which is why Ruby is so easy to pick up.
Ruby confirmed for girly faggots
>>
>>51755066
>do begin end begin do end end do end begin end
N-NO THANK YOU!
>>
>I only have an interest in making functional tools for simplifying things, that other people might actually have a use for.


What's wrong with me?
>>
Ruby is high-end
>>
>>51755042
Thanks. One more question, if you wouldn't mind, that is.
If I'm trying to print out all the elements of a set, one per line, and I start like this, I supposedly wouldn't be able to complete it. Why? I need two alternatives that would work, too.
for(int i = 0; i < sample.size(); i++ ) {
>>
>>51755199
You need to study more type theory.
>>
File: history.png (41KB, 574x331px) Image search: [Google] [Yandex] [Bing]
history.png
41KB, 574x331px
NEW THREAD AT >>51755311

NEW THREAD AT >>51755311
>>
>>51748786
>>C#
>DEPRECATED! Use Infer.net instead.
What are you even saying with this?

Infer.NET is a library used by the C# language.
Thread replies: 318
Thread images: 42
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y / ] [Home]

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
If a post contains illegal content, please click on its [Report] button and follow the instructions.
This is a 4chan archive - all of the content originated from them. If you need information for a Poster - you need to contact them.
This website shows only archived content and is not affiliated with 4chan in any way.
If you like this website please support us by donating with Bitcoin at 1XVgDnu36zCj97gLdeSwHMdiJaBkqhtMK