/dpt/ - Daily Programming Thread

Previous Thread: Next Thread: What are you working on, Sup Forums?

Other urls found in this thread:

tip.golang.org/pkg/context/,
en.wikipedia.org/wiki/The_lexer_hack
twitter.com/SFWRedditVideos

Ada is fucking shit.

>Next Thread
wat

You'll see

Reading this: tip.golang.org/pkg/context/,

I invested in the haskell meme and I got nowhere.
Tell me a language that will land me a job and isn't painful, thanks.

and also, where do you guys look at jobs postings so that you can compare frequency of languages

Haskell isn't painful, it's beautiful

yes, but it won't get me a job
I need a job, so that i cna support my mom

>supporting parents
lmao

>go
why

almost like he wants to be a decent, worthwhile part of society

0-7 - actually work on programming
8 - play video games
9 - go through some Anki flashcards

me in position (780, 418)

>why
Because muh network programming.

Fuck off tyrone

>tyrone
>parents

Me on the bottom right.

Spoken like a true codemonkey!

Me the one getting kissed.

*kissu*

>implying codemonkey is a bad thing

I've been done with uni and been full time employed for 2 years now. I recently had to relearn c++ (the 5 point course we had was basically nothing), and I keep fumbling on the fucking syntax and semantics of the language.

Can any of you recommend a quick guide or similar? I'm mostly used to C and Java / C# languages.

>I'm mostly used to C and Java / C# languages.
then how the fuck are you having an issue with c++ syntax?

Fucking pointers, references, etc.

You should convert the entire company's codebase to Haskell to be honest family

Question, what tasks do you do on a programming job? I mean, solving project Euler problems can't be it.

Sure that high performance C / inline assembly won't suffer a performance hit at all.

>pointers

>how do they work?

How would i go about statically linking a dynamic link library.

I want to get rid of xinput1_3.dll as a dependency for my project. Is there a way to statically link a dynamic link library like that when I don't have the source?

CRUD.
CRUD all day err day.

take the bytes of the .dll file and append it to a section in your exe
then write a function like LoadLibrary, except make it accept a pointer to data instead of a file path
then call that function with your appended dll data and you're good to go

CRUD

>pointers
int* p; //pointer to int
int a=5;
p=&a; //takes the address of a and places in p
*p=*p+*p; //adds the dereference of p to itself and stores in p (which is pointing to a)

That's it for pointers aside from arithmetic
char arr[50]; //arrays are just pointers
arr[4]=*(arr+4); //place the value of element 4 into index 4 (arr[4]=arr[4])
int arr2[50];
arr2[4]=*(arr2+4); //still works becuase adding to pointers is actually p+sizeof(p)*4.

And references
int a=4;
int& b=a; //reference to A
a=7;
int c=pow(b,2); //7^2

It never gets more complicated than that. If you want to consider references to be implicit pointer dereferences where the value is used that's appropriate. Except there's some type safety like making a const reference.

I don't think you will find a good resource for that because it's so simple.

That seems neat. I'l consider that.

Oh and I'm doing this for misguided reasons maybe. Can I just place the dll in the working directory and ship it like that? What's the reason everyone makes you install all kinds of prerequisites?

>Can I just place the dll in the working directory and ship it like that?
yes
>What's the reason everyone makes you install all kinds of prerequisites?
mostly legal reasons but partially portability reasons
just install a virtual machine for each version of windows you want your shit to run on and test it
it'll just work as long as you're distributing 32bit dlls

>mostly legal reasons but partially portability reasons
>mostly legal reasons
Why am I not subject to these legal reasons?

what do I look like, a lawyer?

What is the best method of implementing throwaway variables in C++? So say I need int n and int p, one incrementing and one decrementing, would it be acceptable to just embed a for loop in another for loop that will only run once?

So
for(int p=0;p0;n--)
{
p++;
}
}

Is this acceptable or am I just being lazy?

{
int p = 0;

};

Tensorflow: no windows support, no way to run on GPU on Windows
Theano: full windows support

Fuck this. Ditching Tensorflow and switching to Keras+Theano. Fix your shit google (your library is okay otherwise, by the way).

{
int p = 0;
for(int n=16;n>0;n--)
p++;
}


place it in a scope

You can make declarations inside a for loop in C++?

That doesn't work because it will set it to 0 every time the loop runs.

Haskell will land you a job if you're good enough. Learn JavaScript and PHP if you want to land a job within two weeks of installing the interpreters.

Oh right. I didn't know you could do that. Thanks.

>developing on Windows
This is where you went wrong

No it won't you idiot

even more concise:

for (int p, n = 16; n > 0; n--)

Of course.

How can you get a Haskell job with no experience? Research in a field related to the position?

Well, I'm locked in. I much have Windows. I could dual boot but I don't feel it's an option for me - having ot restart every time i want to visit the other OS.

well in this particular case you can just do
for(int n=16, p=0; n > 0; n--){}
but, still should know scoping

I didn't know you could declare multiple values in a for either to be frank.

you can do whatever you like

for (;condition;)
// while loop

>tfw can't stop thinking about simulation theory
what is life, dpt?

You're entering a world full of even bigger surprises when it comes to C++.

approximately a box of chocolates

life is a long series of 1's and 0's on a computer somewhere far beyond our reach

I would say it is more box of chocolates-esque than a rough approximation.

pro-grammer or pro-gamer

there is literally no difference

>what is ockham's razor

A tool not a rule. USE YO HEAD NIGGA

So when * or &, it's a pointer or reference to that specific type but when its * or & it's a pointer or reference to the value?

It really depends. Some projects on GitHub would definitely be helpful. I suppose, if you're going for a more theoretical position, research would be useful as well. Or choose a shop that will let you use your languages of choice and you should be fine.

>referring to basic thought processes as tools

So I'm going through the "C programming languague" book but don't know any exercises to practice what I learn, any suggestions?

Occam's Razor is indeed a philosophical tool and by no means is an answer reached by applying Occam's Razor inherently the right answer just because it is the most sensible.

How about the actually exercises in the book?

>* or &
Declaring references and pointers:
* pointer;
& reference; //and to my knowledge you have to declare and assign at the same time like & reference=referencedVariable;

Using referenced/pointed to values
* pointer;
& reference;
//usage
result=*pointer;
result=reference; //you never 'dereference' a reference, that's the point of them.

>&
& is not an operator like that.. & can either mean bitwise and
12498&1 //checks if the first bit is set in 12498 (it isn't)

or 'address of'
int a=0;
long b=&a; //gives us some (often large) value which is the address of a

You use them with pointers because pointers are just memory addresses.
Tough to say. Where are you?

the odds of us being a simulation, in my opinion, is about 100%
spouting
>ockham's razor
isn't a convincing argument

similarly,
the odds of there being life on some other planet in this universe are, in my opinion, about 100%
I bet you wouldn't spout
>ockham's razor
in response to that, right?
it is equally unconvincing for exactly the same reasons.

>implying the simulator uses babbys binary
mortals will never understand

References never change the object they refer to, while pointers can.

The dilemma arises in that both are fundamentally unprovable.

I will say that Occam's Razor is not the right approach to problems that are on the surface seemingly unprovable as saying "well this is most likely so let's just leave it at that" is akin to sweeping it under the rug.

But at the same time there really is no way to prove or disprove the problem, and that makes the problem futile. It's like an amoeba trying to figure out how to build a space ship. Maybe in a hundred million years amoeba will have space ships, but right now they really need to focus on just not blowing themselves up with nuclear fusion.

I want foundationalists to leave
Maybe program a neural network or two

>One day we will have entire universes acting as transistors.

>heat death of the universe is just because Timmy wanted an extra .1 GHz

me with bow to the right of cat ears selfie girl

>well this is most likely so let's just leave it at that"
That's not the Occam's Razer, you inbred faggot.

Hey, that's me on the left!

It sounds to me like you're interpreting my post wrong.

Maybe. I was assuming you left out a comma.

What's the best way to learn C#?

not at all

I am moving away from Haskell as well. The type system is neat but it gets in the way of getting things done too often.
I also find the current obsession of pushing Haskell for web "dev" and the people behind it pretty disturbing.

>learn asm x86 as first programming language
>want to learn a high level language so start with python
>too lazy to memorize the long-ass function names and messy syntax
Pls help.

So I just got entered into google foobar. Do you guys know how long you have to do the challenges? Did one already. I'm on call this week so I'm going to be busy until this Friday...

learn a better high level language like C instead

C is a mess, even i386 assembly has saner semantics.

>& is not an operator like that.. & can either mean bitwise and
I meant in terms of function parameters.

So in a function what's the difference between:
func(int &foo)


and

func(int &foo)


Does the first pass a reference to the object, thus you manipulate the object inside the function, whereas the second simply copies the value into a locally scoped variable?

Also, why would you ever want the memory address of a value?

>why would you ever want the memory address of a value?
Edit said value without wasting time/memory copying the data, returning it, and reassigning it.

Define your own scope and management rules.

>2016
>Pretending that programs are anything *but* types + operations over sets of types

Lol! You guys! They actually fell for the oop meme! LOL! They actually think "message-passing" is a legitimate way to structure a program! LOL!

Both pass a reference to an integer.

>Also, why would you ever want the memory address of a value?
To avoid copies.

What's wrong with femdom, exactly?

>To avoid copies.
To avoid expensive copies. You still have to copy the memory address.

Pedantic, I know, but it's best to be 100% clear on these things.

Normally when you copy a value to a function you are outright copying the value to a newly declared variable. By referencing you access the value in the initial variable directly within the function.

I prefer to
int func(int * n){}

func(&var)

though.

>why would you ever want the memory address of a value?
Plenty of reasons. Aligning your values on X-bit boundaries can be very useful for instance, since computers only operate on memory really if you have the address of two objects and compare them you can know that even if the content is the same they aren't the same thing. It's a big topic. But for something that's closer to you references can't really be stored in an array. So if lets say you have had an array of objects and you've searched through it to pick out a few. Maybe you don't want to search it every time you want to get at these objects, for instance. You can construct an array of pointers and pass that around so you don't have to search anymore.
>So in a function what's the difference between:
>func(int &foo)

>and
>func(int &foo)

I'm thinking this wasn't what you meant. Because thiscode is identical. The compiler couldn't even distinguish between the two different functions in any way. What you've written there is a reference to an int (both cases). & is used to declare references (in that context). And in other context it's an operator (so it can't be used where you declare).

If you wanted to make a pointer vs reference comparison it's func(int *foo)

vs
func(int &foo)


The only _real_difference is in syntax honestly. You have to check both for if they're valid or not (assuming you don't have any special expectations on the calling code) they both operate through memory addresses since there's no 'reference' concept on a lower level. It's all just memory addressing. But you can operate on the reference directly without typing:
*foo when you want to access the value. You cna also have the compiler warn you if you do
func(const int &foo)

That creates a constant reference. Meaning you aren't allowed to change foo.
>memorize the long-ass function names and messy syntax
Never learn the standard library. Solved.

me taking a selfie being the qtest girl in the pic

Also it's worth noting
int func(int * n){n[5]=7;}

int array[10];
func(array);

>You can also have the compiler warn you if you do
To be clear. I'm not saying the specific code
func(const int &foo)

Is problematic. But if you do
func(const int &foo){
foo=5; //produces error
}
func(int &foo){
foo=5; //doesn't produce warning
}

So you can avoid certain mistakes like that.
You can't really pass a pointer and make sure the function doesn't change it.

Also I think it's worth mentioning that the * is both used for multiplication, declaring pointers and dereferencing pointers. So it can get very confusing. Commonly considered one of the major syntax flaws in C/C++.

I think it's why people don't understand pointers as easily. Because unlike every other case there's no single rule for what * means.

If the address is already stored in a register, then nothing will be copied.

en.wikipedia.org/wiki/The_lexer_hack