[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: 316
Thread images: 29

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

What are you working on, /g/?
>>
File: .png (1MB, 3840x2160px) Image search: [Google]
.png
1MB, 3840x2160px
>>
>>55725065
Porting MultiROM for i9300 'cause I'm a poorfag.
>>
>>55725065
>Created before the bump limit
>Still spamming your stupid fag meme
Delete this thread and kill yourself.
>>
I have a mentor showing me how to build a terminal spreadsheet from scratch. Things are making a lot more sense with somebody to tell me errors instantly.
>>
File: 1469211120207.jpg (205KB, 706x324px) Image search: [Google]
1469211120207.jpg
205KB, 706x324px
Lawyer minded fags, is GNU STL really free or only GPL'd?
>>
>>55725065
If you're going to put a 2D trap at least put a good one.
>>
>>55725076
Huh, seems like an interesting idea... rolling
>>
>>55725118
>using a stl
Why? Stop it.
>>
Reminder to NOT bully OOP!
>>
Daily reminder, if you need a garbage collector it means you're writing garbage
>>
Why do people complain about GC'd langauges where it's optional? I never get it.
There's GC'd libraries you can use for non-GC'd languages. And if you wouldn't use those why would you use the libraries in those languages that use GC?
>>
>>55725107
I'm interested in teaching people things.
Anything else you've picked up? Do you think you're learning good coding practices or how to write your own software from scratch?

Like, what are you really learning. Do you get a good perspective on the craft?
>>
File: 1467131735909.gif (1MB, 640x360px) Image search: [Google]
1467131735909.gif
1MB, 640x360px
>OOP
>>
>>55725076
Rolling.
>>
>>55725277
teach me algorithms I suck with them
>>
File: 1468308421209.jpg (598KB, 1280x946px) Image search: [Google]
1468308421209.jpg
598KB, 1280x946px
>>55725076
>>
>>55725297
Don't use them.
Really don't use them until you need them. Assuming you're not doing CS and just programming you rarely use that stuff.

Also how do you know you suck? I wanna know what makes you think you suck with them.

Inability to learn/understand after tons of effort to learn?
>>
>>55725288
crossposting because of the new thread
>>
>>55725323
>>algorithms
>don't use them


>daily programming thread
>>
>>55725323
>I don't use algorithms
>Algorithms is only for CS
You're a fucking idiot. Literally your entire program is an algorithm.
>>
>>55725323
I don't understand them after lots of effort and you saying you don't need them makes no sense because you have to think of algorithms for every program you write
>>
>>55725328
>>55725360
Well I obviously assumed he was talking the typical search type stuff. Not in general.

Baiting like this is lame though. Arsehatt.
>>
File: 1399418212025.gif (743KB, 281x281px) Image search: [Google]
1399418212025.gif
743KB, 281x281px
>>55725376
>I said something retarded
>I'll back-pedal and try to pass it off as bait
>Your face when
>>
File: 1466488521628.gif (461KB, 640x480px) Image search: [Google]
1466488521628.gif
461KB, 640x480px
>>55725325
depends who you ask
if you ask a retard who likes OOP they will say use setters

>>55725376
>i can't take a joke
>>
>>55725277
I've only had a few hours of coding under him so it is hard to describe. I do feel like I am learning proper coding, but we are currently working on boring things, and I don't feel like I could produce any thing we have done on my own without extensive googling.
>>
File: Algorithms.png (1MB, 909x788px) Image search: [Google]
Algorithms.png
1MB, 909x788px
>>55725374
>you have to think of algorithms for every program you write
No. Not in the sense that these guys (>>55725328,>>55725360) weren't talking about.
Yes, generally if you're talking about coming up with algorithms in the sense that you quite literally can't figure out what you need to do then. That's not really a programming issue honestly. You just don't know what you want to do. If you were having issues understanding what you need to do to move forward that's another thing. (generally referred to as software architecture)
>>55725395
See what these books talk about?
Just how new are you to programming rookie-anon?
>>55725421
Honestly can't tell if /dpt/ is just retarded sometimes. I'm glad at least you were one person pretending to be retarded.
>>
>>55725437
>Algorithms consist of sorting functions
Literally everything you do is a fucking algorithm. You have your inputs, and you try to get to some correct output. Saying you don't use algorithms is completely retarded.
You're just moving the goalposts of the word to save face.
>>
Alright guys let's settle this once and for all.
What is objectively THE best paradigm out there?
>>
>>55725309
what the piss
>>
Is how to design programs a good book to learn from?
>>
>>55725480
Procedural, while favouring pure functions.
>>
>>55725480
Functional programming, assuming you have an infinitely powerful PC*

*you don't
>>
>>55725480
procedural programming >>55725505
(this)
>>55725495
>the only people who can answer have read the book
>opponents of whatever it's teaching are likely to not have read the book based on how it looks
This is generally true.
I don't know, i haven't read it. I find that most who write books have grand ideas that often don't lead very far.
>>
>>55725480
OOP Java
>>
>>55725519
>OOP Java
Java OOP?
>>
I wrote this and it gives weird output. Why?

template<typename T>
void *charset(){
T *charset = new T(32);
for(int i = 0; i < 26; ++i){
*(charset+i) = 'A' + i;
}
return charset;
}

int main(){
int *intpnt = (int*)charset<int>();
char *charpnt = (char*)charset<char>();
for(int i = 0; i < 26; ++i){
printf("%i %c\n", *(intpnt+i), *(charpnt+i));
}
}
>>
>>55725540
Jesus, that is one retarded mix of C and C++.
If you're going to write one of them, just write one of them, not both.
>>
>>55725519
>>55725536
java OOP pls nerf
>>
>>55725561
What?
>>
>>55725540
Possibly because you're using the same name for both a pointer variable and a function?
>>
>>55725556
I was experimenting, not for actual use obviously
>>
File: file.png (30KB, 853x287px) Image search: [Google]
file.png
30KB, 853x287px
Ok now what is this?
>>
>>55725556
>mix of C and C++
It's entirely C++
>>
>>55725571
Nope that didn't fix it

here's the output
>>
File: doggo.jpg (43KB, 354x341px) Image search: [Google]
doggo.jpg
43KB, 354x341px
>>55725076
>>
>>55725586
Yes, I know it's actually C++, but a lot of his code is how you would write C.
C and C++ are completely different languages, and have evolved differently since 1980. Either fall completely for the C++ meme and lose your sanity and sense of taste, or write proper C.
>>
>>55725617
There isn't a "proper" way to write C++.
You can use it how you like.
You are just mad that it's valid C++ code.

>h-haha C++ is worse than C because look at my c code:
>w-what you can do that? you're not using C++ correctly!!
>>
>>55725633
>A language can be arbitrarily complex without issue because you can choose a subset.
An argument for retards.
>>
>>55725633
>There isn't a "proper" way to write C++.
And that's one of the major flaws in C++. There are a million subsets of it, and two completely different people's "C++" will be completely different.
>>
What's a good non-meme language for me to learn?
>>
>>55725540
I dunno. Set a breakpoint and look at it?
Oh, you're developing in an environment without a debugger set up for you?
Too bad, you will never be a good programmer if you try to 'figure it out' without guiding yourself as well as possible.
>>
>>55725655
I have a debugger set up you assuming fuck
>>
>>55725648
C, C++, C#, Java, Python, scheme, lua, PHP, Javascript.

Go down the list and see what strikes your fancy.

The further down you go. Well you get the hell you deserve anyhow.
>>
>>55725668
So now why were you asking us a question about something so potentially trivial?

It's after you've looked at it in the debugger and gone like "wth there's random values appearing in the registers". You come to /dpt/.
>>
>>55725644
>it doesn't tell you what to do
Holy shit sorry mr gorbachev

>>55725637
That's not what I said
What I said was that it's silly and childish to be so mad that someone is writing "C-style" code in C++
>>
>>55725648
> non-meme
Define that?
>>
>>55725670
>lua near bottom of list
what's so bad about it?
>>
>>55725691
Not being taught in the "GURLS PROGRAMMING" courses (an example of one of these languages would be Javascript), but still widely-used and respected
Other than C, I can't really think of anything that fits this
>>
>>55725692
Not much really.
I couldn't decide wither to put it before or after scheme though.
It's just that all the others cover what it does better (imo).
>>
>>55725644

Technically stroustrup is trying to fix that
https://github.com/isocpp/CppCoreGuidelines
>>
>>55725723
The language is beyond saving.
It should have gone the way of old yeller 20 years ago.
>>
>>55725723
It's such a shithole.
I'd say stay out even if they're trying to make it better.

He's a moron and he's just starting to realize it. He has caused enough harm as is.
If i could I'd put "switch to D" at the top of that. Sure, D is trying to be C++ too much. But I can't put "switch to C" there because C++ devs would just make it hard to find good programmers then.
>>
File: file.png (108KB, 681x505px) Image search: [Google]
file.png
108KB, 681x505px
>>55725715
You want something like this then.
They're all reasonable languages.
Look at the volitility in their use to see how established they are.
>>
>>55725773
>They're all reasonable languages
>PHP
>>
>>55725680
rax looks right when assigning as well as the memory at the printf breakpoint, and it gets normal output when debugging. When running without the debugger the output is fucked. That's why I'm asking
>>
>>55725773
>Haskell one of only two languages with consistent gains
>other is shitty OOP + fake FP microspy.NET bloatbotware
>>
>>55725648
C, C++, Java, C#, Python, Ruby just to name a few. There are no "meme languages", there are just languages better suited for different use-cases.
>>
>>55725806
>inb4 3
Bash isn't a real programming language faggot
>>
>>55725820
>but muh shell scripts
>>
>>55725812
>There are no "meme languages"
There really are.
Why do you think Python became popular? Because they spammed it everywhere and it became a meme.
Same with Java.
C# was also just trying to ride on Java's memetic success.
>>
>>55725820
It's Turing complete.
It's actually somewhat usable.
How is it not a programming language?
>>
>>55725860
Are any of those three "meme languages" bad languages?
>>
>>55725885
not the guy you're replying to, but
All fucking three of them you dumbass
>>
>>55725895
here's your (you)
>>
>>55725885
Yes. They all are.
Python is slow as shit, and encourages sloppy code. Practically every python program is
import solution
solution.run()

Java forces OOP, the fundamentally flawed paradigm.
C# is just Java, with extra Microsoft dick.
>>
Not sure if this is the best place to ask, I've never used regex before, but I'm trying to write a pattern, and was wondering if it's possible to use a value from the string I'm using for the pattern as a repeat value. I can't seem to find anything on this.
>>
>>55725763
>stroustrop
>moron

I guess you haven't seen C++17 yet
>>
>>55725917
... you can create a regex string programmatically
>>
>>55725917
Are you talking about backreferences?
Because if you are, backreferences are shit, and you're trying to parse a non-regular language with regular expressions.
>>
File: 150px-Black_White_Lenora.png (56KB, 150x297px) Image search: [Google]
150px-Black_White_Lenora.png
56KB, 150x297px
>>55725648
>Skyla
Lenora was the hottest leader from that region.

Also learn VB.net alot of jobs ask for it.
>>
>>55725437
Is data and structure algorithims in Python a good meme, or should I just read clrs?
>>
>>55725948
>VB.net
isn't that like, drag and drop
>>
>>55725925
>C++ 17
>no concepts
>no modules
>no ranges
>no couroutines

>>55725952
Why not do both?
The worst part about Python is how it encourages you to import the solution
>>
>>55725907
this. to make it worse the documentation for third party libs make you think you're doing actual programming when realistically it's just copypasta with arguments of your choosing. All the makers of third party libraries just call C functions anyways, making Python... absolutely skiddie friendly
>>
>>55725965
If you can't implement your own range function kill yourself
>>
File: gblpio.gif (9KB, 640x350px) Image search: [Google]
gblpio.gif
9KB, 640x350px
>>55725965
I have no problem reading both actually.
>>
>>55725987
>range function
Oh, so you were just meming
You don't actually know anything about the proposals for C++17
>>
>>55726018
or i should say for C++, as coroutines haven't been _formally_ proposed for C++ yet
>>
Trying an AABB thing.

Here is an example: I need to check columns 9, 10, and 11.

But, when I run the for loop to check, it only looks at columns 9 and 10.

//pesudo code
for ( int i=9; i<11; i++ )
{
...check columns
}


I don't always need to check 3 columns, perhaps the game object is perfectly within 2, so adding a +1 to the end of that wouldn't work for me.

This is what I have been doing:

short min    = floor( ent->hitbox.y/TILE_H ); 
short max = ceil( (float)(ent->hitbox.y+ent->hitbox.h)/TILE_H );


but I don't want to do that, it seems far more convoluted than it needs to be.

Any ideas?
>>
>>55725940
Yeah I read about those, but it didn't seem to what I wanted. I have a large set of data, and some parts are formatted like "49{49 character string}" so I was wondering if there was a regex that would read the 49 and then use that to capture the 49 characters after that.

I would use a different method but the rest of the data is formatted in a way that regex works really well.
>>
File: 1453849145683.gif (622KB, 480x304px) Image search: [Google]
1453849145683.gif
622KB, 480x304px
>>55726018
there's a boost library for that :^)
>>
>>55726041
>i<11
i<=11
>>
>>55725540
I don't know if you're still around, but that's not how you allocate an array.
>>
>>55726174
OH SHIT you're right

I used parenthesis instead of square brackets. Now it works right.
>>
>>55726242
Why are you returning a void*?
>>
>>55726247
just fucking around with void* casts. If I were to actually use it I would just set up the function with a template in place of the void type.
>>
>>55726307
There's literally no reason for void casting there, you're just getting rid of the type information and then putting it back in an unsafe fashion
>>
>>55725076
rollling
>>
>>55726602
I think this is what it mean, and rerolling.

word = open("word.txt","r")
for line in word:
count+=1
print count,line.strip()


output:
1 this is a line
2 so is this
3 this is too
>>
>>55726652
No you idiot

It means count the number of times each word occurs
>>
>>55726684
e.g.

"this is a line so is this this is too" ->
this : 3
is : 3
a : 1
line : 1
so : 1
too : 1
>>
About a year ago I did some work for a client, we didn't have any formal contracts, but it was for a fairly large company.

I still have the source for the program I wrote for them and want to improve on it/ make it open source. If I did that would I be asking for legal trouble if they found out? There aren't any formal contracts regarding ownership of the code or NDAs.

Should I just rewrite the program? I'm just asking because I think it's something many people would have a use for.
>>
>>55725076
rollin
>>
>>55726751
how does your legal team compare to theirs?
>>
http://pastebin.com/qhVywe62

The forloop at line 91 works fine, but the loop at line 201, which is supposed to print the same thing, outputs a bunch of shit. What am I doing wrong? I think it might be something with either pointers or with memory allocation.
>>
>>55725948
>Lenora
B L A C K E D
L
A
C
K
E
D
>>
>>55726751
>Should I just rewrite the program?
yes
>>
Why does the following work?

'''
7-20-2016
http://www.ferg.org/thinking_in_tkinter/all_programs.html

Updated version of tt050_0.py
'''
import tkinter as tk

class MyApp_Pack(tk.Frame):
def __init__(self, parent=None):
# put a container into root
super().__init__(parent)
self.pack()

self.button1 = self.create_button1()
self.button2 = self.create_button2()


def create_button1(self):
'''add button widget to the frame container'''
button = tk.Button()
button["text"] = "Hello, World!"
button["background"] = "green"
button.pack(side=tk.LEFT)
return button

def create_button2(self):
'''add button widget to the frame container'''
button = tk.Button()
button.configure(text='Off to join the circus')
button.configure(background='tan')
button.pack(side=tk.LEFT)


if __name__ == '__main__':
# toplevel window
root = tk.Tk()

# instanciate class
app = MyApp_Pack(root)

# run main loop on root
root.mainloop()

create_button1() returns the button instance and the button is added to the container.

create_button2() returns nothing (None)...but the button added to the container as well.

If the return type is None then how does button2 get added?
>>
>>55725957
>drag and drop
Have you not made windows form applications before?
>>
>>55726794
I don't have one, I don't know about theirs.
>>
is there a way to have a while loop wait for user input in discord with discord.py version 0.9.1 I want to create a while loop with if statements inside but it waits for a correct input first. Sorry if im being stupid im just stuck rn
>>
>>55726751

>we didn't have any formal contracts, but it was for a fairly large company.

You fucked up.

>If I did that would I be asking for legal trouble if they found out? There aren't any formal contracts regarding ownership of the code or NDAs.

Yes. There's no formal contract, but if the client bankrolled the project and the implied intent was for the code to be exclusively licensed to the client, there's a good chance they'll have legal standing to fuck your shit up.
>>
>>55726090
thanks, doc
>>
>>55726892
then you should probably err on the side of caution. court is expensive
>>
>>55726811
In NG3init(), you're assigning to the local variable ptr, and not affecting the 'test' in main().
Since you're using malloc, I assume you want 'test' to be a pointer, not just a normal struct.
Your code should look something like this:
void NG3Hinit (NoiseGenerator3Handler **ptr, long *seed, int x) {
*ptr = malloc(sizeof(NoiseGenerator3) + i * sizeof(NoiseGenerator3Handler));
(*ptr)->b = i;
for(int j = 0; j < i; ++j) {
NG3Hinit (&(*ptr)->a[j], seed, i);
}
}

int main() {
NoiseGenerator3 *test;
...
NG3init(&test, &random, 3);
}

Although there are other ways you might go about this.
>>
>>55726988
>void NG3Hinit (NoiseGenerator3Handler **ptr, long *seed, int x) {
Whoops, I copied in the wrong prototype.
It should be
void NG3init (NoiseGenerator3 **ptr, long *seed, int i) {
>>
So, how do I make money from all this shit when still a student?
>>
>>55726936
>You fucked up.
Yeah I know I did. I was just starting out freelancing at the time and didn't really know what I was doing.

If I rewrote the code would I face the same dilemma?
>>
>>55727010
Ask for money to do other people's assignments.
>>
>>55726751
if there was no contract signed then the source code belongs to the person who wrote it (you)

you could sell it unaltered to their competitors if you wanted.
>>
>>55726988
>>55726999
Thanks, that helped a lot. Here's the fixed code in case anyone was interested:
http://pastebin.com/WdPFJS9U

Also,
>88
>999
Checked.
>>
>>55727010
You don't
>>
>>55727013
the anon you're replying to is entirely incorrect

if you didn't sign away your ownership of the source code then it belongs to you and only you

the only thing that is implied is their license to use the version(s) of the source code that you handed to them
if you handed them a compiled executable, then they don't even have a license to use or modify the source
>>
File: 36500203_p0.jpg (185KB, 750x880px) Image search: [Google]
36500203_p0.jpg
185KB, 750x880px
Python 2 or 3?
>>
>>55727141
2
>>
>>55727141
>Mao or Stalin?
>>
File: python.jpg (435KB, 2000x1334px) Image search: [Google]
python.jpg
435KB, 2000x1334px
if you see a python user, remember to tread on him
>>
>>55725323
I've had to use both DFS and BFS for a problem at work the other day, what the fuck are you smoking.
>>
>>55727284
why did you need to use dfs?
infinitely broad tree?
>>
>>55726751
Yes but they can also get you in trouble for doing uncotracted work, did you pay the taxes? IRS would probably be interested if they heard about it...
>>
>>55725480
Generic
>>
>>55727301
It wasn't actually a tree but an undirected graph which is also disjoint. I had to use DFS to find subgraphs and BFS to find distances between nodes.
>>
>>55725540
>new T(32);
Shouldn't those be brackets?
>>
>>55725540
>new
It's garbage.
>>
In C#, do calls to auto implemented properties within a class get "inlined" when compiled? Seems like there'd potentially be a lot of overhead for no real benefit otherwise.
>>
>>55727313
I did pay the taxes, so they have nothing on me there.
>>
>>55727392
I guess you're clear then, if there was no legal bound to transfer the copyright to the company then it's all yours.
>>
File: wtf.jpg (39KB, 480x360px) Image search: [Google]
wtf.jpg
39KB, 480x360px
>>
>>55725076
done
    static int factortial(int n){
if(n<=1)
return 1;
int result=n*factortial(n-1);
return result;
}

static int pascal(int row){
for(int n =0; n<row+1;n++){
int rowFac =factortial(row);
int numberFac=factortial(n);
int rownumFac=factortial(row-n);
int nCr =rowFac/(rownumFac*numberFac);
System.out.println(nCr);
}
return 0;
}
>>
Is this the nicest and greatest Haskell package of all time?

https://hackage.haskell.org/package/stopwatch-0.1.0.2/docs/src/Control-StopWatch.html#stopWatch
>>
>>55727375
I don't think you should worry about the "calling function overhead" thing, specially if you're using a GC language.
>>
>>55727375
I assume it's inlined
>>
>>55727348
Yeah that was the problem
>>
>>55727348
Those are brackets though.
>( ) round brackets
>[ ] square brackets
>{ } curly brackets
>< > angle brackets
>>
>>55727579
(you)
>>
>>55725076
give me something cool this time
>>
>>55727591
People actually call them that, you know.
>>
>>55727421
What's the purpose of the where keyword in Haskell? It seems a bit superfluous because there are no boundaries, can one package (or module, or whatever you call it in the Haskell world), use the keyword multiple times? Is it a language construct and is it used only to define modules or is it a thing outside of the module definition? Because in either case I cannot make any valid reason for it to exist there in that module syntax.
>>
>>55727601
nope, they don't
even the curly ones are called "braces", not brackets
>>
>>55727579
parens
square braces
curly braces
arrows
>>
>>55725076
roll
>>
>>55727616
There's two uses to it
The use in that is to declare what the module is & what it exports

The other is in functions where it's like a let binding but after the block
>>
>>55727628
Why are ( ) so special that it gets its own word? In mathematical notation, they are all interchangeable.

>>55727617
https://en.wikipedia.org/wiki/Bracket#Names_for_various_bracket_symbols
>>
>>55725076
Taking a roll.
>>
>>55727617

I believe the preferred nomenclature is parens, square brackets, curly niggers, and chevrons.
>>
Please do not be a faggot; do not fuck up the next /dpt/ by filling it full of "rolling" bs

(or else)

>>55727672
Nobody missed you.
>>
>>55727672
parenthesis, brackets, nappy brackets, arrows
>>
File: bracketslogo.jpg (35KB, 800x350px) Image search: [Google]
bracketslogo.jpg
35KB, 800x350px
>>
>>55727579
in javascript hipster land {} are called mustaches.
>>
>>55725076

keh
>>
>>55725076
ayyyy
>>
>>55725806
JavaScript too.
>>
>>55725065
Fuck off this programming trap meme.
>>
New to programming, working through Think Like a Programmer (C++) and currently stumbling through writing code that appends a character to a string using pointers and dynamically allocated memory. Why does this shit give me different results?
#include <iostream>
using std::cout;

void func (char **input) {
cout << "Top: " << *(input[1]) << '\n';
}
int main() {
char *test = new char[3] {'T', 'E', '\0'};
cout <<"Bottom: " << test[1] << '\n';
func(&test);
delete[] test;
return 0;
}
>>
>>55725648
Xojo
>>
Is ASP.NET what I want to look at for doing server side stuff with .NET?
>>
>>55728049
For paid work probably, but Nancy is pretty neat.
>>
I read that scanf() is unsafe. should I use fgets + sscanf()? C
>>
>>55727795

In Ruby hipster land, the left bitshift operator, <<, is sometimes called the "shovel" operator. Furthermore, I have read blog posts from other rubyists asking why it is used for bitshifting.

http://sjmog.github.io/posts/494_shovels_make_me_sad/

>>55728209

scanf is unsafe if and only if you do not clarify the size of the buffer you are reading in with %s. As a general rule of thumb, whatever input method you are using, it should ALWAYS know exactly how big of a buffer it is given, or else it has an opportunity to overflow.

fgets is useful when and only when you are dealing with data line by line.
>>
>>55727983
#include <iostream>
using std::cout;

void func (char *input) {
cout << "Top: " << input[0] << '\n';
}
int main() {
char *test = new char[3] {'T', 'E', '\0'};
cout <<"Bottom: " << test[1] << '\n';
func(test);
delete[] test;
return 0;
}


Not sure what was the point of a pointer to a pointer.
>>
>>55728292
>In Ruby hipster land, the left bitshift operator, <<, is sometimes called the "shovel" operator. Furthermore, I have read blog posts from other rubyists asking why it is used for bitshifting.
>http://sjmog.github.io/posts/494_shovels_make_me_sad/
lol
>>
>>55728209
>I read that scanf() is unsafe
*scanf is unsafe if you use %s without a length limit. as it can write past the end of a buffer. If you specify a max length or just don't use %s, it's fine.
scanf specifically is shit because it can't handle errors well. If it fails (because the user didn't provide properly formatted input), it leaves the stream in a half-read state and is extremely difficult to recover from that error gracefully. That's why you should use fgets() + sscanf().
>>
>>55727579
>all programming resources in my native language are shit
>constantly forget how {} and [] are called
>everyone thinks I'm a pretentious faggot
>I (kinda) am a pretentious faggot
>>
I get
UnboundLocalError: local variable 'var' referenced before assignment

when i try running
    def func1():
var = True

def func2():
if something_random and var == True:
do stuff
>>
>>55727983
> working through Think Like a Programmer (C++)
that book makes you write crazy C-style shit like this?

you get wrong results because of *(input[1])

change it to (*input)[1]

or probably you want (*input)[0]
>>
File: 1468602250456.jpg (45KB, 480x480px) Image search: [Google]
1468602250456.jpg
45KB, 480x480px
>>55727628
>arrows
no.
>>
>>55726830
rtfm
pack method adds the item to the parent
>>
File: soulwax - nite versions.png (3MB, 1920x1080px) Image search: [Google]
soulwax - nite versions.png
3MB, 1920x1080px
>>55728582
your pic reminds me of
>>
>>55728497
Maybe you should try and learn how scope works:
https://en.wikipedia.org/wiki/Scope_(computer_science)#Function_scope
>>
Why has slack became so popular in programming communities over IRC? IRC is so much simpler to use and generally doesn't require you to have a single account, therefore providing more anonymity.
>>
>>55728852
because of californian dumbfucks that ruin just about everything programming related they touch
>>
>>55725076
bang bang
>>
>>55728696
Thank you.

I'll have to go back re-review my notes. I assumed (incorrectly) that nothing would be added to the parent until the local instance of the button was returned.

I actually found this issue as I was working through a PySide tutorial (qt). It looks like the widgets I'm using are being added to the parent when I instantiate them. I'll figure it out.

I thought my problem was with my concept of classes. But I misunderstood how the GUI toolkits were functioning.

Thanks again. I was drowning in StackOverflow searches.
>>
File: print a table with a heading.jpg (39KB, 512x215px) Image search: [Google]
print a table with a heading.jpg
39KB, 512x215px
What's the best way to calculate/print a table like this, including the heading "curry"?
>>
>>55729069
you can do it with std::cout with modifiers, but not sure that's the best
>>
>>55729086
using c. should have said. thinking just print curry and adding 1 to rows variable.
>>
>>55729086
>you can do it with std::cout with modifiers
Jesus chist, the sounds horrible.

>>55729097
printf is more than sufficient.
Look at
man 3 printf
or some other manual for what these do.
printf("%-8s%-8d%-8d%-8d\n", "Curry", 102, 103, 104);
printf("%-8.2f%5.1f %5.1f %5.1f\n", 0.28, 66.6, 75.1, 80.5);
printf("%-8.2f%5.1f %5.1f %5.1f\n", 0.28, 133.3, 143.1, 161.0);

Obviously you would want to put the actual table body in a loop, and extend this to as many fields as you have, but I hope you see the point.
This also has the assumption that the fields are never going to be wider than 5 characters.
>>
If want to work on things like Apple's Siri or Microsoft's Cortana, which language I should be looking into?
>>
>>55729308

Read the kabbalah and learn Paleo Hebrew.

That is the route all of our world leaders have taken.. or off shoots of it. Material gain isn't worth it.
>>
>>55725065
wtf, I thought haskell was supposed to be shorter on average
>>
>>55729537
forgot img
>>
>>55729554
wtf dude
>>
>>55725076
rolando
>>
>>55729578
fuc that
>>
in haskell, when using IO, any code using it has to use IO as well
is it the same case for State too or is it possible to create functions with self contained state?
if so, is it possible for State to leak outside the function?
>>
>>55729595
Please refrain from shitposting in the programming thread, please.
>>
>>55729591
no gui pls
>>55729595
yes
functions with self contained state can be done with pairs
>>
>>55729609
quine's too easy
>>
>>55729609
can state escape the local context (e.g. into an enclosing function)?
>>
>>55729618
impossible in haskell
>>
>>55725076
105 was fun as FUCK
Did it 3 times learning new things each time
>>
>>55729640
yes, the same with IO
if you want to do stuff with a value, you need to get a function which operates on that value
add more context, becomes harder
this is why IO is a pain in the ass, it leaks everywhere
>>
>>55729661
how did you get started
idk assembly btw
>>
>>55725076
br0wll
>>
>>55729688
>how did you get started
Learn how assembly works, then everything makes perfect sense. You'll even know how to create your own language like C with functions and so on once you get it. Obviously don't because writing a good compiler will take you your entire life.
>idk assembly btw
There's your problem
>>
File: 1467984035877.png (1KB, 250x250px) Image search: [Google]
1467984035877.png
1KB, 250x250px
>>55729705
shit. reroll.
>>
>>55729644
triangle n = (n^2 + n) / 2
>>
>>55725076
Why is there no entry for rolling 75?

Either way, rolling.
>>
What are the best practices for writing classes in OOP?

Should I put most of my methods in separate class files or is it acceptable to have one file with 1 public method and like 10 private ones counting about 1000 lines of code?

Is it ok to bloat the project with a lot of files or better to keep it all in just few of them?
>>
What are some essential resources on learning about data structures?
>>
File: 2016-07-24-052036_891x332_scrot.png (25KB, 891x332px) Image search: [Google]
2016-07-24-052036_891x332_scrot.png
25KB, 891x332px
>>55729831
>>
>>55729831
Introduction to Algorithms, AKA CLRS
>>
>>55729831
G O O G L E
O
O
G
L
E
>>
>>55729823
The only real way to use classes and OOP in general efficiently is to imagine what your program would look like in C with structs, function pointers, etc, and realize where and how OOP would make your code better and more maintainable.

And if you don't know C, just kys now.
>>
>>55729823
In C and especially in C++ you can greatly reduce compilation times for huge projects by dumping everything into one file rather than scattering your code throughout files but is it worth giving up maintainability?
>>
>>55729740
Eratosthenes a shit. Re-rolling...
>>
>>55725076
gimme something to do
>>
>>55725076
Rolling for disappointment.
>>
>>55725076
Some of these are really far out, like an MMORPG.
>>
Can I declare an array of no known size in a class, and then in the constructor of that class, set its size, and initialize all elements to 0, in c++? If so, how?
>>
to preincrement or postincrement?
that is the question.
++i or i++ ?
>>
>>55730469
I prefer postfix unless the program actually needs prefix.
>>
>>55730469
depends on the situation.

They are both optimized by compilers, but ++i used to be faster.
>>
>>55730549
>but ++i used to be faster
In your dreams only. Please insert a valid source, not something coming from your ass.
>>
If you were to make a program right now, let's say a calendar. Which language would you use, and which GUI library/framework?
>>
>>55730657
Qt Quick
>>
>>55730671
Works with cpp right?
>>
>>55730677
It's mainly JS, but you can create C++ plugins.
>>
>>55725076
bread
>>
>>55730657
OCaml and HTML5 gui.
>>
Why does a default implementation of an HTTP server in Go have no timeout? Are they retarded?
>>
>>55730783
Yes, it's google.
>>
>>55730739
html5 gui for desktop?
>>
>>55730866
You create a web server. It's the future.
>>
>>55730871
create a web server for personal use, are you crazy pendejo? why would you bother.
>>
>>55730876
You do it once in your life and you use it in every application. And the day you'll need a remote access you will see the truth. Trust me HTML5 is the future.
>>
>>55729891
If you're not writing in C, you're falling for a meme in the first place.
>>
>>55730469
Pre-increment is faster if you're dealing with C++ STL because it avoids creating an extra copy.
>>
>>55730871
That makes no sense, why would you need a web server to render a document on the client side? Are you stupid?
>>
Why do programmers usually code until very late at night, and have fucked up sleeping schedules?
>>
>>55731128
Because it allow mobility and portability. HTML4 was limited but HTML5 ain't. Embrace the future anon.
>>
>>55731136
You're just spouting shit out of your ass.
>>
>>55731139
Nice argument you got there anon. You just convinced me.
>>
>>55731143
I don't feel like arguing with someone who's either trolling or is so ignorant that he thinks he needs a fucking web server to render a document on the desktop.
>>
>>55731155
Stop anon, you convinced me. You don't need to insist.
>>
Does writing to a variable take less time if it is cached?
>>
>>55731166
Usually yes, but your question is not precise.
>>
>tfw you haven't heard of 90% of the tricks on this page
I'm a pleb.
http://www.codeproject.com/Articles/6154/Writing-Efficient-C-and-C-Code-Optimization
>>
>>55731317
I know 100% of those tricks. I am probably a fucking hacker.
>>
>>55731317
>2004
>"register unsigned int variable_name;"
>"We should use unsigned int instead of int if we know the value will never be negative. Some processors can handle unsigned integer arithmetic considerably faster than signed (this is also good practice, and helps make for self-documenting code)."

>some
processors? this can't still be accurate, can it? Surely he meant only FP-less Cyrix CPU's or gimped celerons, yeah? Or perhaps because AMD-64 was not a thing yet?
>>
>>55731395
It's a fucking article on codeproject, don't expect anything of quality from there.
>>
>>55731395
It's still accurate because one's and two's complement are still being used.
>>
>>55729564
>on average
>>
>>55731395
>>55731412
saw this on stack overflow and seems relevant:

>for (size_t i = 0; i < container.length(); ++i)

"It isn't int, but size_t (it exists in C++, not in C) which equals to some "usual" unsigned type, i.e. unsigned int for x86_32."
>>
File: lockpicking.gif (812KB, 333x200px) Image search: [Google]
lockpicking.gif
812KB, 333x200px
>>55725076
>>
tfw 3 billion devices run java
>>
>>55731722
yeah and they all tend to show up here

http://map.norsecorp.com/#/
>>
>>55731565
>size_t doesn't exist in C
That poster is pants on head retarded. size_t is defined in stddef.h

He is right in the other part though, it is usually typedef'd to some known type (unsigned int) on IA-32. It is always unsigned.
>>
Start an intro Java dev job soon. I haven't touched Java since spring 2015. Is there a reputable book I can download to relearn Java?
>>
Dumb question here, in C++ does a static variable within a class function work like a normal static variable?
>>
I have windows 7 should I upgrade to windows 10?
>>
>>55731957
Yup.
>>
>>55731957
Yes, but it is contained in the scope of the class.
>>
>>55731979
>>55731987
Thank you friends.
>>
You all must love Java Learn to love Java
>>
What's wrong with Java? Or Javascript?
>>
>>55732251
>Java
bloated
>Javascript
used by a lot of idiots who suck at coding
>>
>>55732267
Only the most intelligent can make good programs in Java
>>
>>55732301
Why make your life harder tho.
>>
>>55732267
Where were you when i brought this up in the comfy language thread? Why is Java so fucking horribly inefficient??? Is it a coincidence that the popular usage of the word 'lag' came about when Java first saw mainstream usage? NO
>>
>>55725925
No I haven't.
But admiring complex systems in languages that are supposed to be generic. Which is what he has done in the past. That's retarded. C is beautiful because it allows you to write efficient API's for whatever you need to do. What it suffers in is syntax simplicity and ways of expressing yourself simply on the API-user side without macros. Things like default arguments may be problematic in some ways because of how they work in C++. But there's no reason they couldn't be good. Stroustrop seemingly never had it as a goal to make programs nice. He decided that OOP was a nice thing for apparently no reason. He's now largely abandoning it. He keeps making these mistakes and assumptions while not providing the users with the freedom they need. Yes, they're technically getting the freedom they need because you can write "very similar to C"-code in C++. And thus you retain all those qualities the language has. But as a language designer your job is to make the job easier without introducing other problems. He hasn't managed that in the past and I have no confidence in him doing that with the past decisions he has made. Trusting him with a language is like trusting a convicted pedophile with a schoolbus full of children. Sure, the pedophile may have his heart in the right place, you put him there for a reason, he's probably committed to not being a bad guy. But why do you entrust that kind of importance to a guy who has proven himself to be problematic before?

I don't think people change that much. If you want a good language look to people who have developed large and good (performs well in most areas) software projects and see what they would want.

What has Stroustrop done? You'd think I'd be able to mention something major given he's largely in control of a language. I have the impression he's taking more of a back-seat position right now though (with what I argue is a change in direction).

But no, don't trust him with your software career.
>>
>>55732313
Because all the jobs an a large market of phones are in Android if this was not true I would not use or ever learn java
>>
>>55732329
Sometimes I know that I'm not alone in that worlds of idiots. Thank you anon.
>>
>>55727284
And you're claiming you're using them unnecessarily?
>Really don't use them until you need them.
People often look towards algorithms and data-structures as a good solution for things. Yes sure, the field covers practically everything.
But there's a difference between considering it as a field and considering your solutions and then looking for what others have done that might fit.

You do rarely use that stuff necessarily. Why are you using a tree? It's rarely a fast structure, the convenience it offers can easily be achieved through other structures just by having accessing functions. Yes it has its use case of course, but if you fit that narrow case often then maybe you're just there because you're already using them?
>>
>>55732365
Try to make posts you feel are clever aswell.
I also feel rather lonely. It's making me narcissistic and I don't want to be that.
>>
>>55725076
im bored
>>
>>55732439
get a gf or friends
>>
lets program a better twitter platform and make a lot of money
>>
>>55732329
>What has Stroustrop done?
just imagine the time needed to write his million page books

you should feel lazy and stupid
>>
>>55732551
>you should feel lazy and stupid
Ok?
>just imagine the time needed to write his million page books
Why should someone that has no idea what software development is write a programming language?
You can't really be this stupid right? Sure, it's fine to have someone that listens to experienced developers and expresses their ideas. That's not what he's doing though.

If you look at the conferences where they discuss code (cpp con notably) it doesn't really care about most things you as a programmer would care about. They actually masturbate to syntax complexity.
To me this was eyeopening:
https://channel9.msdn.com/Shows/Going+Deep/C-and-Beyond-2012-Andrei-Alexandrescu-Systematic-Error-Handling-in-C
You see how they go through the different ways you could do any of these things. Notice how they settle for the most complex thing, the implementation of it is fucking crazy and even shows them major problems with how confusing C++ code can be (see the using std::move bit for instance). But they're all very happy they can actually build it.

But all they really wanted was multiple returns effectively and a nice syntax for branching on one of the variables.

I don't think any sane person would go down that route and feel proud. I think anyone would call it a terrible hack you're doing. Yet they're presenting it as a solution.

They're also ignoring the performance implications of an error case. Which sure, I agree your program shouldn't be written like that. But is that really something to disregard completely? C++ isn't exactly written by the best of programmers, I hope they know this.
>>
File: D.jpg (42KB, 512x512px) Image search: [Google]
D.jpg
42KB, 512x512px
>>55732640
>shitting on andrei alexandrescu's book
Get the fuck out
>>
>>55732669
>seriously a shitposter in /dpt/
I'm shitting on this specific presentation and the C++ committees reaction to it. I'm sure he's a capable programmer who's put in an awkward spot supporting a terrible language.
>>
>>55732669
this, he's a god
>>
>>55732669
literally who?
>>
Working on: Trying to learn Haskell... Anybody here know Haskell? Just getting started, but does it turn out to be a practical language or really only good for specialized things?
>>
>>55725076
rolling. . .
>>
>>55732707
Haskell is beautiful and you are on the path to self enlightenment
>>
>>55732707
No it's not practical Practical is Java, Javascript, C#,SQL,PHP if you want a career
>>
>>55732762
Yeah trying to learning... has been frustrating, but at the same time I think to myself "This is crazy, but also, I think this is sort of awesome"
>>
>>55732797
Ugh "trying to learn"
Been awake like 24 hours trying to learn Haskell
>>
>>55732640

To quote from the abstract "C++11 is a more expressive language"

It's not for everybody and most people will never use all the possibilities, not even close.
>>
Why are there so many books on simple shit like algorithms and data structures, and extremely specific shit for every branch of CS, yet there is nothing that gives pointers on how to organize a program?

Every once in a while I roll a more complex /g/ challenge, trash 8 different iterations and give up entirely because it always ends up being a terrible spaghetti mess strewn across random files with excessive globals and/or functions with argument lists spanning multiple lines because I tried to "organize" my code.
How do you deal with this?
>>
3D chess shouldn't be that hard to make in C++ apart from the AI right?
>>
>>55732979
git gud
>>
>>55732979
It's called design patterns
>>
File: OOP.png (69KB, 1210x467px) Image search: [Google]
OOP.png
69KB, 1210x467px
>>55733047
Jesus christ no
>>
>>55733079
yes stop being a weenie
>>
>>55733079
that's pretty intuitive though
>>
>>55725076
Is it time /g/ makes a 4.0? We should at least give them difficulty levels
>>
>>55733333
c h e c k e d
>>
>>55732980
one would assume so

>>55733388
c h e c k e d
>>
>>55725076
seriously, why isn't there a decent stop watch app in debian/ubuntu ?
>>
>>55733478
why would you need an entire app for that
>>
>>55733496
trying to improve the time it takes to reach climax while masturbation to become a better lover
>>
>>55733511
Gross
>>
>>55733496
just

sudo apt install stopwatch

and weep
>>
I compile my code with -ggdb flag in gcc but I still don't get function symbols. Why is that? I have no other options besides -Wfatal-errors
>>
>>55733654
I mean when I try to do a backtrace in gdb all it shows are ??'s
>>
>>55725076
troll xd
>>
>>55725065

Ok lads, I made a program that strips the pixel data from a PNG image. It decompresses it and it reads the info in the header block that dictates what form the pixels are in.

I was going to make a sister program that lets you edit the pixel data and recompiles a PNG, but it's just too fucking tedious. What is an easier image format?
>>
>>55733654
Try just -g
>>
>>55725076
rolling

also general question if I only know python do I describe myself as a programmer, coder or scripter
>>
new thread >>55733966
>>
>>55733968
Depends, do you write programs or scripts? If you have to ask, probably the latter.
>>
>>55730340
>Dating Website
Thread posts: 316
Thread images: 29


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