[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: 32
File: ada.png (4 MB, 4800x2700) Image search: [Google]
ada.png
4 MB, 4800x2700
Previous Thread: >>55496229
Next Thread: >>55515905


What are you working on, /g/?
>>
>>55506203
Ada is fucking shit.
>>
>>55506203
>Next Thread
wat
>>
File: 1467398868589.jpg (475 KB, 852x973) Image search: [Google]
1467398868589.jpg
475 KB, 852x973
>>55506249
You'll see
>>
Reading this: https://tip.golang.org/pkg/context/,
>>
>>55506203
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
>>
File: 1466969439647.png (695 KB, 782x1080) Image search: [Google]
1466969439647.png
695 KB, 782x1080
>>55506390
Haskell isn't painful, it's beautiful
>>
>>55506400
yes, but it won't get me a job
I need a job, so that i cna support my mom
>>
>>55506414
>supporting parents
lmao
>>
>>55506297
>go
why

>>55506440
almost like he wants to be a decent, worthwhile part of society
>>
File: 1468063012203.jpg (497 KB, 1280x912) Image search: [Google]
1468063012203.jpg
497 KB, 1280x912
0-7 - actually work on programming
8 - play video games
9 - go through some Anki flashcards
>>
>>55506478
me in position (780, 418)
>>
>>55506454
>why
Because muh network programming.
>>
>>55506440
Fuck off tyrone
>>
File: 1453648836231.png (681 KB, 840x720) Image search: [Google]
1453648836231.png
681 KB, 840x720
>>55506518
>tyrone
>parents
>>
>>55506478
Me on the bottom right.
>>
>>55506231
Spoken like a true codemonkey!
>>
>>55506478
Me the one getting kissed.

>>55506621
*kissu*
>>
>>55506900
>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.
>>
>>55507304
>I'm mostly used to C and Java / C# languages.
then how the fuck are you having an issue with c++ syntax?
>>
>>55507329
Fucking pointers, references, etc.
>>
>>55507304
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.
>>
>>55507358
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?
>>
>>55507366
CRUD.
CRUD all day err day.
>>
>>55507405
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
>>
>>55507366

CRUD
>>
>>55507350
>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.
>>
>>55507534
That seems neat. I'l consider that.
>>
>>55507405
>>55507534
>>55507675
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?
>>
>>55507731
>Can I just place the dll in the working directory and ship it like that?
yes
>>55507731
>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
>>
>>55507772
>mostly legal reasons but partially portability reasons
>mostly legal reasons
Why am I not subject to these legal reasons?
>>
>>55507797
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;p<1;p++)
{
for(int n=16;n>0;n--)
{
p++;
}
}

Is this acceptable or am I just being lazy?
>>
>>55507839
{
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).
>>
>>55507839
{
int p = 0;
for(int n=16;n>0;n--)
p++;
}


place it in a scope
>>
>>55507839
You can make declarations inside a for loop in C++?
>>
>>55507854
That doesn't work because it will set it to 0 every time the loop runs.
>>
>>55506414
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.
>>
>>55507863
Oh right. I didn't know you could do that. Thanks.
>>
>>55507860
>developing on Windows
This is where you went wrong
>>
>>55507866
No it won't you idiot

even more concise:

for (int p, n = 16; n > 0; n--)
>>
>>55507865
Of course.
>>
>>55507872
How can you get a Haskell job with no experience? Research in a field related to the position?
>>
>>55507886
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.
>>
>>55507882
well in this particular case you can just do
for(int n=16, p=0; n > 0; n--){}
but, still should know scoping
>>
>>55507903
I didn't know you could declare multiple values in a for either to be frank.
>>
>>55507916
you can do whatever you like

for (;condition;)
// while loop
>>
File: shining2_008pyxurz.jpg (34 KB, 600x337) Image search: [Google]
shining2_008pyxurz.jpg
34 KB, 600x337
>tfw can't stop thinking about simulation theory
what is life, dpt?
>>
>>55507916
You're entering a world full of even bigger surprises when it comes to C++.
>>
>>55507929
approximately a box of chocolates
>>
>>55507929
life is a long series of 1's and 0's on a computer somewhere far beyond our reach
>>
>>55507937
I would say it is more box of chocolates-esque than a rough approximation.
>>
File: 1465063870310.jpg (66 KB, 600x517) Image search: [Google]
1465063870310.jpg
66 KB, 600x517
pro-grammer or pro-gamer

there is literally no difference
>>
>>55507947
>what is ockham's razor
>>
>>55507969
A tool not a rule. USE YO HEAD NIGGA
>>
>>55507627
So when <type>* or <type>&, it's a pointer or reference to that specific type but when its *<variable> or &<variable> it's a pointer or reference to the value?
>>
>>55507900
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.
>>
>>55507979
>referring to basic thought processes as tools
>>
File: image.jpg (68 KB, 480x364) Image search: [Google]
image.jpg
68 KB, 480x364
>>55506203
So I'm going through the "C programming languague" book but don't know any exercises to practice what I learn, any suggestions?
>>
>>55508005
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.
>>
>>55508029
How about the actually exercises in the book?
>>
>>55507987
><type>* or <type>&
Declaring references and pointers:
<type>* pointer;
<type>& reference; //and to my knowledge you have to declare and assign at the same time like <type>& reference=referencedVariable;

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

>&<variable>
& 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.
>>55508029
Tough to say. Where are you?
>>
>>55507969
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.
>>
>>55507947
>implying the simulator uses babbys binary
mortals will never understand
>>
>>55508048
>>55507987
References never change the object they refer to, while pointers can.
>>
>>55508058
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.
>>
>>55508058 >>55507979 >>55508034 >>55508138
I want foundationalists to leave
Maybe program a neural network or two
>>
>>55508060
>One day we will have entire universes acting as transistors.
>>
>>55508160
>heat death of the universe is just because Timmy wanted an extra .1 GHz
>>
>>55506478
me with bow to the right of cat ears selfie girl
>>
>>55508138
>well this is most likely so let's just leave it at that"
That's not the Occam's Razer, you inbred faggot.
>>
>>55506478
Hey, that's me on the left!
>>
>>55508211
It sounds to me like you're interpreting my post wrong.
>>
>>55508237
Maybe. I was assuming you left out a comma.
>>
What's the best way to learn C#?
>>
>>55508395
not at all
>>
>>55506390
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.
>>
File: 1369469289307.png (293 KB, 482x440) Image search: [Google]
1369469289307.png
293 KB, 482x440
>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.
>>
>>55508432
learn a better high level language like C instead
>>
>>55508464
C is a mess, even i386 assembly has saner semantics.
>>
>>55508048
>& 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?
>>
>>55508536
>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!
>>
>>55508536
Both pass a reference to an integer.

>Also, why would you ever want the memory address of a value?
To avoid copies.
>>
>>55507562
What's wrong with femdom, exactly?
>>
>>55508613
>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.
>>
>>55508536
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.
>>
>>55508536
>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.
>>55508432
>memorize the long-ass function names and messy syntax
Never learn the standard library. Solved.
>>
>>55506478
me taking a selfie being the qtest girl in the pic
>>
>>55508536
>>55508666
Also it's worth noting
int func(int * n){n[5]=7;}

int array[10];
func(array);
>>
>>55508666
>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.
>>
>>55508666
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.
>>
>>55508636
If the address is already stored in a register, then nothing will be copied.
>>
>>55508745
https://en.wikipedia.org/wiki/The_lexer_hack
>>
>>55508587
>>55508613
>>55508664
>>55508666
>>55508696
>>
>>55508968
>>55508587
>>55508613
>>55508664
>>55508666
>>55508696
I cannot into 4chan today it seems.

What I meant was:

func(int &foo)


func(int foo)


But thanks.

Maybe it just takes a bit, but I'm not a big fan of all this * and & syntax. Doesn't really add to the readability.
>>
>>55509035
I'm gonna be honest with you I constantly reference documentation for syntax especially with pointers and type declarations because I use a few different languages, the more I've learned the harder it is to remember which language syntax is which since they're all just slightly different enough.

I feel like the concept is all that matters anyway, as long as you know what references are for and how to use them you should be fine.
>okay I'm going to take this struct and pass it by its address to this because I want it to be modified inside and it's a huge dataset
etc.
>>
File: sasdaaa.png (98 KB, 1095x916) Image search: [Google]
sasdaaa.png
98 KB, 1095x916
Added ability to search through series now. Sort of works well. It's very fast, and only returns the series if any of its episodes have been posted.
The only issue is, in some cases (like pic related) it shows the same series multiple times because it has different names. Not really sure how to fix it, or if its even worth fixing.
>>
>>55506203
Dear /dpt/ ,
I fell for the k&r meme, I read it and I found myself skipping most of it because I pretty much knew most, if not all, of these stuff. I was looking for something that would not only teach me something, but would also give me examples on how to actually make something useful, something useful being something else other than fizzbuzz tier programs. In /g/'s library you can find O'Reilly's Practical C, but from a brief flick through, I noticed it doesn't teach anything better (maybe I am wrong).

I will move on TCP IP sockets in C, which seems interesting, since I have no knowledge on networking. However, I would like your opinion and advice /dpt/. What do? How can I move on, gain experience and actually make something, as I said,m ""useful""? How did you move on from this situation /g/?
With lots of platonic love,
Another /g/tard
>>
>>55509035
Ah right coming from a C#/java background this is a good question.

In C/C++ if you type
func(int foo){
foo=5;
}

The calling site won't see that change. Because a copy was passed. The function was just given the value.
If you type
func(int& foo){
foo=5;
}

or
func(int* foo){
foo=5;
}

The calling site will see the change.

References and pointers are two entirely separate concepts. Which makes the choice of the & symbol for references incredibly dumb.
>Not a big fan of the syntax
Yes. Everyone hates C/C++ because they're crappy languages with either poor expressiveness, confusing syntax or they're simply sub-par (like templates metaprogramming). They just happen to be the best available for what they're good at right now.

But this is an insignificant problem. You will get used to it.
>>
>>55509035
Yes, any change to foo within the first function will modify the original var that was passed to the function, in case of the second one, it creates a copy of the original one and operates on that copy.
>>
>>55509147
>
func(int* foo){
foo=5;
}

God damn it. I meant
func(int* foo){
*foo=5;
}

Doesn't help you or me to make mistakes.
What I wrote:
>
func(int* foo){
foo=5;
}

Would set the address of foo to 5. I think most compilers generate (solvable by casting) errors for this. I hope they do anyway.
>>
>>55509127
Books teach you the language, it's your job as a programmer to make something useful with it. If you don't have any idea of what to build, learning how to use the tools will not be valuable to you.

What don't you know now that's preventing your from applying your knowledge to build the project you want?
>>
>>55509186
>don't learn how to use a hammer if you're not going to build a house.
What kind of retarded niggotry is this?
>>
virtual functions are fine if I put all of the processing inside the function and not run the functions in loops, right?

I am trying to build an audio oscillator and it made most sense to me to have a general 'wave' type and have more complex wave types inherit the base wave type. That way I can throw all the waves into a main loop with no problem.

is this a good way to go about this?
>>
What's your convention for naming member variables, /g/?
>>
>>55509246
camel case
>>
>>55509127
Networking is mainly about interacting with the OS from the programming side. Maybe learn about TCP/IP or UDP first?
>how to make something useful
Think about what you need to do something useful. I like games, both as example and simply like them. Games can be arbitrarily complicated. Games do everything and can do everything because they're programs that take some form of input. Do whatever is fun to do with that input and produce an output.
I think what you're really asking is 'how do I learn how to write software well'. Because the barrier to entry for actually knowing everything you need to make something 'useful' is incredibly low.
>>55509235
It's sensible. You should know what a hammer is though, so you can learn to use it.
>>55509242
I don't see why you'd need virtual functions. you haven't really described where you'd need them.
>>55509246
m_Name();
a_Name;
_m_Name(); //private
_a_Name; //private
>>
>>55509246
whatever i fucking want
>>
>>55509127
>>55509267
Right. Was gonna point you to this.
https://hero.handmade.network/episode/game-architecture/day026
https://hero.handmade.network/episode/game-architecture/day027
Gives a good understanding of software development (at least actual programming to solve actual problems, not just linking libraries together).
>>
>>55509235
That's not at all what I said, you've got it backwards.

I'm asking what their goal is, if it's to build a house, learn how to use a hammer, if you already know how to use a hammer reading another book that teaches you how to use a hammer is pointless.

In the same regard if they're not going to use sockets then why learn it now?

The whole point is you need a goal to "step up" to otherwise you're just learning random things, I can't give advice on how to "step up" if there's no obvious end goal to step towards.
>>
>>55509246
the longest name that conveys the least information
>>
>>55509267
>I don't see why you'd need virtual functions. you haven't really described where you'd need them.
So I can have a general function that runs the oscillator to fill a buffer. This function is to be for all wave types which inherit from the base wave type
>>
>>55509084
See this is what confuses me.

func(int* foo)
{
*foo=5;
}


I can understand it now when I look at it, but tomorrow when I look at it again, I'll have forgotten that you need to both do int* and *foo to actually manipulate the value of foo.
>>
>>55509298
Ah I get it now.
Why not just do a switch case and just pass in a type value if you're concerned? There's not that many primitive wave types.

Are you programming a DSP or is this a toy project?
>>
>>55506478
thanks
>>
>>55509330
>Are you programming a DSP or is this a toy project?
I am learning DSP, but I want to learn proper programming practices at the same time
>>
>>55506390
python. just learn python, it's easy and it will get you a job
>>
>>55509327
Yeah. It gets easier when you get into your head that a int* foo is just an address.
It just has to stick.
>>55509345
>proper
Virtual is frowned upon by people who care about performance.
Never use virtual. The simplest option to implementing polymorphism would be my suggestion I'm pretty sure.

Makes the code easier to follow too imo.
>>
>>55509379
>Never use virtual.
That's what I've been seeing a lot.

I'll try to write it using only C I guess
>>
>>55509286
I feel like I'll never work as fast as this man.
>>
File: 0020.jpg (159 KB, 737x705) Image search: [Google]
0020.jpg
159 KB, 737x705
>>55508432
>long-ass function names and messy syntax

you wat? wat long-ass function names?
and wat messy syntax, python is literally like fucking english are you autistic
>>
>>55509416
He's pretty nuts.
And (atleast according to him) he's slower because he's talking.
But he's like 40 something now. I got time to catch up.
>>
>>55509370
I started learning some python because MIT's algorithms classes 6.006 and 6.046 use it and I must admit that it's pretty nice.
>>
>>55509429
>last frame isn't a bunch of nerds rushing into the scene and mauling her to death
Lame. Very lame /v/.
>>
>>55509235
As the one who asked, I found >>55509186 a good and helpful answer, maybe since you are not in my position, you misinterpreted it.
He is not saying that I shouldn't have learned C, he is just saying that knowing the language but not putting it into practice like I said I can't, is virtually as if I don't know the language.

I guess I should put more effort, starting from small things and moving on to bigger problems/programs and also studying something more useful than I already know or do not need. Thanks >>55509186 & >>55509286 too
>>
>doing webgl in javascript
>have an array that's calculated outside the scope of the render function
>this first solution is dramatically slower than the second

```
var mult = (
[
[
a,
b,
c
]
],
[
[
d,
e,
f
]
]
);
```

```
var mult = [[a, b, c], [d, e, f]];
```

What the fuck is going on?
>>
I feel like programming something but I don't know what

help
>>
>>55507902
maybe VM + GPU passthrough
>>
File: Cm_g2TcWAAAlDS3.jpg (83 KB, 805x768) Image search: [Google]
Cm_g2TcWAAAlDS3.jpg
83 KB, 805x768
>>55509444
oh drop that shit boi

instead do this:

>https://www.coursera.org/specializations/python

for ^ this one you pay for this "specialization" but all the courses included are completely free on coursera, so just search for the course names individually and enroll for free

>https://www.youtube.com/playlist?list=PLGLfVvz_LVvTn3cK5e6LjhgGiSeVlIRwt

this ^ might be the best youtube tutorial

but here are some others:

>https://www.youtube.com/watch?v=D48iCw3WWpI&list=PL82YdDfxhWsDJTq5f0Ae7M7yGcA26wevJ&index=1

>https://www.youtube.com/watch?v=kJv1QDfp1PM&list=PL1A2CSdiySGJd0LJRRSwQZbPZaDP0q67j&index=1

^ basics

>https://www.youtube.com/playlist?list=PL1A2CSdiySGLPTXm0cTxlGYbReGqTcGRA

^ intermediate

>https://www.youtube.com/playlist?list=PL1A2CSdiySGIPxpSlgzsZiWDavYTAx61d

^ advanced


>https://www.udacity.com/course/intro-to-computer-science--cs101

^ udacity intro to computer science with python

Those MIT courses are shit for a starting point. Pick any of the links I posted and you will learn the language much faster.
>>
>>55509604
Besides that the code is different? You have two ['s after the comma in the first example.
>>
>>55509701
>reddit
>>
>>55509701
I'm not a beginner, I'm just refreshing my algorithm-fu for interviews.
>>
>>55509736
>getting triggered by a screenshot of a reddit post

just how autistic can you even be?
>>
>>55509701
What's the context of that image?
>>
>>55509604
V8 does not optimize functions that are longer than 600 characters or something like this. This is counting newlines and comments inside of function bodies so the chances are these few new lines that you add are exceeding the character limit. Why would you subject yourself to JS?
>>
>>55509778
>just how autistic can you even be?
Half of a Subaru
>>
>>55509772
even for that there are better tutorials, such as this one and also the second in the series, possibly the best thing on algorithms

https://www.coursera.org/learn/introduction-to-algorithms
>>
>>55509793
Come on man, think a bit. From the second image, you can see Jupiter. Thus it's the Juno orbiter. The problem is that Goygle is pushing forced diversity for some reason. The top image is the reality and it's even more apparent when you see the control room. The disgusting redditor is at least red pilled.

Sage for sage.
>>
>>55509476
>I guess I should put more effort, starting from small things and moving on to bigger problems/programs and also studying something more useful than I already know or do not need.
Very good!

A lot of my experience came from doing just that, set an achievable goal that requires some of what you already know and maybe something you don't know, it forces you to apply your knowledge while also learning something new and practically useful, first hand.

Refactoring can certainly teach you a lot about design too, those "I should have done it this way to begin with" should stick with you and you will next time.
>>
File: 002.png (85 KB, 217x373) Image search: [Google]
002.png
85 KB, 217x373
>>55509793
google, or really whatever SJW does google's doodle things has a real thing against white men, in the picture those are men who achieved something, they are all white but google doodle celebrating their achievement is diverse and inclusive TM.

They do the same shit for historical figures, they are never white. They are always brown for some reason. Shakespeare was brown

Also, fun example of this progressive bullshit was some american military holiday where in the front there was a brown woman next to her was a black man, on the other side an asian man and all the way in the back is the white man who consist most of the USA military, I even think it was something about WW2 so the doodle would need to be all white basically
>>
I had this idea out of the blue to code some procuderally generated music, then I found out that this tool exists:
https://www.youtube.com/watch?v=6haUes-usG4

How did they do it? This is so good, it must have taken years right?
>>
>>55509659
make your waifu
or make AI that can make memes.
>>
>>55509822
Yeah, I followed that one a couple years ago and I still remember most of the algorithms explained there. Sedgewick is a great teacher.
>>
>>55509701
>image
What compels someone to do this, I feel immensely bad for many reasons.
>>
>>55509659
just automate tasks on your computer until you have everything working without you, and then off yourself you cunt
>>
>>55509701
Think this can be well combined with Codecademy's Python noob course or would it be superfluous?
>>
>>55509957
>cunt
I want obnoxious bogans out of my /g/
>>
>>55509958
you can go through it, it won't hurt but you should know that CodeCademy is in Python2

Now, at the start you won't really get that many differences between Python2 and Python3, pretty much the only difference you'll see is that in Python3 print is a function, and needs (). If you keep little changes like that in mind you can go through it.

And also you can go through this if you want to do some practical things with programming right away:

>https://automatetheboringstuff.com/

And this is also in python2:

>http://learnpythonthehardway.org/book/

You can just torrent, there is like a million resources for pyhon.

but yeah, go through code cademy, it's quick and you'll be familiar with the syntax afterwords
>>
>>55509957
>creating a shitposting algorithm so I can shitpost beyond death.
How truly horrible.
>>
Matrixes, how the fuck do they work?
>>
>>55510009
Thanks d00d
>>
>>55510021
you make an array and then you put arrays inside it
>>
>>55510018
check out the python module 'pyautogui' you can literally make that in 5 mins, just automate the mouse to click on something to post and then you automate the keyboard to shitpost and then mouse again to submit the problem is captcha , you could do it on a website without captcha
>>
>>55510021
Work on a PhD in pure maths.
>>
>>55506454
go is the hot new shit. all the cool kids are doing it
>>
>>55510021
like in programming or in mathematics? and if in mathematics rules are pretty simple, are you asking why matrixes are what they are and they way they are or?

in programming just put two for loops bam!
>>
>>55510098
Trying to make tetris. I figure I'll store where a "block" is in a matrix, because that seems more efficient than doing collision detection, but I don't quite understand how to matrix.
>>
>>55510082
300K starting job here I come!
>>
>>55506203
I was the anon who complained about the last thread's image.

This is much better, thank you OP.
>>
>>55506203
shitposting on 4chan for the 40th hour straight

just staying awake so i can get back on a normal sleep schedule.

then i'm gonna learn webpack. i'm a useless css turd trying to inch my way to frontend dev.
>>
>>55510113
lmao, what do you not understand, how to make a matrix or how to put a value in a specific place?
>>
>>55510113
the declaration depends on the language, just Google it.

a matrix is just a vector with two indices, there's literally nothing to get, it's not an advanced concept
>>
>>55510133
I'm sorry I'm so dumb anon, I just started programing like yesterday.

More how to put a value in a specific place,.

>>55510163
I know it's not advanced, but I just finished learning shit like if/else and loops like 2 minutes ago.
>>
>>55510187
what language are you using?
>>
Any personal project ideas?
I wanted to do a Chrome extension that replaces your typical ads and clickbait with "INCREASE PENIS SIZE NOW!!!" "HOT GIRL LOOKING FOR SEX IN ANONYMOUS PROXY!!!!" for shit sites like Forbes and such but apparently it's been done already, but with news instead of pornsite-y ads.
>>
>>55510199
C#.
>>
In c++ how do I initialize pointers without a segmentation fault?
>>
>>55510210
How does Microsoft's throbbing cock destroying your tight boipucci feel?
>>
>>55510201
I want a chrome extension that fucking remembers where I bookmark specific websites and makes it so that's the first bookmark folder it offers me to bookmark the new website.

If i placed 100 bookmarks from youtube into folder Videos, you could at least offer me that the next time I bookmark something from youtube instead of offering me the last folder I used...


>>55510210
sorry don't know shit about that, but if you were using python this is how easy it would be http://stackoverflow.com/a/6667361

just google your problems and read stackoverflow like the rest of us, that's how you do programming
>>
>>55510231
Just trap the segfault and recover from that.
(I'm kidding)
>>
>>55510245
I want to make 2d games. c# is used for unity if I want to use an engine, and monogame if I just wanna use a framework (what I'm currently doing). I'm welcome to suggestions, though, anon.

>>55510251
Hm. Alright. I'll look through stackoverflow.
>>
>>55510201
extension that removes forum signatures, post count, and avatars.
>>
>>55510251
That's actually a pretty great idea except I have no idea how to code it so that it works.

Check names of bookmark folders and their contents, compare them with the name & content of the page you're bookmarking, then decide if the page goes into one of the folders?

Dis gon be gud, thanks anon.
>>
File: 1342010687132.jpg (11 KB, 251x218) Image search: [Google]
1342010687132.jpg
11 KB, 251x218
I make if-statements like this
if(bool)
{
}

and not like this
if(bool){
}

Am I a bad person for doing this?
>>
>>55510361
for (bool b = condition; b; b = false) {

}
>>
>>55510361
As long as you're consistent.
>>
>>55510361
Absolutely. Kill yourself.
>>
>>55510361
That's how I do it too. People who do it the second way are autisms and their code looks like shit.
>>
>>55510293
Unity is a brilliant 2D engine aswell. I would know, since I've released a 2D game with unity. It has it's flaws (no 2D shadows & poor 2D animation support is just some) but it's certainly good enough to make something with.

Monogame is awesome aswell. I can't make anything fancy with it personally, but I've seen alot of other people make awesome stuff with it.

I have also heard good things about LÖVE and Godot, but those are a little more out there.
>>
File: 009.png (189 KB, 2106x1819) Image search: [Google]
009.png
189 KB, 2106x1819
>>55510319
I don't know about chrome or javascript, if you could check each folder and see what the highest percent of bookmarks lead too and then use that as the first offered bookmark folder, the second offered could be the second bookmark folder with the second highest concentration of bookmarks from that website.

so if you have two folders: music, videos, and they both have youtube bookmarsk inside of them, but like 70% of the bookmarks in music folder are from youtube while only 40 % of bookmarks in the videos folder are from youtube. Then you next time you bookmark something from youtube it first gives you the music folder and right below it the videos folder and so on.

If that's possible, it would make bookmarking so much easier and faster. Half the time I just put everything in other bookmarks because I can't be bothered to look for a specific folder
>>
>>55510361
No. Not in C at least.
Because whitespace doesn't matter and anyone who doesn't know how to process C code for their own reading convenience is a moron.
>>
>>55510472
Yeah, I'm working my way through monogame stuff because I'd like to learn programming while I do it, and unity is mostly scripting, if I understand correctly. Plus, deservedly or not, it has a stigma as low effort in the gaming community due to people just buying premade assets and throwing it all together, so if I do release something I want to avoid that.

It's slow going though, because monogame doesn't seem to be well documented, because they basically say to use XNA docs, so.
>>
>>55510361
why >>55510361
would you do it any different?
having the first brace in the same line looks messy and sophomoric.
>>
Currently working on a procedurally generated erotic text adventure in pure Lua.
>>
>>55510661
Can I follow this project somewhere?
>>
>>55510570
>unity is mostly scripting
I told my teacher this to an exam and he lowered me a score because of it. Fucking dick.

Anyways. Yes. Monogame is a bit tougher, but you will definetely be happier with yourself once you kow your way around it.
>unity has a stigma as low effort in the gaming community
I wouldn't really say that. It's true that there is some faggets out there who just slam bullshit together from the asset store, but most of the proffesional part of the industry is ignoring the steam-greenlight shit and the shit part of mobile. (not all greelight is shit, but the shit part is ignored) and once you put on those glasses, unity doesn't look half bad. Hell.. Even Heathstone was made in unity.

Still. Good on you for using monogame man :) Keep it up! Hoping to see your games soon dude
>>
>>55510671
Soon
>>
>>55510693
Can I ask for you to email me when you have a place to follow it on?
>>
>>55510661
What kind of scenarios will it involve?
>>
Ok /dpt/, here's a hard one:

What's the difference between the concept of pointer and reference? And now, what's the difference between those two concepts in C++ specifically?
>>
>>55510697
As it matures beyond a drunken weekend codepile, I'll be posting updates in dpt.

>>55510707
I'm seeding it with portions of short stories and flash fiction that I wrote over the course of the past few months. Setting is something like early colonial American with heavy folkloric/fantasy influence; mostly creature x human, dubcon, transformation.

I originally intended to create a choose-your-own adventure from these story fragments, but thought it would be more fun to augment it with more randomization and variety.
>>
>>55510685
Eh, the barrier to entry for unity is much lower, so people see more crap with unity. Among my friends and aquitances at least, people are wary of unity games

Thanks for the well wishes anon! I've managed to make pong so far, and I plan on keeping it up! Good luck on your projects, too!
>>
>>55510779
>I'll be posting updates in dpt.
Ok sure I'l just archive dpt and search it later.
Here's a mail. Please just send an email if it happens. I don't see why you can't do that really.
[email protected]
>>
File: art.png (305 KB, 1432x652) Image search: [Google]
art.png
305 KB, 1432x652
>>55510771
> C ++

what are you some old white cis hetero patriarchal male? don't you want to be like the cool kids and use Ruby? Don't you want to be a code artisan?
>>
>>55510771
References are pointers that once declared cannot change the object they refer to.
>>
>>55510771
Pointer points to a place in memory, reference is more like alias.
>>
>>55510815
So if you clear that memory, will they then be non-changeable dangling pointers forever untill you delete them?
>C++ newb here
>>
>>55510771
>what's the difference between those two concepts in C++ specifically?
Aside from certain limitations references have (some helpful, like const references) there's no difference. In any scope where a reference would not be a variable on its own a pointer is just the same. In any scope where a reference can not be compiled away it's just a pointer.

They're incredibly similar.
>concept of pointer vs reference
Depends on context. You can't answer this alone.
>>
I always seem to make mom's spaghetti. Do you anons have any general tips on how to avoid spaghetti code?
>>
My automatic luabind bindings generator based on clang libtooling/libastmatchers is almost complete. I've had global functions done for a while, and I can see the finish line for classes.
>>
>>55511182
Here:
https://hero.handmade.network/episode/game-architecture/day026
https://hero.handmade.network/episode/game-architecture/day027
https://hero.handmade.network/episode/game-architecture/day156#4674 (this is timestamped)

Watch this when on the toilet or whatever.
You can skip any programming parts.

It's the philosophy that helps you.
>>
>>55511205
>yet another tripfag
>>
>>55511221
thanks senpai
>>
File: 1386208641268.png (196 KB, 342x359) Image search: [Google]
1386208641268.png
196 KB, 342x359
I kind made a mess with git.

I have a libgdx project and because of the nature of it I fucked up everything and my master branch.
Now I have redone everything and I can push shit to my second branch and it just works fine. However, how can I now delete or merge my second tree to the master? I use the git plugin for eclipse if that helps
>>
>>55511233
>giving it attention
>>
>>55511293
https://classroom.udacity.com/courses/ud775/lessons/2980038599/concepts/29607789240923

just learn it again
>>
>>55511293
Any reason you're not doing this?
https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging
If there's no conflicting changes (master hasn't changed since the branch) you can merge automatically. If there are conflicting changes you just want to keep all the changes from the branch right?
What's the problem?
>>
>>55511335
those are some cringe videos

>>55511339
the problem is a huge mess with the local files, nested projects and dependencies. I will just delete the whole project and start over.
>>
>>55511429
ikr that one looks like a hamster lmao
>>
>>55511233
I only drop in occasionally, but I've been here for a while.
>>
> >55511516
I didn't ask you
>>
>>55511205
>>55511233
>>55511516
>>55511549

> /dpt/ - Dramatic Programming Thread
>>
>>55511686
daily platform for tripfags
>>
>>55511686
>>55511725
D Programming Thread
>>
Haskell?
>>
>>55510771
A reference is exactly like a pointer, except that it only lets you manipulate the value it points to, not the contents of the pointer itself. So you can't do pointer arithmetic with it, and you can't change what it points to. The syntax is different to enforce these limitations.
>>
>>55511968
what about it you autist
>>
>>55511968
meme language of yesteryear
primitive and hard to use and slow
its safe to pretend it never existed
>>
>>55511988
little baby couldn't grasp it so now it cries boo boo
>>
>>55512003
>defending a language with no while loop
>>
I heard feedback mode in modern opengl is deprecated and is done on the CPU side nowadays.
Is that true?
>>
>>55512012
>not mastering the art of the TCO
>>
>>55512132
Kek.
Recursion is for masturbating retards.

Conventional looping is superior in most cases.
>>
>>55511968
pretty good but no first class instances
>>
I want to write a simple text editor in python, but I have no idea where to start. Should I use curses or tkinter? if I use curses how should I handle saving the file with a key combo?
>>
>>55512132
I hate those homos who do fibonacci recursively. They love those functional languages and they're worthless. It just makes them feel smart.

https://www.youtube.com/watch?v=RFgDtatn4OM&t=353s
>>
>>55512303
search for it on youtube, I remember watching a guy make a text editor in like 10 mins or something
>>
>>55512387
But I don't want to use someone else's code.
>>
>>55512415
to see how it's done, not to copy it jesus
>>
>>55512303
In ncurses you'll basically have a loop that is waiting for some key press. Following vim's example, if you detect a colon being pressed, you can open up a command line. When they press enter, parse what they typed in. "w" save, "wq" save and exit, etc.
>>
File: FUCK.png (34 KB, 646x265) Image search: [Google]
FUCK.png
34 KB, 646x265
I think this is the most disgusting SQL query I've ever written.
>>
>>55512415
xddd
>>
>>55512909
>*
>lang is a string

xdd
>>
I copied and pasted this a while back, and now I can't figure out what the regexp replaces. It's in JavaScript. Can someone give me a hint as to what the hell this is: /<(?:.|\n)*?>/gm

var strippedText = text.replace(/<(?:.|\n)*?>/gm, '');
>>
>>55508029
Why not try this? http://mooc.fi/courses/2016/aalto-c/en/
>>
Anyone care to help a newb with pointers in c? It seems i'm printing out the memory address and not changing the value in the struct.

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>


//character struct
struct character{
char *name;
int strength, intelligence, charisma;

};


// strength function
void strengthRanNum(struct character *strength){
srand(time(NULL));
strength->strength=50; //testing to see if rand() is messing it up
}

//intelligence function
void intelligenceRanNum(struct character *intel){
srand(time(NULL));
intel->intelligence=rand()%99+0;
}

//charisma function
void charismaRanNum(struct character *chrsma){
srand(time(NULL));
chrsma->charisma=rand()%99+0;
}


//main function

int main(void){

struct character c;

//set characters name
c.name = "Iron Man";
//call function
void strengthRanNum();
void intelligenceRanNum();
void charismaRanNum();

//strings to equal either high or low
char highLowStrength[6] = "low";
char highLowIntel[6]= "low";
char highLowChsma[6]= "low";


if(c.strength>=50){
strcpy(highLowStrength, "high");

}
if(c.intelligence>=50){
strcpy(highLowIntel, "high");
}

if(c.charisma>=50){
strcpy(highLowChsma, "high");
}

//printf();
printf("%s stats are %d Strength %d Intelligence %d Charsima\n", c.name, c.strength, c.intelligence, c.charisma);
printf("So %s has %s Strength %s Intelligence %s Charsima\n", c.name, highLowStrength, highLowIntel, highLowChsma);

}
>>
File: 1466347634608.jpg (2 MB, 3888x2592) Image search: [Google]
1466347634608.jpg
2 MB, 3888x2592
So I was trying to get the hang of IO in haskell, so I wrote a little program that gets the ID3 tags of songs and renames and reorders them into folders based on their tags.

Obviously this was always going to be heavy on IO but nearly all of my functions started with a "do", and it felt I was doing a lot of imperative style programming. Is there a lot of this or does it depend what you're programming?

I guess there would probably be less IO if I knew what I was doing, haven't got onto monads yet in my tutorial so was kinda fighting with the compiler but it's done now and it seems I get less bugs with haskell than when I made the same program before in python
>>
File: Happy_Good_People.jpg (61 KB, 500x375) Image search: [Google]
Happy_Good_People.jpg
61 KB, 500x375
>>55506203
>tfw studied algos, data structures, Python, java, C#
>make app for fagbook users to talk to each other
>tfw retired, never have to work again

Thanks /g/
>>
>>55513044
What does it do that's different from facebook's app?
>>
>>55513038
show some code
>>
>>55512954
I'm pretty sure it's just removing every thing that occurs between two angle brackets, including the brackets themselves.
<test>
<>
<asdgfa asdga >
etc.
>>
>>55513070
handleTags tagfile t mp3 path = do
cwd <- getCurrentDirectory
artist <- TagLib.artist t
album <- TagLib.album t
title <- TagLib.title t
if "" `elem` [artist,album,title] --if any empty tags ignore it, will fuck up path
then return ()
else do TagLib.save tagfile --will segfault if files aren't closed with enough files
let extension = if mp3 then ".mp3" else ".flac"
newpath = cwd ++ "/" ++ artist ++ "/" ++ album ++ "/" ++ title ++ extension
if path == newpath --don't needlessly rename
then return ()
else do
putStrLn $ "renaming " ++ path ++ " to " ++ newpath
createDirectoryIfMissing True $ takeDirectory newpath
renameFile path newpath
>>
>>55513097
>
putStrLn $ "renaming " ++ path ++ " to " ++ newpath


nasty
>>
>>55513092
Sweet, thanks!
>>
>>55513068
It allows users to connect from around the world utilizing a series of tubes through which they can perform intercourse digitally.
>>
>>55513097
trivial point but you might prefer
concat [ "renaming ", path, " to ", newpath ]

similarly for newpath

concat [ cwd,"/",artist,"/",album,"/",title,extension ]
or even better

intersperse '/' [ cwd, artist, album, title ++ extension ]
>>
>>55513144
*bottom would need a concat & should be "/" not '/'
>>
>>55513123
>>55513144
yeah I knew there was a much better way to do that, forgot to look it up, thanks
>>
>>55513028
Please indent your code correctly. It makes it so much nicer to read.
>//call function
>void strengthRanNum();
>void intelligenceRanNum();
>void charismaRanNum();
You're not actually calling any of the functions there. You're just declaring them as prototypes.
Even then, you're not passing your struct as an arguement.
strengthRanNum(&c);
intelligenceRanNum(&c);
charismaRanNum(&c);

is what it should be.
>srand(time(NULL));
You should only call that ONCE at the start of your program. All of your things are going to have the same value if you keep reseeding it.
>>
>>55513097
also you could write a function to get all the data at once, so in handleTags you end up doing

(artist, album, title) <- TagDetails t
Thread replies: 255
Thread images: 32

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.