[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: 25
File: 1444378145195.png (2 MB, 1696x2467) Image search: [Google]
1444378145195.png
2 MB, 1696x2467
old thread: >>52496734

What are you working on, /g/?
>>
#define N 10

struct buffer {
char *left;
char *right;
char *begin;
char *end;
};

char* extract(struct buffer *b)
{
char *beginloc = b->begin >= b->left && b->begin < b->left + N ? b->left : b->right;
char *endloc = b->end >= b->left && b->end < b->left + N ? b->left : b->right;
char *ret;

if (beginloc != endloc) {
ptrdiff_t len1 = beginloc + N - b->begin;
ptrdiff_t len2 = b->end - endloc;

ret = malloc(len1 + len2);

memcpy(ret, b->begin, len1);
memcpy(ret + len1, endloc, len2);
} else {
ptrdiff_t len = b->end - b->begin;

ret = malloc(len);

memcpy(ret, b->begin, len);
}

return ret;
}


Could I do anything to improve this function?
>>
>>52503608
Would it kill you to write more descriptive variable names?
Also, stop abusing ternary operators
>>
File: snake.jpg (15 KB, 769x409) Image search: [Google]
snake.jpg
15 KB, 769x409
>>52503588
>>
>>52503608
>char *beginloc = b->begin >= b->left && b->begin < b->left + N ? b->left : b->right;
>char *endloc = b->end >= b->left && b->end < b->left + N ? b->left : b->right;
Jesus christ
>>
>>52503639
chip8?
>>
>>52503739
yeah famalam
>>
>>52503608

What the fuck does it actually do?
>>
>>52503633
The buffer is in two halves, left and right, where begin and end point to the beginning and end of a string to extract. I'm not sure what names I could use that would be more descriptive.

>stop abusing ternary operators
char *beginloc, *endloc;

if (b->begin >= b->left && b->begin < b->left + N) {
beginloc = b->left;
} else {
beginloc = b->right;
}

if (b->end >= b->left && b->end < b->left + N) {
endloc = b->left;
} else {
endloc = b->right;
}


So I should do it like this?
>>
>>52503608
what if b->begin was less than b->left? Would it still be b->right?
>>
>>52503748
I write a chip8 emulator in any new language I learn as an exercise. So far it was simplest in golang, but easiest to build/debug in C#. Thinking I may try it in something weird next.

I fucking hate the sprite drawing function. I always spend half the entire damn time implementing that shit. You'd think I'd have it down by now, but it grinds my nuts each time.
>>
>>52503803

#define anonproc(bigend) \
bigend ## loc = \
(b-> ## bigend >= b->left && b-> ## bigend < b->left + N) ? \
b->left : b->right

anonproc(begin);
anonproc(end);

#undef anonproc
>>
>>52503789
-- left          -- right
V V
+----------------+----------------+
|i:f: :(:m:y:_:\0|v:a:r: :=:=: :\0|
+--------^-------+----^-----------+
| |
begin end


Extracts a string which may or may not be split over two buffers like this.

>>52503810
Yes. I mean I suppose I could do another check to make sure it's in b->right but I'm just assuming if it's not in left then it's in right.
>>
can someone give me a rundown of rails vs django? i'm coming from rails, and i'd like a heads up before i run into shitty problems.
>>
I'm writing css for Firefox, and when I use

.tabbrowser-tab[selected=true] { }

it works for the selected tab but,

.tabbrowser-tab[selected=false] { }

doesn't work for the rest of the tabs. What would I use to target the tabs that aren't currently selected?
>>
>>52503854
>css
>programming
>>
>>52503818
>I fucking hate the sprite drawing function
Are you separating the drawing from the actual grid array changing? From what interpreters online are saying, CLS and DRW set a draw flag and that's the ONLY time you go through the screen array and update all the squares.

If you are doing that, but it's the algorithm for setting the screen squares, it's really not that difficult. You loop through each line and XOR each bit onto the screen x and y which is mod 64 and 32 respectively, setting the VF to 1 if it becomes 0.

Which bit do you find difficult?
>>
>Trap threads are the norm now and no one complains

We've become enlightened
>>
What's the difference between being a C# developer and being a .Net developer? Can I call myself a .net developer if I'm good enough at c#? What if I do C# in mono on linux?
>>
>>52503854
:not
now go back to >>>/g/wdg
or a search engine, preferably
>>
>>52503878
If you only use C# you're not a .NET developer
>>
>>52503845
>Yes. I mean I suppose I could do another check to make sure it's in b->right but I'm just assuming if it's not in left then it's in right.
Oh that diagram explains it. I'm assuming that when 2 buffers are passed through, that it is only passed through through that format or if b->end was left of b->right
>>
File: q46L4QH.jpg (166 KB, 790x403) Image search: [Google]
q46L4QH.jpg
166 KB, 790x403
>>52503888
How does one become a .net devloper. Do I have to learn fucking visual basic? What is the benefit of being a .net developer other than all the Microsoft jew gold
>>
File: FSharp.jpg (64 KB, 440x389) Image search: [Google]
FSharp.jpg
64 KB, 440x389
>>52503905
Become an F# wizard like me
>>
>>52503927
Does anyone hire F# developers?
>>
>>52503952
                                                                                                           no
incidentally no one hires functional programmers in general
>>
>>52503952
Get a job as a .NET developer and just use F#
>>
>>52503963
>no one hires functional programmers in general
Scala is pretty big in job searches. At least here in london
>>
>>52503973
So .net is like the JVM right? So if I were to get hired as a .net dev, I could dick around in C#, VB.net, asp.net, of f# and nobody would have a problem with it because it all runs on the same platform?
>>
>>52503992
In theory. At the end of the day it's still up to your employer if they dislike F#, or need performance critical code.
>>
>>52503981
name a good coder that has ever come out of london
>>
>>52503588
Why aren't there any good programming languages, /dpt/?
>>
>>52504015
do your own homework
>>
>>52504010
let mutable ...
>>
>>52503992
All .NET languages compile down to IL.
>>
>>52504010
So let's say a team is working on some API for internal use. Of course, we all agree on the same language (let's say C#). Could we write an API in C# whose endpoints could be use by a Visual basic developer?

If I wanted to be a .net developer, do I simply learn all the most common languages on the .net framework?

Also. I hate using windows. Is mono acceptable enough for me to learn at home?
>>
34th for new nim release

http://nim-lang.org/news.html#Z2016-01-18-version-0-13-0-released
>>
>>52503866
I use a draw flag, yes.

It's just the sprite drawing itself. It's just the right amount of looping that solving it the obvious way looks like "there's gotta be a more concise way".

I'm never sure how much of it I should break out into a function for readability or if I should inline everything for "speed".

It's mostly self imposed superstition.
>>
>>52503866
>screen x and y which is mod 64 and 32 respectively

Explain, please. How does mod help in this case? I may be dumb, I just do i++ style indexing over x and y values. How could mod simplify it?
>>
File: draw func.jpg (36 KB, 549x229) Image search: [Google]
draw func.jpg
36 KB, 549x229
>>52504078
It's 2 for loops mate

>>52504095
mod is used because CHIP-8 spec says sprites wrap around the screen, so if the next x or y goes 64 or 32 respectively, mod turns it into 0. 65 or 33 is 1, etc
>>
>>52504046
>2 -1 and 2 - 1 parsed differently
>echo $foo and echo $ foo parsed differently
>first release with multi line comments

damnit nim
>>
What stops you from killing yourself, /dpt/?
What keeps you alive?
What do you live for?
>>
File: draw func.jpg (39 KB, 392x257) Image search: [Google]
draw func.jpg
39 KB, 392x257
>>52504129
this might make it simpler. As you can see, the screen's x index and y index is the place you're drawing to + where you are in the loop, but mod 64 or 32 to screen wrap
>>
>>52504165
Thales said there was no difference between life and death. "Why, then," said some one to him, "do not you die?" "Because," said he, "it does make no difference."

A deterministic universe programmed me to do certain things, of them, being alive is one.

To learn.

>cheer up, friend.
>>
>>52503608
>>52503845
char *extract(struct buffer *b)
{
char *ret;

bool begin_is_left = (size_t)(b->begin - b->left) < 10;
bool end_is_left = (size_t)(b->end - b->left) < 10;

if (begin_is_left == end_is_left)
asprintf(&ret, "%.*s", b->end - b->begin + 1, b->begin);
else
asprintf(&ret, "%s%.*s", b->begin, b->end - b->right +1, b->right);

return ret;
}

This makes a few assumptions about the buffer, is untested and uses non-standard (but POSIX standard) functions.
-The buffers are always null terminated
-If begin and end are in different buffers, begin is in left and end is in right
-It relies on signed to unsigned conversion, but that is well-defined in C.
>>
>>52504165
Need to hack E corp and free the world
>>
>>52504292
>but POSIX standard
Actually wait, I realised I'm actually wrong.
It's a GNU extension and part of the Linux Standard's Base.
>>
I'm trying to get 4chan threads, but I'm having trouble with the fact I absolutely have to have my "dpt" method be exactly as it is right now (synchronous, returning a List<string>).

I can't figure out how I'm supposed to get the board data because all of the bits that actually get the JSON can only run Async.

How in the fuck am I supposed to do this?

http://pastebin.com/E7RwwgMZ
>>
>>52504517
Never mind, ".Result" allows me to run the requests synchronously.
>>
How would you implement a natural sorting algorithm /dpt/?
ex: 1 2 3 4 5 6 7 8 9 10 11 instead of 1 10 11 2 3 4 5 6 7 8 9
I looked at the examples here but I'm too retarded to understand them
http://www.davekoelle.com/alphanum.html
>>
>>52504772
bool sorted(char* str1, char* str2)
{
return (str1 <= str2);
}
>>
File: prog_sleepsort_40.png (556 KB, 1907x5648) Image search: [Google]
prog_sleepsort_40.png
556 KB, 1907x5648
>>52504772
>>
>>52504860
O(1)
>>
>>52504865
There is no list sorting algorithm that's O(1).
>>
>>52504870
http://c2.com/cgi/wiki?QuantumBogoSort

:^)
>>
>>52503588
That image is /dpt/ epitomised. Good choice.
>>
>>52504292
>If begin and end are in different buffers, begin is in left and end is in right
This is not always the case, if end moves past the right buffer it wraps around to the left buffer. I suppose I could just swap what left and right point to in that case.
>>
>>52504905
/dpt/ is full of meme spouting retards from facebook. Not a single cute trap among them.
>>
>>52504927
>Not a single cute trap among them

b-but ;_;
>>
>>52504927
There's one at least but I'm not sure how active she is. We talk on irc.
>>
>>52504924
I wasn't sure if the buffer was circular or not. Modifying it to support that wouldn't be too hard though.
>>
>>52504936
>she
>s
>>
>>52504936
>irc
A trap is not a tranny.
>>
>>52504933
I'm sure you're adorable.
>>
>>52504947
I'm using a colloquialism. Fight me.

>>52504945
You heard me.
>>
I feel sick and don't want to do anything
but I have a paper I need to write
>>
>>52504964
Trannies are not cute so you didn't even do that part right.
>>
does anyone else feel empty because they know they can never learn everything about computers? Trying out smashthestack I figured out a few things but ultimately it's over my head. Feels bad man.
>>
>>52504990
They are too. You're just thinking of bad porn.
>>
>>52505018
You just need to keep at it. There's a lot of foundational knowledge you need to build up.
>>
>>52504970
200 UTF-8 characters about Free Software
>>
>>52505027
They are not. You're just bias.
>>
>>52505050
You're just gay.
>>
>>52505057
That would mean I'd like trannies because they're still men.
>>
where's that anon that was working on snake in haskell????
>>
>>52505068
Nah. They're more feminine than your boys with shaved legs.
>>
>>52505089
Anyone retard can be a tranny. A trap is a trap.
>>
>>52505122
Literally gay.
>>
>>52505126
You're the one that likes trannies right?
>>
>>52505089
crossdressing is moe
having a mental disorder and believing you're a woman trapped in a man's body is not
>>
>>52505035
I mean, I know a lot of fundamental knowledge, I've studied computers my whole life and read a lot of books, what kind of fundamental knowledge are you talking about exactly?
>>
I'm not a programmer but wanted to make a little script that rolls a random number and plays a file with that number. I then wanted to add a little database with info about each webm so I could display links to the song etc if it was a song.

It worked for numbers under 10 and from there on it will pull other titles and it seems like it has no pattern. Right as I run into this I notice that I'm retarded and my script would have broken anyways for numbers that recur like 1 11 111.

Wont post source because it's disgusting. Also, kill me.
>>
>>52505260
Just to tag on to my post is there a way I could have done this instead with metadata in the webm or something?
>>
>>52505260
If you don't post source no one can help you, can't diagnose an error that we can't see senpai.

Just post it, nobody cares how dogshit ugly your code looks.

>>52505278
Yes, depending on what language you're using - In C# there's a library called "taglib" which can pull metadata from files.

Filenames should work fine as far as I know, I can't tell though because I can't see your damn code.
>>
>>52505260
Working on a bug for Thunderbird. Some joker figured out that if you date your emails from before epoc you can get it to wrap around and say that the email is from the future.

So some dude dates his email as being from the 1920's and thunderbird thinks it's from 2105.
>>
>>52505283
I've gone about it the wrong way though I think anyways. It's in php but I'm willing to do it in any other language though since I am a beginner at php.
>>
>>52505327
Do it in C# family.

Join the dpt IRC (irc.rizon.net || #DPT) and I'll help you out.
>>
>>52505327
The obvious way I can think of is using the index in an sql database as the number for the random number, then just have a bunch of info in the other fields and a filename.
>>
>>52505408
oshit, there's a DPT IRC channel?
>>
>>52505408
dpt is fake, the real channel is #/g/sicp
>>
>>52505408
>>52505425
Doesn't irc give away my location?
>>
>>52505408
Stop spamming your shitty IRC channel
>>
>>52505432
No, it's far better than /dpt/.

>>52505427
Not if you do what every other IRC user does and masks their client.

>>52505425
>Implying
>>
>>52505427
not if you use a proxy like ircclound
>>
>>52505436
Why the hell are you even here, fag?

!loli
>>
>>52505410
I've got no experience with sql really. The server I'm running on is extremely tight on ram so I'd like to do it in sqlite or something. I'm gonna do it tomorrow though since it's late as fuck.
>>
>>52505432
DDOS his IRC senpai.
>>
>>52505425
this
>>
>>52505473

>DDoSing Rizon
Really?
>>
What's that article/blog post rant about programming with the s/underscore/camel/ part?
>>
I'm learning C by reading/using Head First C. Its pretty fun so far, I've only really used C# before this, my goal is building a better foundation knowledge of programs, computers, and programming. I'm going to start going to my community college for a CS degree.

I want to make programming my life.
>>
>>52505862

Sounds like an alright plan, but do know that the only thing good about community college is getting all of one's GUR courses out of the way before heading to university. And once you're in university, you may want to consider how you wish to specialize your knowledge of programming.
>>
>>52505896
I might be too poor for university. I didn't get good grades in high school and I'm a straight up white male. I didn't take any classes that would lead into programming in highschool and to be honest I didn't do any of it before the age of 23. I'm 23 now going on 24 but I actually like programming and have stopped playing games entirely because almost all my free time goes to reading and programming.

This is going to sound dumb/cliche but I want to get into game development even though I know the hours are stressful, its more difficult, and you get paid less. I'm kind of hoping that between work and school I can make enough games to attract some sort of attention. Its a good thing that everything you need to program is basically free and the only limits of what you can do are your own boundaries pretty much.

Programming is literally magic.
>>
i'm going for a php/js internship tomorrow and so i've been learning php over the past day or so and i've got a quick question

function myAge($birthYear)                                       // defines a function, this one is named "myAge"
{
$yearsOld = date('Y') - $birthYear; // calculates the age
return $yearsOld . ' year' . ($yearsOld != 1 ? 's' : ''); // returns the age in a descriptive form
}

echo 'I am currently ' . myAge(1981) . ' old.'; // outputs the text concatenated
// with the return value of myAge()
// As the result of this syntax, myAge() is called.
// In 2014, the output of this sample program will be 'I am currently 33 years old.'


is
($yearsOld != 1 ? 's' : '')
just a macro function (if that's what they're called in this context) saying that if the variable $yearsOld is not 1, then concatenate an 's', otherwise concatenate ''?
>>
>>52506057
https://en.wikipedia.org/wiki/%3F:
>>
>>52505976
i don't mean to shit on your parade but imo you probably won't really have enough time and energy to get really good at game development if you have both work and school as well. proper games can take years to make even when working full-time on them.
>>
Does Haskell have type type class classes yet? Fucking slackers and their shitty type system
>>
>>52505976

>I might be too poor for university.
My mother is disabled due to a blood disorder called HTLV-1. We live on her disability, food stamps, and section 8 housing because she literally cannot work. Nonetheless, while living with her, I have managed to get my bachelor's degree, paid for entirely with pell grants, student loans, and work study. I am now working on my master's degree, and am no longer able to receive the pell grants. Fortunately, however, I am able to work on a research assisstantship, and get a partial tuition waiver.

If I can get a BS in computer science with nothing but government assistance, surely your broke ass can too. And if you feel any bit guilty about it, just remember that when you're making decent money on your programming, about 30% of it is going to be robbed from you every year to pay for the next guy... and a bunch of other people who aren't trying to lift themselves out of poverty.
>>
>>52503588
SAUCE! I KNOW IT'S A DANK MAYMAY SHOOP! BUT SAUCE PLEASE GODDAMMIT!
>>
>>52506105
I live with my parents and they make enough that we can't get federal aid, they just spend all the money on cigarettes, alcohol, and terrible luck with car troubles. Not that I'm blaming them, I just can't really get federal aid while I live with them. Next year I won't be a dependent though so I could probably get some sort of government aid from college. I'd rather not take student loans though even if it takes me longer and probably costs me more money in the long run. My paranoia extends beyond just using linux instead of windows, I don't EVER want to be in debt.
>>
>>52504136
In which way are they parsed differently?
>>
>>52506201
RTFLink
>>
How can I make OnWeightChanged more efficient here? It's called often and _bag can be fairly big at times.

using System.Collections.Generic;

public class WeightedPicker<T> {
public WeightedData<T>[] Data { get; set; }

private readonly int _min = 0;
private int _max;

private readonly List<int> _bag;

public WeightedPicker(WeightedData<T>[] data) {
Data = data;
List<int> bag = new List<int>();
for (int i = 0; i < Data.Length; i++) {
Data[i].WeightChanged += OnWeightChanged;
for (int j = 0; j < Data[i].Weight; j++) {
bag.Add(i);
_max++;
}
}
_bag = bag;
}

void OnWeightChanged(object sender, WeightChangedEventArgs args) {
int difference = args.NewValue - args.OldValue;
if (difference != 0) {
bool remove = difference < 0;
WeightedData<T> data = (WeightedData<T>)sender;
for (int i = 0; i < Mathf.Abs(difference); i++) {
int index = IndexOf(Data, data);
if (remove) _bag.Remove(index);
else _bag.Add(index);
}
_max += difference;
}
}

int IndexOf(WeightedData<T>[] array, WeightedData<T> item) {
for (int i = 0; i < array.Length; i++) {
WeightedData<T> other = array[i];
if (other == item) return i;
}
return -1;
}

public WeightedData<T> GetRandomWeightedData() {
if (_bag.Count == 0) return null;
int r = Random.Range(_min, _max);
return Data[_bag[r]];
}
}
>>
>>52506071
>>52506057
https://en.wikipedia.org/wiki/Ternary_operation
>>
>>52506194

>Next year I won't be a dependent though so I could probably get some sort of government aid from college.
This is good. Go to university after a good 2 cheap years of community college.

>I'd rather not take student loans though even if it takes me longer and probably costs me more money in the long run
I'll admit it's a bit of risk, but if you can find a little confidence in your abilities, you may find it a risk worth taking. My bachelor's degree cost me a total of 17k due to a combination of pell grants and work study. In hindsight, had I invested a little time into finding scholarships, it might have been less. After I obtain my Master's Degree, however, based on my current rate of accumulating debt, it should be around 40k, as I no longer have the grants (although I still have work study). This amount still amounts to a lot, but if one considers that I have grown used to being extremely frugal, even if I were to take a shitty 60k a year job making CRUD apps (and I will note that 60k a year is quite low for someone with a master's degree and experience in security research), I could still pay off the entire thing in 1 or 2 years.

Debt isn't a bad thing to have. You can be smart and responsible and maintain a little bit of debt. But you can also be stupid with it and treat it like free money. I know damn well my loans aren't free, but I also know damn well I can pay them back if I keep playing my cards right.
>>
File: chip8.png (15 KB, 794x479) Image search: [Google]
chip8.png
15 KB, 794x479
>>52503818
speaking of chip-8, I started writing the instruction interpreter for my own and it looks something like this.

Whenever it comes to anything of this nature, which is pretty common, I always feel like there is some better way than just using switches I just don't know about? Is there or is this about what should be expected?
>>
>>52506347
>My bachelor's degree cost me a total of 17k
You mean "including everything" or just university costs?
>>
>>52506388
> case 0x$: return INSTR_$$NN(instance, opcode);
Why aren't you using macros?
>>
>>52506388
x-macros are pretty fucking cool so I want to tell people about them.
http://bisqwit.iki.fi/jutut/kuvat/programming_examples/chip8/chip8.cc
>>
>>52506419
I thought about it

I didn't because a macro would feel kind of dirty when you're using it to pass the same two arguments over and over. Should I have?

I did however use one for defining the routines for the instructions themselves. i.e

#define INSTR_MAKE_DECLARATION(n) static inline \
__attribute__((__always_inline__)) int INSTR ## n (chip8::Inst *instance, word opcode)

#define INSTR_DEF(name) INSTR_MAKE_DECLARATION(name) // needed for proper expansion

...

// program counter = NNN
INSTR_DEF(_1NNN) {
instance->PC = (opcode & 0x0FFF);
// Cycle(instance);
return 0;
}


which was probably pretty pointless
>>
>>52506397

What do you define as "including everything"? I live with my mother, so I don't pay rent, although I do help her out with a couple of bills, namely cable, and some of the household necessities. Other than that, I guess the 17k was entirely for tuition. Although to be honest, it could have been less had I been able to get my bachelor's in 4 years instead of 5. Which is half due to not wanting to overload myself with work (something I'm doing now out of what is either insanity, boredom, or masochism), and half due to the core classes getting filled up way too damn fast. 20-40 seats every quarter for a class that is a prerequisite for half the classes in the program.
>>
>>52506474
Get the FUCK off /g/ Aaron
>>
>>52506473
define two macros
>>
File: 2ea.jpg (11 KB, 200x291) Image search: [Google]
2ea.jpg
11 KB, 200x291
>>52506483
Oh no! you know my incredibly common name!

Let me delete my post with great haste!
>>
File: Reimu-KittyEars.jpg (116 KB, 600x600) Image search: [Google]
Reimu-KittyEars.jpg
116 KB, 600x600
>>52506474

Because I program in Times New Roman, size 12, Anon.
>>
>>52506492
If you don't get off /g/ I'm gonna let Michael know.
>>
>>52506492
Go away Aaron King
>>
>>52506492
>he actually deleted it
fucking kek

saved
>>
>>52506487
is it normal to make a macro that would contain variable names you're using hardcoded into it? it doesn't seem like something I should be doing

>>52506434
I don't understand some of what I'm looking at here.
>>
>>52506515
use macros whenever you repeat code and can't refactor another way
>>
>>52506515
x-macro:

#define oneToTen \
X(1) X(2) X(3) X(4) X(5) \
X(6) X(7) X(8) X(9) X(10)

#define X(x) printf "%i" x
oneToTen
#undef X

#define X(x) int i_ ## x = x
oneToTen
#undef X
>>
File: kk.jpg (19 KB, 640x619) Image search: [Google]
kk.jpg
19 KB, 640x619
>think of something incredibly easy and useful to make
>google search
>it has already been made and has a shit ton of good feedback

Every single time.
>>
>>52506288

public WeightedData<T>[]

to
public List<WeightedData<T>>
>>
>>52506552
>array to list
this has to be bait
... right?
>>
>>52506551
Maybe if you weren't a dumb frogposter, that wouldn't happen.
>>
How should I organise my libs and dependancies? For example a Chip8 where should I put my sdl stuff.
>>
>>52506114
Mesu-Nized Festival
https://hitomi.la/galleries/773189.html
>>
>>52504046
>Happy coding!
triggered
>>
>>52506578

Windows? Static link all the things.
Linux? Dynamic link all the things.
Mac? Shit platform; don't bother.
>>
Looking at jobs in my area, it seems almost none hire java/c++ which are the focus of languages in the programming classes for my comp sci degree.

Should i ignore my university teachings and instead focus on industry demands for my city, or refine my skills in what my university program is teaching?
>>
>>52506638
It's trivial to learn other languages even when you're attending university.
>>
>>52506638

Learn whatever language is necessary for the job you want.
>>
>>52506626
To clarify, static linking is within the folder? What if I want to put this onto github, should I take that into account?
>>
>>52506288
So you're handling weights by storing multiples of each object in proportion to their weight?

One option is to not do that, but store <weight,object> pairs and an array of cumulative weights. Use a binary search to find an object given a random value. That makes insertion and deletion faster at the expense of lookups. It also allows floating-point weights.

Failing that, don't call IndexOf() inside the loop. All copies of a given object will be at consecutive locations, right? So after you remove the first copy, the next copy should be at the same location.
>>
>>52506638
java and C++ are literally the best languages

don't fall for whatever fleeting web dev memes are hot right now, focus on serious programming and then you'll be able to pick up any other language if needed
>>
>>52506648
Why is it trivial?

It seems every job requires experience in specific languages/tools (none of which are taught at university) or they won't consider applicants.
>>
>>52506564
nope
C# List<T> is stored as a continous block in memory so you wont lose fast iteration or O(1) access, while resizing an array comes with significant cost

that wasn't what i meant to write though, what i meant was:
private readonly LinkedList<int> _bag;

i have no idea without actually profiling the code, but it seems to me like removing and adding elements from a large _bag will cause a huge performance loss
>>
>>52506675
Once you have the fundamentals of a language down and know how to "think like a programmer" then the language isn't the barrier to creating things. I and I'm sure most people in the thread could look at a new language right now and have it down within like 20 minutes.
>>
>>52506675
you can learn those languages/tools quite easily once you've become experienced in programming in general. you could even bullshit your way into job interviews and then they might hire you out of sheer desperation
>>
>>52506685
>think like a programmer

Mind elaborating?
>>
>>52506685
You are confusing easy and trivial.
Learning a new language is easy.
Nothing is trivial.
>>
>>52506704
Control flow and how to do things. Logic and how to represent data.
>>
>>52506685
So long as it conforms to paradigms we're familiar with.

I am still getting my head around haskell.
>>
>>52506704
What information is required so I can do this task.
What data structure would make this task easier.
What algorithm would be better to do this thing.
>>
>>52506733
>>52506718
thanks
>>
>>52506653
Static linking is where the linker copies the code from the .lib file into the executable. As opposed to dynamic linking where it just adds a reference to a .dll file which needs to be found at run time.
>>
>>52506755
For some reason none of this was even covered during university. I learnt about the compilation process but not how to actually do it.
>>
>sin(2*min(3,4)^max(2,3))
2 3 4 min 2 3 max ^ * sin = -0.558789


So now that I've written a program to parse and evaluate expressions with functions and shit, what should I do next?
>>
>>52506733
>What data structure would make this task easier.
>What algorithm would be better to do this thing.
these are really just things you learn after an hour of googling
imo the "programmers mindset" is how to design, structure and properly encapsulate your code to make it reusable and maintainable without performance chokes
but thats just me i guess
>>
File: 1285244821880.png (99 KB, 247x248) Image search: [Google]
1285244821880.png
99 KB, 247x248
https://www.reddit.com/r/tifu/comments/41l7qn/tifu_by_accidentally_creating_33_million_folders/

>Java programmers
>>
File: 1452161393989.png (481 KB, 650x632) Image search: [Google]
1452161393989.png
481 KB, 650x632
>>52506626
wait, linux has dynamic linking?
>>
File: sh.png (579 KB, 1600x2160) Image search: [Google]
sh.png
579 KB, 1600x2160
document.addEventListener("DOMContentLoaded", function(e) {
function Loli(name, age, hairColour, eyeColour, virgin) {
name = name || "Akari";
age = age || 9;
hairColour = hairColour || "black";
eyeColour = eyeColour || "brown";

if(virgin === undefined) {
virgin = true;
}

this.name = name;
this.hairColour = hairColour;
this.eyeColour = eyeColour;
this.age = age;
this.virgin = virgin;
}

function loliBio(loli) {
console.log(loli.name + " is " + loli.age + " years old.");
console.log(loli.name + " has " + loli.hairColour + " hair and " + loli.eyeColour + " eyes.");

if(loli.virgin) {
console.log(loli.name + " is a virgin.");
} else {
console.log(loli.name + " is a not virgin.");
}
}

var sarah = new Loli("Sarah", 7, "blonde", "blue");

loliBio(sarah);
});


Learning how to use constructors tbqh.
>>
>>52506832
sin(2*min(3,x)^max(2,3))=0.1
>>
>>52506852
>brown eyes
put it down
>>
>>52506478
>What do you define as "including everything"?
Rent, food, clothing, ...
I paid 5k for five years of bachelor's btw (just university costs).
>>
>>52506855
?
>>
File: Capture.png (20 KB, 647x276) Image search: [Google]
Capture.png
20 KB, 647x276
Why can't I compile programs with 32bit libraries? It complains about incompatible.
>>
>>52506852
name = name || "Akari";

this is legit js code?
>>
>>52506653

Static linking is where you've got some blob of a bunch of .o files glued together, generally libwhatever.a, and your linker just takes all of the symbols out of that blob and crams them into your executable. Dynamic linking is where you've got some file libwhatever.dll or libwhatever.so, that your OS is going to pull symbols from and add into your process' address space as your executable is loaded. But otherwise, are not a part of the overall binary size.

Neither the .a nor the .dll/.so files should be added to your github. It is expected that someone compiling your project will have downloaded the dependencies already, just as it is expected that they will have a compiler. If you are using a modification of these libraries, include the source to the modifications, along with any custom build scripts you have included.

>>52506766

I've had at least two classes go over the linking process, and yet I have still met people who don't understand why they're getting linker errors despite including ncurses.h into their file, as if the header file is going to actually contain the function definitions, and not just the function signatures.

I'd give you a lecture on all of this crap, but to be honest, it's almost 4 in the morning, I need to be up at 10, and I'm just going to head to sleep.

>>52506849

Every useful OS can do dynamic linking. Linux just happens to have the advantage of having a package manager to make having a "everybody just does dynamic linking" deal easier.
>>
>>52506863
But that's just the default, anon.
>>
>>52506887
Because the ABI between 32 and 64 bit applications is different.
>>
>>52506889
Yeah, basically if name is undefined, null, or 0 it sets name to Akari.
>>
>>52506907
Not sure what you mean.
>>
>>52506887

64-bit and 32-bit code don't mix. A computer running in long mode (64-bit mode) can jump down into protected mode (32-bit mode) if the OS tells it to, but that doesn't mean you can just arbitrarily mix 32-bit and 64-bit instructions. Also, what this guy says: >>52506907

>>52506924

On 64-bit Windows programs, arguments are passed in the registers rcx, rdx, r8, and r9. On 32-bit, arguments are passed in through the stack. So if a 64-bit program calls a 32-bit function, it's going to be passing its arguments in through the registers, and the 32-bit code is going to be looking at the stack, and presumably fucking with the stack, which is going to contain some local variables it wasn't meant to touch.
>>
>>52506924
Then use Google.
>>
>>52506897
the default should be blonde hair blue eyes
>>
>>52506937
I know that but I thought it was common to use 32bit libraries for compatibility.
>>
>>52506956
But blonde hair and blue eyes are supposed to be special.
>>
>>52506969
no
>>
>>52506980
Yes. Boring black hair and brown eyes makes the most sense being the default.
>>
>>52506852
I want pedos to leave.
>>
>>52506996
Black hair isn't boring, brown hair is
>>
File: nice floor.jpg (492 KB, 1920x1080) Image search: [Google]
nice floor.jpg
492 KB, 1920x1080
>>52507004
>>
>>52506852
I legit might send this to fbi tips

This shit is fucking scary
>>
>>52507032
>This shit is fucking scary
It doesn't even say anything lewd about lolis, what's the problem, anon?
>>
>>52507032
Wait till you see that C project someone made about lolis.
>>
>>52507032
>replace loli and virgin by any other string and it's not an issue
Wow I get triggered over other anons naming schemes.
>>
File: re.png (3 MB, 3840x2160) Image search: [Google]
re.png
3 MB, 3840x2160
Doing some late night World of Warcraft network protocol reverse engineering.
>>
>>52507087
Symbolism exists, imbecile.
>>
>>52507097
code is shit
>>
>>52507097
For what purposes?
>>
>>52507097
>6.6
you do know 6.8 is out anon (leaked that is) , that and bindiff updated too.

>>52507106
So are you positing that there are such things as "bad" words, what's next thought police ?
>>
File: Capture.png (24 KB, 647x306) Image search: [Google]
Capture.png
24 KB, 647x306
I'm getting really confused by this linking stuff. I'm just trying to compile a simple hello world for opengl. I keep getting this error which I thought was that I might be using 32bit libraries but I made sure to use 64.

Here's the command I'm using
gcc main.c -Iinclude -Llib -lglew32 -lglfw3 -lopengl32 -o hello.exe


Attached is the error. Yes include and lib exist.
>>
>>52507118
I work for a private sever, you can even see which one in the solution name.

>>52507120
I wasn't aware, thanks anon I'll track it down and have a look.
>>
>>52507120
There is clear intent in the code above.
>>
>>52507160
I figured everything was reversed already. I'm on a phone so I couldn't waste 3mb on your image.
>>
>>52507133
>../lib64/gcc/x86_64-w64...
You're not using a 32-bit compiler.
>>
>>52507120
Just stop responding to his shitposts, m8.
>>
>>52507162
>There is clear intent in the code above.
Idk man, you could change literally two strings and it'd become a simple classification prorgram

>>52507178
I still have some of the mop idbs laying around, back when I did things with the HB group, do you want me to take a look ?
>>
>>52507178
In Cataclysm and Mists of Pandaria Blizzard randomised every packet structure and their underlying structures every patch, about 1500 packets have to be done mostly by hand.
>>
>>52507216
>>52507210
Cool thanks. Did they do that just to make private servers more of a pain?
>>
>>52507232
it was to combat exploits, bots and the like, aswel as obviously making it a lot harder to make private servers.


>I still have some of the mop idbs laying around, back when I did things with the HB group, do you want me to take a look ?
was for >>52507097
>>
>>52506852
class Loli {
constructor(
name = "Akari",
age = 9,
hairColour = "black",
eyeColour = "brown",
virgin = true
) {
this.name = name;
this.age = age;
this.hairColour = hairColour;
this.eyeColour = eyeColour;
this.virgin = virgin;
}

toString() {
return `${this.name} is ${this.age} years old.\n` +
`${this.name} has ${this.hairColour} hair and ${this.eyeColour} eyes.\n` +
`${this.name} is ${this.virgin ? 'a virgin' : 'not a virgin'}.`;
}
}

document.addEventListener('DOMContentLoaded', e => {
let sarah = new Loli('Sarah', 7, 'blonde', 'blue');
console.log(sarah);
});
>>
>>52507243
Thanks, if you have a 18291 or 18414 IDB around I wouldn't mind having a look.
>>
>>52507097
cool, goodluck m8
i used to reverse a lot a couple of years back when i still made cheats and stuff, i just wish it wasn't so goddamn time consuming
>>
>>52507262
>unsupported in just about any browser except firefox
i implore you to reconsider
>>
>>52507283
Reverse engineering is time consuming but it's very satisfying spending so long on something and finally cracking or understanding it.
>>
>>52506837
lel

but the reason something like this wouldn't happen in python is that python is so shit that it would probably run out of memory or take a ridic amount of time
>>
>>52507282
from what I see you're on 5-4-8-18291
which I don't have but I'll go ask I'm sure someone kept it.
>>
>>52507310
more fun to create something of your own than to break someone else's shit
>>
>>52504028
But there is, Lisp.
>>
>>52507353
Which one?
>>
http://wiki.call-cc.org/eggref/4/format
MUH DICK
>>
>>52507342
You say breaking I say improving ;)
>>
>>52507400
http://wiki.call-cc.org/eggref/4/loop
The end is near.
benis asplode
>>
>>52507262
There's something about grave accents that triggers me.

Not sure what it is.
>>
>>52507464
In F# you can escape identifiers
let ```like this for example``` = "with triple backticks"
>>
>>52506852
document.addEventListener("DOMContentLoaded", function(e)
{
function Lawly(name="Akari", age=9, hairColor="black", eyeColor="brown", virgin=true)
{
this.bio = function()
{
console.log(name + " is " + age + " years old.");
console.log(name + " has " + hairColor + " hair and " + eyeColor + " eyes.");
console.log(name + " is " + (virgin ? "a virgin." : "not a virgin."));
}
}

let sarah = new Lawly();
sarah.bio();
});
>>
>>52503878
To many companies, .NET means proficiency in at least one language and other aspects of the .NET stack.

Some examples of things you'd want to familiarize yourself with:
>SSRS
>Powershell
>SQL Server
>Using VS as an IDE
>ASP.NET
>>
>>52507525
What's wrong with saying 'loli', anon?
>>
>>52507561
Anime hasn't been made real yet
>>
>>52507080
shit, he's still working on that?
>>
>>52507525
{
//Disgusting
}
>>
>>52507605
Are you triggered?
>>
>>52507080
You mean LRS? That's C++ actually, not C.
>>
>>52507525
>Color
>>
>>52507525
>Unexpected token =
smdh
>>
File: iio.png (614 KB, 640x890) Image search: [Google]
iio.png
614 KB, 640x890
document.addEventListener("DOMContentLoaded", function(e) {
function Loli(name, age, hairColour, eyeColour, weapon, virgin) {
name = name || "Akari";
age = age || 9;
hairColour = hairColour || "black";
eyeColour = eyeColour || "brown";
weapon = weapon || "knife";

if(virgin === undefined) {
virgin = true;
}

this.name = name;
this.hairColour = hairColour;
this.eyeColour = eyeColour;
this.age = age;
this.virgin = virgin;
}

function loliBio(loli) {
console.log(loli.name + " is " + loli.age + " years old.");
console.log(loli.name + " has " + loli.hairColour + " hair and " + loli.eyeColour + " eyes.");

if(loli.virgin) {
console.log(loli.name + " is a virgin.");
} else {
console.log(loli.name + " is a not virgin.");
}
}

function loliBattle(loli, loli2) {
//what do?
}
});


>tfw I'm not sure what would be a good way to simulate a loli battle
>>
>>52507776
need injuries for a battle obv
>>
jesus christ

ask yourself
how autistic are haskell users?

now read this
http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
>>
More shoutouts to the guy who suggested a quite rinse of the ass instead of wiping. Just did it again and it saved me a few minutes and I'm undoubtedly cleaner than I would have been by wiping.
>>
>>52507936
Seems like a good learning resource

What's your problem?
>>
>>52507954
read it
>>
>>52507936
I don't like Haskell myself, quite the opposite, but the article seems nice for people interested in Haskell. It's friendly and described with simple yet explanatory pictures, what's wrong?
>>
>>52507979
read it
>>
Dear HASKAL
Assume we have a function f(x) = x! that we wish to implement in pseudocode.
f(x) ->
pr = 1
for n = 2 to x do:
pr = pr * n
return pr

Is this functional programming?
>>
>>52507776
Why is the loli a function and not an object?

I'm unfamiliar with the usages in this language.
>>
>>52508061
>mutable state
are you trying to kill them
>>
Does /dpt/ fap to their own code?
>>
>>52508066
>Why is the loli a function and not an object?
trust me, you dont want to know
>>
>>52508066
it's a dynamically typed language
calling the function creates the object and provides properties and member functions
>>
>>52507561
It gets you banned from shithub.
>>
>>52503588
Learning haskell
>>
why are the syntaxes of functional languages so horrible?
>>
>>52508131
Really? You get banned for saying loli on github?
>>
What is the meaning of dequeue in ios programming? I've Google but it doesn't make sense
>>
>>52508259
Well someone got banned for posting a fucking eggplant emoji, so yeah you get banned for saying loli.
>>
>>52508250
>implying

>>52508262
double ended queue
>>
Post shit code
toRevDigits :: Integer -> [Integer]

toRevDigits 0 = []
toRevDigits (n) = []
toRevDigits n = lastDigit n : toRevDigits (dropLastDigit n)

toDigs :: Integer -> [Integer]
toDigs 0 = []
toDigs (n) = []
toDigs n = reverse (toRevDigits n)
>>
>>52508105
Weird.
>>
>>52508290
>returning a list of integers
>>
So I was able to make some really good stuff in Silverlight a while back, very quickly and easily.

What's the new way to dev simple web apps with the .NET stack?

I'm talking one page that serves up dynamic content.
>>
I want to try that text snaking thing, I can't remember what it's called but someone always posts it.

If I could get the name of it, I'd be able to go find a comprehensible non-one line version to try and understand.
>>
Why is wikipedia so shit at explaining computer science concepts.
>>
>>52508290
where are lastDigit, dropLastDigit and reverse defined?
>>
>>52508360
Because SJW write it.
Thread replies: 255
Thread images: 25

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.