[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: big__Black-Lagoon-Review-04.jpg (56 KB, 800x450) Image search: [Google]
big__Black-Lagoon-Review-04.jpg
56 KB, 800x450
old thread >>54079710

What are you working on /g/?
>>
Any sed magicians here?

How would I go about replacing "::" with a new line?
>>
>they don't realise I've been namefagging as Anonymous all day long
>>
>>54089272
>not being called a faggot every time I do something retarded somehow implies that others approve what I did
>>
>>54089330
Who are you quoting?
>>
>>54089362
I'm quoting (You)
>>
>>54089267
what language?
>>
>>54089267
s/::/\n/g
Or something along the lines of that. Might have to escape some characters, who knows.
>>
>>54089437
Well i'm working with sed so I'm not sure what you mean

I'm writing a quick bash script
>>
File: MIS.png (314 KB, 798x510) Image search: [Google]
MIS.png
314 KB, 798x510
Working on my path tracer. Got Multiple Importance Sampling working today (pic related. MIS reduces the variance for points close to a light source introduced, which was introduced by next event estimation, since that doesn't take into account the light encountered in a random walk for diffuse materials).
Also implemented a quick tone mapping algorithm so my HDR environment maps give something presentable.

Next up is coming up with a decent stratification scheme to further reduce variance.
>>
>>54089247
Not sure if this is the place to post this, but I'm working on some hacking techniques for a class. We're supposed to hack a class-prepared website. I've tried sql injection, cross site scripting, and remote file inclusion, but neither of these seem to work (remote file inclusion isn't working because there isn't anywhere in the POST request where I could put it). Does anyone have any ideas on what else I could try?
>>
Fucking hell, C++ really needs some bloody async
>>
>>54089663
Pay someone with a bot-net to DDOS the ever loving shit out of it.
>>
>>54082096
Yep, not even 6 months ago, the threads would reach bump limit in 7 hours.

Considering the current post rate, this one will take 10-12 hours.
>>
>>54089485
i'd like to see some sort of hybrid rasterizer/path tracer, where the scene is initially drawn with a quick rasterization pass, then additional passes are added with the path tracer.

as it is now, with a pure path tracing engine, any movement causes all this fucking noise.
>>
>>54082096
>>54089763
Everyone left when we became populated with faggots. 6 months ago, nobody would have fucking thought of talking about web dev in here, or suggesting that Java might be so much as mediocre, let alone good, or supporting dynamically typed languages like Javascript or Python
>>
>>54089742
lel unfortunately DDoS is not one of the allowed approaches
>>
>>54089791

But where did they leave ?
Is it also because of the OP image ? I think there's a correlation between the OP image and the posting rate.

>nobody would have fucking thought of talking about web dev in here

I guess that's also why there's not the web dev general from a few months ago: it was merged with this one.
>>
I want to create an IRC client in C++, what are some good frameworks I should look at for the UI?
>>
>>54089840
No, it's got literally nothing to do with the OP image. People complain all the fucking time, but it doesn't affect the thread at all.
>>
>>54089842
ncurses
Qt
>>
>>54089842
Qt
>>
>>54089686
u wat

http://en.cppreference.com/w/cpp/thread/async
>>
>>54089766
Not to mention that it's pretty slow. Although when you implement good and fast acceleration structures on the cpu while doing rendering on the gpu you can get something quite interactive. With a lot of noise still, yes, but I expect real time path tracing to be realistic within the near future.
>>
>>54089932
I mean async with coroutines and keywords
>>
File: Unbenannt.png (23 KB, 866x690) Image search: [Google]
Unbenannt.png
23 KB, 866x690
n-body simulation in python w numpy and matplotlib

http://pastebin.com/Hrcv85gt

(it's a hack, but works)
>>
What does an AST for a type/struct deceleration typically look like?
>>
>>54090066
https://www.google.co.uk/images?q=AST+type+declaration
>>
File: 1460362735531.jpg (118 KB, 499x389) Image search: [Google]
1460362735531.jpg
118 KB, 499x389
/dpt/ I have a micro optimization question. I see conflicting reports on the performance of int32 and int64 on x86 and x64 systems, some people say an int32 will work best on both, some say the int32 will be slower. Regardless of those 2 types though I'm wondering about even smaller ones, would using an int8 or int16 be worse than using the native int type?

I am sending data over a network and figured using the smallest possible type for my needs would be best so I'm stuck with it regardless but I want to know for future reference if it actually makes a difference. I figured a smaller type than the native would be fine, only bigger would be problematic but I don't actually know.
>>
>>54090106
Unless I'm missing something, none of those show what I'm asking for.
>>
>>54089840
It's true.
I only post in here when the OP pic is hime.
>>
Hi dpt, should I pick up a book on Lisp/Scheme to go along with reading SICP?
>>
File: 2016-04-18_00h05m21s.png (17 KB, 494x175) Image search: [Google]
2016-04-18_00h05m21s.png
17 KB, 494x175
Is there some XOR predicate-wise in prolog?
The if-statement looks really ugly, since the 'else' clause is just a repeat of the conditional, but I assume prolog needs it to ensure determinism in unifying X.
Otherwise i would simply have written
(fizzy(N,X) -> true; atom_number(X,N))

instead.
Might seem like a trivial problem, even though I deem myself fairly advanced in Prolog.
>>
>>54090266
Are you doing any computing using the int or simply sending it over the internet?
>>
>>54090570
In this specific case it's just a handle which gets used as an index later, the only computation done on it is -1 and +1 to shift it to/from 0 base index to 1 base. I have it as a uint8 because there should never be that many at one time (it's limited to below the max range elsewhere). I'm trying to make the data passed around as small as possible.

I'm wondering in the general case though, if there was a lot of computation on it then would it make more sense to just use int for performance over size?
>>
VS 2015 i thought Crystal Reports were included? DId i fuck up somehow?
>>
>>54090711
In the general case I would always go for the default integer, cause that's what other developers expect. Choosing size of int is more of a concern when you are vectorizing your code which shouldn't be related to the size of int you are sending over the internet.

You mentioned that you want data that is passed around as small as possible, have you looked into how the packets are defragmented and that stuff?
>>
>>54090822
Got it, thanks for the input.

>have you looked into how the packets are defragmented and that stuff?
Not yet, currently I'm letting something else manage the packets and socket while I work out the protocol, data types, dispatching, and procedures. I plan on looking at the lower end of things once everything else works well.

This is my first time doing anything over the internet so I'm pretty clueless to be honest, everything is working but I'm curious if I'm doing something egregious somewhere. I feel like it's important to do my first network program as correct as possible so I can look back on it later as a reference of what to and what not to do.
>>
>>54090925
>I feel like it's important to do my first network program as correct as possible so I can look back on it later as a reference of what to and what not to do.

Haven't we all? But yet again months later we look back and realize what kind of shitty code we wrote.
I do that a lot atleast, with Haskell nowadays.

Focus on a structured protocol, error handling and in the case of unordered messages and the pure structure of the program. Try not to tie your code down to the sockets themself, use Object-serializing classes (proxy design pattern) as a middle man between your models and the protocol-classes.
>>
Newbie here, I'm working on a simple python script which sends arbitrary stuff between Twitter and IRC. Right now I've got the Twitter bot working separately from the IRC bot, but I'm not sure how to combine the two.

stream_listener = CustomStreamListener()
stream = tweepy.Stream(auth, stream_listener)
stream.userstream()


ircbot = IRCBot("#somechannel", rand_name(), "irc.freenode.net")
ircbot.start()


These two code snippets work independently from one another, but they block one another I just run them as-is. Can anyone tell me how to combine both and run them together as a module (or whatever)?
>>
>>54091019
If these calls are blocking then start them in separate threads?
>>
>>54091035
I don't know what I'm doing and I'm essentially just googling around
This is what I started implementing before I saw your reply:
http://stackoverflow.com/questions/7207309/python-how-can-i-run-python-functions-in-parallel

am I on the right track?
>>
>>54090999
Thanks for the advice. Everything was pretty simple up until the error handling part, it's not very complicated but it sure is a lot of handling just to abort things in a more granular manner.

Constantly slimming things down and reworking it to be more general is kind of fun but takes some thinking and time.
>>
What's /dpt/'s shitty opinion on Visual Studio Code?
>>
>>54091048
Yes that would work.
>>
     document.getElementById('RP').innerHTML = 'Hello World!'; </script>


Rate my code.
>>
>>54091081
I kinda like it as it's quite nice OOTB but the lack of tabs and split tab groups makes it a no-no for me, so until they implement that, I'm not taking it for a full spin to form an opinion on it.
>>
>>54091083
thanks, doesn't seem to work, though
any tips?

def run_parallel(*fns):
proc = []
for fn in fns:
p = Process(target=fn)
p.start()
proc.append(p)
for p in proc:
p.join()

#need to have people @mention me or some shit and message them upon receipt, that's the only way to avoid stupid DM bullshit

stream_listener = CustomStreamListener()
stream = tweepy.Stream(auth, stream_listener)
#stream.userstream()

ircbot = IRCBot("#test", rand_name(), "irc.freenode.net")
#ircbot.start()

run_parallel(stream.userstream(), ircbot.start())
>>
>>54091113
You're supposed to pass the functions to the run_parallel function, not call them and pass the return value (which won't "arrive" since they block).

So try that instead:
run_parallel(stream.userstream, ircbot.start)


Although I don't know if you can do that like that with object instances, if that doesn't work, try to look for whatever is Python's alternative to C++'s std::bind.
>>
>>54091139
>You're supposed to pass the functions to the run_parallel function, not call them and pass the return value (which won't "arrive" since they block).
>
>So try that instead:
Woops, yeah, I realized that immediately after I posted. It doesn't work with object instances (fug)

>try to look for whatever is Python's alternative to C++'s std::bind.

will do
>>
>>54090514
bump. No other Prologers in town?
>>
who /erlang/
>>
any of you interested in game dev?
>>
>>54091139
>>54091163
Still sort of clueless here--anyone happen to know what the simplest way to get this to work is?
>>
>>54091445
Make sure to check /agdg/ on /v/, /vg/, 8ch, etc. if you're interested. Not saying to get out, just letting you know.
>>
>>54091445
I do/teach myself gamedev as a hobby.
>>
>>54091445
only retro themed pixelart procedurally generated instant permadeath metroidvania roguelikes with "8-bit" in the name even if it isn't anything like an 8-bit game
>>
>>54091479
/agdg/ is /vg/. do you go there too?

>>54091489
it's good practise for application

>>54091495
are you the haskell dev
>>
>>54091532
i only program in real men's languages such as C, FORTRAN and assemnbly
>>
>>54091532
>/agdg/ is /vg/. do you go there too?
Not yet, I need to up my game before I can make any. I lurk occasionally and learn a few things, I'm real interested in seeing everyone elses work though, it's really motivating.
>they did it
>I could do that
>>
>>54091532
Yeah indeed a really good practice since I'm a self taught programmer
>>
File: taylor-ln.png (20 KB, 400x400) Image search: [Google]
taylor-ln.png
20 KB, 400x400
I saw a post the other day about graphing Taylor series approximations of functions, so I thought I'd do that myself. It was pretty fun.
>>
File: glossy.png (936 KB, 797x508) Image search: [Google]
glossy.png
936 KB, 797x508
Implemented a brdf for glossy materials, neat.
I should implement a microfacet brdf actually, that would be much more versatile.
>>
>>54091674
>1.27 fps
>>
>>54091574
>taylor series
>fun
fkn nerd
>>
>>54091674
Robustness_issues.png
>>
>>54091685
It's a monte carlo path tracer, of course it's slow.
Could be improved by using a better acceleration structure for ray/scene intersection though. My current BVH isn't that high quality (simple binned BVH with SAH heuristic). By far most of the time is spent traversing it, so that's where most of the gains are.

And yes, there is noise, I only let it render for a couple of minutes. Eventually it should converge to a photo-realistic image. I still have to implement stratification, which will increase convergence further.
>>
>>54090367

Iirc the sicp intro said lisp is intuitive enough that you don't need to separately learn it. Also they teach you the basics in the first few chapters
>>
>>54089983
Cute. If I were you I'd pre-allocate the done and e_pot arrays instead of using append. You're already using enumerate so append isn't really clearer than just accessing the nth element, not to mention that it's wasteful. Also I don't really get the changing the axis parameters all the time. I mean, it only tracks two of them either way (in the default example the most boring ones) so it doesn't really make sense to waste cycles on it imo. I liked the animation.
>>
>>54091476
Import threads and use threads.start_new_thread or whatever it is, threads are super easy but you might have to add a trope to your functions
>>
File: taylor-sin.png (24 KB, 400x400) Image search: [Google]
taylor-sin.png
24 KB, 400x400
>>54091574
>>54091695
It's magic!
>>
>>54092128
do a taylor series for sign(x)
>>
>>54090367
I was kind of turned off by all the math involved with SICP. If you're not a mathy person, pick up The Scheme Programming Language by Kent Dybvig.
>>
>>54089247
What does this picture have to do with programming? Please use a relevant OP when making a thread.
>>
File: lol i trold u xd.jpg (15 KB, 325x184) Image search: [Google]
lol i trold u xd.jpg
15 KB, 325x184
>>54092446
>anime
>not related to programming
>>
File: ctards will defend this.png (2 MB, 1920x1080) Image search: [Google]
ctards will defend this.png
2 MB, 1920x1080
c v. haskell
>>
>>54092576
Performance?
>>
>>54092601
everything on the haskell is optimized such that it uses O(1) space and at worst O(n) time (quicksort and reverse)
>>
>>54092624
Performance?
>>
File: utter bollocks.png (392 KB, 832x832) Image search: [Google]
utter bollocks.png
392 KB, 832x832
>>54092624
jesus christ that's the most fucking ridiculous thing I've heard all day
>>
>>54092644
Performance?
>>54092656
not all Haskell code, cuck
This code specifically
Also, I'm not a lefty
>>
>>54092677
What's the actual performance?
>>
sleep(3000000);
printf("%s", "Hello World!");

>muh time complexity

printf("%s", "Hello World");
>>
>>54092698
its a bait image I made a while ago, so I don't have the files anymore
But I'd say they're all pretty quick, except maybe quicksort for very large inputs
>>
File: spoonge.jpg (44 KB, 639x628) Image search: [Google]
spoonge.jpg
44 KB, 639x628
>>54092677
you're incredible anon
>>
>>54092733
I bet you the C versions are faster
>>
>>54090266
nice loli senpai
>>
Some java assignment for uni, got to draw different shape objects falling in a window.
>>
>>54092624
worst case better than n logn, if that were the case we'd all be using haskell.
>>
My final project for a software design class is to make a board game, and we're doing Risk. However, I'm pretty much clueless on how to get the front-end GUI stuff working, other than a bunch of shitty buttons all over the screen.

The main caveat is that the class is focused on C# and Windows Forms, so I think third-party shit like Unity or XNA is out of the question. Anyone ever do stuff like this? Help?
>>
How do I reference my ircbot object from within the on_status method here (see arrow)? I know this is wrong (it doesn't work and throws an error) but I don't know how to fix it. My goal is to call the pubmsg function of ircbot when the stream listener receives a status update.

class CustomStreamListener(tweepy.StreamListener):

def on_status(self, status):

if status.user.screen_name == bot_screen_name:
return
if status_text[0] == "\"" and status_text[-1] == "\"":
print "debug: quote text"
ircbot.pubmsg("testing") #### <----------

def main():
stream_listener = CustomStreamListener()
stream = tweepy.Stream(auth, stream_listener)
stream.userstream(async=True)

ircbot = IRCBot("#test", rand_name(), "irc.freenode.net")
ircbot.start()

if __name__ == "__main__":
main()
>>
>>54092943
put
global ircbot
in main()
>>
>>54093084
as in,
global ircbot
ircbot = IRCBot("#testchan", rand_name(), "irc.freenode.net")
ircbot.start()

?

This seems to break the code
>>
>>54091476
Instantiate the objects in functions called by parallel
>>
>/dpt/ has been completely taken over by snekfags

why must all things decay
>>
im a fucking wasteman programmer, trying to get the basics of java via youtube tutorials because i havent got a teacher in my programming class. So that i can do this super simple application that i would fucking pay someone to make for me, so i can pass this unit and forget about java forever.
>>
File: 91i328.jpg (142 KB, 740x740) Image search: [Google]
91i328.jpg
142 KB, 740x740
>>54093463
>Java
>>
File: haskelel2.jpg (745 KB, 1920x1080) Image search: [Google]
haskelel2.jpg
745 KB, 1920x1080
>>54092576
>>
>>54092943
In main set stream_listener.ircbot = ircbot then in on_status use self.ircbot
>>
>>54093463
>youtube tutorials
i shiggy diggy

https://docs.oracle.com/javase/tutorial/
>>
>>54093476
if you hate java you're a bad programmer
>>
File: Untitled.png (726 KB, 840x927) Image search: [Google]
Untitled.png
726 KB, 840x927
thinking of what to feature to add to browser #113 next.

when do programs become feature complete?
>>
File: 1451553795827.jpg (21 KB, 500x500) Image search: [Google]
1451553795827.jpg
21 KB, 500x500
>>54093512
>>
>>54093417
To be clear, here's my code:
http://pastebin.com/tnw6nZzw

A method in the IRCBot class creates a connection object called c. Connections have a method called pubmsg which simply sends a message to an IRC channel. I'm trying to get the on_status method in the StreamListener class to call the pubmsg method of c, but none of that commented-out code works and I don't know what I'm doing (it just throws an attribute not found error)

>>54093506
>>54093506
>In main set stream_listener.ircbot
this makes no sense to me
>>
>>54093512
they don't really hate java, they just think they hate java when in fact they hate their shitty school
>>
Can you use Jackson to convert json files directly in to GML(graph modeling language)?

Do I have to convert the JSON files straight to XML first?( I know how to use the objectMapper)

Java is the language.
>>
>>54093528
>>54093516
>>
why do you guys program?
>>
>>54093616
i do it for the fame
>>
>>54093616
It's fun, but I'm learning java and android shit to make $$$
>>
>>54093616
Creative outlet, and making something new that doesn't exist and does exactly what I want.
>>
>>54093616
for fun, to have something to do
for money
for the challenge
for the fame
and >>54093647
>>
>>54093616
Cash money
>>
Will A.I. ever replace human programmers? What then?
>>
>>54091019

this right here is the type of shit node is actually good at
>>
>>54093679
Obviously.
>>
>>54093719
>sorry to fag up the thread
Well, you certainly succeeded.
>>
4chan browser #112.

http://www.mediafire.com/download/sk04f0r92tk4bih/browser_112.zip
http://www38.zippyshare.com/v/rpiD9HOu/file.html
https://openload.co/f/0sczR9_i2g4/browser_112.zip
https://www.sendmyway.com/epobjnt58ka0
https://www.datafilehost.com/d/f13b286c
https://userscloud.com/mxzp5ln4h96l

pw: CRUISECONTROL


ok, done testing.
I'll never understand why the server allows some file sharing links, but not others. What's the cutoff?
>>
>>54093506
>>54093506
Holy shit, this worked. Thanks so much. Can you point me in the right direction for reading up on this? I clearly don't understand scope or something... is this particular way of doing things unique to Python in any way?
>>
>>54093818
>What's the cutoff?
Shit that people spam in threads.
>>
>>54093945
well, it seems like sites such as mediafire and rapidshare were always allowed, no matter what.

hell, /rs/ used to gather links from all the boards and list them in one handy location.
>>
>>54093844
I think every dynamic language lets you add attributes to objects at any time. In this case just added a reference to ircbot. Defining it at module level e.g. Global would have worked to.
Maybe read up on the difference between lexical scope and object lifetimes.
>>
>>54093979
thanks
>>
>>54092576
You're really going around embarrassing yourself with your shitty programming skills? gj
>>
>>54093679
AI isn't inherently good at problem solving, so it will be a very long time until this happens.
>>
>>54093679
Do you think programmers would deprecate themselves? fuck no
>>
File: 1460810159228.jpg (9 KB, 246x227) Image search: [Google]
1460810159228.jpg
9 KB, 246x227
>>54093616
I have no clue anymore.
I've been doing this since I was like 12 and I'm still utterly shit at it and could never earn money doing professional programming work.
Not that I would even enjoy programming as a profession.
But I'm too damn poor so I need to find a way to make money without resorting to flipping burgers.
Honestly I prefer living in a box to working on things that will never have any impact on the world whatsoever, and I have lived in a box before.
How do I be a professional?
>>
>>54094170
It wouldn't necessarily be on purpose. I'm not talking "judgement day", but sometimes things creep up without us realizing it; like that one myth about how a frog will allow itself to be boiled alive if you heat it up slowly (it won't).
>>
>>54094170
>be good programmer
>create well-documented, well-designed code
>create easy-mode libraries that allow you to do impressive things using just a few lines of code
>company fires you and replaces you with pajeet, who has no trouble maintaining your well-written code
>become unemployable because the pajeets you're competing with have written impressive-looking projects made up entirely of glue code using your libraries

It happens all the time and yes, they will eventually put all of us out of a job.
All it takes is one gloriously brilliant moron.
>>
>>54094230
>All it takes is one gloriously brilliant moron.

aka CEO.
>>
>>54093616
Entry level position, 60k starting
>>
>>54094230
Way to go sideways. The question was about AI; not another human.

But, would things really be so bad if nobody had to work?
>>
>>54090066
Depends if you're using clang, but it should be CXXRecordDecl or something similar.
>>
>>54094230
>be good programmer
>create well-documented, well-designed code
>create easy-mode libraries that allow you to do impressive things using just a few lines of code
>own none of it
then you are either a cuck or Stallman. we have copyright laws for a reason.
>>
>>54094266
>But, would things really be so bad if nobody had to work?

How are companies supposed to make money if nobody can afford to buy their products anymore?
The government would go bankrupt trying to provide emergency welfare for everyone.
>>
>>54093796
kek
>>
>>54094293
I mean, it all boils down to:
> what is money?
> what is the economy?
Why do people HAVE to make money? Why can't we all just spontaneously agree to do things to help each other out just because it's the right thing to do?

I'll give you some of my corn that I grew. If you give me some of your chicken that you raised, great. If you have no chicken, well that's fine too.

Too philosophical?
>>
I want to take a picture with a camera on vb net i found aforge.net is it botnet? Is there something better what do you recommend me
>>
>>54094355
>Too philosophical?
yes fuck off to >>>/sci/
>>
>>54094357
I don't have a recommendation, but these days I'd settle for a botnet over a ransomware.
>>
>>54094355
Money exists because barter sucks.
Also how is anyone supposed to start from nothing?

>here i'll trade you 20 dirt pies for one of your chickens
>>
I've been doing pretty well in C++ class, since mostly so far we've been in the "C with classes" portion of the course and I had a great instructor for C last semester. But we just hit all the inheritance/polymorphism and derived/subclass stuff and I'm completely lost, plus my current instructor can't string a comprehensible sentence together to explain the concepts clearly enough to me.

Are there any resources you'd recommend? I prefer video lectures rather than reading if I can find them as I absorb concepts faster from an actual person than a book, but youtube is just full of Indians with atrocious accents that are about as unskilled as my instructor at actually explaining stuff.

Reading material is fine too, as long as it gets the concepts across concisely. I'm an EE, not a CS/SoftEng major, so while I appreciate the theory, I'd rather skip straight to understanding how and when to apply this stuff right now so I can finish my assignments.
>>
>>54094382
What a time to be alive, i mean i am using W10 already anyways
>>
>>54094396
>barter sucks
But money is basically the same as bartering. It's just been converted into universally accepted credits.
>>
>>54094409
Ok, either English isn't your language, or the AI bot is here. Or maybe drugs.
>>
>>54094355
your girl sucked my dick for free because it was "the right thing to do."
>>
Why is Java Object Oriented Programming so difficult?
>>
Does anyone use the auto keyword in c++ to accomplish variable assignments?

auto var { 0 };
>>vs
int var = 0;

Are there any real advantages or disadvantages when using auto in c++?
>>
>>54094230
If Pajeet is stealing your job guess what? You aren't that good at programming anyways
>>
>>54094536
Because you're an idiot. OOP is easy as shit and the main reason pajeet is stealing your job
>>
>>54094446
;)
>>
>>54094624
I understand functional programming I don't understand why Java forces you to make everything as an object it makes no sense to do so
>>
>>54089247
Based Black Lagoon OP.
>>
>tfw no bottom bitch fuccboi to document your code and write unit tests
>>
>>54094540
None, and gurus like Herb Sutter recommend using it as much as possible, as in your first example.
>>
>>54093512
If you use java you're a bad programmer.
>>
>>54094540
It's basically a preprocessor that the compiler figures out later. Basically a weakly typed feature that anyone who actually uses C++ hates, including me. More compile time, more obfuscation, less readability. Use it if you want, no real advantage.
>>
File: Capture.png (6 KB, 547x181) Image search: [Google]
Capture.png
6 KB, 547x181
Guys how do i read a random line off a file, whatever im doing in pic related is wrong someone must know. its in java also
>>
Working on the project in my trip
>>
>>54094758
>>
>>54094374
But /sci/ hates philosophy unless you're talking about pseuds and post structuralists like chomsky and habermas, they love those faggots.
>>
>>54094749
Scan the file in as an array of strings. Pick a random number between 0 and size-1 of your array. Your random line is that string at that index. If you don't know how to do one of those tasks google it
>>
>>54094744
There's nothing weakly typed about it.
>>
>>54094799
but there are a ton of words in the file, is this the most efficient way? i wanna grab the word and do things with it later and i dont wanna make an array out of an array ifyagetme
>>
>>54094837
import every word into a hashmap
>>
File: stocker.png (62 KB, 1848x500) Image search: [Google]
stocker.png
62 KB, 1848x500
Stock market bot.

Can a C# guru tell me what the proper way of wrapping an async pub/sub wrapper?

The picture on the right is a diagram of how it is currently setup. I feel like communication to an object in the UI thread is incorrect.
>>
>>54094850
wtf no, when the program starts it will select a random word and the user will interact with the word
>>
>>54094837
a line is defined as any amount of text ended by CRLF or whatever your operating system is. there's no way to see where a line is in a file until you look at all the CRLFs. there's no more efficient way
>>
>>54094355
Because not all people hold themselves to the virtue of charity.
(well, except the church actually)
>>
>>54094869
yes?
import your dictionary into the hashmap and have your program display a random entry in your hashmap
or if you want equal probability of all entries being displayed without collisions, flatten your hashmap into a flat array and
rand() % NUMBER_OF_ENTRIES
>>
>>54094859
>I feel like communication to an object in the UI thread is incorrect.

MethodInvoker
>>
>>54094859
Are you currently using callbacks through WCF? That would probably be the easiest solution.
>>
>>54094824
Lol ok. Javascript is weakly typed, right?
var whatever = 1;

auto whatever = 1;
>>
This is my GET request function in C being used,you can just call it and it does everything
    int bufsize = lazyKB(16);
char buffer[bufsize];
int length = 0;
length = lazyGET("www.timeapi.org", "/utc/now?format=%25I:%25M:%25S", buffer, bufsize);


Is this how you would expect to use this? What extra things would you want control over?
>>
>>54094988
You obviously have no idea how C++1X works
>>
>>54094792
/dpt/ also hates ""philosophy"", i shouldn't have to explain why money is good or why "muh altruism" doesn't work in a freaking programming thread
>>
>>54094744
How would you assign a lambda without Auto?
>>
>>54094540
It allows you to not have to repeat yourself in eg:
MyHPControllerMaster HPControllerMaster_instance = new HPControllerMaster(HPControllerArbiter_inst)
>>
>>54094953
Thanks, this is what I was looking for. I a new to C# and UI.

>>54094981
Messages come back through a wrapper implementation class.

https://www.interactivebrokers.com/en/software/api/apiguide/csharp/csharptutorial_implementewrapperinterface.htm
>>
>>54094889
I think society could still function without everyone going along with charity. The system would be able to support a certain percentage of 'freeloaders' (those who are unable or refuse to participate). Some would want to help others just because. Things would balance out. Maybe it's wishful thinking. It works on the small scale though.
>>
>>54095081
>Thanks, this is what I was looking for.

No problem, fambly.
>>
>>54094540
vector<T> ts;
for(const auto& e : ts)
[\code]

is nice, I use it everywhere more generally anytime you have something like

mytemplatetype<othertype> a;

auto b = a; //much nicer than
mytemplatetype<othertype> c = a; //this


It's an automatic typedef, use it as such. Don't turn your code into some messy Python bullshit.
>>
>>54094744
>It's basically a preprocessor that the compiler figures out later
>Basically a weakly typed feature
you seem to be confusing dynamic typing and weak typing. C is weakly typed but also statically typed, while Scheme is strongly typed but dynamically typed. on the other ends of the spectrum, Javascript is both weak and dynamic and Haskell is strong and static.
>more obfuscation, less readability
readability should not be focused on the internal parts of a function. in fact, if you have to open up abcdef.cpp in someone's code base and skip to line 3291, chances are that code is absolute dog shit (regardless of whether auto is used). putting types in explicitly is not a part of readability, especially when it comes to huge template types that "obfuscate" your code even more.
>>54094988
type inference has nothing to do with dynamic typing other than surface syntax. in C++,
whatever
has a type that it is type-checked against at compile-time. in javascript, the variable just takes whatever value makes sense in the context and never gets type-checked ahead of time
>>
how would you sort a list inside a list. for example if you had a list of odd numbers 1, 3, 5, 7 and a list of evens 2, 4, 6, 8
List<Integer> odd;
List<Integer> even;

numbers.add(odd);
numbers.add(even);

Collections.sort(numbers);
so that the sorted list is 1, 2, 3, 4, etc. but what if you want to sort even numbers within the sorted list so that the result can be something like 1, 8, 3, 6, 5, 4, 7, 2. how would you do this efficiently
>>
can someone explain vTables to me? to my understand (correct if im wrong) but it's a table that a base class will have if it has member methods marked virtual, and derived classes will have it they then overwrite that parent member method. the vTable then basically contains a pointer to the derived class's new, overriding member method?
>>
>>54095081
>Messages come back through a wrapper implementation class.
Okay, I think I understand your problem better now. So if I'm correct, you're connecting to this stock API through this wrapper, and you want your UI thread to reflect these changes when that occurs.

Are you using WPF? You can use INotifyPropertyChanged to implement this behavior with data binding. You might want to look at the MVVM pattern if you're not doing so already.
>>
>>54095304
http://www.cs.ust.hk/~dekai/library/ECKEL_Bruce/TICPP-2nd-ed-Vol-one/TICPP-2nd-ed-Vol-one-html/TIC2Vo16.gif
>>
>>54095353
does
Instrument
not have a vTable?
>>
>>54095366
iff Instrument has virtual functions
>>
>>54095376
ah i see

but apart from that is my description of a virtual table correct? the lecture slides im going off a bit convoluted
>>
>>54095376
>>54095366
I mean iff it inherits a virtual function
>>
Seeing if I can prove that philosophy is horse shit using a markov text generator. I had it read philosophy books and made a few weighing functions to determine what the optimal output is. See if you can determine which is a quote from German philosopher Immanuel Kant, and which is the robot which learned to speak by reading Immanuel Kant's works, without googling either quote. Then check yourself to see if you were right:

>[...] apply a priori to objects, the transcendental deduction of conceptions, and I distinguish it from the empirical deduction, which indicates the mode in which conception is obtained through experience and reflection thereon; consequently, does not concern itself with the right, but only with the fact of our obtaining conceptions in [...]

>[...] and dry, as the brain; and that everything which the understanding estimates distance, it thus happens that in both cases the quantity reference throughout to the limitations of its own free will. The close connection of the concept-spheres in order to pass over to thought, [...]

If you got it right, congratulations you're prepared for the coming SkyNet uprising.
>>
>>54095382
subclasses have a table of pointers to their implementations of virtual functions
objects of that subclass have a pointer to that table

>>54095385
oh, also I assume if it provides a default functionality then it also needs a vtable
>>
>>54095408
>watch me prove philosophy is horseshit by quote mining and comparing it with a selected generated quote with no knowledge of specific terms

This is some really bad philosophy you're doing
>>
Sheltered friendless person here. I'm finishing up a uni course that I hear my peers call the "interviews will all be based on this" course. We use this book.

Thoughts?
>>
>>54095304
you really don't need to know how vTables work. basic knowledge can help make sense of vTable errors I suppose, which is probably why you're asking, but solving enough of those errors and/or reading on how to do things the correct way will accomplish the same feat.
>>
What's changed in python3 for modules vs python2?

project_folder
start.py
/subfolder
dog.py
main.py


start.py
from subfolder import dog


main.py
import dog
dog.bark()

python3 start.py
#ImportError No module named dog
python2 start.py
"bark!"
>>
>>54095441
nah i ask because i have a midsem exam tomorrow and apparently 8 marks is on vTables
>>
>>54095433
https://en.wikipedia.org/wiki/Sokal_affair

I'll give you that philosopher before the 20th century was legitimate, but postmodernism is definitely horseshit
>>
>>54095476
>cultural studies
>philosophy

in the sense that all studies are philosophy, maybe
>>
>>54095439
Actually took a course taught by the author, he is pretty good. I thought the book was decent.

For a book on algorithms, you want this book.
>>
>>54095492
It essentially took postmodernism ad absurdum and stated that an objectively physical property of the universe is explained as a social construct.
>>
>looking through the opencl spec
>see CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE
>mfw
>>
>>54095476

Truly leftism is a mental illness.
>>
>>54095449
ha that sucks. guess an in depth course should cover it. what country has the middle of its semesters in april?
>>
>>54095680
australia
>>
test
>>
>>54095795
Nice tripget
>>
I have 3 nested lists that all have two elements in each minor list, like this:

a = [[1,0],[2,1],[4,1]...


a is an Ax2 matrix, b is Bx2 and c is Cx2. In most cases A=B=C but not always. any sn4kelyfers on that know a nice way to write this to a file so the out put looks something like:

a00,a01-b00,b01-c00,c01
a10,a11-b10,b11-c10,c11
....
aA0,aA1-bA0,bA1-cA0,cA1
....
,,-,,-cC0,cC1


the "-" isn't necessary, it can all be commas or whatever.
>>
>>54095476
>Anyone who believes that the laws of physics are mere social conventions is invited to try transgressing those conventions from the windows of my apartment. I live on the twenty-first floor.
based
>>
>>54095842
>sn4kelyfers
YOU ALMOST GOT AWAY YOU SON OF A BITCH

SNAKES MUST LEAVE
>>
>>54095802
what about mine :3
>>
File: this article is real and true.png (329 KB, 711x610) Image search: [Google]
this article is real and true.png
329 KB, 711x610
>>54095875
>turd
>GNU
you may only pick both
>>
File: 1413325309751.gif (949 KB, 301x300) Image search: [Google]
1413325309751.gif
949 KB, 301x300
>tfw falling down the AI rabbit hole
Dear god, how deep does this go? I hope you are all are prepared to welcome your AI overlords.
>>
>>54095919
>memeing this hard
>>
>>54095865
sorry bud, but I'm pretty convinced that any basic string/text/html parsing/getting should be scripted.


>and i've never taken the time to try lua or ruby
>>
File: 1430240827313.gif (607 KB, 800x792) Image search: [Google]
1430240827313.gif
607 KB, 800x792
>>54095940
>implying it's a meme
I'm making machines design machines for fucks sake
>>
I think I may have made a mistake becoming a programmer.

I'd rather write stories than maintain servers and shit like that. Game dev would be an option if it weren't for the fact that I can't get job in the industry without making a game of my own first. Naturally I blew the one opportunity I had by making a collaborative code editor instead that doesn't work and now I'm going to have to devote my life to something I have no passion for

>>54095842
dude, are you serious?

assuming you're using a language with dynamic-length strings, this is pretty damn easy

str = "";
max = max(A, B, C);

//an IxJ matrix only goes up to I-1 and J-1
for (i = 0; i < max; i++) {
if (i < A) str += ai0 + "," + ai1 + "-";
else str += ",-";

if (i < B) str += bi0 + "," + bi1 + "-";
else str += ",-";

if (i < C) str += ci0 + "," + ci1 + "-";
else str += ",\n";
}
>>
>>54095973
ok, yeah, I'm embarrassed. it's midnight tho and I've been working all day so leave me alone damnit

thanks bro.
>>
>>54095959
don't be that kind of idiot anon

!htaVEO6emg get
>>
>>54095973
>your programmer job makes you maintain servers
lol you're getting exploited, get a decent job fgt
>>
>>54095973
>maintain servers and shit like that
It's called devops and it's exploitative shenanigans because it saves money.
>>
>>54096028
I'm not kidding you: this is some crazy shit.

I'm almost done implementing Bayesian inference techniques on top of my enumerated design space. Then I can have my code design anything I can write a fitness function for.
>>
>>54096032
>>54096052

90% of the jobs I'm finding are server shit, web shit, or developing shit for trading firms. Sadly, the things I want to get involved in are all on the other side of the country. New York may be my home, but it's a fucking nightmare for programmers who want freedom
>>
>>54096127
>jew york
>>
If you don't think macro magic in C isn't the coolest thing in the world then get out of this thread
>>
File: stoolworthblessed.jpg (1 MB, 1688x2535) Image search: [Google]
stoolworthblessed.jpg
1 MB, 1688x2535
does /dpt/ keep up with RMS's urgent action items? Have you:

>called on Congress to invest in world-wide family planning
gotta pay for dirty Africans to wear condoms dontcha know?

>called on NOAA Fisheries not to help fishing boats cover up the amount of "bycatch" (sea animals that they catch inadvertently, and throw away dead).
a picture on twitter of a tally board on the boat should suffice.

>called on the CEOs of the 50 largest companies to come to an Earth Day meeting and make a plan to curb global heating and environmental destruction.
We all know the likes of Home Depot, Kroger, and large banks + insurance companies are to blame for increasing carbon emissions. only their CEOs could possibly help us.
>>
>>54096214
C is about the dorkiest thing in the world
>>
>>54096193
got a problem with that?
>>
>>54096214
Macros in C are kinda underpowered, though...
>>
>>54096214
the fact you need to do macro magic in C is a crime and a stain on the language
>>
>>54096224
>>called on Congress to invest in world-wide family planning

Makes sense. Communists are always into eugenics.
>>
>>54096224
RMS is a big sad meme. Only one step higher on the totem pole than Chris-chan. He's still around because we love to make fun of his retarded beliefs
>>
>>54096271
>giving people condoms is eugenics

what a fascinating wonderland you live in OSGTP
>>
>>54096285
Have you considered that some of use oldfags pay attention because he almost invariably gets proven correct given enough time, no matter how much people criticize him?

>in all of time and space, there are no words uttered with more sadness than "Stallman was right again"
>>
>>54096224
no but i still use emacs and gcc. rms is a hero.
>>
>>54096311
government giving people condoms = government telling them to have more sex
>>
>>54096317
literally what
>>
>>54096226
got that right

>>54096235
Of course macros in other languages are more powerful, but what I find great about C macros is that you can "expand" the language far more than you thought. Lisps are expected to do all sorts of crazy things, C, not so much. (in this scenario)

>>54096236
You never need to, unless you consider stringification to be magic. Using crazy macros is always frowned upon in real code but really interesting.
>>
>>54096334

C macros should be written like regular C code.
>>
c++14
>>
>>54096376
C++17 is shit
>>
>>54096329
government giving people condoms = government giving people a way to have sex without catching STDs or getting pregnant
>>
>>54096224
Do you think he has friends? Or is he just like in a circle of 15 people who occasionally invite him to parties because they feel bad for him
>>
>>54096388
yeah, that's a bad thing
>>
>>54096402
Fuck, get off /g/ you filthy newfag.

Oh how this place has fallen.
>>
>>54096410
if you weren't a newfag you'd know that /g/ was never any better
>>
>>54096410
he was always a meme you delusional fuck
>>
>>54096404
how?

>>54096385
do we know anything about C++17? Do we even know there will be a C++17?
>>
>>54096388
>>54096404

Humans and STDs are symbiotic. STDs are mother nature's way of slut shaming.

Getting pregnant is good - 1) civilised people (mostly white countries) will stop having sex before they're ready
2) birth rate will go up
3) traditional roles will return
>>
>>54096421
It's certainly had its ups and downs, but over the last two years it's gotten especially bad.

>>54096423
>newfags believe this
>>
>>54096435
i bet if you went to /fit/ you fell for the rippletits starting strength meme too ahahahaha
>>
>>54096410
It's a serious question faggot. If you can't lampoon your idols then you're taking them too seriously.

Either way I'm sure he has more friends than me.
>>
>>54096456
starting strength is a fine program for beginning lifters. now stay on topic.
>>
>>54096434
you are either a clever troll or genuinely retarded. Which is it?
>>
File: Fm6GGe.jpg.gif (1000 KB, 450x234) Image search: [Google]
Fm6GGe.jpg.gif
1000 KB, 450x234
>>54096456
>people forget this quickly all the shit the government and proprietary software vendors were caught doing
>now there's people here shilling for candidates who are running on a platform of expanding the NSA
Fuck all of you.
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.