[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: 334
Thread images: 35

File: anime.png (786KB, 1000x1300px) Image search: [Google]
anime.png
786KB, 1000x1300px
What are you working on, /g/?


Previous Thread: >>57445335
>>
>>57451610
Other op is a faggot. this is the real thread now
>>
File: elite hacker.png (618KB, 1024x576px) Image search: [Google]
elite hacker.png
618KB, 1024x576px
bump
>>
I'm trying to make a Pong game in Java using Model-View-Controller design pattern. I have a fully functional Menu with textfields for player names, a spinner for ball speed and a button to start a new PongGame window. I also have a Model where all neccessary variables will be stored.

My problem is this:
I need to use the same instance of Model in the PongGame window to preserve the settings from Menu. How do I launch a second JavaFX window while being able to access Menu's instance of Model?

Is it possible to send either the whole Menu object containing everything or the Model object containing the variables I need to access?

Any ideas?
>>
>>57452968
composition
Java uses references, after all
>>
Alright /dpt/
I need some help

How can I do the following in Python:
>Open a file containing a list of words
>some of the words if reversed are also words on the list
eg: rotator and rotator or redrawer and rewarder
>how do I check which of the words in the file can be reversed to create another word in the file?

I tried making 2 sets and checking using reversed() and [::-1] but no luck at all...
>>
Does anyone use Pascal nowadays?
>>
>>57453717
for each word a in file
for each word b in file
a == reverse b
>>
>>57453717
dictionary map every word to both the word and its reverse and see if you get any collisions
>>
>>57453747
O(n^2) ;)
>>
>>57453717

in Haskell this is just

import Data.List (nubBy)
main = (readFile filename) >>= (print . nubBy test . words)
where test a b = (a == b) || (reverse a == b)
>>
I fucking swear if I ever meet people responsible for creating git I will punch them in the face.

I have a uni project and starting this year we are required to use git instead of svn, and so far git seems to be worse in every imaginable way possible.
>>
>>57453813
git is strange yes, but svn is prehistoric. Learn git, after that you'll never go back.
>>
>>57453784
or with Kleisli composition

f = k print . k (pure . nubBy test . words) . k readFile
where k = Kleisli
test a b = (a == b) || (reverse a == b)



f filename
>>
File: slide_3.jpg (94KB, 960x720px) Image search: [Google]
slide_3.jpg
94KB, 960x720px
>>57451610
Is there any reason for using Cilk or Cilk++ now that C++ has concurrency support?
>>
I am a supervisor on a programming course at uni.
This is example code of a 2nd year student:
int* function(){
int *x = new int;
*x = 5;
return x;
delete x;
}
>>
File: 1475195100325.jpg (29KB, 600x456px) Image search: [Google]
1475195100325.jpg
29KB, 600x456px
>>57454052
>>
>>57454052
They're kind of getting it. Was the first year just a bunch of waffle?
>>
>>57454052
Are you not teaching RAII?
>>
File: 2016-11-09-220225_462x522_scrot.png (40KB, 462x522px) Image search: [Google]
2016-11-09-220225_462x522_scrot.png
40KB, 462x522px
somebody rate my common lisp snippet
>>
>>57453784
What does ">>=" for?
>>
https://github.com/sirdoombox/Overwatch.Net

Trying to make progress on this, no idea where to go with it now though seeing as it's functional.

Not really sure what to add so I'm open to suggestions for new projects - I really like writing API's for stuff like this, parsing web pages is really enjoyable with AngleSharp.

Any other suggestions are welcome, I have quite bad insomnia at the moment so I really need something to work on.
>>
>>57453914
wtf is this
Kleisli seems to be a constructor of a data tyoe
>>
>>57454604
rewrite it in python
>>
File: hereyougo.gif (88KB, 10000x10000px) Image search: [Google]
hereyougo.gif
88KB, 10000x10000px
bask in the glory
>>
>>57454621
https://github.com/SunDwarf/OWAPI

Already been done.
>>
I'm having so much fun playing around with Ruby. If Java is Blighttown, Ruby is the first time you look up and see the sky while riding the elevator out.
>>
>>57454535
Too short.


>>57454635
Ruby's a fun language.
>>
>>57454597
for composition of functions with necessary contexts such container types like IO, Lists, Maybe, Either, Reader, State, or even trees.
>>
>>57454629

RIP my computer
>>
>>57454659
Beautiful, I know. Brings a tear to my eye every time.
>>
>>57454635
Ruby is valley of the drakes?
>>
Lmfao, my program found a pastebin that had someones ok cupid username and pass
http://pastebin.com/GezFqTHT
>>
>>57453813
My previous work had CVS stop complaining
>>
>>57454674
Ruby is the glimmer of hope you get the first time you see the fresh air.
>>
>>57454697
So, anor londo then?

I would actually consider learning ruby/ rails if I didn't read it being a hipster language
>>
>>57453813
>so far git seems to be worse in every imaginable way possible.
If you check out, update and commit, it's basically the same. What are the ways in which it's worse?
>>
Can anyone tell me how to run up a check?
>>
I need an idea for a simple game to do in pygame?
>>
>>57455913
Don't use python for games, that's not what it is meant for. Pick a new project.
>>
>>57455969
I want to. Just please give me an idea.
>>
>>57455981
You are going to be disappointed in the end, python is great for a lot of things. But it is shit for gaming. Don't do it.
>>
>>57455996
Goddamnit, I don't care. I just want an idea.
>>
>>57456040
I will not support your bad habits, come up with a different project and I will help you.
>>
>>57456056
I need to do it for a project.
>>
>>57456068
No, pick another project and I will help you.
>>
>>57456073
I have to do the fucking project in pygame. It's a requirement.
>>
>>57456081
No, pick another project and I will help you.
>>
>>57456090
Alright i'm just gonna do snake.
>>
>>57456096
No, pick another project and I will help you.
>>
i need to learn VHDL in this nigth, any siggestions?
>>
>>57456223
get out of 4chan and start now.
>>
>>57454597
bind

>>57454617
it is, because that way it can have a different . from the category typeclass (you have to hide the regular prelude .)
>>
File: 1406092672685.jpg (71KB, 1063x1200px) Image search: [Google]
1406092672685.jpg
71KB, 1063x1200px
Anyone do the amazon online assessment? I feel like I'm going to get fucked.
>>
http://paste.debian.net/894238/

for no reason.
>>
>>57455065
No, it's excellent for developers. Dynamic typing is 100% useless.
>>
>>57457807
what
>>
>>57458014
>replying in the wrong thread because the OP pic triggers you
your tears are delicious
>>
>>57453779
That's not beyond the parameters of the question
>>
>>57454629
What the point of this image anon? It just show a white square on my computer, it's not even animated
>>
>>57454629
what is this
>>
>>57454629
delete ur account
>>
>>57460121
It's very high resolution and most of the anons here are kiddos on their mom's laptop or basement lurkers with terrible CPUs that choke on an image as big as that.
>>
>>57460362
Weird, it load just fine for me and I don't have any problems
>>
>>57460386
Yeah same here, but I'm on a decent browser on a decent OS and a decent computer so these things have never done more than take a few seconds to load.
>>
>>57453717
Test the initial vales to the list then push them onto a stack and pop them back off into a string so they're in reverse order and test that value with every item on the list. Can use a map to speed it up a lot.
>>
>>57453738
Writing a pascal compiler for compiler class; Haskell is starting to become semi big because of its prime number abilities (the names are related atleast)
>>
>>57453747
Associative array will make it much faster
>>
File: Retarded_Meme.png (88KB, 500x532px) Image search: [Google]
Retarded_Meme.png
88KB, 500x532px
>>57454282
class Integer {
int* i;
public:
Integer(int ii) i{ new int{ ii } } {}
~Integer() { delete this->i; }
};

int main()
{
Integer i{ 3 };
}
>>
File: 1478309282075.png (2MB, 2000x2000px) Image search: [Google]
1478309282075.png
2MB, 2000x2000px
>>57454052
>>57454282
>>
>>57461019
>not using numeric literals
>>
>>57461056
>not using numeric literals
:D
class Integer {
int* i;
public:
Integer(int ii) i{ new int{ ii } } {}
Integer(const int& ii) : Integer{ const_cast<int>(ii) } {}
~Integer() { delete this->i; }
};
>>
>>57461019
> DELETE THIS
>>
https://www.toptal.com/c-plus-plus/interview-questions

Any more of these? Link related.
>>
File: linus-eff-you-640x363.png (213KB, 640x359px) Image search: [Google]
linus-eff-you-640x363.png
213KB, 640x359px
>>57453813
Heard you wanna fight faggot
>>
>>57454629
>88kb
That's just so wasteful
>>
Not sure if this is the best place to ask this but here goes nothing.

I've been reworking some GLSL shader stuff lately, when suddenly I realized something. Almost every time you read a tutorial on how to use shaders in OpenGL they first write a shader class:

class Shader {
...
bool load(const std::string &name);
...
void setUniform1i(const std::string &name, const int i);
... and so on ...
};


So then they can have multiple shaders going around at the same time, like this:

Shader foo, bar;

foo.load("whatever.shader");
bar.load("somethingelse.shader");

foo.bind();
foo.setUniform1i("crap", 1234);


But why?

In OpenGL, only one shader can be active at any given time. You must glUseProgram(...) a shader before it can be used. You can't even set uniforms and attribute streams without binding a shader. Why use a class for containing a shader and wrapping the glUniform*() calls in member functions, when you can't even use/call them if the shader hasn't been bound?! I know there are bindless shader extensions that allow you to change uniforms without binding a shader, but those aren't very widespread yet.

So *what* purpose does a shader class serve? What do they do that I can't do by just keeping a few GLuint variables around that contain program IDs, then binding them with glUseProgram() and setting uniforms and streams manually (or through VAOs)? OpenGL is not OOP, the shader program is part of the global state, so an OOP shader class approach does not work with it very well.

A global shader manager that prevents the same shader program from being loaded multiple times and takes care of the cleanup I can understand. But not classes for individual shaders.

Have I misunderstood something?
>>
>>57461558
Convenience.
>>
>>57461590
I don't see much convenience in having to lug around references/pointers to shader classes when all I really need is one unsigned integer that identifies the shader program I want to use next.
>>
>>57461683
Good for you then.
>>
File: Trump.jpg (1MB, 2337x1753px) Image search: [Google]
Trump.jpg
1MB, 2337x1753px
>>57451610
Is Trump going to make it harder for Canadian grads to work in the US?
>>
Why is there two active /dpt/ threads?
>>
>>57461719
Because some weeb felt compelled to shitpost an OP with anime.
>>
>>57461719
We're evaluating the mods to see if they are doing their job properly
To nobody's surprise, they aren't
>>
>>57461719
I made this one because the other used a /pol/ image, which inevitably devolves into political discussion (hence they're usually deleted)

We can keep both going and use this as the new one
>>
I recently got a job offer as a python programmer. I am to write modules for odoo erp. I've got a small assignment to do with odoo and I hated it. The documentation sucks, examples are for old versions atc. Plus it's nothing great, writing bussiness logic modules. But I'll get 30% more than at my current job. Should I take it?
>>
>>57461683
>>57461558
I don't know much about opengl/graphics in general. But I know that games use multiple different shaders depending on the scenario.

Best example I know is that Saints Row 2 on the PC has inside and outside shaders. Things lighten up if the game detects you're inside. And also that bullshit brown overlay that they use to make it realistic but makes it look like shit
>>
>>57461558
People feel the need to use OOP everywhere.
>What do they do that I can't do by just keeping a few GLuint variables around that contain program IDs, then binding them with glUseProgram() and setting uniforms and streams manually (or through VAOs)?
Nothing, except perhaps convenience. And also API independence (so you can swap OpenGL for Direct3D for example).
>>
Every time someone tells me that C is hard or complicated, I am convinced that they have either been programming for less than a year, or that they are unintelligent.
>>
>>57461929
People tend to mistake simplicity for complexity.
>>
>>57461823
>games use multiple different shaders depending on the scenario
You can have 1000 shaders loaded if you want, but only one of them can be actually bound at any given moment. A shader program is made up from multiple individual shaders (vertex/fragment/geometry/etc.) but it's still just "one" program, like you link multiple object files to make an executable.

And only the active shader can have its attributes changed. If you have shaders "foo" and "bar", you can't say "bar.setUniform3f(...)" if the shader "bar" is not bound at the moment. If you do, nothing happens. That's exactly my point: why wrap them in classes when the member functions can do nothing if the shader is not bound? It's pointless abstraction.

>>57461882
>API independence
Not what I'm doing. All my code is OpenGL. Vulkan maybe in the future, but I'm not maintaining multiple renderer backends. Direct3D? Screw that proprietary shit.
>>
>>57461988
>why wrap them in classes when the member functions can do nothing if the shader is not bound
They can, they just have to do glGet to get current program, glUseProgram to set the selected program, glUniform and then glProgram again to restore.
>>
How long does it take to normally learn .net?
>>
>>57462038
.NET is a massive animal, and you really just keep learning it.

That goes for any programming language, really. You've got to define what your target competency level is.

That being said, you can learn C#/.NET enough to perform most basic tasks in a few months, but it's just a massive toolbox and the tools you use on a day-to-day basic will be different than anyone else.
>>
File: oop p2.png (57KB, 682x473px) Image search: [Google]
oop p2.png
57KB, 682x473px
>>57462065
>.NET is a massive animal
does .NET implement leggable?
>>
>>57462008
Which leads to a horrible number of unnecessary state changes. Shader changes are the second-heaviest changes that exist (render targets are the heaviest).

Yeah, I think I've done my decision: no OOP in my shader system.
>>
char *sChar(size_t s) {
char *str = (char *)malloc(s);
memset(str, 'x', sizeof(s) -1);
return str;
}
>>
>>57462065
Well I'm dead for my interview tomorrow then.
>>
>>57462144
What the fuck is wrong with you cunts?

Someone yesterday had a Javascript interview in an hour and thought he could know enough for the interview.

Learn a skill before you ask someone to pay you for it, dumbass.
>>
>>57462164
Well the job asked for a lot of languages but it was in the preferred section. I already knew about mysql when they wanted t-sql so I thought I could transfer my skills there. So it's them who decided they wanted me to try me out not the other way around.
>>
>>57461287

http://skillgun.com/cpp/interview-questions-and-answers

But in all seriousness, it's not like those questions will be the focus of what you are doing during an interview.

A good thing to fall back on is to answer "undefined behavior or implementation-defined" for something they ask that looks non-nonsensical but apparently will work.
>>
>>57452968
Use interfaces to connect classes (Pattern Observer), so that they are not too tightly linked.
>>
>>57457567

How did you do?

When I took it, their web based test tracked everything you did with webcam activation and what I suspected was javascript that would track you via taking screenshots of your screen so you don't cheat. You can't have programming references either, IIRC. A lot of questions asking you to implement simple stuff but then got progressively harder and then some random math and reasoning questions.

Was stressful and sure enough, didn't get past that initial web test. IMO, I wouldn't work at Amazon after hearing all the stories of how Amazon treats their employees.
>>
>>57462131
>(char *)
>Casing malloc

>sizeof(s)
>sizeof(size_t)
>probably 8
>>
Mentoring CS freshmen
>>
>>57462506

Dear god.

At least you are introducing SVN first instead of Git. I find it very hard to explain Git to non-technical people but easier to explain how SVN is like Dropbox.
>>
File: pepe.jpg (10KB, 480x360px) Image search: [Google]
pepe.jpg
10KB, 480x360px
>>57462506
>those people will have a job while I continue being a poor NEET
>>
>>57462455
Can you take it for free to find out how good you are? Remember any specific questions?
>>
>>57462524
>I find it very hard to explain Git to non-technical people
touch file.txt
git add file.txt
git commit -m "added file.txt"
git push master origin

What was so difficult about that?
>>
>>57461019
nice this is my code good to see my teacher is a fucking asshole I'm just trying to learn
>>
>>57462524
The professor did introduce svn. Actually since he goes full command-line-only, git would have probably been the better choice as this is what will be used in real-life later.

She's just worried that she won't get the points because we didn't use Eclipse but NetBeans instead. She doesn't understand, that it's just an editor, basically.

Anyway it's a good thing after all. A cute girl, I write her assignments and she sucks my dick.
>>
>>57462550

No, the web based test doesn't work like that.

And it's been 2 years since that test so questions have sure changed. But it's on par with what you would find on sites like Hackerrank or LeetCode.

I specifically remember one of the questions being palindrome detection on a given string. There was another string question I can't recall, and then something with primes.

In any case, they don't ask really hard questions on the web test. The in person test is when they get serious and start asking things like how to implement a hash map or some self-balancing tree function.

>>57462575

The concept of it. You can tell anyone that can follow commands how to use git on a basic level but that goes nowhere close to how to explain to people the model of Git's tree system with branching and merging.

SVN is much easier to explain in that regard.

>>57462608

GUI clients for version control makes things a lot simpler but yeah, Eclipse is a POS that needs to die. I don't use NetBeans but IntelliJ, which is better IMO.
>>
File: output.webm (963KB, 526x310px) Image search: [Google]
output.webm
963KB, 526x310px
Working on my terminal emulator, just finished adding mouse support.

That was easier than I expected, wew.

Now onto adding mouse support to overlay mode!
>>
Are there any good books/material about problem solving in C? I feel like I over complicate problems/exercises. Sometimes I give up, and look at the answer I go like: "Wait, that's it? Are you SERIOUS?" I am still a beginner, but that's why I feel like I need to tackle on this problem early on, because that's pretty much what programming is all about: "Problem solving".
>>
>>57462641
bost sauce bls
>>
>>57462653
It's on github, search for "github rust cancer".
>>
>>57462641
>mouse support
literally cancer 2bh
>>
>>57462810
Except it's useful to people in some applications, like htop or tmux, heck, even vim has mouse support.
>>
>>57462823
No. I mean it's literally cancer
>>
>>57462823
>heck, even vim has mouse support

we're not supposed to talk about that
>>
I'm learning about java streams.
A function returns me a dataoutput, and the example uses this to turn it into a dataoutputstream to write away into a file.
Is there any way to turn this dataoutput into a datainputstream so I can reuse the data without having to save it to a file and reopen?
>>
>>57462835
Oh okay, then I agree.
>>
>>57453717
Seems like this is as simple as: read lines into set, map reverser function onto set to create reversed set, intersect the two sets.
>>
>>57462927
ByteArrayOutputStream and ByteArrayInputStream
>>
File: 1453651138545.jpg (57KB, 601x577px) Image search: [Google]
1453651138545.jpg
57KB, 601x577px
>>57463162
>Java
>>
>>57463193
Literally nothing wrong with it :^)
>>
>>57463238
ironic use of java is still using java :-)
>>
What are decent projects that will land me a job?
>>
>>57463276
write an extension for GHC
>>
>>57463276
depends what are you aiming for
>>
>>57463286
i want to be a hacker
>>
>>57463298
you mean like >>57452079 ?
>>
File: 1459955917753.png (461KB, 870x722px) Image search: [Google]
1459955917753.png
461KB, 870x722px
trying to write out a functioning game of blackjack in python. what would be the best way to iterate through a list of Ace through king and assign number values to them? I figured you could do it with a for loop but I don't know how to account for ace also having a value of 11, or how to stop incrementing once I would hit 10. I obviously wouldn't want to have to assign everything individually.
>>
>>57463311
i'd prefer serious answers to being mocked, thanks
>>
>>57463390
>>>how do i become a hacker
>serious answers pls
>>
>>57463390
google "bug bounty" and get to work fagit.
>>
>>57463390
to be a real hacker you have to be able to figure things out on your own without getting spoonfed
>>
>>57453717
>I tried making 2 sets and checking using reversed() and [::-1] but no luck at all...
>I tried doing something random, but it didn't solve my problem
/dpt/ really is a bunch of fizzbuzzers
>>
What's the best way to get better at algorithmic thinking? I'm trying to work my way through Project Euler and it's a struggle and my solutions are shit.

My math is also weak which makes it harder what kind of math should I learn to make stuff like this easier?
>>
>>57463476
>a real hacker
he asked for serious answers
>>
>>57451610
"hacking" is more about scripts and phone calls now more than it is about manually wriggling around a network looking for vulnerabilities. Its a nearly dead art.
>>
>>57463358
since there's only four non number cards I'd say doing those manually isn't too much of a hassle
>>
prime?(x){
for (i = 2,...,x-1){
if i is a factor of x, return false
}
return true
}


can someone explain how this takes polynomial time? my prof says it takes time 10^|x| where |x| is the length of x. i thought it'd take proportional to x because of the loop going from 2 to x
>>
Does anyone want to show me how to solve this?
https://hackerrank-challenge-pdfs.s3.amazonaws.com/26945-hackerland-radio-transmitters-English?AWSAccessKeyId=AKIAJAMR4KJHHUS76CYQ&Expires=1478821995&Signature=vSObrko%2FV%2Bm94vWOOXUD1PiVNnQ%3D&response-content-disposition=inline%3B%20filename%3Dhackerland-radio-transmitters-English.pdf&response-content-type=application%2Fpdf

My solution passes the sample tests but fails in several submit tests and I can't think of a test case that my solution wouldn't solve correctly.
>>
>>57463917
x = O(2^|X|)
>>
>>57463938
can you spoonfeed?
>>
>>57463917
It is polynomial, I'm not sure what your prof is smoking. You can make it more efficient by iterating from 2 to sqrt(x).
>>
>>57463920
And your solution is?

Does it consider the case where the second line with the x's are in order and you must sort them first? (Assuming your solution requires them in order).
>>
>>57463495
if you really want to serious answers you have to be more specific about what you mean by hacking. pentesting or...?
>>
>>57463917
is he talking about the entire program or just this function?
>>
Model View Control programming is simple right?
Model just holds all the data
View is just the gui
Control is the code for the buttons on the gui
Is that correct?
>>
File: c programming language.jpg (475KB, 852x973px) Image search: [Google]
c programming language.jpg
475KB, 852x973px
>>57463358
Just enum all keywords for the cards?
>>
Would this work? I have an idea for a Python script where it sends an email to my Gmail email account. I don't want to run an email server or route it through an email service, I want the script to directly send an email using email protocols to me.

The reason for this is that I want to run it on my raspberry pi and want to be notified about changes to variables via email.

I've googled it and have briefly seen the email libraries available to me in Python, but I don't know if it can work the way I want it to. Again, I don't want to route it through an email service nor do I want to run an email server.
>>
Fuck, im struggling with this really basic java shit. I basically want the first part of a string of a user input to indicate what the user wants, then use the second part to look for a corresponding key in a hashmap. Problem is I cant seem to understand how substrings work.

so basically if the user writes "buy soda" I want buy to indicate what the user wants to do, and then to check if there is an object with the key "soda" in the hashmap.

Anyone want to spare 5 minutes for a retard?
>>
>>57464194
String.split()
or maybe Scanner has a function for reading a string up to the next whitespace character
>>
>>57462641
what is it written in and is it under a free license ?
>>
>>57464194
http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#split%28java.lang.String%29

"buy soda".split(" ") will return the array {"buy", "soda"}.
>>
>>57463987
there is no real program, it's pseudocode
>>
Do I normally need to call a repaint if a value on a GUI changes? Or does it get updated automatically on the GUI by itself when the value changes?
>>
>>57464125
you could use the gmail api to send an email to yourself
https://developers.google.com/gmail/api/quickstart/python
>>
>>57463917
polynomial in x, exponential in |x|, since |x| = log10(x)
>>
>>57464224
It's written in Rust and is under GPLv3.
>>
>>57464225
I got that part, but I want "soda" to represent any given key in the Hashmap, not just a single key.
>>
>>57464560
params = input.split(" ");

then you can do hashmap.get(params[1]) to get the second thing you typed ("buy xxx")
>>
>>57453784
Unnecessary parentheses and no definition for filename / 10.
>>
>>57464602
All righty, gonna work on it. Thanks.
>>
>>57464612
you're supposed to insert filename

this is like complaining that
>>57453914
doesn't import Control.Category, Control.Arrow, and hide prelude's (.)
>>
>>57464651
Oh right, thanks.

>>57453914
You forgot your imports.
>>
File: circulararrayqueuejava.png (96KB, 771x846px) Image search: [Google]
circulararrayqueuejava.png
96KB, 771x846px
>>
>>57464797
OH MY GOD YOU'RE IN MY CLASS NIGGA WHERE YOU AT ON CAMPUS
>>
>>57464854
I don't live on campus homeboy
>>
>>57464854
You fucking scared me, motherfucker. I thought you were sitting right behind me

not that anon btw
>>
>>57464863
you got a way to communicate famalam? Also is this Justin, Tyler, or Omar? or some other fag who browses /g/
>>
>>57464874
You got discord or steam? I could tell you who I am over there.
>>
File: 1468274225076.png (150KB, 1024x713px) Image search: [Google]
1468274225076.png
150KB, 1024x713px
>>57464854
>>57464863
>>57464874
>cybering
Where the fuck do you newfags think you are?
Bad enough we've got the fucking tripfags to deal with
It's an anonymous imageboard, be anonymous or fuck off
>>
i got to make a prolog program that moves everyone from 1 bank to another, where there's 3 cannibals, 3 missionaries, the cannibals can never outnumber the missionaries, and 2 people max can be on the boat. this is what i have so far
EmptyBank = [],
FullBank = [C,C,C,M,M,M],
FirstState = state(FullBank, EmptyBank),
GoalState = sate(EmptyBank, FullBank),


we haven't gone over prolog at all. please help me
>>57464797
>java
>>
>>57464892
ye https://discord.gg/xRXwbjU
>>
>>57454052
>function that always returns 5
literally 6 lines of code that replicates the 5 literal. They're a female right?
>>
>>57463494
Learn about:
Greedy Algorithms
Dynamic Programming
and Divide and Conquer.

Understanding these three, and knowing when to use which, is key.

Any particular type of problem you find hard?
>>
>>57464954
in Haskell this is just
function = const 5
>>
What is an online algorithm? How do I know if the algorithm is online? How do I make algorithms be online?
>>
>>57465013
or
function _ = 5
>>
>>57465013
But that's a unary function. The C code is nullary, so
function = 5
>>
i'm not smart enough to understand how to use structs but i keep coming back to programming

wake me up inside
>>
>>57454629
DO NOT CLICK THIS CONFIRMED FOR MIRRI BOTNET

I REPATE DO NOT CLICK THIS WE'RE ANAYLZNING IN VIRTUAL MACHINE R
>>
>>57465042
apply yourself
>>
File: 1477426295280.jpg (54KB, 680x598px) Image search: [Google]
1477426295280.jpg
54KB, 680x598px
>>57465042
tfw to intelligent to program
>>
>>57465040
>the C code is nullary

The C code is a procedure that takes a value of unit type as a parameter.
>>
>>57464602
so ive tried some things but I cant get it to work correctly. I can get this to work:

if (inputcommand.startsWith(params[0]) 


So I can get it to recognize "buy", but I cannot find a way for it to recognize the second part. I've tried endsWith(), but it doesn't seem to work the way I want it to.
>>
>>57465076
No actual representation of any unit value is present in the C's semantics. And no shit it's a procedure, all C "functions" are you twat. In this case it's a procedure that implements a pure function, and pure functions from unit are isomorphic to plain values (modulo strictness, though neither unary function given in earlier posts was strict in its argument).
>>
>>57454052

My first semester course won't even teach us functions.

We've literally just learned while loops after 6 weeks. It's torture, I do the courseworks and labs in 5 minutes and then leave.
>>
File: Portal culling.png (9KB, 674x577px) Image search: [Google]
Portal culling.png
9KB, 674x577px
So I'm making portals in Unity, and I'm trying to capitalize performance gainz

I have cameras rendering portals via pic related, and they're rendering within the red matrix. I want to change them to render in the blue matrix instead. What would be the best way to achieve this? What kind of matrix calculation should I be looking at?
I could simply move up the culling plane to the portal to prevent back-rendering, but I want to go farther- there's just absolutely no reason that I can tell to render all that extra shit that you just won't ever see.
Anybody have any ideas? Is this a good idea, or am I overlooking something?
>>
>>57465186
what university?
>>
>>57465109
did you try params[1] ? it will be the SECOND element of params if you made it with .split(" ")
>>
>>57465159
calm down

void is C's unit value
>>
>>57451610
is there any point in using the duff's device in C programming anymore? Won't gcc unroll all my loops for me?
>>
>>57465277
type*
>>
>>57465282

Not really, it's better to unroll manually yourself via assembly or let the compiler do it.
>>
>>57464305
It depends what GUI you are talking about.
>>
>>57465248
Yeah, the one thats listed is the one I want to recognize the "buy" command. I cant seem to get the next part to work, ive tried

if (inputcommand.endsWith(params[1])) {


within the brackets listed above, but it doesnt work.
>>
>>57465292
Does GCC unroll loops with indeterminate runtime at compile?

Or would duffs be useful in that case?
>>
>>57465309

Why does it matter if the loop is indeterminate? The loop is unrolled according to set parameters and optimized respectively for cache/CPU.

It's also known as dynamic unrolling.

https://en.wikipedia.org/wiki/Loop_unwinding#Dynamic_unrolling
>>
do I need a degree in CS to work in a videogame studio? I have several years of programming experience on a wide range of projects but my degree is econ
>>
File: 1405715758915.gif (255KB, 256x540px) Image search: [Google]
1405715758915.gif
255KB, 256x540px
>>57462455
Haven't taken it yet, got a few more days to procrastinate on it. First half is supposed to be a bug finding thing, then the second part is supposed to be a reasoning test.
>>
>>57454535
What font?
looks comfy
>>
File: 20161024_105300.jpg (137KB, 400x562px) Image search: [Google]
20161024_105300.jpg
137KB, 400x562px
So long story short my school provided jvreator but only on their desktops. Could someone link a video on how to open up existing java files ? I really new at this so please bare with me. I open them up but I have my main on one java file and my class on another and for some reason they do not find each other.
>>
Who needs music when you have a python script playing bleeps at frequencies that vary every 0.1 second by a random amount up to 100hz
>>
>>57465715

You mean JCreator? What version? Latest one?

I don't like that IDE, but it's relatively easy to open up .java files. I went and googled up a video for you to install. Hopefully, you have no problems with the whole video and following instructions.

https://www.youtube.com/watch?v=90apTsJDOZU
>>
>>57465800
Omg my bad I meant how to open them up in NetBeans I fucked up.
>>
>>57465858

https://www.youtube.com/watch?v=-H4C9T1ResQ
>>
>>57453717
I'd load the whole fucking thing into a hashtable and then go through the list reversing em and checking if they're in the hashtable

o(N) is not terrible efficiency
>>
>>57451610
So if I have an infinite loop for receiving data off a socket, how do I compartmentalize various parsing jobs?
I guess I just need to write a proper parser, shit's hard tho.
>>
FUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVA!

Holy fucking shit fuck Java!

They were such simple questions and the only way I could have only fucked every single one of them up if I used java

Question1: You're given a integer and have to find the fastest way to get to that number from zero by incrementing and doubling. Easy! Just while loop in reverse, halving if even and decrementing if odd. Oh, the int is actually a String? Just parse it? Wait, the integer is invalid? Just match /\d+/. How do you do that in Java 7? First you create a pattern to compile it (making sure to write \ as \\), then use the matcher method with the string to get Matcher object, then use the group method to get the match. Oh wait, it returns nothing, because "\\d+" doesn't match and neither does "\d+" or "[0-9]+"

next one is easier. you have a list of non-unique integers and a long. Find all unique pairs that add up to the long. Just use them as hash map keys to remove duplicates, then double-loop through the key list to find the pairs. Oh wait, once they're in the map, using the keySet method returns a set, not an array, and using the set.toArray() method is worthless even if you do casting. It should't even exist!. So now you have to give it a new array inside the array! Wait, are you telling me that some ints can be converted to Integers, but those same Integers can't be converted back to ints? Fuck You!

Final question: you a string containing a char, whitespace, and a fixed-length bit pattern, and also a string of bits. Convert the binary to text. Oh, wait, you need regex again? Fuck YOU!

FUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVA!FUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVAFUCKJAVA!
>>
>>57466323
>Wait, the integer is invalid? Just match /\d+/.
No. You use TryParse.

>Just use them as hash map keys to remove duplicates
>non-unique integers
Completely unnecessary, just do the for loops and get it over with.

>Oh wait, once they're in the map, using the keySet method returns a set
If you are using the keyset of a hashmap you took the wrong approach.

>Wait, are you telling me that some ints can be converted to Integers, but those same Integers can't be converted back to ints? Fuck You!
Integer.intValue. Note that Integer can be null and int can't.

>Oh, wait, you need regex again? Fuck YOU!
No.
>>
>>57466427
>No. You use TryParse.
no, you don't because you need an integer. it's not a fucking option to not get one, and regex is pre-imported

>Completely unnecessary, just do the for loops and get it over with.
no, you don't becuase you need a list of UNIQUE pairs, not all the possible pairs

>If you are using the keyset of a hashmap you took the wrong approach.
then how the fuck do you get the keys?

>Integer.intValue. Note that Integer can be null and int can't.
note that these are all valid ints converted into Integers and back into ints

>No.
Fuck you personally!
>>
>>57466427
yep, >>57466323 has no fucking clue what they're talking about. God damn.
>>
>>57466497
kill yourself you fucking piece of shit asshole motherfucker!
>>
File: screen.png (49KB, 904x745px) Image search: [Google]
screen.png
49KB, 904x745px
>>
>it's not a fucking option to not get one
What? If it's not a valid int you just make up your own int? What good is that supposed to do? It SHOULD error if it gets invalid input, anything else would be insane.

>>57466488
>you need a list of UNIQUE pairs, not all the possible pairs
You didn't specify that, but just add them to a set then.

>then how the fuck do you get the keys?
You don't. If you ever need the keys from a hashmap then you shouldn't be using a hashmap. You lose the only advantage hashmaps have (O(1) insertion and retrieval) if you iterate over the keys.

>note that these are all valid ints converted into Integers and back into ints
Then there shouldn't be a problem? I think in newer Java version you can even just
Integer x = 5;
int y = x;
So I don't see what you are chimping out about.

>Fuck you personally!
I'm surprised you didn't get hired in spite of your technical failings, with that fantastic personality and willingness to learn from your mistakes.
>>
>>57466576
>What? If it's not a valid int you just make up your own int? What good is that supposed to do? It SHOULD error if it gets invalid input, anything else would be insane.
no, you find the proper number in the string with regex! "100\n" is invalid despite having a valid int in it

>You didn't specify that, but just add them to a set then.
what part of "next one is easier. you have a list of non-unique integers and a long. Find all unique pairs that add up to the long." do you not understand

>You don't. If you ever need the keys from a hashmap then you shouldn't be using a hashmap. You lose the only advantage hashmaps have (O(1) insertion and retrieval) if you iterate over the keys.
I'm sorry, do you have an easier way that's not O(N^2)?

>Then there shouldn't be a problem? I think in >newer Java version you can even just
>Integer x = 5;
>int y = x;
>So I don't see what you are chimping out about.
because I'm getting fucking invalid int exceptions
>>
File: 1405749004944.gif (442KB, 400x425px) Image search: [Google]
1405749004944.gif
442KB, 400x425px
Post motivational videos

https://www.youtube.com/watch?v=YJZCUhxNCv8

(please)
>>
>>57451610
So a friend made a simple python chat client (server.py client.py) me and a friend are learning python so we want to add to it we're adding encryption, username support and fixing a few bugs - now as for the encryption we want something easy to add for us and easy for the users to remember so we plan on having it client>ROT>affine>server I know it's not really that strong but does anyone have something else we should consider?
>>
>>57466657
I'm on the quantity vs quality slide now - loving this video anon thanks, might even convince me to start looking for work.
>>
>>57466828
You should just run it over tls like any other application that uses tcp and needs encryption.
>>
>>57466998
alright will do, thanks (new to encryption and networking stuff)
>>
>>57466630
>no, you find the proper number in the string with regex! "100\n" is invalid despite having a valid int in it
Scanner.nextInt
>>
Can someone clear my understanding of hash tables. Say I have a hash function that is n % 5
If I have a pair (2, apple) (7, banana). When I look in the hash table for 7, how would it know that apple is the wrong one and I want banana?
>>
>>57451610
Can someone halp pls? I'm pulling my hair out over this shit. I'm trying to fetch text data from websites using python and BeautifulSoup, the text comes in fine with the code I have when I use print, but when I write it as a function and call the function it only prints one line instead of iterating through all of the elements in the for loop.

from bs4 import BeautifulSoup
import urllib2

data = open('Input', 'w')

def fetcher():
site = urllib2.urlopen('http://www.huffingtonpost.com/entry/donald-trump-white-house-press_us_58249ef3e4b01019814dab06')
article = BeautifulSoup(site , 'lxml')
for x in article.find_all('p'):
return x.get_text()

print fetcher()


basically if I replace the <return> inside the for loop with <print> it works perfectly, otherwise it only prints one line.

I need it to return all the text because then I have to write it to a file.


thanks to anyone who can help. I'm
about to commit soduku over this bullshit I'm so frustrated. I cant find anyhelp in either the documentation for BS4 or stackoverflow.
>>
>>57467038
https://en.wikipedia.org/wiki/Hash_table#Collision_resolution

There are many strategies. The simplest is, you insert apple at position 2. You try to insert banana at position 2, notice there's already something there, and insert banana in position 3.
>>
>>57467031
the point was to use regular expressions
>>
started coding an ai for my tic tac toe game. the the bot literally just chooses random places to move. mainly wanted to code it to where it doesn't pic an already spot but the code is broken during a winstate the wil lstill pick?
>>
>>57467061
You can only return once from a function, you can print as many times as you want. You need to concatenate the p segments, or put them in a array, or something like that.
>>
>>57467038
here's the simplest thing
it's easiest to ignore apple and banana for a bit. they come along for the ride
your backing data structure is an array of linked lists
if you lookup 7 you go to position 2 of the array and check if the head of the list has key 7. if not, you follow its next pointer and keep checking
>>
>>57467093
God Bless your soul.

Can you explain why just <continue> won't work though?
>>
File: chip8_chlang_a (3).webm (2MB, 960x600px) Image search: [Google]
chip8_chlang_a (3).webm
2MB, 960x600px
Hi /dpt/,

I'm working on my Chip-8 compiler still. Now that my parse tree is definitely, positively correct, I need to find a way to annotate the AST, and later to generate byte code / assembly.

However, I've run into an issue. If I want functions to be separate areas in code to which I can jump to and return from, how do I ensure they don't overwrite registers that the previous function is using? Say, the main function / routine is using registers 1-4 to store data / variables (Chip-8 has 16 registers), and I call jmp to a subroutine which also uses registers 1-4, when it returns, the main function's variables would have changed (because they were in the registers and got overridden). Do I just not use registers at all, or save them into memory? It's not like I have a lot of memory, and not using the registers sounds like a waste...I also don't want to write my own stack implementation since Chip-8's stack can only hold return addresses..

WebM related, it's the parser in action.
>>
>>57467106
return immediately exits the function and /returns/ to executing the caller. After return is invoked nothing is ran from that function until it is called again, where it will be running from the top. If you do want to return multiple values you could return a array, or you could look into turning your function into a 'generator function' where you can use yield to exit to the caller, but when invoked again you start from where you left off, not at the top, sortof.
>>
>>57466937
The GPA thing was reassuring for me. But at the same time it is a little sad how you can be pretty shit at school, but as long as your good at interviews, you're still good to go.
>>
>>57467094
This makes a bit more sense. But If I don't use anything extra and all I have is an array with literal values, then that situation cannot be resolved and I will always get apple instead of banana since I only have a key and it can't tell if the data returned is correct?
>>
>>57467126

Look at an existing implementation and take ideas from there.
>>
>>57467163
See >>57467063

The lookup works by checking 2, if it's a different item, you check 3, and so on until you get to an empty index.

This strategy is generally pretty bad as it has a worst case of just turning your hash table into a list, i.e. O(n) search.
>>
>>57467163
it's unclear to me what you're allowing as "literal values"
at a minimum it seems like you definitely want to use "open addressing" as anon suggests >>57467063. there you have to do more than just provide a hash function
>>
>>57467145
Gret thanks it worked! Now I just have to figure out how to get rid of all that unicode formatting like /u...
>>
>>57467220
html.unescape
>>
>>57467210
Like banana and apple, I should've just used zip codes and the states associated with them instead for the question. Once you had all your things into the table and began look up using a key, I wanted to know if it was possible to get the banana when you put in a 7 since the initial values I put in were (2,apple) and (7, banana) the 2 spot was taken so it had to be put somewhere else for banana like 3 with just a standard array that had values only in it, banana, apple. I was looking up simple examples of hash tables and noticed that they didn't seem to have code for cases where this happened using only a simple array with values
>>
>>57467309
it's a one-way map (hence 'hash' - hashes don't go both ways), you go from banana to a number, you can't use the same map to go from number to a banana, you'd have to use a separate hash map for that
>>
>>57467348
Forget it, I'm bad at explaining my question but I think I got my answer, just wanted to make sure
>>
Do you guys think the tech bubble is going to burst soon? Would it be a waste of time learning web development?
>>
>>57467382
learn whatever the fuck you have to to pass a palantir interview
>>
>>57467472
Is it hard?
>>
>>57467472
>muh big data

>>57467522
you'd need a degree and not be retarded
>>
>>57467534
>CS & webdev requires intelligence
lmao
>>
>>57467534
>you'd need a degree and not be retarded>>
Ok, but you didn't answer the question.
>>
>>57467541
>palantir
good luck with that
>>
>>57467553
nothing is hard unless you're retarded
>>
>>57467534
i don't like it either
but we're talking about prospects. thiel was practically the only industry figure to embrace the next president. his company will get as much work as it wants
>>
>>57467581
Ok, whatever sent an app anyways.
>>
>>57454052
triggered
>>
>>57462131
delet dis
>>
what happened to /dpt/? why is it so slow now?
>>
>>57468261
We had two threads going at once because dumb weebs
>>
>>57452968
don't pls
If you are going to use Java and you are some kiddo or pajeet, just use Python instead, its way more confy and better.

If you are serious and want OOP and want a career just use C++

If you are in the middle ue Cython.

Just avoid the smelly old shit Java
>>
File: fig.png (44KB, 400x300px) Image search: [Google]
fig.png
44KB, 400x300px
>>57451610
If I can create a small tile based game, including the A* pathfinding algorith from scratch and Another wolfstein ray casting clone, again all from scratch. As well as all the basics shit (such as phone apps, cross platform stuff etc.)

Am I OKish for a junior dev somewhere ? I want min j dev wage, just to start my career off, nothing special, so I have more time to learn and get better at it.

I was able to do both first in Python, then in C++ and now I am trying to see if its any better if I use Cython and libraries for mobile (so far so good)


All in all, I know I can have nice job if I finished my CS meme degree, but its too late now, I have full time job (nothing related to CS tho) so basically, after 1st year I spend another year learning at home, watching lectures at google and stuff, Udemy, Udacity, torrents everything.

Just asking if anyone has any experience, the whole "getting a job" thing seems so far away, I have this gut feeling that even if they let me in for the interview, they will discard me for not having the said degree. Yet I see ppl saying that degrees doesn't matter and you can get a entry level job, and move on even without one, just slower (and I am ok with this).

>pls respond
>>
>>57468261
normie faggots are on discord
>>
>>57468330
python is trash stupid kid
>>
>>57467126
fucking macfag, go fuck yourself
>>
>>57468434
and java is shit
so you are saying, you want to eat shit, instead of thrash ?
>>
>>57468456
java is literally one of the best languages alongside C++

python is literally one of the worst languages alongside php

kys
>>
>>57468536
prove if faggot, coz I can prove otherwise.
C++ is awesome, dont even put it on the same line as
pajava

And comparing php with python is speaking a lot of your experience with programming, kiddo
>>
I think I broke my brain. I understand that java is pass by value but what why do changes stick when you pass in an object into a method?
>>
>>57468568
Because you're passing a reference by value. You can never actually deal with the object itself, it's always a reference.
>>
>>57468568
Imagine you have a gigantic object, hundreds of megabytes. You want to pass that object into a method. Pure pass by value would mean you have to make a deep copy of it and pass that in, spending the hundreds of megabytes of memory again. Not to mention computation power. This obviously isn't what happens.

Instead they pass a value that is akin to points in C if you're familiar. A dumbed down explanation would be something like, every object created gets an ID, that way you just have to pass in the ID and the method will know which object you're talking about, and not have to make a copy of it. Both the terms pass by value and pass by reference are kind of misleading when it comes to this way of passing arguments, for reason I can't be bothered going into.
>>
>>57468568
Object a = new Object();

a points to an object in memory
doSomething(a);

pass a to a method

public void doSomething(Object b){ }

both A and B are now pointing to the object. If the method ends b will be "released" in a way but A still points to object
>>
I need a good way to build up some shit i can actually put on a resume. ie github contributions, personal projects, something. I need to start with some reasonable projects though, my biggest antagonist is my total lack of motivation or creativity. All my best work has been done when I have some serious pressure on me, from classes or similar. Luckily I'll be dead soon if I don't figure something out, so that makes me hopeful that I'll actually be able to get something going.

So what are some reasonable projects to start working on? I want to do projects small enough that I can manage them in a relatively short amount of time, but also not so simple that they're entirely trivial. Basically what are some things I can make or skills I can show that would trick someone into thinking I'm actually employable?
>>
>>57468568
just look up pointers in C/C++ and you will understand how easy is in Java
>>
>>57468623
public class PassByReferenceConfusion {

public static void main(String args[]) {
Car car = new Car("BMW");
System.out.println("Brand of Car Inside main() before: "+ car.brand);
printBrand(car);
System.out.println("Brand of Car Inside main()after: "+ car.brand);
}

public static void printBrand(Car car){
car.brand = "Maruti";
System.out.println("Brand of Car Inside printBrand(): "+car.brand);
}

private static class Car{
private String brand;

public Car(String brand){
this.brand = brand;
}

}
}

Output:
Brand of Car Inside main() before: BMW
Brand of Car Inside printBrand(): Maruti
Brand of Car Inside main()after: Maruti

I mean like this example I was looking at, why does the brand stay maruti?
>>
>>57468624
This is what I usually do

>had previous work
>use some tool/library/website/etc that is used in work
>tool is ok but its missing something
>make your own tool and add that
>>
>>57468624
Github contributions to other projects count infinitely more than your personal projects, unless your personal projects grows into something that other people contribute to.

Some projects are more open to others smaller, simple changes. If you can find those just start adding comments, fixing typos, writing test cases, maybe making smaller changes to the codebase itself like better variable names or minor refactoring.

That'll get you in the door before you start writing patches to close issues and such, as that requires some familiarity with the codebase.
>>
>>57466572

Is this open-sourced, anon?
>>
>>57468703
    public static void printBrand(Car car){
car = new Car("Poo");
car.brand = "Maruti";
System.out.println("Brand of Car Inside printBrand(): "+car.brand);
}
>>
>>57468741
Fuck it, I'm just gonna try reading about pointers because that just makes me confused on why setting it to a new object doesn't "save" but changing a primitive does
>>
>>57468711
Well, thats fine and dandy but, what if I made mistake myself, like will they "ban" me from doing stuff on their project or some bad "karma" or something ?

Or as long as I contribute with good heart and learn from my (and other's) mistakes its all good ?
>>
>>57468832
It depends a lot on the project you're trying to contribute to.
I think it's safe to say that 95% will either just outright reject your code with little to no constructive criticism, or reject it with some criticism and that will be the end of it.

The only thing I would stay really far away from, especially right now, is anything political. You don't want your name tied to projects like C+equality or whatever in the current political climate. But I think that's pretty much the only thing that could get you ostracized.
>>
>>57468711

That's what I thought, but I also have no real clue how to effectively find things I can actually contribute to, so I didn't focus on it as much in my post. Any advice? I've seen a couple websites that supposedly track things that are relatively simple and looking for contributions, but they don't seem great. Do I just have to search github one-by-one?
>>
So I read up on pointers, so it has the memory address of where something is so you can mess with things directly.
>>57468741
Why does putting a new object into the space from the pointer not allowed though?

>This is useful as it means you can pass references to the object around, without worrying that someone else is going to change its contents
And what does this mean? Doesn't having a reference mean you do have to worry about someone changing it's contents since it's linking directly to the variable?
>>
>>57469094
Scratch the bottom question, I'm dumb
>>
>>57468703
because car variable of main method and car variable of printBrand method are two different variable but point to same object. Whatever printBrand did to the object should be obtained y every other variable

>>57468741
public static void printBrand(Car car)

before this is pointing to the BMW
car = new Car("Poo");

you removed the pointer from BMW and pointed it to a new Poo one


>>57468789
primitives and objects are just two different things. It's just designed for memory conservation, I dunno if I can describe it more simply, it just "fucking works that way"
>>
>>57469094
>Why does putting a new object into the space from the pointer not allowed though?
That's not what you're doing though. The second
xyz = new SomeObject();
doesn't overwrite the thing xyz was pointing to before. It simply points xyz to a new, different object.
>>
I am bad. How do I fix this?
>>
>>57469193
git gud
>>
>>57469155
Ohh now it's making sense
>>
Just wanted to drop in and say that I'm responsible for forcing Haskell in /dpt/.

You're welcome.
>>
File: haskell anime.png (368KB, 498x707px) Image search: [Google]
haskell anime.png
368KB, 498x707px
>>57470034
no you aren't
>>
Why does /g/ hates Java so much?
I'm having fun doing some Spring Boot web stuff like RESTful APIs and MVC applications and now i discover that Java is considered to be absolute evil, and everyone doing Java is considered a Pajeet.
>>
>>57470107
>Why does /g/ hates Java so much?
OOP
>>
>>57468411
You're going to have trouble getting a job in game dev without a degree.

Unlike many areas, game dev requires actual math and CS skills.

Even if you can do enough for the lowest-tier job, they'll be concerned about your ability to progress beyond that.

There's no shortage of skilled applicants; if there was, working conditions would be a lot better than they are.
>>
what's an up-to-date c++ compiler for windows?
>>
File: cute_gentoo_hairclip.jpg (324KB, 768x960px) Image search: [Google]
cute_gentoo_hairclip.jpg
324KB, 768x960px
>>57470107
The only purpose of Java is to hide the futility of a project through abstraction.
>>
>>57470107
> Why does /g/ hates Java so much?
Java enforces the use of OOP, and /g/ doesn't like OOP.

OOP forces you to think about high-level design, which requires that you're at least moderately competent. Like, a few years of full-time programming, which is probably the 90th percentile of /g/'s audience.

If you try to use OOP while you're at the point of having read one textbook and think that ten source files is a large project, it's going to be a clusterfuck.

Also, Java is not exactly "hip". It's a language for people who work in an office and wear a suit. Safety over efficiency, mundane pragmatism over ... pretty much anything, really.
>>
>>57470185
code monkey spotted
>>
>>57470142

GCC.

http://tdm-gcc.tdragon.net/
>>
>>57470136
I didn't put it right, I do not want game dev job, I actually avoid it, I want a simple 8-5 desk job as a junior dev for a year or so, so I can get in the business, my CV so far looks great, but not related in that field in any matter.

Also CS was my second ba degree that I started (and not finished), I have another one with architecture, that involves math at some degree (I guess not as much, or not the same as CS does). So I am not complete idiot.

Does the faggot startups in the valley count as good opportunities ? Or in that sense, any startup.
>>
File: 1475554518847.jpg (85KB, 749x720px) Image search: [Google]
1475554518847.jpg
85KB, 749x720px
>>57470185
>OOP
>high-level design
>>
>>57470185
C++ does the same, yet /g/ likes it, your argument about OOP is invalid.
C++ also requires better forward thinking and strategy as well as general and in depth OOP techniques.

C++ is superior to Java in OOP and many other aspects. Yet, way more harder to learn.

YET /g/ likes it.

JAVA IS JUST SHIT FOR EVERY PAJEET.
>>
>>57453717
with open("file.txt") as f:
words = f.readlines()
for word in words:
if word[::-1] in words:
print(word)
>>
File: 1457255168605.jpg (3MB, 3890x2768px) Image search: [Google]
1457255168605.jpg
3MB, 3890x2768px
#include <functional>

static int foo_auto(int x, auto l)
{
return l(x);
}

static int foo_fun(int x, std::function<int(int)> l)
{
return l(x);
}

int main()
{
for (int i = 0; i < 100000000; i++)
{
foo_auto(3, [](int x){return x * 3;});
//foo_fun(3, [](int x){return x * 3;});
}
}


g++ main.cxx --std=c++14 -Wall -O0
# No optimizations are important for accurate results


# using foo_auto (non-std::function):
$ time ./a.out
./a.out 0.73s user 0.00s system 99% cpu 0.734 total


# using foo_fun (std::function):
$ time ./a.out
./a.out 7.22s user 0.00s system 99% cpu 7.274 total


Friendly reminder not to use std::function.
>>
>>57470232
But anon, the execution always matter.
>>
>>57470232
>C++ does the same
Plain dead wrong and retarded. Fuck off back to your java classes pajeet.
>>
>>57470232
>t. master degree unemployed C fizzbuzz expert
>>
>>57470247
Jesus christ
>>
>>57470232
C++ doesn't force OOP.

Also, it's complicated, fast, and dangerous, which give it a certain amount of hipster cred.

But mostly it's the fact that Java forces OOP and a large chunk of /g/ hates OOP.

Disclaimer: I've spent the last 20 years writing C++ code for a living. For the first half of that, Java didn't exist; much of the latter part has been embedded systems where Java wouldn't be appropriate.

Java certainly doesn't warrant the hate from any kind of objective standpoint. Save that for real shit like JS or PHP.
>>
I have an (Audio)InputStream that I need to split up into multiple InputStreams in java. How would I go about in doing this?
>>
>>57470297
Unrelated, but what are you thoughts on modern C++14 code and features?
>>
File: 1464895673863.jpg (55KB, 1280x720px) Image search: [Google]
1464895673863.jpg
55KB, 1280x720px
>>57470297
>Java certainly doesn't warrant the hate from any kind of objective standpoint.
>>
implementing a search select using dom manipulation. I'll need to refactor the code because I'll be using it again and again.
>>
>>57462575
yes but how can i git gud?
>>
>>57470320
Prove that it does :^)
>>
>>57470320
Wait... you can't sympathizes with the good side, can you?
>>
File: anal beads.png (30KB, 141x1147px) Image search: [Google]
anal beads.png
30KB, 141x1147px
>>57468420
Discord is bretty quiet and off-topic 100% of the time.

>>57468718
Not that anon, but the information is really easy to do. Just plug into your preferred GUI.

This probably isn't perfect, but only took about 30 seconds because I already have a library to pull 4chan things:
Chan.GetBoard().Boards
.Select(x => x.BoardName)
.Select(x => $"{x.PadRight(5)}: {Chan.GetThreadPage(x, 1).Threads.First(y => !y.Posts.First().IsStickied).Posts.First().PostNumber}")
.ForEach(WriteLine);
>>
>>57470297
I don't necessarily hate Java, but it's really hard to use once you've used C#.
>>
>>57470401
>functional programming
>>
>>57470431
Multiparadigm, mate. That ain't a functional language, and that snippet of code ain't purely functional.
>>
>>57470443
It is purely functional, in the sense that it is exclusively functional. It isn't pure, but it could be

haskell equivalent:

boards (getBoard chan)
& map boardName
& map (printf ...)
& mapM_ print
>>
That's a nice stack you have there.

It'd be a shame if something happened to it.

;^)

private int thing;
public int Thing
{
get { return Thing; }
}
>>
>>57470458
delet this
>>
What a pajeet?
>>
let pop = function
| [] -> failwith "empty stack"
| x :: stack -> x, stack
;;

let apply_word stack word =
let op =
match word with
| "+" -> Some ( +. )
| "-" -> Some ( -. )
| "*" -> Some ( *. )
| "/" -> Some ( /. )
| "^" -> Some ( ** )
| _ -> None in
match op with
| Some op ->
let y, stack = pop stack in
let x, stack = pop stack in
op x y :: stack
| None ->
try
let x = float_of_string word in
x :: stack
with
| Failure _ -> failwith (Printf.sprintf "unknown: %S" word)
;;

let apply_line stack line =
try
let ib = Scanf.Scanning.from_string line in
Scanf.bscanf ib " " ();
let rec loop stack =
if Scanf.Scanning.end_of_input ib then
stack
else
Scanf.bscanf
ib " %s "
(fun word ->
let stack = apply_word stack word in
loop stack) in
loop stack
with
| Failure message ->
prerr_endline message;
stack
;;

let print_stack stack =
let rec loop i = function
| [] -> ()
| x :: xs ->
loop (succ i) xs;
Printf.printf "%d:\t%F" i x;
print_newline () in
loop 1 stack
;;

let rec main_loop stack =
print_stack stack;
let line = read_line () in
let stack = apply_line stack line in
main_loop stack
;;

let () = main_loop [];;
>>
>>57470494
Someone who only writes code.
>>
>>57470511
rewrite this in haskell
>>
>>57470538
No. I'm paid for producing OCaml code, I won't code in Haskell.
>>
>>57470259
You never saw the whole comment, didn't you, sjw
>>
>>57454535
need font and color scheme please
will provide lewd list code in return
>>
NEW THREAD

>>57470763
>>57470763
>>57470763

NEW THREAD
>>
>>57470592
>Randomly assuming I'm an SJW
What the fuck is wrong with you.
>>
>>57471420
you used pajeet
Thread posts: 334
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.