[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: 339
Thread images: 33

File: 1467387907257.png (1MB, 1000x1400px) Image search: [Google]
1467387907257.png
1MB, 1000x1400px
Old thread: >>55677105

What are you working on, /g/?
>>
first for Java is king
>>
>>55688901

first for java

btw best spring tutorial aside from documentation which is not that bad but still a little too verbose ?
>>
>>55688901
Please stop with this stupid programming trap meme.
It's not funny or endearing in any way.
>>
>>55688949
No.
>>
File: o0412060010713180731.jpg (24KB, 412x600px) Image search: [Google]
o0412060010713180731.jpg
24KB, 412x600px
Just fixed a problem which has been bugging me for weeks.

Now onto the next big problem which will bug me for weeks.
>>
>>55688901
Fuck off with your stupid forced meme.
>>
File: Screenshot_2016-07-21_23-40-29.png (217KB, 518x681px) Image search: [Google]
Screenshot_2016-07-21_23-40-29.png
217KB, 518x681px
Wish me luck lads.
>>
>>55688835
>>
File: 1469137185.png (13KB, 119x532px) Image search: [Google]
1469137185.png
13KB, 119x532px
python
this is my array
how do I remove purple ones?
I would call it every 3rd item I guess
its one I dont want, 2 I want, 1 out, 2 stay

final array should be without any purples, but will all the others

it feels like it should be trivial
like, enumarate for and checking if its divisable, but by what

then I am thinking, I am going to split that large array in to smaller chunks of 3 items, remove first item from each chnk and then put them together

but that sounds retarded plus spliting I am not sure how,
>>
>>55689196
Try something like this:

list = [1,2,3,4,5,5,5,6]
filtered_list = [elem for elem in list if elem != 5]
>>
Reposting my bullshit from the tail end of the last thread:

Anyone here ever work with a dysfunctional team? I've been on this team for about a month now, ~20 people randing from QA, Escalation, devs and a tech writer.

there is 3-4 senior devs but no one is the "top dog".

The product its self was inherited and is absolute fucking trash in terms of how it was built, talking 20k lines of javascript for the webclient.

everyone seems to agree that shit is wrong but nothing is being done about it, any advice? I don't want to bail (pay/benefits are good) but fuck am I stressed out after a month of this.
>>
How do lisp/scheme macros work?
>>
>>55688901
What's a good way to set up notifications that is not emailing?

I have some bot that is run by a crontab every half an hour, and I'd like to know when the bot posts something or when it encounters an error. However, I don't want to get a million emails. I was thinking to set up WhatsApp but it seems like I need a phone number that doesn't use whatsapp and not sure if they have an official API (and cba to keep maintaining when the unofficial API breaks)

What's something that notifies me everywhere (home, phone, work) I was also considering Slack but not sure, I only ever used it for work

>>55689162
maybe
d[ip_address1] = d.get(ip_address1, 0) + 1
if d[ip_address1] == 1:
print(...)
>>
Hey! Working on a chunk of golang code that reads and writes to a MongoDB server. The DB responses are supposed to have a similar feel to a digraph.
>>
>>55689257
filtered_list = filter(lambda x: x!=5, list)
>>
>>55689313
>muh functional pyton
list comprehensions are faster
>>
>>55688901
Nothing as I don't know jack shit about programming.
>>
>>55689324
>list comprehensions are faster
prove it.
>>
>>55688901
Is that book a meme?
I keep seeing it a lot.

Also, where's that girl from?
>>
Given a non-empty 2D matrix matrix and an integer k, find the max sum of a rectangle in the matrix such that its sum is no larger than k.

Given matrix = [
[1, 0, 1],
[0, -2, 3]
]
k = 2

The answer is 2. Because the sum of rectangle [[0, 1], [-2, 3]] is 2 and 2 is the max number no larger than k (k = 2).

Note:

The rectangle inside the matrix must have an area > 0.
What if the number of rows is much larger than the number of columns?
>>
>>55689356
>do my work for me

 python -c 'import timeit; help(timeit)'
>>
File: 1439851835548.png (490KB, 526x895px) Image search: [Google]
1439851835548.png
490KB, 526x895px
>>55689366
Himegoto
Not a meme
>>
>>55689387
you still didn't prove it.

fuck off
>>
>>55689432
cry more n00b
>>
>>55689259
Yes. It sounds like your problem is poor project management and poor design criteria. Both things if not corrected for can easily doom a project in the long term. Weirdly though such projects can still sustain businesses for many years.

Chill out, don't take things too seriously. If your starting to get burned out with it see if you can work on something else (if they're the sort of place to be starting new projects), otherwise start looking around for a new job. It's not worth it being stressed in the long term since you can really fuck up your health.

In my experience unless someone takes the reins and brings about serious order, it's not going to happen by itself.
>>
>>55689366
>girl
I have news for you
>>
File: heil.png (18KB, 520x175px) Image search: [Google]
heil.png
18KB, 520x175px
>>55689302
Also, I just finished up a twitter bot that posts images from danbooru and writes sporadic shit.
>>
>>55689440
muh functional pyton is faster than list comprehension

cry more
>>
>>55689464
at the end of the day only one of us is right doe ;]
>>
>>55689196
you mean like this?

def remove_every_third_element(l):
return [e for (i, e) in enumerate(l) if i % 3 != 0]
>>
>>55689381
summing of matrixes must have the same dimensions
>>
>>55689298
bump
>>
>>55689555
what about tweets?
>>
>>55689569
That's actually smart and useful. Too bad I don't really use Twitter
>>
39th for fuck Oauth2
>>
>>55689608
just use a library mang
>>
>>55689298
xmpp?
>>
So is the general idea of "yield" in C# just "return here and if this method is called again restart execution after the yield instead of from the beginning"?
>>
I want to learn something useful and new. I know Java and Python. What should I program as a somewhat beginner programmer? I know most data structures and how classes work and things like that.
>>
>>55689632
That sounds like a good idea but what are some relatively popular modern cross-platform clients that use XMPP?
>>
>>55689701
Pidgin for example
there's a lot of them
>>
Im building my own duplicate image finder. I know these exist already but fuck that, its a fun challenge and fun researching about measuring color distance etc
>>
>>55689778
>color distance
>not using convolutional neural networks and natural language processing to describe images and measure the similarity between descriptions
>not at least using machine learning to train a classifier on similar images and output confidence levels
>color distance
>>
>>55689667
FizzBuzz
>>
>>55689836
Its supposed to find images that are exactly the same, but maybe of higher/lower resolution or quality as well, therefore I can't just compare pixels for exact color matching.
>>
How do I make this not go into double nested code?

if items:
for item in items:
<code>
>>
>>55689972
u cant
>>
>>55688901
Fuck your weaboo shit
>>
>>55688901
Kill yourself weabfag
>>
>>55689264
Macros take an AST and transform it into another (hopefully valid) AST. Basic lisp macro systems have it so that you explicitly provide a function that takes an AST (in the form of nested lists, as if you quoted an sexp) and returns an AST. This can cause issues with variable name collisions so typically lisps with this form of macro provide "gensym" or something like it, which generates symbols with unique names.

Scheme macros are a kind of "hygienic macro", which means it automatically does the name substitutions and shit for you, guessing from context where a name actually refers to. Scheme macros also have some pattern matching you can do in your macro, you don't just give a function that transforms ASTs. Scheme macros are harder to explain that ordinary AST transformers to maybe you should look it up.

So basically macros have some sort of code associated with them that will change the input syntax into the result syntax. If it's a compiler, it will need access to an interpreter at compile-time so it can expand macros.
>>
>>55690193
>>55690208

(((pure coincidence)))
>>
>>55688901
Bake yourself a nice cake weab-tan :3
>>
>>55690234
Fuck off with your shit tier facebook faggotry
>>
how come no one talks about swift or objective-c here?
>>
>>55690421
Because both are shit.
>>
>>55690421
> swift

there's a reason it's only two characters away from shit
>>
>>55690421

This is /g/ it's going to be mostly Linux / windows developers
>>
>>55690297
>inspect element
Go troll >>/b/
>>
>>55690511
>inspect element
>in a mobile app
Jesus Christ you're autistic
>>
>>55690575
Yeah, because he can tell which medium your parents bought you you're using.
>>
>>55690698
>>55690511
God damnit you're one autistic fuck. I bet your parents wish you were a blowjob instead.
>>
I want to be as great as you fags at programming. How do I git gud?
>>
>>55690923
Program.
>>
>>55689667
Help please!!! I feel myself stagnating. Not learning anything. I want to work. I want to learn. I want to get good.
>>
>>55690729
>phoneposter insulting anyone
you're a huge faggot
>>
>>55688901
getting a job
>>
>>55690923
Install git
echo -e '#!/bin/sh\necho git gud' > bin/git-gud && chmod +x bin/git-gud

git gud
>>
Do you think you could train an LSTM to determine how shit a thread is?
>>
>>55691045

Probably could be calculated just by weighing the number of insults in the thread. Typically the more times "Faggot, autistic, and fuck" appear in a dpt the more likely it is to be a cesspool until the next one starts.
>>
>>55691045
Yeah just search for how many times the word Haskell is mentioned.
>>
How do I resolve this?

Error:(14, 23) java: incompatible types: java.lang.String cannot be converted to java.net.URL

public static void main(String[] args) {
Scanner input = new Scanner(System.in);
URL archive = new URL("");
System.out.println("What board would you like to search?");
String query = input.next();
if (query.equals("pol")) {
archive = "http://archive.4plebs.org";
}
System.out.println(archive);
}
}


Also is there a better way to do this than to make if statements like this:

if(board.equals(a)||board.equals(b)||...||...||...
>>
File: gitgud.png (8KB, 164x86px) Image search: [Google]
gitgud.png
8KB, 164x86px
>>55690998
>>
http://clhs.lisp.se/Body/f_car_c.htm

lol
>>
>>55688901
Fuck off this programming fag meme
>>
>>55691280
kys
>>
>>55691212
You're trying to assign a String object to a URL object. Read the java.net.URL documentation to resolve this issue.

>Also is there a better way to do this than to make if statements like this:
Using a lookup table.
>>
>>55691212
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
URL archive; // <------
System.out.println("What board would you like to search?");
String query = input.next();
if (query.equals("pol")) {
archive = new URL("http://archive.4plebs.org"); // <--------
}
System.out.println(archive);
}
}
>>
>>55690968
That sure showed him!
>>
>>55691212
Wait a minute lads!!! I GOT IT!!

public class Main {

public static void main(String[] args) throws MalformedURLException {
Scanner input = new Scanner(System.in);
String url = null;
System.out.println("What board would you like to search?");
String query = input.next();
if (query.equals("pol")) {
url = "http://archive.4plebs.org";
}
URL archive = new URL(url);
System.out.println(archive);
}


>>55691300
Hash table? Dictionary? Anyway to make the code less cluttered? I'm assuming making the hash table a .txt file and creating it by reading in the .txt?
>>55691301
I did something similar.
>>
>>55691338
>I did something similar.
there's no need to create a new string, but whatever
>>
>>55689127
God, programming book covers are utter shit.
>>
>>55691370
That doesn't work. You can't create a variable in an if statement, because the variable doesn't exist UNLESS the if statements conditions are met. I tried your version and it was wrong.

Error:(16, 28) java: cannot find symbol
symbol: variable archive
location: class com.company.Main
>>
File: Screenshot - 220716 - 01:19:14.png (247KB, 505x651px) Image search: [Google]
Screenshot - 220716 - 01:19:14.png
247KB, 505x651px
>>55691382
>>
>>55689196
You mean

[x | x<-xs, 3 /= mod x 3]
>>
>>55691402
>>>55691370 (You)
>That doesn't work. You can't create a variable in an if statement, because the variable doesn't exist UNLESS the if statements conditions are met. I tried your version and it was wrong.
just initialize archive then

 URL archive = null; // <------
>>
>>55691382
What's wrong with a silver fern? At least, I think that is what it is.
There isn't really much related to programming that you could put on a book cover, so people just put random shit.
>>
>>55691411
>javascript
>programming
>>
>>55691424
what is this? memeskel?
>>
>>55691443
That is exactly what I did at first when it gave me my error..
>>
>>55691457
top meme my man! keep it up
>>
>>55691460
You mean Haskell? Yes

[x | x<-xs, 0 /= mod x 3]
>>
>>55691483
explain the code you posted

can't undersartand shit
>>
>>55690102
u cunt

>>55689972
for item in items or []:
<code>
>>
>>55691483
Loop trough xs and take all x which has modulo (remainder of the division) 0.

It's high school maths, you.
>>
>>55691498
It's just a list of numbers that were in the list xs that aren't a multiple of 3.
>>
>>55691483
filter ((0/=) . (flip mod 3))
>>
>get back to working on a project that I was working on yesterday
>wondering why these two functions weren't working
>turns out I declared them, but forgot to actually implement them
Nice job me
>>
>>55691678
ahahah
>>
File: 1469042675299.jpg (57KB, 1280x720px) Image search: [Google]
1469042675299.jpg
57KB, 1280x720px
>>55691678
>mfw I don't need to "implement" my functions
>>
>>55691771
how cum?
>>
>>55689972
Just do for item in items, if it's empty the body won't execute.
>>
>>55690923
haha no you don't
>>
I am making my lisp. I wonder, should a string be a seperate type or a list and why?
If it is a list, how will functions like print know if it is a string?
If it is not a list it would be difficult and painful to handle strings as the functions would be different than the list ones.
>>
>>55691912
>should a string be a seperate type or a list and why
Whichever. A separate type is faster if you use a vector.

>If it is a list, how will functions like print know if it is a string?
You'd need to print all homogenous lists of characters as strings. Haskell does this.

>If it is not a list it would be difficult and painful to handle strings as the functions would be different than the list ones.
Slightly. You could go the polymorphic route and generalize strings as a sequence and define a set of operations that work across all sequences.
>>
>>55691817
Haskell
>>
>>55692033
>Slightly. You could go the polymorphic route and generalize strings as a sequence and define a set of operations that work across all sequences.
This seems like a fine idea.

>Whichever. A separate type is faster if you use a vector.
The list type under the hood includes array and actual list types. Depending on the usage each time.

>You'd need to print all homogenous lists of characters as strings. Haskell does this.
And this makes another question arise, should I have an actual character type?
I do know that Erlang, while it does not have a character type, it prints all lists with integers in it as strings.
>>
So if I want to learn more than one programing languages, would it be a good idea to focus on one or keep switching between them?
>>
>>55692088
>And this makes another question arise, should I have an actual character type?
I had a separate type for mine. Integers aren't really a proper character type unless you want to use UTF-32 encoded characters. There are pros and cons to various character encodings -- UTF-32 is sort of nice because it's simple and is unicode. It's bad because a lot of documents just store ASCII characters and you're using 4x the bits necessary per character. You'd probably use a library rather than implement UTF-8 or UTF-16 support by hand. Since my Lisp was an educational project, I restricted my char set to ASCII and called it a day.
>>
Map <String,String> archives = new HashMap <String,String>();
archives.put("a", "www.google.com");
System.out.println("What board would you like to search?");
Scanner input = new Scanner(System.in);
String query = input.next();
System.out.println(archives.get(input));


Why am I getting a null value from this?
>>
>>55692258
AHHH NEVER MIND.
>>
>>55692178
Are you at college anon?
>>
anybody else write a compiler
>>
>>55692295
Yes, currently at internship for summer tho
>>
>>55692383
I've written a console hangman game, pretty much the same level of competency.
>>
Trying to do the challenges in Project Euler because I'm a chump.

I'm currently stuck on problem 13, adding 100 50-digit numbers together, and I'm having a bit of trouble.

The way I'm going about this is that, I know I don't need to add all of the numbers, only the first ten digits of each number and you don't necessarily need the rest.

I formatted the numbers in here:
https://projecteuler.net/problem=13
and stored them into a string array, Here's my implementation of the result

    for(int i = 0; i < 100; i++)
{
SUM += stringToInt(numsToAdd[i].substr(40, 10));
}

unsigned long long int stringToInt(std::string conversion)
{
unsigned long long int retVal = 0;
int counter = 9;
for(int i = 0; i < conversion.length(); i++)
{
retVal += ( (conversion[i]-'0') * pow(10, counter));
counter--;
}
std::cout << "Returning " << retVal << std::endl;
return retVal;
}
>>
>>55692383
just use the free monad
>>
File: hangman.gif (1MB, 766x604px) Image search: [Google]
hangman.gif
1MB, 766x604px
rate my hangman function.

also why doesn't 4chan allow vp9 webms, i can't seem to get ffmpeg to output vp8.
>>
File: Screenshot_2016-07-21_21-09-52.png (742KB, 1600x900px) Image search: [Google]
Screenshot_2016-07-21_21-09-52.png
742KB, 1600x900px
Finished getting basic IO setup on my VM. Shit on the right is the bytecode, basically all it does is read 8 characters and then outputs 8 characters.

Also, could anyone rec a better hex editor? I have to exit out of this one whenever I want to save the current file and I hate it.
>>
>>55692697
Mathematica?
>>
>>55692697
Pretty good! I enjoyed the graphics, but I'm a bit confused as to why the letters seemed to move after you click them
>>
>>55688901
my own x86 disassembler written in C++.
>>
>>55692719
yep.

>>55692722
that's just the Grid function doing it's thing.
>>
Alright lads. Now it's time to display the text on the screen. How do I do that?
        Map <String,String> archives = new HashMap <String,String>();
archives.put("a", "https://boards.fireden.net");
archives.put("g", "https://archive.rebeccablacktech.com");
archives.put("int", "http://desuarchive.org");
archives.put("lit", "http://warosu.org");
archives.put("mu", "https://archive.rebeccablacktech.com");
archives.put("pol", "http://archive.4plebs.org");
archives.put("r9k", "http://desuarchive.org");
archives.put("v", "https://boards.fireden.net");
archives.put("vg", "https://boards.fireden.net");

System.out.println("What board would you like to search?");
Scanner input = new Scanner(System.in);
String board = input.next();
System.out.println("What would you like to search for?");
String query = input.next();
URL archive = new URL(archives.get(board)+"/"+board+"/search/text/"+query); Map <String,String> archives = new HashMap <String,String>();
archives.put("a", "https://boards.fireden.net");
archives.put("g", "https://archive.rebeccablacktech.com");
archives.put("int", "http://desuarchive.org");
archives.put("lit", "http://warosu.org");
archives.put("mu", "https://archive.rebeccablacktech.com");
archives.put("pol", "http://archive.4plebs.org");
archives.put("r9k", "http://desuarchive.org");
archives.put("v", "https://boards.fireden.net");
archives.put("vg", "https://boards.fireden.net");

System.out.println("What board would you like to search?");
Scanner input = new Scanner(System.in);
String board = input.next();
System.out.println("What would you like to search for?");
String query = input.next();
URL archive = new URL(archives.get(board)+"/"+board+"/search/text/"+query);
>>
>>55692735
>archives.put
>archives.put
>archives.put
>archives.put
>archives.put
>archives.put
>>
>>55692802
Am I doing something wrong?
>>
>>55692824
stop repeating yourself
>>
How many of you in this thread self-taugh or did you do Comp Sci?
>>
>>55692824
>>55692846
you could put it into two lists or one list of tuples and then add every element in the list
>>
>>55692846
I have to put all of them in the map you dummy, not just one.
>>
>>55692851
I've been self-teaching for a year, but I don't feel employable yet.
>>
>>55692865
I'm thinking of teaching myself Java and HTML/CSS. I'm currently studying Graphic Design but have a much higher interest in the UX/UI and Web Design/Developing side of things rather than the print side.
>>
>>55692824
Use an array with all your boards and then use an array instead of all these "put".
>>
>>55692862
Oh it's Java
Nevermind, you get what you deserve
>>
>>55692851
I did a year in college then dropped out. Even in college I was mostly self-teaching.
>>
>>55692902
I really don't want to go back to college, I was self-teaching programming and data structures the entire time and I feel like I was wasting my time doing with general ed.
I haven't even made any real progress toward major specific coursework as a CS major.
>>
>>55692897
What is the point? I'd have to iterate through a loop to put all the elements in the map. I don't care if theres a few extra lines of code.

I need to now somehow get the contents of each post and print them on the screen... that's what I asked about.
>>
>>55692923
>I feel like I was wasting my time with general ed.
This is what made me decide to leave. I understand that without a degree it's going to harder to get a first job but I'd rather bust ass studying comp sci than the other classes I would've taken. How far into college are you?
>>
>>55692961
Retrofit and GSON with the 4chan api
>>
>>55692718

" vim -b : edit binary using xxd-format!
augroup Binary
au!
au BufReadPre *.bin let &bin=1
au BufReadPost *.bin if &bin | %!xxd
au BufReadPost *.bin set ft=xxd | endif
au BufWritePre *.bin if &bin | %!xxd -r
au BufWritePre *.bin endif
au BufWritePost *.bin if &bin | %!xxd
au BufWritePost *.bin set nomod | endif
augroup END


Vim works perfectly fine as a hex editor.
>>
>>55692998
I don't know what any of that stuff is... and the 4chan API works for external 4chan archives?
>>
adding analytics to https://nigge.rs
>>
>>55692975
I did 2 years.
I had done 1 programming related course the entire time and it only taught me horrible habits in C++ and Java.
It made me feel like college is a mistake if I just want to write software.
>>
>>55693086
I don't know if it works for external archives but if you're using Java and are going to be interacting with a REST api in nearly any circumstance, use Retrofit and GSON (also RxJava for built in threading for Retrofit). It's pretty simple to learn and it makes the whole thing an interface class for defining api calls and a call instance for getting the data. It is soooooo worth learning, you'll want to bash your head into a table for ever manually doing api calls and scraping json.
>>
>>55693116
If you accept that it's going to be that much tougher to get started with a career and are prepared to deal with that, then dropping out isn't the end of everything.
>>
>>55693116

College isn't about teaching you to get a job. It's about accruing more student loan debt that cannot be escaped.

Quite honestly most college graduates now are getting set up with a giant bill and no jobs.
>>
>>55692672
USE PYTHON
S
E

P
Y
T
H
O
N
>>
>>55693116
In this day and age you can self-teach anything you want to because of the internet.
>>
>>55693081
Actually, I probably won't use vim, but you made me realize emacs probably has a hex mode
Thanks m80
>>
>>55693218
>>55693163
>>55693158
I read conflicting information everywhere on the viability of someone being hired without a degree simply because everyone asks for a CS degree and 5 years experience for an entry level junior developer position.
And it's not even a matter of being incapable of getting your foot in the door, they simply autofilter you.
>>
>>55693250
I imagine it'd help to have something to show competency, so my suggestion would be to create a portfolio of actually useful programs. That might help getting hired.
>>
>>55693250

Conflicting information on degrees is because the colleges, student loan corporations, and government are putting out purposely skewed data to get more people to take loans.

It's true you have to get a degree and spend enough money to buy a house or put a down payment on a house just to get auto filter at a lot of places for a bs entry level position. Sadly this is just a side effect of the horrible condition our economy is in.

If you're not in the top 10% we're actually worse than back in 2008. They counting all the people who have been searching for jobs and not getting them as not in the work force. Most people don't even have a net worth of more than $100. It's normal to be paying out around 50% of your income on housing.
>>
>>55693172
Disgusting language, your mother would be ashamed
Can't believe someone just recommended this in /dpt/ of all places
>>
>>55693345

Let me correct this post.. I just woke up and haven't had caffeine yet so it's fucked to hell and back.

"It's true that you have to get a degree and spend enough money to buy a house or put a down payment on a house to just get out of the auto filtering at a lot of places for a bs entry level position. Sadly, this is just a side effect of the horrible condition our economy is in. Everyone outside the top 10% is actually worse off economically than they were back in 2008. The job statistics are counting all the people who have been searching for jobs and not getting them as not in the work force. The net worth of most people isn't even $100. It's normal for the average person to be spending around 50% of their income on just housing."

Don't post within minutes of waking up on a day off. It'll result in a jumbled up unreadable mess.
>>
>>55691498
"all x such that x comes from a list of exes, or xs (hence x"S") and x isn't divisble by 3"
>>
>>55689456
share twitter pls
>>
>>55693235
emacs does, but entering anything into it is a pain in the fucking ass
>>
File: putin-steals.gif (3MB, 400x200px) Image search: [Google]
putin-steals.gif
3MB, 400x200px
>>55692735
>code that looks like an 8th grade essay
>>
>>55691483
>>55691460

you mean Hasklel
>>
>>55693473
Really? I'll fuck around with both then, see what I think
>>
>>55693678
it's also very poorly documenated as far as im concerned

if you understand elisp, read this to get an idea of how to configure it:
https://github.com/emacs-mirror/emacs/blob/master/lisp/hexl.el
>>
I'm so nervous. I thought I did well in an interview about a little more than a week ago. They were really friendly and said they would get back to me when they're ready, just that they're really busy. I sent them an email yesterday and still no reply. I really need to work soon ):

it's my fault thinking I gotten it and didn't apply to more.
>>
>>55693947
They may be really busy...like you just said. Don't let your needs corrupt your confidence.
>>
>>55693985
Okay, thanks. Honestly I've been trying to tell myself this but hearing it from another is nice assurance. Thanks.
>>
help me, g

I'm learning C. I've gone ahead and written a Chip-8 emulator / interpreter, and I started on making a Chip-8 compiler but compilers take a long ass time to learn to make and I want to keep my skills fresh.

What do I code?
Networking in C / C++ is just pure hoops without libraries. I've already done a bunch of project euler challenges. Also wrote a self balancing btree.
>>
>>55693131
This guy here again. Just needed an HTML parser. Used Jsoup. This is what I got...

System.out.println("What board would you like to search?");
Scanner input = new Scanner(System.in);
String board = input.next();
System.out.println("What would you like to search for?");
String query = input.next();
URL archive = new URL(archives.get(board) + "/" + board + "/search/text/" + query);

//System.out.println(archive);
Connection connection = Jsoup.connect(String.valueOf(archive));
connection.userAgent("Mozilla/5.0");
Document doc = connection.get();
Elements elements = doc.select("div [class=text]");

System.out.println(elements.toString());

Sample output:

<div class="text"> 
<span class="greentext"><a href="http://archive.4plebs.org/pol/post/82167638/" class="backlink" data-function="highlight" data-backlink="true" data-board="pol" data-post="82167638">&gt;&gt;82167638</a></span>
<br>
<span class="greentext">&gt;this is actually how Trump supporters feel</span>


Now to remove all that nasty HTML and just get the raw text. How do I do that?
>>
>>55694228

Filter out any text in "" or between > and < ignore it if it is empty whitespace.
>>
C really is like plumbing while high on glue.
>>
>>55694139
Minimal HTTP server.
>>
File: ????.jpg (45KB, 577x622px) Image search: [Google]
????.jpg
45KB, 577x622px
Any examples of a symbol table implemented as a binary search tree in C?
I typically see people just use enums for identifiers that only map a single value.
Are there cases where a type has to have multiple attributes?
Trying to write a recursive descent parser here.
>>
>>55694548
Holy crap anon I'm trying to make a lexer / parser for a compiler too

I can't help you much, i'm pretty bad but

don't give up!
>>
What library could I use for cross platform audio in a C++ program?
I'm already using SDL2, should I use it? I tried SDL2_mixer in my last program (an extension, or rather a wrapper to SDL's own audio system), but it had a nasty bug which made it not play sound on some Windows machines at all. Any ideas?
>>
Have you guys seen this?

https://github.com/andlabs/libui

I think that's a pretty cool idea!
>>
>>55694548
>>55694579
Why not just use LLVM?
>>
>>55693947
My current boss kept me waiting for 2 weeks before contacting me. Don't lose hope, but keep sending resumes everyday, like at least 20 a day.
>>
>>55694637
Self-education for me. Idk about other anon
>>
>>55694630
What's the point when Qt exists?
>>
>>55694650
libui is C, Qt is C++. That's about it.
>>
>>55694228
Why you would parse html and not use the fucking api is amazing. Your name might as well be Pajeet.
>>
>>55692672
>>55693172
>>55693395
U N I X
N
I
X
paste -sd+ input_numbers.txt | bc | cut -c -10
>>
>>55692672
Just use a BigInteger. Even if you only use the first 10 digits, it would still overflow. Or use another language for this problem that has infinite integers.
>>
>>55692735
>>55692802
>>55692824
>>55692897
>>55692961
>>55692998
>>55693086
>>55693131
Being this fucking ignorant. Fuck you, pajeet
>>
>>55692672
>>55693172
>>55693395
>>55694890
A W K
W
K
awk '{sum += $1} END{print substr(sum, 0, 10)}' input_numbers.txt
>>
>>55694920
>projecting this hard
>>
>>55692672
>>55693172
>>55693395
>>55694890
>>55694945
P Y T H O N
Y
T
H
O
N
python -c "import sys; print str(sum((int(i) for i in sys.stdin)))[:10]" < input_numbers.txt
>>
File: duty_calls.png (14KB, 300x330px) Image search: [Google]
duty_calls.png
14KB, 300x330px
>>55694988
le rage is filling me
>>
>>55695072
Because this is more elegant than >>55694945's solution, right?
>>
>>55688901

Dunno if this counts as proper program or whatever, but...

Having some issues with a bash script, Var1 and Var2 aren't returning anything. What am I missing?

#!/bin/sh

for f in $SrcFile
do
echo "Checking file $f"
Var1=`cat $f | $DateVar`
echo $Var1
Var2=`cat $f | $RefVar`
echo $Var2
done
>>
>>55695183

Sorry, the variables...

SrcFile="/text/PREFIX*"
DateVar="grep '^FFU' | sed 's/\^FFU\([0-9]\+\).*/\1/g'"
RefVar="grep '^FFZ'"
>>
>jquery
Is there a more obnoxious syntax than this garbage?
>>
>>55695183
>>55695224
Use a site called whose name starts with 'shell', ends in 'check', and has a TLD of 'net'.

Use it on your script to catch common errors. I see several in your script.
>>
>>55695273

Legend, thanks.

Got a few errors about UUOC (Useless Use of Cat), will need to figure out how to get rid of this.
>>
>>55692034
yes sure feels good to have no difference between
fib n = fib (n - 1) + fib (n - 2)

and
fibloop !a b n = fibloop (a + b) a (n - 1)
>>
>>55694228
sed -e 's/<[^>]*>//'
>>
>>55695328
Don't use 'cat'...

So you want to print the lines that art with "FFZ", and also print the lines starting with "FFU[0-9].*" but changed so that they end up being "FFU[0-9]?
>>
>>55695380
>>55695183
>>55695224
>>55695328
I'm not sure if you want the introductory "FFU" but this does what you want if you do:

grep -Eo "(^FFU[0-9]+|^FFZ)" /text/PREFIX*
>>
>>55695328
>>55695416
If you don't want the introductory FFU then you can use:
grep -Po "(^FFU\K[0-9]+|^FFZ)" /text/PREFIX*

Alternatively:
grep -Po "((?<=^FFU)[0-9]+|^FFZ)" /text/PREFIX*
>>
http://pastebin.com/vBDTxmp4

What the fuck is this shit? How can there be uninitialized bytes inside a block allocated by calloc (something uninitialized memcpy'd into the block I guess?). How the fuck do I stop it happening.
>>
>tfw we you found your old college flashdrive with your old programming activities in visual basic
god i felt really old
>>
In libreoffice calc, how do I check whether any element of a given range conforms to a certain condition?

Say I want to know whether the value of one of the cells A12:A20 equals 20, then
=if(A12:A20=20, "yes", "no")

returns Error:502.
>>
> C++11

how the fuck does this work and the loop knows where to stop ?

   int i[10]={0};

for (int& j: i)
std::cout<< j << std::endl;
>>
>>55696485
It calls std::begin, and std::end internally, and it has a special overload for built-in arrays:

template <class T, std::size_t N>
T* begin( T (&array)[N] );
>>
>>55689298
LeBump.Jpg
>>
>>55696655
great, so it's standard C++?
>>
>>55688901
Working on a pre-compiler c++ check for beginning students at my school. Almost done.
>>
>>55689298
Boxcar 2 for iOS. Just send a POST request to an API and you'll get a push message on your phone.
>>
>>55694139
if you're so advanced then maybe join a bigger free software project and work on something useful while learning from others
>>
>>55696757
Yup, you can define begin, and end in your own containers, and the range-based for loop will work with them as well.

In C++17 it's going to look even easier:
for (i : j) {
}
>>
>>55696757
Yes
>>
>>55696783
>In C++17 it's going to look even easier:
>easier

How is that easier? All type information, including whether or not it's an reference, is lost.
>>
>>55696807
It'll be an universal reference internally.
>>
>>55696839
So what if I don't want a reference and want to call the copy constructor?
>>
>>55696851
You just explicitly state it like before.
>>
>>55696851
for (auto i : j)
>>
>>55696861
or maybe you'll need to use the type, I don't know this shit yet
>>
>>55696876
You wouldn't, auto is perfectly fine in this context.
>>
>>55696860
>>55696861
>>55696876
>>55696888
I can see all sort of troubles with this. In old C, a reference with no type declaration would default to type int.
>>
>>55696901
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0184r0.html
>>
>>55696914
I realise it is part of the standard, I'm just saying that C++ is trying too hard to be like Python
>>
>>55696934
> C++ is trying too hard to be like Python
yep, just saw this as I was reading about the new stuff

for(auto&& [first,second] : mymap) {
// use first and second
}


the key difference is that behind C++ is a committee of scientists who hopefully wouldn't compromise efficiency too much
>>
>>55696976
>wouldn't compromise efficiency
>exceptions
>virtual functions
>templates
>practically every other feature
>>
Any guys proficient in ZOPE TAL?
<div tal:define="global rownumus python: 1">
<td class="analysis tableIndexColumn">
<span tal:define="global rownumus python: rownumus + 1"></span>
<span tal:content="rownumus">#####</span>
</td>
</div>

This code only gives me rows filled with 2.
I need to have rows 2, 3, 4, 5 and so on.
What can I do?
>>
>>55697081
Templates don't compromise efficiency.
>>
>>55697081
>>templates
nothing wrong with that, the compiler creates only the necessary instances
>>
>>55697081
Templates are resolved in compile time you fucking faggot. Exceptions have little penalty cost other than escaping scope (which function returns do anyway, so basically, it's a glorified return/longjump). Virtual functions only have the small penalty of having to look up in a table, which is only going to matter if you have extremely few registers and/or an extremely small cache, or if you have so many objects and threads that you're thrashing the cache
>>
>>55696901
>I can see
No you don't. The people designing sepples are experts with more years of experience each than you are old They work very carefully and weight all possibilities and risks.


>>55697081
>templates
>compromise efficiency

Case in point
>>
File: sussman shig.jpg (71KB, 500x375px) Image search: [Google]
sussman shig.jpg
71KB, 500x375px
>>55689972
>using a language where false, nil and the empty list aren't equivalent
I shig at your life.
>>
>>55697161
>The people designing sepples are experts with more years of experience each than you are old
That's half of the problem. C++ should have shifted into modern approaches to programming ages ago and that shitty C compatibility agenda the committee pushed for years should have been abandoned long ago. That's the reason we get syntax like this: >>55696976

and lambdas (don't get me wrong, lambdas are hellacool, but their syntax in sepples.... yeck).

>Case in point
That's not me, I'm >>55697106
>>
>>55697094
>>55697101
>>55697106
>>55697161
Enjoy your code bloat and cache misses.
>>
>>55697206
templates have nothing to do with cache misses and they reduce bloat (having to write the same this multiple times)
>>
>>55697243
Templates cause shitloads of executable code to be generated. You need possibly dozens of versions of the same code.
It causes instruction cache misses, because now there is so much more code.
>>
>>55697243
>muh cache misses
I see this spouted all the time by people who don't understand how C++ works at all.
>>
>>55697260
>You need possibly dozens of versions of the same code.
you need what you need, but it's not gonna generate shit you don't need
>>
Should I learn java or c if I want to make big money?
>>
>>55697260
>much more code
What is going to make more code? Writing some boilerplate function that tries to be generic as fuck and having a gazillean different branches and side-effects, or a small, concise functions that are only generated by the compiler when they are needed?
>>
>>55697289
And, if I may add, even (usually) inlined when practically possible, because of how template functions are (usually) defined in headers.
>>
>>55697287
depends how much you want to make and in which domain

I'm not sure the best paid programmers (in finance, high frequency trading, etc) use languages like java
>>
>>55697318
>HFT
They definitively use Java AND C

OpenHFT, Azul Zing, etc.
>>
>>55697280
Yes, if you use it on dozens of different types, you get dozens of different versions of the code.
If you're only using it on one type or types with trivial differences (such as just integers), why even bother at all?
Why do you think C++ libraries are usually so massive? It's because they have a gorrillion template instantiations in them.
>>
>>55697330
I saw a shitton of C/C++ job ads in HFT
>>
>>55697343
>Why do you think C++ libraries are usually so massive? It's because they have a gorrillion template instantiations in them.
They are massive in code, but the compiled output is not massive.

>If you're only using it on one type or types with trivial differences (such as just integers), why even bother at all?
You shouldn't, that's bad form. But the second you use it on more types, it is good form.

Do you really think that simple types, such as integers, and complex types, such as strings or vectors, should be compared and sorted in the same function?
>>
>>55697347
They use both, C for low latency and Java for high-throughput and algorithmic stuff.

Let this be your friendly reminder that just like Python, you can implement native C bindings for Java as well

https://en.wikipedia.org/wiki/Java_Native_Interface
>>
File: fragzeichenkatze.jpg (59KB, 640x496px) Image search: [Google]
fragzeichenkatze.jpg
59KB, 640x496px
So I'm writing an iOS app and using Swift, which is the first time I've ever been exposed to OOP, and I'm just left wondering "why?"

Are structs objects? Because I think a struct full of named heterogeneous variables is pretty nice and useful. But I'm left wondering why I would ever want a function hidden away inside a certain object. To me it seems like a disaster waiting to happen, especially if that function is stateful. How on earth is this not considered harmful?

Am I missing some kind of secret here? There must be a reason why OOP is as popular as it is.
>>
>>55697396
Having interoperability with the C ABI isn't a feature you tout, you know.
It's a requirement for every language that expects to be taken seriously and isn't super domain-specific.
>>
File: le pointing penn.jpg (116KB, 1516x892px) Image search: [Google]
le pointing penn.jpg
116KB, 1516x892px
>duck typing
>>
>>55697421
I never said anything else, I'm just pointing it out because no one on /g/ appears to know anything about programming.
>>
>>55697396
> Java for high-throughput and algorithmic stuff.

it makes sense to use because of all the apache hadoop and apache spark stuff and some popular ML libraries, but do a quick search, there's just much more demand for C++

and I'll add my opinion that HFT is evil and should be transaction-taxed out of existence
>>
>>55697442
>but do a quick search, there's just much more demand for C++
I was under the impression that they needed mathematicians and statisticians more than domain-specific programmers, but I guess demand will vary depending on where you live.

>and I'll add my opinion that HFT is evil and should be transaction-taxed out of existence
I agree
>>
What about ocaml in finance?
Is that just a meme?
>>
>>55697396
JNI is SHOW AS BALLS
>>
File: le dinpoo pajeet browsing :pol:.jpg (125KB, 1200x887px) Image search: [Google]
le dinpoo pajeet browsing :pol:.jpg
125KB, 1200x887px
>>55697442
>hapoop
>>
>>55691411
Can one use Lambda functions, map, filter and other Functional concepts in JS?
>>
>>55697576
yes
>>
File: smile senjougahara.gif (564KB, 480x200px) Image search: [Google]
smile senjougahara.gif
564KB, 480x200px
>>55697673
Not bad
>>
File: 1462835918940.jpg (36KB, 680x578px) Image search: [Google]
1462835918940.jpg
36KB, 680x578px
>>55688901
>What are you working on, /g/?
Debugging C code that crashes due to "member access within misaligned address 0x60606f686365 for type 'struct syntax', which requires 8 byte alignment".
Makes me want to kill myself
>>
File: 1407905937240.jpg (23KB, 500x375px) Image search: [Google]
1407905937240.jpg
23KB, 500x375px
>>55697875
>Managing to misalign a pointer
You must be doing some REALLY stupid shit for that to happen.
>>
>>55697400
No, objects are structs
>>
>>55693091
Fuck off pea before I rape u
>>
>>55697400
>There must be a reason why OOP is as popular as it is.
You're not going to get a good answer on /dpt/.

The bottom line is that OOP is designed to make it manageable for 500+ programmers to be working on one code base.

When you write an object with private methods and private variables, you're intentionally hiding the behavior and internal data from other parts of the code base to compartmentalize things and prevent their code from making decisions based on the state of your object, beyond what you intentionally show them.
>>
>>55698110
Too bad that is all a fantasy and not what happens in practice.
Objects are always fucking with each other's state.
>>
dumb animeNEETs
>>
Apache Cordova app. It's such shit I miss native Android so much

>>55689127
That's an excellent book
>>
>>55698251
There's actually quite a few employed anons here.
>>
>>55698228
how to use it became a subfield of CS, it's probably worth studying

https://en.wikipedia.org/wiki/Software_design_patterns#Classification_and_list
>>
File: ThuringaBratwurst.jpg (84KB, 854x565px) Image search: [Google]
ThuringaBratwurst.jpg
84KB, 854x565px
>>55697400
OOP works well if your problem can be conceptualised using data-driven objects with methods. People usually find it easier to objectify things as opposed to conceptualizing data flow processes.
>>
File: pdm.png (61KB, 812x375px) Image search: [Google]
pdm.png
61KB, 812x375px
>>55688901
>What are you working on, /g/?
>>
>>55698228
>Objects are always fucking with each other's state.
Then those are poorly designed or poorly documented objects.
>>
>>55698251
>people learning programming and reading programming books
not NEETs, temporarily inconvenienced highly paid professionals
>>
>>55698276
"""Design Patterns""" aren't CS.

>>55698293
OOP encourages shared state between objects.
By calling messages on an object, you are indirectly modifying that object's state, making you responsible for that object and it becomes part of your own internal state. If anything else fucks with the state of that objects, they are now messing with YOUR state. That is no better than having a global variable that several objects/functions/whatever are sharing.
>>
Went to job interview.
Denied due to not having team spirit.
Am convinced it's because there's a person there who has a friend working there and is getting the spot.
He even told us he has a friend working there.
Lack of team spirit is impossible. Everyone lacked spirit.

Oh well, I'll start making a new game powered by this disappointment.
>>
File: maine-coon-28.jpg (95KB, 300x300px) Image search: [Google]
maine-coon-28.jpg
95KB, 300x300px
Are functional programmers TOO smart to be employed?
>>
>>55698441
That's why you instantiate an instance of the object and use it correctly.
>>
>>55698456
lol
>>
>>55698487
You're literally just spouting crap.
Did you understand what I wrote at all? Do you even understand the fundamentals of the paradigm that you seem to revere so much?
>>
>>55698507
Yes, and yes.

>If anything else fucks with the state of that objects
Why are you allowing something to "fuck with" the state of the instance of an object you're using?
>>
>>55698449
if they use that as an excuse it's probably not a good place to work in the first place

don't get attached to any one place just keep applying, in the end it's the law of big numbers
>>
>>55698449
>Oh well, I'll start making a new game powered by this disappointment.
Or you could apply to another company instead of being defeated by one single bullshit rejection.
>>
File: inthetrashnow.jpg (27KB, 948x711px) Image search: [Google]
inthetrashnow.jpg
27KB, 948x711px
Is functional programming a meme?
>>
>>55698531
Of course, not stopping.

>>55698540
It's not my first rejection.
First time I've received a retarded reason.
You got 9 people unable to start a conversation in a group task, get them going, but you're the one lacking team spirit? Come on now.
I make shit when I have nothing to do.
Very little new applications appear on Fridays and almost none on Saturdays, might as well wait for Monday. I'll still check but not as much today.
>>
>>55698529
>Why are you allowing something to "fuck with" the state of the instance of an object you're using?
Are you saying that you have an absolute strict hierarchy of objects in your program? At no point does a method/function return a reference to an object, and all objects ONLY access objects that they created themselves?
>>
>>55698566
You're complaining about some mysterious other bit of code "fucking with" the state of your object.

If this is an issue, prevent other sources from accessing your object.
>>
>>55698110
So I shouldn't even bother as one man?
>>
>>55698614
It's entirely up to you.

Just because a language is object-oriented, does not mean that you have to force yourself to do full OOP practices.

Some things are useful for a one-man project, and other things can be useful, but can be cumbersome to bother with.
>>
>>55698549
yes
>>
>>55698614
learn it, don't listen to idiots
>>
>>55698456
if you're so smart then get funding and be in charge, and then you can program in whatever the fuck you want

otherwise learn what people actually use in production
>>
>>55698602
What I'm saying is that if ANY two objects have a reference to one other object, they have shared state, and modifications to the one object will have effects on seemingly unrelated objects.
Here is some MemeCoffee-like psuedocode;
class A {
C whatever;

void do_thing() {
c.mutate();
}
}

class B {
C whatever;
}

A obj1;
B obj2;
// Both of them have a reference to the same C object.

obj1.do_something();

Now with that call, you're modifying BOTH the states of obj1 and obj2, because they both rely on the state of that C object.
This is what OOP actively encourages you to do. This shit is no better than global variables.

The only way to fix this is to have a strict tree of objects, with no "cross cutting" across branches of the tree.
People don't program that way though, because it's a pain in the ass, unintuitive, indirect, and doesn't model any problem well.

You'll probably say "just make a new C object, so that obj1 and obj2 don't share a reference". However, what if you can't create a new C object? Say it represents a hardware device or a file handle or some shit. Maybe you could have multiple instances of it, but how will you keep them synchronised?

OOP in fundamentally flawed.
>>
>>55698768
OOP is fundamentally flawed*
>>
>>55698669
well there's a difference between learning and using
the concept of OOP is not exactly mind-bending. I grasp it quite firmly as it is
I just see no use for it in my code at the moment
If it's meant to be used by ENTERPRISE teams of hundreds of pajeets, then I understand, but I'm just me
>>
>>55698783
>I just see no use for it in my code at the moment
what kind of programs do you write?

I used to think like this too, until I saw what other people are doing
>>
>>55698768
>Now with that call, you're modifying BOTH the states of obj1 and obj2
I don't think so, tim.
>>
>>55698768
>Now with that call, you're modifying BOTH the states of obj1 and obj2
You are incorrect.
>>
>>55698783
>>55698456
>>
>>55698768
You gotta understand OOP first m8 before you bash it
>>
>>55698891
>>55698896
Both obj1 and obj2 hold a reference to that C object, so it is part of their internal state.
In my fake code, I didn't want to spend ages writing crap actually defining C and behaviours for why A and B rely on C, so I left it out. In a non-trivial non-contrived example, they would actually rely on C.

>>55698913
Do you understand OOP? Do you even understand what it's trying to fix?
>>
>>55698936
>Do you understand OOP?
I don't use it much myself, but I know enough to see why your example is retarded. Do you know how scope works at all? obj1.whatever is going to be different from obj2.whatever. Your do_thing() method isn't even correct because it modifies what I'm assuming is supposed to be an object of class C, but that object never actually got instantiated. Plus your last line also calls a nonexistent method.
>>
>>55698987
>obj1.whatever is going to be different from obj2.whatever
Did you not read my comment?
>// Both of them have a reference to the same C object.

>Your do_thing() method isn't even correct because it modifies what I'm assuming is supposed to be an object of class C, but that object never actually got instantiated
Notice how I called it "psuedocode"
I didn't want to be bothered with the actual required implementation, as that would make my code 10 times longer and add nothing to value to my point.
>Plus your last line also calls a nonexistent method
That was a typo.
>>
why is there a push to have macros in haskell
it's dogshit
>>
>>55699018
>>55698936

if you want help with OOP design then explain what the fuck you're trying to accomplish
>>
>>55699053
I'm saying that OOP is fundamentally flawed and you shouldn't use it.
Use something else.
>>
>>55699018
>Both of them have a reference to the same C object
They don't, that's like saying the following two functions share the same foo variable
int fun1(void)
{
int foo;
}

int fun2(void)
{
int foo;
}


With this code, then they'd share the same whatever object
obj1.whatever = obj2.whatever
>>
>>55699063
no one should use it like you do, it's not as simple as creating objects that kinda relevant and later figuring out what to do and creating a mess

you must think and plan ahead
>>
>>55699084
>Comparing lexical scope to struct/object membership
You're fucking retarded. OOP zealots never really seem to understand anything.
Also, as I said, it's not always possible/practical for them to have different references.
>>
File: 1465987913964.png (29KB, 500x275px) Image search: [Google]
1465987913964.png
29KB, 500x275px
>>55699120
>OOP zealots
> can't explain his butthurt with a real world example
>>
>>55698936
>>55699120
Your example is retarded and wouldn't compile anyway.

Can you attempt to write something more coherent so we can attempt to understand where you're coming from?
>>
File: r9cItot.png (26KB, 433x773px) Image search: [Google]
r9cItot.png
26KB, 433x773px
I'm not entirely sure what that anon was trying to do with his example, but without instantiating new Cee's, those Cee objects are null anyway.
>>
>>55699152
His point was that both Ayy and Bee will modify CeeString if you do something like this:
var ayy = new Ayy();
var bee = new Bee();
var cee = new Cee();
ayy.whatever = cee;
bee.whatever = cee;

ayy.do_thing();


Now I'm not familiar with C# so I'm not sure if the code is correct but you get the gist.
>>
>>55699178
Well, of course.

This is expected behavior, and in no way is a flaw.

If this behavior is a problem, it's easily modified to prevent both states from changing in this case.

>what if the C object is a driver

Shouldn't all objects reliant on a driver's state reflect changes when that driver's state changes?
>>
>>55699090
Let me guess, you actually think shit like UML is actually a good idea?
Also, there are several reasons to why that isn't practical or a good idea.
>You'll spend all of your time in analysis paralysis and never actually get anything done
>Your code becomes extremely inflexible, as everything you write now relies on this arbitrary object hierarchy you made up
>It's extremely likely that your arbitrary object hierarchy doesn't fit your problem well
>You cannot possibly foresee all of the possible implementation issues that may come up, and it will be hard to change later
>Requirements may change, and it will be hard to change later
There are all sorts of other crap piled on top of OOP to try and fix that bullshit. Agile shit or whatever, but none of them fix the inherent flaws in OOP.
>>
>>55699138
>>55699139
Are you guys retarded? Can't you even try to understand anything even slightly abstract?
Here you fucking go then. I had to write 60 lines of shitty code, and it adds nothing to my point.
class A {
private C c;

A(C in) {
c = in;
}

void do_whatever() {
c.mutate();
}
}

class B {
private C c;

B(C in) {
c = in;
}

int get_thing() {
return c.get();
}
}

class C {
private int a;

int get() {
return a;
}

void mutate() {
++a;
};
}

public class shit {
public static void main(String[] args) {
/* Initialisation shit.
* Obviously a real world example would be far less trivial than this
* and wouldn't be so direct about 'a' and 'b' getting a refernce to 'c',
* but the point still stands. They both get their reference to 'c', one way
* or another.
* Imagine this initalisation is buried is some other AbstractFactoryBuilderBean
* or some shit, so it's nowhere near this obvious, like real ENTERPRISE java
* would have done.
*/
C c = new C();

A a = new A(c);
B b = new B(c);

// b has not been modified
System.out.println(b.get_thing());

// Modify a seemingly unrelated object.
a.do_whatever();

// now b is suddely different, even though we never modified it
System.out.println(b.get_thing());
}
}
>>
>>55698768
>both of the have a reference to the same C object
>gets pissed because he's using references
I actually think I get what your problem is here, you want A and B to have a C object with the same state. References are not used for this obviously, there is a "copy constructor" in C++ which you can use in that case. Can't think of a real world example of what you're implementing though.
>>
File: AndLilyQuestion.jpg (93KB, 560x560px) Image search: [Google]
AndLilyQuestion.jpg
93KB, 560x560px
What are the best libraries to use when making an HTML5 MMORPG?

I found out in another thread Jagex moved RuneScape from Java to HTML5+JS+WebGL.

I saw in one thing that WebGL & WebSocket would probably be the way to go.
Any other libraries I should learn?
I already have a book on Node.js, and IO have a decent grasp of jQuery

In addition, what backend languages should I use? I know PHP and MySQL (and Java, but it seems we've ruled that out). Would Node be enough? Player data WILL need to be stored in some kind of database, so I was thinking just use my MySQL. I can't really figure if I'd need a NoSQL db. I mean, I can always stored deliminated data as a theoretical object in my rows and columns. Should I learn Couch or Mongo, though? I'm kinda not partial to NoSQL, as it doesn't make sense to me from an abstract standpoint.

Additional notes: I also know C++, if that would be a better backend, but I'm not sure it's right for an HTML5 game. Correct me if I'm wrong.

Could learn Ruby/Rails, too. Don't know that yet, though.

>TL;DR: What JS libraries should I use to make an HTML5 MMORPG? Also, what backend is recommended? I currently know C++ and PHP as backend (excluding Java, b/c it seems not to be the best option anymore). Should I Ruby? Should I Rails? Is MySQL best, or would I really truly NEED a NoSQL like Couch or Mongo for this?
>>
>>55699242
Oh, I wasn't arguing whether it's the expected behavior or not, I was simply stating that your example did not reflect what the other guy meant, that's all.
>>
>>55699280
the thing is, you keep claiming that this behavior is a flaw, but you haven't shown why it is a flaw

all I'm seeing is expected behavior
>>
NEW THREAD

>>55699322
>>55699322
>>55699322
>>
>>55699280
>now b is suddely different
But it's not, c is the only thing that changed.
>>
>>55699327
It makes programs extremely difficult to reason about. One change in one place of your program can affect a completely different, seemingly unrelated piece of your program.
Now, whenever you want to think about what state your program is in at some possible point, you know have to think about the state that every possible object could have, and how changing one object will invisibly change another.
Shared state is the antithesis of designing good software.
>>
>>55699309
Just learn React, Redux, jQuery and WebSockets then you're partially set. Afterwards you can also learn to use Node and Electron to be able to redistribute your HTML5 game on desktop platforms. Why Node though? Because it will be handy to manage your project and its dependencies. You also should learn either Webpack or Babel which will compile your JavaScript and its dependencies into a single minified JS file. That's all advice I can give you but I'm not that familiar with web ""programming"" so there's a chance I'm missing something.

As for backend, MySQL will do, Postgres would probably be better though, do not buy into the NoSQL memes, they're catastrophic failures. C++ will do just fine for a backend but you will need a WebSocket library as well as a very simple HTTP server to make the clients capable of negotiating the WS connection (that's how WS works, it needs to make a HTTP request first). You will also want to learn something like ZeroMQ because since you're aiming for an MMO, you will want the components to communicate with each other (you will also want to split the backend into something like a chat server, a session server, a game shard server etc).

I've worked with MMOs before but they were rather minor - just a couple thousands of user, so I don't know how that knowledge applies beyond that.
>>
>>55699270
>arbitrary object hierarchy
as I said, that's your problem

you're not willing to think first
>>
>>55699309
Node is shit
PHP is shit
Ruby is shit
C++ is shit
Just use a normal language for the backend like C, Scheme, Haskell, Erlang, etc

>but I'm not sure it's right for an HTML5 game
Nothing makes it incorrect
>>
>>55699369
c is a part of b's internal state. When c's state changes, b's state changes.

>>55699379
And you appantly ignored the rest of my post and my entire point.
>>
File: notthesame.png (67KB, 1679x1049px) Image search: [Google]
notthesame.png
67KB, 1679x1049px
>>55698768
>>55699280
Congrats, you made me install dmd on my work computer to prove you wrong

Commence damage control
>>
>>55699397
If you didn't want them to share a C, why did you give them both a reference to the one C instead of their own Cs?
>>
File: CirNoCirYesCirMaybe.jpg (84KB, 811x470px) Image search: [Google]
CirNoCirYesCirMaybe.jpg
84KB, 811x470px
>>55699378
Thanks, I'll save this post to look all those up in my free time.

This helped a lot.

Unlike this guy:
>>55699384
>>
>>55699414
How does that prove me wrong?
Also, they aren't even sharing a reference you fucking idiot.

I'm seriously starting to believe that everybody on here who defends OOP is a literal Pajeet code monkey and is probably legally retarded.
>>
>>55699280
WELL NO SHIT THEY'RE GOING TO SHARE THE SAME C OBJECT WHEN YOU MAKE IT THAT WAY
>>
>>55699431
>Unlike this guy:
>>>55699384(You)
If it did not help you, then you are either a braindead retard or a trolling dick.
>>
>>55699427
>>55699446
Because in REAL code, you would actually run into several different objects sharing a reference one way or another.
It was just a fucking contrived example.
>>
>>55699444
Well, your original example was implying that declaring C whatever in two different classes would mean that those two classes would be sharing the same whatever object, and now I see you're backpedaling and ACTIVELY making sure they share the same whatever object.

This is something that can be avoided by careful planning you know.
>>
>>55699372
this has never once been an issue for me

one of the major benefits of OOP is that you can have an object and use it without having to think about what's going on inside of it

if class A and class B have a reference to an object of class C, they never have to think about C's current state. They just use it like a black box.

if you do have to think about C's state to reason about A or B, then you have a very poor design
>>
>>55699455
The only valid thing you posted in that entire comment to me was that:
>Nothing makes it incorrect
It's one thing to say C might be better than C++, or use X instead of Y, but shutting down every single major language/library without offering another option (other than C for the backend) is trolling yourself.
Lemme guess: Linux? Lemme guess: FOSS?
Lemme guess: Firefox?
Lemme guess: You probably argue with anyone who uses Windows, Chrome, or Mac, too?
>>
>>55699466
What do you want to happen?

>Because in REAL code, you would actually run into several different objects sharing a reference one way or another.
And this would be done intentionally for a specific reason, or it's shitty code.

>>55699372
>a completely different, seemingly unrelated piece of your program
They aren't 'seemingly unrelated' if you intentionally make two objects reference the same object.

Holy shit you are dumb.
>>
>The inherent flaw is that I don't know how to use this feature
>>
>>55699526
>The only valid thing you posted in that entire comment to me was that:
Everything was valid in there.

>but shutting down every single major language
No, I only shutted down a few shitty languages.

>without offering another option (other than C for the backend)
Are you kidding? I offered multiple examples as opinions.

>Lemme guess: Linux? Lemme guess: FOSS?
Yes like half of this board, so what?

>Lemme guess: Firefox?
Again yes, like half of this board.
Also, it's superior than all the other options I am aware of.

Now, let me guess. Windows? Chrome?
>>
>>55699502
>one of the major benefits of OOP is that you can have an object and use it without having to think about what's going on inside of it
How fucking naive you are.
And again, my whole point about analysis paralysis and inflexibility.

>>55699491
>your original example was implying that declaring C whatever in two different classes would mean that those two classes would be sharing the same whatever object
No it fucking wasn't. I thought I being clear that those two objects got the same reference somehow (read the comment). At no point did I say that it was supposed to taken as literal Java code ("Pseudocode").

>>55699536
>it's shitty code
I'm implying that OOP encourages this shitty code.
>They aren't 'seemingly unrelated' if you intentionally make two objects reference the same object.
Again, my example is contrived. In a real example, it would be way more complicated and not at all obvious.
Say my program has some user-facing "Functionality A" and "Functionality B", which are supposed to be represented by an object each respectively.
Even if they are apparently completely unrelated, they still can affect the state of each other if there are shared references, which in a non-trivial piece of software, there probably are.
>>
>>55699466
>run into several different objects sharing a reference
>run into
and this guy was bitching about "pajeets"
>>
>>55699595
>And again, my whole point about analysis paralysis and inflexibility.
does not apply, you can do this on the fly with no planning
in fact it's easier to do things the right way than the wrong way once you know what you're doing
>>
>>55699595
>I thought I being clear that those two objects got the same reference somehow (read the comment)
Your comment doesn't clarify shit, in fact it made it seem like you were saying with just that code snippet, and just that code snippet only, A and B would share whatever (and further reinforcing it with your comment), not what you intended. Nobody would look at that code and say, "wow, A and B must share the same C object". Unless you don't know how OOP works of course.
>>
>>55690966

Does it have to be about programming, though? I would recommend reading this baby
Thread posts: 339
Thread images: 33


[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.