[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
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 42
old thread: >>51741895

What are you working on, /g/?
>>
>>51748143
C!
>>
File: 1448263215242.jpg (63 KB, 600x338) Image search: [Google]
1448263215242.jpg
63 KB, 600x338
>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 (430 KB, 811x599) Image search: [Google]
1445277014687.png
430 KB, 811x599
>>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 (38 KB, 1130x847) Image search: [Google]
pos.png
38 KB, 1130x847
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 (499 KB, 300x250) Image search: [Google]
wheeeeee.gif
499 KB, 300x250
>>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 (265 KB, 637x477) Image search: [Google]
1429667391238.png
265 KB, 637x477
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 (119 KB, 1080x1080) Image search: [Google]
1448457441953-3.jpg
119 KB, 1080x1080
>>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 (48 KB, 1008x720) Image search: [Google]
lain-is-a-bear.jpg
48 KB, 1008x720
>>51749022
Rush and white girls are disgusting.
>>
File: 1444748701765-1.jpg (378 KB, 2592x1944) Image search: [Google]
1444748701765-1.jpg
378 KB, 2592x1944
>>51749022
Subhuman please go.
>>
File: 1431929892325.jpg (311 KB, 800x1202) Image search: [Google]
1431929892325.jpg
311 KB, 800x1202
>>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 (3 MB, 550x309) Image search: [Google]
1448870372218.gif
3 MB, 550x309
>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 (479 KB, 320x240) Image search: [Google]
1446962972638.gif
479 KB, 320x240
>>51749113
>need to make an object just to pass "primitives" by reference
>>
File: 1444748701766-4.jpg (4 MB, 4288x2848) Image search: [Google]
1444748701766-4.jpg
4 MB, 4288x2848
>>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 (56 KB, 408x383) Image search: [Google]
1386792647769.jpg
56 KB, 408x383
>>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 (319 KB, 2560x1707) Image search: [Google]
1449069094557-1.jpg
319 KB, 2560x1707
>>51749183
I actually am dating a light-skinned hispanic girl. They are good too.

>>51749196
That's an American.
>>
File: 1428462828977.png (73 KB, 360x403) Image search: [Google]
1428462828977.png
73 KB, 360x403
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 (10 KB, 213x319) Image search: [Google]
lelastar.jpg
10 KB, 213x319
>>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 (301 KB, 641x720) Image search: [Google]
1436514829711.png
301 KB, 641x720
>>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 (319 KB, 740x926) Image search: [Google]
bingo.png
319 KB, 740x926
Late night bingo time.
>>
File: rangeindicator.png (2 KB, 345x351) Image search: [Google]
rangeindicator.png
2 KB, 345x351
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 (5 KB, 345x351) Image search: [Google]
rangeindicator.gif
5 KB, 345x351
>>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 (365 KB, 740x926) Image search: [Google]
nobingo.png
365 KB, 740x926
>>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 (325 KB, 740x926) Image search: [Google]
bingo.png
325 KB, 740x926
>>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 (181 KB, 708x914) Image search: [Google]
image.jpg
181 KB, 708x914
>>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 (300 KB, 740x926) Image search: [Google]
code-bingo.png
300 KB, 740x926
>>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 (166 KB, 740x926) Image search: [Google]
bong.jpg
166 KB, 740x926
>>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 (341 KB, 740x926) Image search: [Google]
bingo.png
341 KB, 740x926
>>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 (505 B, 86x21) Image search: [Google]
attencopper.png
505 B, 86x21
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 (1 MB, 853x480) Image search: [Google]
pf.webm
1 MB, 853x480
Ask your beloved programming literate anything.
>>
File: 1418867137457.gif (542 KB, 311x283) Image search: [Google]
1418867137457.gif
542 KB, 311x283
>>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 (4 KB, 205x223) Image search: [Google]
1345891784347.png
4 KB, 205x223
>>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 (43 KB, 675x722) Image search: [Google]
Screenshot_1.png
43 KB, 675x722
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 (69 KB, 590x750) Image search: [Google]
1448760534865.jpg
69 KB, 590x750
>>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 (42 KB, 540x420) Image search: [Google]
checker.jpg
42 KB, 540x420
Best functional lang?
>>
File: 4322.jpg (197 KB, 840x422) Image search: [Google]
4322.jpg
197 KB, 840x422
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 (367 KB, 898x475) Image search: [Google]
8a0mptg.png
367 KB, 898x475
>>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
Thread replies: 255
Thread images: 42

banner
banner
[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.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.