[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 345
Thread images: 35

File: 1481030613770.jpg (64KB, 1024x906px) Image search: [Google]
1481030613770.jpg
64KB, 1024x906px
What are you working on, /g/?


Previous Thread: >>57861948
>>
fpbp
>>
>>57866411
https://github.com/deeepaaa/wassily
>>
File: 1466799123560.jpg (68KB, 461x588px) Image search: [Google]
1466799123560.jpg
68KB, 461x588px
>>57866298
C is a different kind of hard, and requires a different kind of autism from video game development.

My advice for learning practical C is to use open source projects written in C, and dig around whenever you find something that breaks. Otherwise, learning the best practices can be hard, since the language has been around so long, and everyone has their own ideas of what is best.

And don't be afraid to reinvent the wheel because, for better or worse, that's just part of the C culture. Every company seems to have their own library for shit like LinkedList, HashMap, etc. Use it as an excuse to learn more of what goes on under the hood. Then go ahead and use a battle tested lib if you need it for a real project.
>>
File: ride.webm (3MB, 720x404px) Image search: [Google]
ride.webm
3MB, 720x404px
Ask your much beloved and highly praised programming literate anything (r/IAMA)

>>57866411
Thank you for using an anime image.
>>
>>57866480
Why haven't you killed yourself yet
>>
>>57866480

What is the point in programming?
>>
>>57866492
to kill time until death
>>
>>57866480
What do you think about using unikernels in production environments?
>>
>>57866411
Please stop using anime on a tech related discussion board
>>
>>57866556
>implying this isn't a tech discussion board framed in the context of a site that has a culture of anime being applied to a myriad of aspects of our daily lives and interests

In other words, "no".

>>57866411
>What are you working on, /g/?
Trying to figure out how to move data from one point in the cloud to another point in the cloud without it routing through my on-premise server.
>>
>>57866587
> Trying to figure out how to move data from one point in the cloud to another point in the cloud without it routing through my on-premise server.

usually not possible, unfortunately, but for many cloud services (e.g. AWS, I think) traffic inside the same datacenter is free. So e.g. you could do an S3->EC2->S3 copy for $0, AFAIR.
>>
can someone help me, I don't understand this error

im using requests, I do a post request and I get the answer and I get a
AttributeError: 'dict' object has no attribute 'loads'


asd = res.content.decode("utf-8")
tjson = json.loads(asd)
>>
>>57866603
I'm actually trying to move data within an Azure SQL Server instance to another database in that instance, but the Azure SQL Server is a standalone application, so I can't run a .NET application on it like I would if it was installed on a Red Hat Linux server locally.

I'm wondering if I should host up an azure application service or something; good point on the in-cloud transfer, that might be something I can abuse.
>>
>>57866475
>requires a different kind of autism from video game development.
Yeah, I get that. I'm not really interested in the programming aspect of video games.
The kernel and driver stuff sounds interesting though.
>My advice for learning practical C is to use open source projects written in C,
That's what I planned to do.
>and dig around whenever you find something that breaks.
What do you mean? Finding something broken then fixing it for an open source project?

Thanks for your posts, I guess I'll stick to C for now.
>>
>>57866615
you probably shadowed the json identifier with a dict somewhere by doing something like

json = {}


or so
>>
>>57866615
Well it seems like to me, tjson has no attribute "loads"

It's a dictionary and in Python, dictionaries don't have a method called "loads"
>>
>>57866625
idk shit about either azure or SQL server. Maybe it has something like postgres where you can use an SQL command to connect to another postgres server and then dump over tables. IDK how billing works on azure though, they would probably bill you for the traffic.

Maybe you can just use the replication system
>>
>>57866411
hwat hwanime
>>
>>57866679
eva
>>
>>57866693
waitwhat.
Is that Shinji?
>>
File: Sadamoto_nadia-shinji.png (116KB, 492x488px) Image search: [Google]
Sadamoto_nadia-shinji.png
116KB, 492x488px
>>57866718
of course
>>
>>57866631
argh, omg thanks that was the problem
>>
I am in think python's third chapter and wanted to try out importing and using functions in the interactive shell.

Pic related is what I get.
The file is in the root folder, as it should be

this is the code
def print_lyrics():
print("I am a lumberjack, and I am okay with that")
print("I am sleeping all day and working all day")



def repeat_lyrics():
print_lyrics()
print_lyrics()


repeat_lyrics()



any assistance would be a huge improvement on my case.
>>
>>57866752
did you try


>>> import filename
>>> filename.print_lyrics()


?
>>
File: huh..png (36KB, 679x723px) Image search: [Google]
huh..png
36KB, 679x723px
>>57866752
forgot pic
>>
>>57866761
no.
I did that and it made it work.
Thank you.
>>
>>57866764
import
import Lyrics_man.py
import Lyrics_man.py
repeat_lyrics
import Lyrics_man
ArithmeticError
repeat_lyrics
repeat_lyrics()

wtf
>>
>>57866649
Well, it would be easy enough if what I'm doing could be easily done in SQL, but it's going to need to run through a .NET application for some transformation logic.
>>
>>57866783
You can also do something like

>>> from Lyrics_man import print_lyrics
>>> print_lyrics()


or even
>>> from Lyrics_man import *
>>> print_lyrics()
>>> repeat_lyrics()

which dumps all of the functions and variables defined in Lyrics_man into your current namespace (not generally that recommended though, 'cause it clutters things up)
>>
>>57866790
I was trying some stuff out.
I am new for fucks sake.
>>
>>57866793
And you can't do that transformation logic in SQL? I bet you can...

Other than that, guess your only option is to spin up an instance and run some code.

> Is data transfer between Azure services located within the same region charged?
> No. For example, an Azure SQL database in the same region will not have any additional data transfer costs.
>>
>>57866822
If it didn't work the first time, what made you think it work the next 10,000 times?
>>
>>57866822
Nah man, don't you know you're never allowed to make a mistake? :^)
Don't let him turn you off of programming. Not all of us are fuckheads.
>>
implementing my own React
>>
>>57866831
Ever hit a nail with a hammer, made it look strange and still tried to continue with the hopes that MAYBE, the nail will still get inside?
>>
File: 1467014476053.jpg (126KB, 700x979px) Image search: [Google]
1467014476053.jpg
126KB, 700x979px
>>57866629
>The kernel and driver stuff sounds interesting though.
It's harder to learn that on your own, but definitely doable (since at the very least, I did it). Get used to using virtual machines early, since that'll be your bread and butter for testing kernel work. And don't be afraid to download the linux kernel source code and start poking around. Even if you don't understand the code at first, the documentation is pretty amazing, and it will teach you a lot.

>Finding something broken then fixing it for an open source project?
Yeah, but starting out, you don't even have to fix it. Just being able to navigate the code to the point where you can understand why things are broken is a huge challenge at first. But you'll learn a lot that way.

Also, a solid way to get used to a C codebase is to choose one message the program outputs, figure out where it lives in the code, and change it to say something else. It's mostly a matter of code navigation, but code navigation is one of the most important skills for C, since C codebases are often fuckhuge. Plus it feels good to make a tangible, easily verifiable change in a program.

>I'll stick to C for now.
It sounds like the right choice for you. Have fun!
>>
>>57866871
A nail isn't a computer. It's literal. 2+2 will always give an output of 4 no matter how many times you repeat it
>>
>Read trump's tweets comments.
>Massive amounts of retards.

wew lad
>>
>>57866994
Not even remotely related to programming.

Piss off, wankuh.
>>
>>57867037
What are you talking about? Trump will ban Haskell once and for all.
>>
>>57866629
There's a small os written by MIT called xv6 the source code is online along with the book which explains each line of the code. Maybe start with that

For kernel I liked Robert love. Also you can try os161 for os assignments
>>
What would you recommend to learn regex? Doesn't need to be advanced at all, just need to parse some strings in a nicer way
>>
>>57867051
This. I also recall he tweeted that Java was created by the Chinese to make American software uncompetitive.
>>
>>57867126
Use an online regex tester such as:
https://regex101.com/

And read this:
http://www.regular-expressions.info/tutorial.html

And google anything else you need to know to parse that particular string.
Like anything else, the best way to learn is by doing. After using regex several times it will start to come naturally.
>>
>>57867126
Yeah. It's useful for some cases. But be warned, it's not a end all be all solution.
http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html
>>
>>57867168
wew lad

won't be doing anything that complex, I've never been a fan of it, but for short strings it seems a lot easier in some languages than traditional ways.

>>57867151
thanks, I'll have a go
>>
>>57866901
Well, coming from a blue collar household, I didn't realize that.
What I can say though, that coding IS fun. Plus I get to learn so much from my own mistakes and other's advice.
>>
>>57866411
Worth learning Golang? I hear that people around /g/ seem to like it. Is it just a meme?
>>
>>57867249
Go is about 92% meme
>>
>>57867249
Not really, the only thing that it's got going for itself is goroutines but you can have that in other languages as well.
>>
>>57867241
Protip: ignore posts containing either "wtf", "omg", "XD", "fuck", "tfw" or "retard"
>>
>>57866411
Thank you for not using Himegoto image
>>
>>57867249
>I hear that people around /g/ seem to like it.

Where the fuck did you hear that?
>>
>>57867370
Since your post contains all of those phrases, I've ignored it.

>>57867415
>"I am easily triggered"

>>57867241
Don't ever forget that coding is fun. When you stop having fun you're going to stop learning things. Make sure you're doing stuff that you like.
>>
>>57867249
its ok, I use it at work

it has some really annoying aspects to it, and the community is extremely shit and deluded. If you say anything that can be remotely construed as a criticism of anything related to go, people will jump on your throat. Or if you just mention that you also use C or C++ etc, they will declare you insane. OTOH when there is any progress, the crowd starts chanting "we realtime now, we realtime now" etc. If you ask or question any of the internals of the go implementation, people will scream "YOU'RE NOT SUPPOSED TO CARE ABOUT THAT!!!!" at you.

Just don't let yourself get infected with the toxicity, and you'll be fine.

But it is a good & productive language if you want to get shit done, like implementing HTTP APIs and other such services. The lack of generics and exceptions is annoying at times, but you can live with it. It has a decent amount of libraries etc (we use the go AWS SDK a lot to interact with amazon etc)

the type-system is also not as powerful as one might wish, as a result there are a lot of interface{}'s being thrown around in stead of properly safe generics as you would have in C++. But you can make do.

>>57867276
while that's true, in many other languages they are not nearly as well-integrated. since they are a "default" feature of go, everything plays nice with them. I've used coroutines etc in other languages, and it's often not that easy.

OTOH goroutines, channels and the other primitives go offers are really not the end-all be-all solution of modelling concurrent or parallel problems either. They have a lot of subtleties and edge-cases that can cause hung goroutines, leaks (goroutine leaks, filehandle leaks, slice leaks, ...) etc.

Also, it has occurred in some cases that I would've preferred to just have an asynchronous, single-threaded i/o event loop instead of spawning a shittonne of goroutines, but you don't get to chose, in that case goroutines are kinda forced on you. but oh well.
>>
I'm trying to pass a member of a struct to a function but I get an error "Request for member year of something not a structure or union"
typedef struct {
int year;
int month;
int day;
} Date;
char *parseInt( char *s, int *value )
char *parseDate( char *s, Date *d )
{
/* The date looks like this '2016-10-05', so read an int, skip the
'-', read an int, etc
*/

parseInt(s, d.year);//Error here!
>>
>>57867642
d.year is an int, but parseInt expects to receive an int*.

try

parseInt(s, &d.year);
>>
>>57866426
pretty cool
>>
>>57867642
also, parseDate takes a Date* not a Date, so you can't write d.year, you have to write d->year (or change it to not take a Date* but a Date instead)

so you have to do something like
parseInt(s, &d->year);

actually.
>>
>>57866480
how do I get my dick sucked by the cute girl who's sitting next to me in programming class?
>>
>>57867708
Impress "her" by not being a sperglord and just asking "her" out. Extra points if you shower, brush your teeth, and groom regularly.
>>
Guys! I got an A in C Programming! I know that is laughable to many of you but it is quite the accomplishment for me at 29. If you were in my shoes, which language would you learn next; C++ or Java? Those are my choices as of now.
>>
>>57867744
what are you implying here? that it's a dude?
>>
>>57867821
what do you mean you got an a in C? I would go for c++ and java.
>>
>>57867708
Show her your gentoo install with haskell source code open on emacs.
>>
>>57867821
java if you want to go into android programming or do web services etc

c++ if desktop applications, games, low-level applications (microcontrollers, operating systems, drivers, ...) or anything performance-critical are more your thing

java is quite a bit easier to get your head around, there's less stuff to learn about.
>>
I'm making a chinese name generator, any ideas?
>>
>>57867890
ideas for what?
>>
>>57867825
I'm not implying anything anon. Your subconscious seems to be fixated on something.
>>
>>57867890
ching bong ding dong
>>
File: 1480439467113.jpg (208KB, 728x518px) Image search: [Google]
1480439467113.jpg
208KB, 728x518px
>>57867907
The names, sorry for not being specific enough
>>
>>57867665
thank you.
>>
are functions in a bunch of languages the same as methods in java?
>>
>>57866411
About to take my programming final consisting of trick multiple choice questions which don't test my ability to write a program at all!

Wish me luck :')
>>
File: noideawhatelsetodo.png (1KB, 357x57px) Image search: [Google]
noideawhatelsetodo.png
1KB, 357x57px
>>57867929
>>57867907
what else can be added?
>>
>>57867956
methods stem off of functions, but functions are just java classes which are just java files
>>
>>57867972
>;
Shit, too much C
>>
>>57867915
I'm not gay anon, I promise!!
>>
>>57867843
In my college, it was required to learn C before C++. I got an A in that programming class is what I meant. Do you mean try to take both at the same time?

>>57867882
>java is quite a bit easier to get your head around, there's less stuff to learn about.

Heh. I had someone tell me the opposite. He said since I know C, if I know java; I will know both. He said C++ is basically a hybrid of java and C. -Some guy from India.
>>
>>57868037
There is a *lot* more to C++ than that. Javas type-system is not nearly as powerful as C++s, for instance. C++ also has its own standard-library which is very different from java, and many concepts that make no sense in java like xrefs/rrefs/etc, move semantics, destructors, smart pointers etc
>>
>>57867972
Pretty low tier, anon. At least do an array for first name and last name and return a whole name.
You could even give the function an argument to determine whether you need a first name, a last name, or both.

>>57868010
Anon doth protest too much, methinks.
>>
>>57868002
...Are you okay there, anon?
>>
>>57868070
>smart pointers
So that's how those kids get head shots every time.
Which is better for getting an entry-level job? Java or c++
>>
>>57867890
Obviously the program have to dynamically generate its own name
>>
>>57868183

probably java, I'd rather employ an inexperienced java programmer writing shit java code than an inexperienced C++ programmer writing shit c++ code that has security issues. If I'm looking for a C++ dev, I'd definitely put the bar a good deal higher.

But both are very in-demand languages, so ultimately learning either is a good time-investment for your career.
>>
I have mandatory programming as a team class in 5 minutes set up by by work to the entire IT dept, which I'm pretty sure is just a free demonstration to try and get us to take their class. Please end me
>>
>>57868183
Smart pointers are pretty much pointers that know when they're going to be dereferenced so that go out of scope.
>>
>>57868254
congrats on giving the worst explanation of smart pointers I've ever read
>>
>>57868183
java is master race
>>
>>57868283
What do I win?
>>
>>57868254
???
>>
How do I write a program to stop me from reading /r9k/'s posts from girls who are hopelessly lonely just like me.
It just fills me with wanton desire to find girls like that and it's not healthy.
I just want to walk the pious path and be a programming literate just like our exemplary poster here.
>>
>>57868370
don't go to r9k then???
next
>>
File: baka_big.png (2MB, 2000x2000px) Image search: [Google]
baka_big.png
2MB, 2000x2000px
>>57868370
Start small, do some "Hello World" and "FizzBuzz" programs.

Eventually, you'll be able to do slightly more advanced things, like basic automation.

Use this knowledge to do some small freelance jobs for office workers trying to make their life easier.

Eventually, you'll have enough money to buy a fairly cheap pistol and take a class or two on how to use it.

After that, simply load the weapon, put the barrel in your mouth pointing towards the top of your skull, and then pull the trigger!
>>
>>57868302
a dumb pointer

>>57868370
> /r9k/
> girls

you got memed, friendo :^)

also
sudo sh -c 'echo -e "127.0.0.1      www.4chan.org   www.4chan.org\n127.0.0.1      boards.4chan.org        boards.4chan.org\n127.0.0.1      sys.4chan.org   sys.4chan.org" >> /etc/hosts'


you'll thank me later
>>
>>57868254
Would saying that smart pointers are just pointers that enforce some encapsulation to assure that you use them in stricter ways that let you be assured of their more narrow space of potential states.
>>
>>57868433
that's also wrong
>>
>>57868442
>wrong
Could you please correct it? I'd learn a lot from that.
>>
>>57868433
I suppose in a sense that is correct, if you consider e.g. "dangling"/"leaked" to be states of the pointer

but there's really not much point in trying to give a description of "smart pointers" in general; rather, one should give a description of the two main kind of smart pointers (std::shared_ptr and std::unique_ptr) individually, since they achieve rather different things
>>
>>57868452
read a book
>>
File: 1476924920014.jpg (125KB, 540x720px) Image search: [Google]
1476924920014.jpg
125KB, 540x720px
>>57866411
Hey fags I got a question for you, is it possible to set up a second virtual desktop with it's own mouse on a windows 10 laptop? Got a program running that uses my mouse and clicks and so obviously prevents me from using my laptop. I'd like to set up a second virtual desktop (which is easy to do) but also create a mouse to move on that desktop while it is not in view.

Any of you know if this is possible? I'd like to have my program running in that second desktop moving and clicking while I use my other desktop view with my actual mouse.
>>
>>57868491
not possible
use a virtual machine
>>
>>57868491
just rewrite the program to dispatch events rather than taking the control over your peripherals
what kinda dumb design is that
>>
>>57868482
>in a sense that's correct
Well I didn't consider there to be other relevant states of smart pointers. Shared_ptr is for reference counting. Unique_ptr aims to ensure only one reference.

What else is there really?
>they achieve different things
I genuinely haven't seen that. They're just used differently for the same purpose afaik.
>>57868483
Surely that's a bit extreme. I wouldn't need an entire book for smart pointers.
Either way I'm looking to be informed from where I am right now rather than start ground up. In some sense that's really the point of questions in general.
>>
>>57868422
>it's not girls
I think it is genuinely but it doesn't matter because there are lonely girls.
>>57868403
>eventually you have enough to buy a cheap pistol
Ah well I can already afford that. Practically anyone can. The hipoint C9 is really cheap.
But gun suicide isn't what I want I just want a girl to hug and make feel good. More and more I realise that's what my earthly desires are and I can't escape.
I don't want to be a slave to these feelings.
>>
>>57868542
>Either way I'm looking to be informed from where I am right now rather than start ground up.

read the following pages on cppreference then:
http://en.cppreference.com/w/cpp/memory/unique_ptr
http://en.cppreference.com/w/cpp/memory/shared_ptr
http://en.cppreference.com/w/cpp/memory/weak_ptr
>>
>>57868510
>>57868501
Hey I know it's stupid as shit but the client wants what the clients wants. I'd rather make sure it's 100% impossible before i go back to him. Everything I've found and known says it's not but wanted to check with the /g/eniuses (kek) to be sure
>>
>>57868573
So if the client wants the program to take control of the mouse then what's the problem?
Unless they do not - in which case, again, rewrite the program to send mouse events rather than taking control over the mouse.
>>
>>57866411
best girl
>>
Started working through the problems on rosalind.info a while ago.

Having fun, learning a shit ton, and I'm keeping myself productive.

Anyone got any tips for someone interested in bioinformatics/computational biology?
>>
>>57868573
I'm like 95% sure the windows input system is designed with the limitation of there only being one pointer device at the same time (and there may be additional limitations like it being impossible to use it on another workspace without switching to that workspace). One think you could look into is whether you can get something to work by telling windows you have a touchscreen and then sending touch events? dunno

The better idea may be to just send events into the event-queue of the application. I think on windows it's possible to just place a mouseclick at a certain location into the event queue of a GUI program. That way you could be able to make the application to anything you want it to do without ever actually using the mouse. Well, at least I think this is how it worked in the XP days, no idea about modern windows. This may require admin privileges nowadays etc.
>>
>>57868573
Sounds like it's for mirroring a game to control two accounts or something.

That's actually possible, I would think. If you capture the coordinates of mouse clicks and then basically capture the mouse, move it to the equivalent on the other monitor, and make a click event, then that would be one way to do it.

You could do this as an overlay to whatever you want.

Yes, I'd say it's possible.
>>
>>57866411
tfw no job c++ developer here, what's a good freelance website for me ;'c?
>>
Is it worth to program in C as close as possible to a purely functional language or not?

I mean is there any performance gain to use the global scope?
>>
>>57868640
Your shit's all fucked up and you talk like a fag.

C++ has a fuckton of jobs, on par with C and Python, only behind C# and Java, excluding Javascript and SQL.

You should be able to get a job if you're hunting in a city. Be willing to move.
>>
>>57868643
scope? C has no concepts of scopes. Do you mean avoiding functions? There is generally no point to avoiding functions in C, as the compiler can generally inline them (if they are small enough) and calling a function is pretty cheap (and makes sense if they are big enough, so that you won't have all that duplicated code in your cache)
>>
>>57868643
>is there any performance gain
Performance gain for what?

Why do you need performance gains?

Have you benchmarked your application, ensured functionality, and actually confirmed that the performance is unacceptable?

Surely you're not trying to optimize prematurely, right?
>>
>>57868664
Not American my guy, here is kinda hard to get a job as a C++ goy (and they offer leftovers wage)
>>
>>57868669
>C has no concepts of scopes
what??
>>
>>57868669
s/scopes/namespaces/
confused myself there
>>
>>57868569
>unique_ptr
But that's exactly what I described. It ensures only one reference to the object. When the last reference disappears it frees the object (well, not necessarily. You could extend the use of the ptr. It could consciously just leak it or add it to a free queue for later processing but you get my point)
>shared_ptr
Again it seems to fit my description well.

This additional use you (multiple of you) have claimed seems fairly invisible.

Why are C++ programmers so secretive? It's a rather small question and you could probably describe it or point me in the right direction with a single word.
People put way more effort into helping concrete errors here, so why not give me this small piece?
It makes it seem like you actually don't know and it was just a falsification. I'm sure you'd agree with that assessment.
>>
>>57868669
For example:
static int x;
void f() {
x = 6;
}

// vs

int f(int x) {
return 6;
}


First one might be faster?
>>
Reposting for more ideas.
>>57868343

>>57868705
It doesn't have to be a website. It's probably best if it isn't as me and my partner don't know PHP or anything.
>>
>>57868694
> the last reference
well, there is only one, in the case of unique_ptr. That's a big part of the point (and indeed, rust has this embedded into its type-system, even) -- if two parts of your code can point to the same buffer and mutate that buffer, you can easily run into trouble. A big class of problems is avoided when you know for certain that a pointer is unique (also e.g. the issue of aliasing pointers inside a single function, which is an issue in C, fortran, ... - in C you can declare a pointer "restrict" to promise to the compiler that it doesn't alias, but with unique_ptr (or in rust) you know this *for sure*.)

Basically almost anywhere you may use a pointer, it is better to use a unique_ptr. It also has zero space overhead.

> shared_ptr
shared_ptr is for managing multiple views of the same piece of data, so it's more akin to being a garbage-collected pointer (in the sense of garbage-collection that e.g. perl do, which has no "real" garbage-collector, only reference-counting). it has overhead compared to using a raw pointer.

idk what you were asking exactly, but maybe this answers it. they're not difficult concepts anyway.
>>
>>57868669
>>57868729
Wait nvm I meant something like
static int x;
void f() {
// Do stuff with x
}

// vs

int f(int x) {
// ...
}
>>
>>57868730
What languages do you know?

You could easily set up a proof-of-concept with C# + WPF, or whatever language you're familiar with combined with the most popular GUI framework.
>>
>>57868643
>purely functional
That tends to imply performance implications. At least with normal usage.
>>57868729
Well since both are constant and equally cache local (Presuming you don't pack your X in with other data to be processed) they should be identical if you save the return of the second version.
Both should also be inlined in practically all cases.
>>
I really need some advice guys. I need to make this in python. My only concerns are the colours. They are user inputted. How would I approach this? I tried using if statements to set the right colours but it doesn't work and seems wrong (too many lines of code).
>>
>>57868694
It does not ensure a single reference to the object.
While not semantically correct, you can have multiple const references to an unique_ptr.

Consider this:
#include <memory>

void f1(const std::unique_ptr<int> &v)
{
}

void f2(const std::unique_ptr<int> &v)
{
}

int main(int, const char **)
{
auto a = std::make_unique<int>(5);
f1(a);
f2(a);
return 0;
}
>>
>>57868763
C/C++, Java, and Python are what we're most familiar with.
>>
>>57868729
not really, but it's not that easy of a question to answer. It depends on where the function boundary is. Either way, there is never a point to using the global scope. If you want to avoid returning something from a function, the alternative is to pass a function pointer.

So it's really

void f(int *x) {
*x = 5;
}
int main(void){
int a;
f(&a);
}

vs.
int f() {return 5;}
int main(void){
int a = f();
}


Returning small things from a function is generally considered faster than passing pointers. For larger objects the answer is not so simple. Often it doesn't make a difference, either because the function ends up being inlined anyway (in which case functions are a zero-overhead abstraction) or if the function is e.g. in the same compilation unit, then the stackframe of main() can already allocate space for the object returned by f (even if its very large). If you're returning large objects through a DSO boundary (e.g. from a .so into your program, or on windows from a .dll to your .exe) then there may be considerable overhead to returning large objects on the stack, and passing a pointer that the function writes into may be faster.

If none of that makes sense to you or you're not sure if you need to care, the TL;DR is "just use functions whenever you want, they have basically no performance penality. Using global variables has basically never a performance benefit"
>>
>>57868775
...make what? Can you post your assignment description and current code?
>>
>>57868775
With the code you posted so that we can help you with your issue, I've identified that the problem is on line 17: It appears that you may be a massive fucking faggot that has no idea how to ask for help properly.
>>
File: 1478605265072.png (32KB, 164x164px) Image search: [Google]
1478605265072.png
32KB, 164x164px
>mfw docker for windows is actually pretty good
its nice with an unexpected surprise every once in a while
>>
I'm writing a scraper in Rust using Emacs as part of my upcoming project.
I like Emacs as an editor, but I'm not sure about the keybindings. The vim keybindings feel more comfy.
>>
>>57868822
>>57868823
Sorry, I'm noided because plagiarism so I put it into pastebin. colour1, colour2 and colour3 are user inputted. How would I make it so that the colour set is based on the position of the square (see original pic) >>57868775

code: http://pastebin.com/38xvq9eA
>>
>>57868762
The difference here of the compiler being able to specialise the case where it knows the value of X in the second case if it's passed a constant is quite significant.
If you're not passing a constant and the function wasn't inlined you will (potentially depending on the use of X within the function) do a copy of the argument.


It's not where performance crops up generally. Failure to inline appropriately is rare. And in certain cases it's preferable to not inline. The global variable use doesn't in particular have any downside on the performance end (assuming the argument versions return is saved, or it simply won't be an effective statement as its dead code). The real downside to it is the amount of stuff to consider. The (imo) major upside to functional programming. You don't need to consider that much state.
But if you actually care about performance and want to learn how to care about performance here's a post I wrote:
https://archive.rebeccablacktech.com/g/thread/S57679595#p57680511
>>
>>57868809
Thanks for the answer.
>just use functions whenever you want, they have basically no performance penality
I'll stick to that. To be honest I was hoping the truth were along those lines
>>
>>57868924
>being able to specialise
My bad. I assumed a volatile global (which is the norm for me). In that case the compiler should be able to do both as well.

So its really just a copy.
Use whichever you prefer.
>>
>>57849969
So I'm learning Perl now. That's my first *real* language after C#.
Thank guys from /flgt/ for pushing me out.
Tell me how faggot I am.
>>
File: 1481001595779.png (73KB, 436x395px) Image search: [Google]
1481001595779.png
73KB, 436x395px
>the first programmer was a woman
>the first compiler was written by a woman
these facts make janny so mad he'll give you a warning for pointing out the programming is inherently feminine
>>
Am I the only one that absolutely despises syntax highlighting, I like autocomplete and auto indentation, but s-h distracts me more than it helps.
>>
>>57869048
> current year
> willingly subjecting yourself to perl

at least "use strict; use warnings;"
>>
I wrote this out of boredom -

    def anagram_list(self):
for i in self.list:
i = i.encode('utf-8')
x = hashlib.sha1(i).digest()
y = urllib.parse.quote(x)
print(y, i)

user_input = str(input('anagram this word: '))
new = anagram_word(user_input)
for i in range(5):
new.anagram()
new.anagram_list()
>>
>>57869080
what is this degeneracy
>>
>>57869080
That's because real men are electronics engineers
>>
>>57869048
Any reason why you would go with Perl over something like either Python or Ruby?
>>
>>57869094
At least it's not memesnek
>>
>>57869080
If programming is so feminine why don't I have a nice programming girlfriend?
Really even in the more abstract sense women don't tend to solve problems in a programmatic fashion.

I'd love that to be the case but it doesn't seem to be.
>see: Why I'm making my waifu ai.
>>
File: received_1196416713758619.jpg (143KB, 1807x1080px) Image search: [Google]
received_1196416713758619.jpg
143KB, 1807x1080px
>>57866411
Trying to design a useable GUI with WinForms.
>>
>>57869151
What's wrong with WPF?

Don't you know it's THE CURRENT YEAR?
>>
>>57869151
>winforms
Why?

Nearly all computers running right now support WPF.

Even XP supports WPF.
>>
>>57869169
>>57869181
WPF looks like shit on the developer side.
>>
>>57869169
>>57869181
Because it's the requirement for the current project.
>>
>>57869151
What a perfect shitpost language you speak
>>
>>57869196
no it doesn't.
>>
>>57869196
Once you learn the basics, XAML is infinitely superior than using C# for markup.

>>57869200
Fair enough, carry on.
>>
>>57869113
I don't like when language tells me how I should organize my code. So python is not option (but I pretty familiar with it anyway, because plenty of open source math-related libraries and cli apps was written with it).
I wanted something very flexible, like "swiss knife" of languages, but powerful and with large base of modules in the same time.
>>57869094
Got it. Will use.
>>
File: cantonese cartoons.png (305KB, 853x480px) Image search: [Google]
cantonese cartoons.png
305KB, 853x480px
What's the best speech to text library for C++, /dpt/?
I've thought about using Voce but it requires the JDK to be installed. I could do that but I'd rather stay away from Java.
>>
>>57869151
wpf is pretty good though, only reason i don't use it is that i don't use c#
>>
>>57869215
XAML becomes an unreadable piece of shit after adding and designing a lot of Controls.
>>
>>57869101
   for i in self.word:
word_list.append(i)

for i in range(len(word_list)):
x = len(word_list)
randomizer = random.randint(0, x)
if randomizer == x:
new = word_list.pop(randomizer-1)
s += new
else:
new = word_list.pop(randomizer)
s += new
self.list.append(s)


twas fun but now i have to actually get determined to write a twisted client ;-;

some things are confusing.
>>
>>57869237
>XAML becomes an unreadable piece of shit after adding and designing a lot of Controls.
No it doesn't.

Also, the WinForms alternative is to put everything in fucking .designer.cs partial classes. pukinganimegirl.jpeg
>>
>>57869219
Also, "home of regular expressions"-tier sounds very nice.
>>
>>57869237
For you.

And >>57869254 beat me to it.

Using a markup language for markup is simply a better option, and WPF exposes much more functionality to take advantage of the GPU and properly scale UI.

That plus something like MahApps makes for much more modern-feeling applications.
>>
>>57869254
>winforms alternative
Is better.
While OOP gui generally sucks and we need some proper systems for it.
The advantages a OOP system has in terms of automatically generating a UI from a design tool is great.
Markup doesn't lend itself well to a mixed system where you do some of it programmatically and some of it programmatically.
Winforms keeps it all in one format and that's a major advantage.
>>
>>57869325

Yeah, but scaling...
>>
>>57869354
>scaling
Yeah you do that programmatically anon.
Any advantage towards that end is in favor of scaling.

Really. Can you expect Microsoft to ever go in the right direction with things?
>>
>>57869325
>While OOP gui generally sucks and we need some proper systems for it.
>The advantages a OOP system has in terms of automatically generating a UI from a design tool is great.
What is it about WPF that you don't think it exactly as OOP as WinForms?

>Markup doesn't lend itself well to a mixed system where you do some of it programmatically and some of it programmatically.
Yes it does. It does perfectly.

>where you do some of it programmatically and some of it programmatically.
...
>>
>>57869386
>Yeah you do that programmatically anon.
WinForms scales automatically. It just looks like shit.
>>
File: .gif (6KB, 133x63px) Image search: [Google]
.gif
6KB, 133x63px
Is Object Pascal good to use if I don't want to use C++ but want OOP and stay close to bare metal?
>>
>>57869325
>Markup doesn't lend itself well to a mixed system where you do some of it programmatically and some of it programmatically.
wut

Also, the fact that you use a language designed for logic as descriptive markup in WinForm is a disadvantage, not an advantage.

XAML was built to describe UI, while C# was only repurposed for it in WinForms.

Your UI should have no logic, and the grid-based system of XAML combined with the other things I've mentioned make it a superior framework.

Either way, it's opinions and opinions, but I think your opinion is borne from stagnation.

When you use MVVM with XAML+C# or even XAML + Javascript, you end up with a very maintainable compartmentalized application that is actually made for the modern world, rather than something messy, limited, and only exists due to laziness in learning.
>>
Could an intellectually disabled person learn how to program?
>>
File: IMG_0730.jpg (50KB, 589x443px) Image search: [Google]
IMG_0730.jpg
50KB, 589x443px
So as an assignment i am going to code a garbage collector in C. Right now i'm trying to figure out a way to iterate over all pointers in the stack, anyone got an idea how this could be done?
>>
File: lexibelle3.jpg (28KB, 480x640px) Image search: [Google]
lexibelle3.jpg
28KB, 480x640px
are sagas a meme?
>>
>>57869434
Do you mean *a* stack or *the* stack as in stack memory. The first is trivial, the second is dangerous and probably impossible.
>>
>>57869432

Microsoft has a whole company built on mentally disabled software developers, you'll be fine.
>>
>>57869390
I wasn't making myself clear at all sorry. I had my I don't like OOP gui hat on.
I meant the object.verb representation of designed gui vs markup.
>where you do some of it..
Yeah I obviously mean you mix your approach.
>>
>>57869494
not literally though. please don't joke I'm trying to deduce this.
>>
>>57869434
that cannot be done without support from the runtime/compiler somehow. You can take an approach where anything that looks like a pointer is treated as one, but that's rather dangerous and leaky (I think go used to do this before it got a proper GC)
>>
>>57869432
Probably well enough to get a job yea.
I'm not sure it will be easy to have team interactions or keep the job. But I'm pretty sure they could do the basic tasks well enough.
>>
>>57869432
Probably not. I've seen enough people with above-average intelligence struggle to program. I can't imagine someone with an intellectual disability faring well.
>>
>>57869507
>I meant the object.verb representation of designed gui vs markup.
What is the difference between that and WPF? WinForms and WPF both do object.verb representation
>>
>>57869432
Depends on the degree of intellectual disability, of course.

That's like asking if a handicapped person can play basketball.

Depends on the handicap, and your definition of "playing basketball".
>>
>>57869486
I guess *the* stack, i need some way of checking pointers to implement a mark-sweep algorithm.
>>
>>57869411
Let pascal die for its obvious and objectively better successor.
>>
>>57869511

Okay, seriously now:

Any person that can string a chain of events (eg: peel potatoes, put in pot, add water, etc.) together should be able to program, it honestly isn't as difficult thing as people make it out to be, this hypothetical special needs person might not be as productive and might not be able to complete large projects, but they can do it for fun for sure.
>>
>>57869569
But C++ isn't successor of Pascal
>>
>>57869581
I wasn't talking about C++
>>
>>57869537
Because you can process your design output and easily insert the shit you want.
For instance you can make a class which your pre-processor handles and (just as a random example) duplicates within the element you're in to fill it up and makes a unified code path for all those different objects to respond through.

I'm not very good at explaining. Sorry if I fail.
I'm sure you can get the gist of it here though. You would have to jump through hoops to get the XAML to do the same thing.
>>
>>57869591
You wasn't talking about anything other though
>>
>>57869600

C you fucking nobhead
>>
>>57869434
Why would you implement it that way?

(Correct me if I'm wrong here, never implemented GC.)

Seems the right way would be to add to malloc, or add a wrapper around malloc, so that you also maintain a list of every single pointer to data on the heap. Then you will occasionally iterate over the list (add some kind of trigger) and call free for the data that is no longer referenced. (You will have to maintain a sort of graph.)

Traversing the stack seems wrong.
>>
>>57869598
>For instance you can make a class which your pre-processor handles and (just as a random example) duplicates within the element you're in to fill it up and makes a unified code path for all those different objects to respond through.
how is that any easier to do in WinForms than WPF? I don't even know why you would do something like that.

>You would have to jump through hoops to get the XAML to do the same thing.
uh... how do you figure that?
>>
>>57869411
If you're willing to accept the drawbacks with using object pascal

- no fast compiler (what's the point of being close to metal if you can't go fast?)
- no community
- no library ecosystem
- may not run (well) on all platforms you care about (e.g. ARM because the compiler can't target it (well) or ios/android because you can't access the relevant APIs to do stuff)
- etc

I mean, I've never actually used object pascal myself, but I bet most or all of these hold true.
>>
>>57869600
Ada is the unofficial pascal++
>>
>>57869556
I think a better way is to store pointers in a global data structure as they are created. Maybe you can find a way of overriding the definition of malloc.
>>
If I do this:

template <typename T>
void whatever(const T& arg) {
//do stuff
}

int somefunction(char);

whatever(somefunction);

What's the type of T? Reference to function pointer?
>>
>>57869613
You are indeed right in that we need the maintain a list of all the pointers to the heap. We do need some way of determining if a pointer is no longer references though.
>>
>>57869631
>I don't know why
Well. I thought for sure you'd understand a circumstance based UI decision to be preferably on the programmatic end.
>how do you figure that
I don't quite see how to do the same thing through WPF without moving from the XAML to C# first, doing the transformation and then moving back.

You could of course have this construct within your program and have an initialization step where you have to figure out what the UI is like at that moment and fix it but in my experience it's easier to do it before that stage.

But I could be wrong.
>>
>>57869648
Function pointer yes.
The type of arg is a const function pointer reference.
>>
File: 1386290036806.png (263KB, 800x720px) Image search: [Google]
1386290036806.png
263KB, 800x720px
Can anyone recommend any good DirectX 11 books?
>>
>>57869710
Sorry to ask I don't mean to be offensive.
But what is the reason to use directx? I hear most nvidia and amd drivers are more opengl suitable.
It seems odd to choose the platform locked version. So there must be good reason behind it but I don't see it.
>>
>>57869662
that is exceedingly difficult tho, because you can throw pointers around on the stack as you please, and increment/decrement them so that they point into the middle of some buffer. So how will you know if something is a pointer anymore when it got incremented and is not pointing to the start of one of your allocations anymore? It could just be some random integer. check out the boehm gc.

you can keep track of the ranges of all your allocated regions and then if there is anything looking like an integer/pointer on the stack that points inside one of those regions, you keep the region around, otherwise you GC it. But this is very leaky (on 32 bit, where your address space is not that big and many integers will coincidentally point into your regions -- not so much of an issue on 64 bit systems)
>>
>>57869685
I'm having a lot of trouble trying to figure out exactly what the fuck you're talking about, but you can certainly lay the bare bones of a control out in XAML and then do all sorts of programmatic modification and population of the control when instantiated/when the program is started.

Frankly, after using both for a long time, I cannot thing of one single advantage of WinForms in performance, programmability, or maintainability.

The only advantage WinForms has is that there is an implementation that runs on Linux machines and Windows 98, so there's some edge-case compatibility.
>>
>>57869742
Direct X is at 12 and Open GL is like 4.something or 5, so that means DierectuX is like more than twice as powerful...
>>
Writing a recursive sort algorithm that takes an abstract class as an argument
How would I init a new variable of whatever type the argument is in pajeet (java)?
>>
>>57869780
Oh. I should switch then.
Why isn't macs switching? Fucking newbs.
>>
>>57869744
The problem of ambiguous pointers is something we have to deal with, which is why we use the bartlett method of garbage collection.
>>
>>57869780

I think you take your VRAM and divide that by the API number to get the speed, so for me

8/12 = .6
8/4.5 = 1.7

and for Vulcan

8/0.inf = nan

IDK what it's sayin bout my nan, but OGL seems to be faster
>>
What should I use instead of object.__dict__ in Python? I read somewhere it's not good to use methods and values bothsided with underscores.
>>
>>57869819
never heard of it, godspeed I guess.
>>
>>57869869
>What should I use instead

A real programming language 'll probably suit you best.
>>
>>57869884
it's my work, unfortunately
>>
>>57866426
>Perl v5.24.0 required


DROPPPED
>>
>>57869742
No real reason other than personal preference. I plan on learning both eventually anyways.
>>
>>57869900

Then you'll probably get paid more flipping patties
>>
>>57869909
So why start with dx?
>>
>>57869869
Why would you have to access that directly?
>>
>>57869925
What do you even mean by this?

I can't stand Python, but it is a relatively high-paid language with plenty of job opportunities.
>>
>>57869909
Shouldn't you be starting with the new APIs on DX12?
>>
File: 168.png (77KB, 259x345px) Image search: [Google]
168.png
77KB, 259x345px
>>57869884
please no bully snakescript
>>
>>57869940
I actually started with 9.0c

>>57869927
The personal preference thing.
>>
File: WVW69j3M-XkEIx3ASN.jpg (205KB, 400x240px) Image search: [Google]
WVW69j3M-XkEIx3ASN.jpg
205KB, 400x240px
I got working a SNES Mode7 algorithm. Same thing i posted yesterday, but now with pic related.

The logic is basically project 3D to 2D (x/z and y/z), grab the color of a certain pixel of a 2D map given the previous calculation, then display that color on screen.

Max_X= //Get width of the screen;
Max_Y= //Get height of the screen;

HORIZON=90;
FOV=300;

While(TRUE)
{
for (X=0; X < Max_X; X++)
for (Y=0; Y < Max_Y; Y++)
{
PX=X;
PY=FOV;
PZ=Y/HORIZON;

SX=PX/PZ;
SY=PY/PZ;

//Grab the color of a pixel
COLOR= //GrabColor(SX,SY);

//Display the color on screen

//PlaceColor(X,Y,COLOR);
}
}


Not optimized BTW.
>>
>>57869959
>preference
Ah ok. I was thinking you decided to start with Dx. If you just happened upon it I get it.
>>
>>57867956
They're only called methods in Java because Java is dumb and is OOP only
You can't write freestanding functions at all
>>
>>57869932
I need to get a list of subobjects called ebin4, ebin7, ebin11 and so on.
I don't know how to get a list of methods to work with, and those ebin subobjects, considering they can differ in every iteration.
Kinda like that.
>>
>>57869609
C was created independently from Pascal, wasn't it?
>>
>>57870070
>You can't write freestanding functions at all
lmao
what a piece of shit
>>
private static <T extends Comparable<T>> void sort(ListIterableInterface<T> list){
if(list.size() == 0){
return;
}
T pivot = list.removeFirst();
//new list of type list.getClass() for left
//new list of type list.getClass() for right

How do I do that commented bit? I've got this all laid out but this is the part that's fucking me over
>>
Is Java worth learning? I breezed through my C assignments and then I've hit a wall on my Java assignment. I thought the transition wouldn't be that bad, but it was. The stricter compiler and all these libraries to learn are putting me off the language for good. I am a lazy shit though, so C suits the way I work. Sorry for blogposting.
>>
>>57870180
>I am a lazy shit though, so C suits the way I work
You probably write horrendously bad C code.
Also yes, Java and C# are the bread and butter of the industry, so get used to them (C# is way more pleasant to use imo)
>>
>>57870125
you actually can tho? They have to be inside a class, true, but just think of the class as being a namespace.
>>
>>57870180
>The stricter compiler and all these libraries to learn are putting me off the language for good.
That'll come with any higher level language, however Java kinda sucks due to it being OOP only.
>>
What is the best C tutorial?
The best book would be K&R, right?
>>
>>57870256
I'd recommend C Programming: A Modern Approach instead
K&R is only good if you're already somewhat familiar with programming
>>
So I was playing the Regexp matching game in uni today.
Then I decided that the completely random examples are too easy and the number of supplied examples is too small. The solution: a backwards regexp generator. Input a regular expression, output a random string matching that expression.
So if you want the user to, say, match all valid times between 00:00:00 and 23:59:59, you'll start your generator with the expression
\d\d:\d\d:\d\d
which will result in valid time codes, but also nonsensical ones like 30:91:99. Generate a couple, manually annotate which ones are actual times and which ones aren't, then give that to the user and have him write a regexp that only matches valid examples.
Implementing a regexp parser is a little more more work than I thought thanks to recursion being an option.

So I got sidetracked and and just came up with tasks on my own without a random generator.
Turns out it's surprisingly difficult to write a (Perl style) regexp that matches all valid dates between 0000-01-01 and 9999-12-31, but excluding:
> February 30th / 31st
> April / June / September / November 31st
> February 29th in all years not divisible by 4
> February 29th in all years divisible by 100 (1900, 2000 etc)

My best attempt was 265 characters. Behold:
\d{2}((00|[02468][1-35-79]|[13579][013-57-9])-(02-(0[1-9]|1\d|2[0-8])|(0[469]|11)-(0[1-9]|[12]\d|30)|(0[13578]|1[02])-(0[1-9]|[12]\d|3[01]))|(0[48]|[2468][048]|[13579][26])-(02-(0[1-9]|[12]\d)|(0[469]|11)-(0[1-9]|[12]\d|30)|(0[13578]|1[02])-(0[1-9]|[12]\d|3[01])))
>>
>>57870274
I'll check it out then.
And what's the best non-book tutorial?
>>
>>57870313
>non-book tutorial?
Programming something.
>>
>>57870210
They all take a this pointer (equivalent).
Which ideally gets compiled away if you don't use it. But likely not.
>>
>>57870293
>excluding
Can't you just have a check for those particular dates and 'break' the regex past that?
>>
>>57870416
I don't know, can you? I'm pretty new to this.
>>
template<typename T>
T average(T a,T b)
{
return a/2 + b/2 + (a%2 & b%2);
}

Find a flaw.
>>
>>57870439
average("str1", "str2");
>>
>>57870467
destroyed
>>
>>57870467
Wouldn't even compile. Ain't my fault that the nigger coding after me can't check types himself
>>
>>57870393
I haven't done java in forever, but I think if you declare a method static, there won't be a this pointer available in it.
>>
>>57870429
he's saying you should parse the list after the regex runs instead by using your typical calendar methods.
>>
>>57870497
>Poor quality coder is also a le edgy racist
>>
>>57870538
But that's no fun. The challenge was to do it with a single regexp.
>>
>>57870429
I looked it up.
Non-consuming lookahead and and.
i.e
(?!casewedontwant)|(casewedowant)
We can obviously have negative cases chained. If any fail it doesn't match.
>>57870538
No I'm not smart.
>>57870558
As far as fun goes. My idea here is pretty lame too.
>>
File: 1478189357765.png (16KB, 651x316px) Image search: [Google]
1478189357765.png
16KB, 651x316px
>>57870555
CIA niggers need to go away

The compiler error messages are obvious. Anyone who doesn't understand the error messages need to leave
>>
File: chillin.webm (319KB, 1300x744px) Image search: [Google]
chillin.webm
319KB, 1300x744px
>>57866411
finished up my editor for now. going to try to hook this little guy up to a neural net
>>
File: .jpg (47KB, 637x579px) Image search: [Google]
.jpg
47KB, 637x579px
How about this next /dpt/ OP image?
>>
>>57870497
>hasn't defined operator slash and modulus for strings
It's like you don't even program C++.
>>57870587
I like it. I learned from this book.
>>
>>57870555
wut

Using "nigger" as a casual insult is an age-old 4chan pastime.

>>57870587
I like it.
>>
>>57870582
Nice, you implemented joints.

Where should I start learning box2d if i have a very slight familiarity with ideas like broadphase and narrow phase but don't really know how physics is done in computers at all?
>>
>>57870497
Don't know if C++ has anything like this, but it's p. cool
https://dlang.org/spec/template.html#template_constraints
>>
>>57870179
iterate through the list and add everything less than pivot to the left list and everything greater than or equal to pivot to the right list.

I'm guessing you're doing quicksort
>>
>>57870587
I don't get it.
>>
>>57866629
Try writing embedded software for an ATmega chip, you can just use an Arduino without all the Arduino libraries.
You will learn a lot about low level programming by doing this.
>>
>>57870661
Yes, and the algorithm isn't the problem
The problem is I can't create a left list and a right list.
I'm only being passed the interface type of the list, so I can't call new ListIterableInterface()
>>
>>57870676
isn't it like
ListIterableInterface<t> left = new list.getClass();

or something.
>>
>>57870625
>Where should I start learning box2d
iforce2d.net is pretty good for reference, just look up some tutorials. and here's the official manual http://box2d.org/manual.pdf

if you just want to learn to use box2d, copy off some other people's programs and read some tutorials on iforce

>broadphase and narrow phase but don't really know how physics is done in computers at all?
i looked into it a bit, while there is some tough math involved it isn't the hardest part to understand how they work. there are many tutorials on how to write your own physics engine. the hard part is handling all the edge cases and being super optimized, tried & tested as box2d has. just not worth it to write and use your own physics engine when box2d is open source under the zlib license
>>
>>57870643
Constantly checking with each function call is going to slow down the function.

There is a way to do it, but it's way too long to remember
template<typename T, class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
int foo(T a)
{
return a * 2
}
>>
>>57870700
Tried that, gave me
Required: ListIterableInterface <T>
Found: java.lang.Class <capture<? extends ListIterableInterface>>
>>
>>57870643
>>57870721
Wait. No float modulus in C++
template<typename T, class = typename std::enable_if<std::is_integral<T>::value>::type>
>>
>>57870747
some reading I came upon this
https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#newInstance--
>>
>>57870721
std::enable_if<std::is_arithmetic<T>::value>::type>

Pretty gross senpai
>>
>>57870758
in haskell this is just
Integral t =>
>>
>>57870781
In Haskell this
module Main (main) where

main = putStrLn "Hello, World!"

is 2 megabytes
>>
thread theme we run it now

https://www.youtube.com/watch?v=bZrffnZgM2o
>>
>>57870812
bigger filesize is better
>>
how do I static link dll in c#?
>>
File: 1479769685282.png (75KB, 500x255px) Image search: [Google]
1479769685282.png
75KB, 500x255px
>>57870765
Does the trick.
Neat. Time to turn this sort method into the usual disgusting java mess of method chains and exception handling
>>
>>57870837
why don't you google it faggot??
>>
>>57870555
Fresh off the boat, from reddit, kid? heh I remember when I was just like you. Braindead. Lemme give you a tip so you can make it in this cyber sanctuary: never make jokes like that. You got no reputation here, you got no name, you got jackshit here. It's survival of the fittest and you ain't gonna survive long on 4chan by saying stupid jokes that your little hugbox cuntsucking reddit friends would upboat. None of that here. You don't upboat. You don't downboat. This ain't reddit, kid. This is 4chan. We have REAL intellectual discussion, something I don't think you're all that familiar with. You don't like it, you can hit the bricks on over to imgur, you daily show watching son of a bitch. I hope you don't tho. I hope you stay here and learn our ways. Things are different here, unlike any other place that the light of internet pop culture reaches. You can be anything here. Me ? heh, I'm a judge.. this place.... this place has a lot to offer... heh you'll see, kid . . . that is if you can handle it...
>>
Methods for baking animation clips in textures and the shadercode play them back using vertex offsets for lower LOD animations on characters, plants, etc in Unity and CG
>>
clang -Weverything -Werror -fsanitize=address

Prove me wrong.
>>
>>57870859
>clang
>>
File: haskell.png (203KB, 716x716px) Image search: [Google]
haskell.png
203KB, 716x716px
>>57870781
In the production world, haskell is just
>>
/dpt/ am I making a huge mistake by using a template cover letter for every job application and going in bulk, or should I only send out a few applications but personalize each one?

I feel like I do better when I have a chance to show off my wit, but I can't be sure
>>
File: relativists btfo.png (5KB, 470x102px) Image search: [Google]
relativists btfo.png
5KB, 470x102px
>>57870885
You're right.
Haskell is just.
>>
>>57870859
No C++14? No optimizations? No debug symbols? And -Weverything has some silly warnings, such as warnings for breaking C++98 compatibility.
>>
>>57870889
i wrote webrobot to apply to jobs so you should just make him to where he can scrape hte content then feed inteh desired rresume/cover letter.
>>
File: 1480969119606.png (56KB, 419x248px) Image search: [Google]
1480969119606.png
56KB, 419x248px
>>57870906
>iff
>>
>>57870920
Yes, iff, as in "if and only if".
>>
>>57870841
why are you implying I didn't?
>>
>>57870925
You're meme
>>
In C++, is there a way to make a derived virtual function always call the base version? I know I can do it manually by adding
 base::method(); 
in the derived version, but can this be made automatic?
>>
File: coqawaii.png (276KB, 650x600px) Image search: [Google]
coqawaii.png
276KB, 650x600px
>>57870920
>>57870934

but i appreciate the anime reaction image
>>
>>57870941
Don't let yourself too easily fooled anon.
>>
>>57870919
already applied to  [email protected]

already applied to [email protected]

already applied to [email protected]

already applied to [email protected]

already applied to [email protected]

already applied to [email protected]

already applied to [email protected]

already applied to [email protected]



good little robot nigger
>>
>>57870935
>but can this be made automatic?
No, that's how virtual works.
>>
>>57870935
I think (but I don't do OOP, but I used to) when you inherit from a class you inherit all the functions. If you don't overload it just calls the base class.
I'm not sure you can go to the grandparent automatically though.
>>
>>57870919
Have you gotten any actual job offers or even an interview?
>>
>>57870925
"if and only if" should be iif, nerdtron
>>
>>57870910
clang -std=c11 -Weverything -Werror -fsanitize=address -g
>>
>>57871000
ya for what i'm applying for but i'm not cs. i'm applying to like entry level shit and teaching myself cs onteh side.

i'd stil refine the bot to mass apply to specified programming jobs and then the parameter specifications just have acover letter/resume designed to apply to that job for me i hate actually manually pappying.
>>
>>57870919
I did this for (state owned) apartments when I was gonna do my degree. They had a first come first serve policy so I just wrote a crawler that looked at the postings page and signed up the one I wanted based on the metrics I chose.

Pretty awesome how much you can beat certain systems.
I got first pick on 6 of the best available. Ended up 50m from my university and got fat and lazy. Later quit because I didn't have that much to learn from them I realised (watched senior lectures etc).
Huge waste of time, university, don't bother.
>>
>>57871048
...and now using any C11 feature will prevent your program from compiling.
>>
>>57871036
Well, it isn't.
https://en.wikipedia.org/wiki/If_and_only_if#Origin_of_iff
>>
>>57871081
care to explain? It works fine for me
>>
File: 1478644195064.jpg (395KB, 1154x1500px) Image search: [Google]
1478644195064.jpg
395KB, 1154x1500px
>too smart for git
I want to contribute to a project but cant figure out how to create pull requests? the whole git-shit is just a clusterfuck full of made up words to look smart.
>>
>>57871174
There's a button. Press it and it tells you how.
>>
Beginner here, in C, what's the easiest way to pass the i counter in a for loop as a char to a function?
>>
>>57871174
do you lack basic reading comprehension skills or are you just autistic?
>>
>>57871207
the same way you'd pass anything else?
>>
Almost at bump limit. New thread.

>>57871217
>>
>>57871174
pull requests aren't part of git, it's some made up thing that makes git merge between different repos easier over github.

Read the instructions, it's so simple a literal retard could pull it off.
>>
>>57871224
Damnit, i was about to post one.
>>
>>57871231
uhh. does it matter who posts it
>>
>>57871207
void f(char i) {
// ...
}

// ...

for (i = 0; i < end; ++i) {
f(i);
}
>>
>>57871207
void passto(char a)
{
// do something with a
}
for(int i = 0; i < 100;i++)
passto(char(i));
>>
>>57871225
that's the problem. it's made for retards like webdevs and javascript user. I cant go that low.
>>
>>57871240
>>57871218
Oh, I assumed I'd get an error. Thanks
>>
>>57871256
this conversation can serve no further purpose
>>
File: 1477825178477.png (785KB, 524x753px) Image search: [Google]
1477825178477.png
785KB, 524x753px
>>57871264
did I hit a nerve?
>>
>>57871236
Yes. For some of us, it's the highlight of our day :(
>>
>>57871260
You probably mean you want to convert the integer to characters right?
>>
>>57871260
you'll only get an error with >>57871252 because they don't know how to cast in C
(char) i

but you won't get an error if you leave out the cast, C is not strongly typed.
>>
>>57871280
Yeah.
>>
>>57871174
>>57871256
This makes you look really stupid.
>>
>>57871287
a cast between char() and (char) is different?
i didn't know.
>>
File: 1476457397818.jpg (17KB, 233x217px) Image search: [Google]
1476457397818.jpg
17KB, 233x217px
>>57871298
-t webdev
>>
>>57871308
char(i) isn't the syntax for casting at all, you are thinking of another language
>>
>>57871310
>t. literal retard
>>
>>57871333
Oh, I'm mixing up constructors in c++ with casting.
>>
>>57871289
https://en.m.wikibooks.org/wiki/C_Programming/C_Reference/stdlib.h/itoa
Just passing the integer like they suggest will give you the value of the integer as a char. So for instance 48 would give you a '0'.
But itoa or other similar functions produce an array of characters based on the integer. So 0 would become '0'. 23 would become '2','3'.
Which is more what you want.
>>
get in the new thread
>>57871217
>>57871217
>>57871217
>>
>>57871260
why not

for (char c = ...; ..; ...)
>>
File: 56884511_p0.png (981KB, 918x1302px) Image search: [Google]
56884511_p0.png
981KB, 918x1302px
I just found a cool maki fanart. I don't have anything relevant to say but I'll ask a stupid question and maki lovers will provide me thoroughly insightful answers.

What's the point of programming when you're not the best?
>>
>>57871289
>>57871349
And just so you know
>>57871363
Doesn't really do that either.
>>
/dpt/ am I making a huge mistake by using a template cover letter for every job application and going in bulk, or should I only send out a few applications but personalize each one?

I feel like I do better when I have a chance to show off my wit, but I can't be sure

>>57870965
good idea using it on craigslist. I don't think it would work on any other job site
>>
>>57871373
>tfw my bait failed and everyone left in the new thread
>tfw captcha images are now pizza
>>
Just finished reworking to handle multiple clients on Android, moved it to asynctask, and it's more efficient. Going to work on root checker in my Android rat.
>>
>>57871445
>bait
How so? It's an interesting question when posted with that 3 dick-hole structure we call maki
>>
>>57871363
sounds more like they want to iterate over integers and print out the string representation of those integers

but if you want to iterate over characters this is fine
#include <stdio.h>
#include <string.h>

int main(void)
{
char freq[256];

char c;

memset(freq, 0, 256);

while ((c = getchar()) != '\n') {
++freq[c];
}

for (c = 'a'; c <= 'z'; ++c) {
if (freq[c] > 0) {
printf("You entered the letter %c %d times.\n", c, freq[c]);
}
}

return 0;
}
>>
>>57871445
You're being responded to in the new thread, anon.
>>
I don't get how classes work.
how do you make a class for something like this in java? christ self-teaching is shit

public class FractionClient
{
public static void main( String [] args )
{
Fraction r1 = new Fraction( 2, 3 );
Fraction r2 = new Fraction( 5, 7 );

System.out.println( "The numerator of fraction #1 is " + r1.getNumerator( ) );
System.out.println( "The denominator of fraction #1 is " + r1.getDenominator( ) );

System.out.println( "\nFraction #2 is " + r2.toString( ) + "\n" );

if ( r1.equals( r2 ) )
System.out.println( "Original fraction #1 and #2 are identical" );
else
System.out.println( "Original fraction #1 and #2 are different" );

r2.setNumerator( 2 );
System.out.println( "\nSetting denominator of fraction #2 to 0\n" );
r2.setDenominator( 0 );
System.out.println( "\nSetting denominator of fraction #2 to 3\n" );
r2.setDenominator( 3 );

if ( r1.equals( r2 ) )
System.out.println( "Original fraction #1 and modified fraction #2 are identical" );
else
System.out.println( "Original fraction #1 and modified fraction #2 are different" );

}
}
>>
>>57871748
a class embodies functions specific to it, if your program is small you don't need multiple classes
>>
>>57871748
Post in the new thread. This is dead.
>>
>>57872165
My P70 runs incredibly quiet, so I don't know.
>>
>>57870721
Wow, so instead of getting multiples errors about a failed substitution, you now get multiples errors about another kind of failed substitution!
Thread posts: 345
Thread images: 35


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.