[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: 359
Thread images: 39

What are you working on, /g/?

Old thread: >>59656280
>>
First for C.
>>
>>59661245
Would there be any disadvantages for building GC support directly into the hardware?
>>
>>59661245
I'm working on this trying to make the last button switch to next line every time clicked. Days text file contains days from Monday to Sunday but when I click the first time it says Sundays and second click does nothing. Any ideas?
from Tkinter import *

def Last(ReadLines):
Read = open('Days.txt', 'r')
for line in Read:
LastButton = Read
ReadLines.config(text=line)

def main():
root = Tk()
root.title("NKD")
root.geometry('500x230')
w1 = Label(root, text="Line")
w1.pack()
ReadLines = Label(root, text='', width=50)
ReadLines.pack()
LastButton = Button(root,text="Last", width=9, command=lambda:Last(ReadLines))
LastButton.pack(side=LEFT, padx=5, pady=5, anchor=SE)
root.mainloop()

if __name__ == '__main__':
main()
>>
File: all of c c++.jpg (49KB, 600x381px) Image search: [Google]
all of c c++.jpg
49KB, 600x381px
C with Classes > C++
>>
>>59661327
c with templates > c with classes > c++
>>
Best way to multiply two 64-bit integers into a 128-bit integer? Can I do the same trick as with imull?
>>
File: ln96kTL - Imgur.gif (2MB, 320x180px) Image search: [Google]
ln96kTL - Imgur.gif
2MB, 320x180px
>>59661245
Trying to learn data science / machine learning. I'm tired of being web dev drone. I want to move to something more challenging, rather than being stuck in a field which is full of substandard programmers.
>>
>>59661325
Look at your for loop. Here, ReadLines.config(text=line), line will always be the last line of the textfile, in this case "Sunday".
>>
>>59661374
You could probably leverage inline assembly in the mul instruction to do it
>>
>>59661440
>Trying to learn data science / machine learning
you got a CS degree? or you just a pajeet trying to "level up"
>>
>>59661465
Sure, but how? Does imulq %edx store EAX*EDX in EDX:EAX?
>>
>>59661465
>>59661500
Sorry, I mean RAX and RDX of course.
>>
>>59661325
The assignment to LastButton in Last looks fishy. You're assigning to a variable that you never read from.
>>
>>59661486
I do have a CS degree. I studied a few AI modules in the university. Now I'm trying to remember what I learnt and catching up on what's new.

Back in university (3 years ago) I though cloud would be a much bigger thing.
>>
>>59661440
>data science
It's just doing statistics by programming computers. Dull unless you understand and like the area that the input data is coming from.
>>
Need some help guys. I'm doing this template clusterfuck:
template<typename M>
struct matrix_range
{
using T = typename M::value_type;
constexpr matrix_range(M& matrix, const vector2i& position, const vector2i& dimensions) noexcept
: m(matrix), pos(position), dim(dimensions) { }

/* snip */

template<typename T>
struct matrix : public matrix_range<matrix<T>>
{
using value_type = T;
constexpr matrix(std::size_t w, std::size_t h, T* data) noexcept
: matrix_range<matrix<T>>(*this, { 0, 0 }, { w, h }), p(data) { }

but the compiler says:
matrix.h(13,41): error :  no type named 'value_type' in 'struct matrix<int>'
using T = typename M::value_type;
^

I don't see the error here. There's obviously a value_type defined. Am I doing something wrong or what?
>>
>>59661552
does your company sponsor masters programs? check it out bc they may
>>
>>59661552
>Back in university (3 years ago) I though cloud would be a much bigger thing.
Cloud's pretty big, but was hyped a lot more. ALWAYS ignore the hype.
>>
Someone explain hash collisions to me:
>>> set(range(3, 14, 2))
{3, 5, 7, 9, 11, 13}
>>> set(range(3, 13, 2))
{11, 9, 3, 5, 7}
>>
>>59661573
Pure statistics might be dull, but they have very interesting applications (image processing, classification, text analysis, analytics etc.).

>>59661589
I don't really enjoy university live. I prefer to study things on my own or learning at work.
>>
C stands for circlejerk
>>
>>59661635
Last I checked, "data science" was being used to squeeze more profits out of vulnerable insurance elderly patients by calculating likelihood of death and simply cutting them off if the data trends say they're not worth spending more money on.

It's truly vile what they're doing.
>>
>>59661603
that's not has collision mate. that just generates a list of number starting at 3 with increments of two which are less than 13 / 14. In second case, 11 is the last number in the list, so 13 is not in the result.

Simply run range(3, 14, 2) and range(3, 13, 2) to see it.
>>
>>59661636
C stand for Circumference, e.g. circumference of your brain and cock. The better you are with C, the bigger your brain and thicker your package.
>>
>>59661665
Data science is a tool and like all tools, it all depends on how it's used. IBM's Watson supposedly saves lives.
>>
>>59661603
When hashing, you convert an arbitrary value to an integer. You can do that uniquely for any finite value, but that's really not very useful as the values get very large; everyone instead maps to small integers (32 bits often). That's going to end up with things mapping to the same thing, but getting Perfect Hashing (which doesn't do that) right is much harder than handling collisions. Since collisions are handled anyway, there's no shame in reducing the size of the hash value after computing it; the mod operator is a favorite way of doing that.

Practical code handles collisions by hanging other data structures (usually lists or trees) off the hash table entries; those use normal comparison. Things are kept efficient by occasionally growing the hash table when the number of values grows.
>>
>>59661635
>very interesting applications
Yes, that was the point of what I said. The interesting bits are exactly the applications. Some people really like that. (Me, not so much.)
>>
>>59661677
>so 13 is not in the result
I'm talking about the order of the set. The first is ordered, the second is second isn't. This has broken a function I made, as I relied on the order of integers in the set for set.pop().
>>
>>59661734
sets are not ordered in python. use lists, if you want a defined order.
>>
>>59661701
IBM also sold computers to the third reich so they they could extrapolate public records and target all the undesireables and ship them off to death camps.
>>
I'm having a fucking brain fuck right now.

In C, say
int i=5,x=10,n;
n = i + i + x*++i;


n is coming out to be 70. I cannot wrap my head around it at fucking all.

First, ++i should become 6. Then 6*10 = 60, then 60 + 6 + 6 = 72.

But for some reason, i+i is happening before ++i. Why the fuck would addition happen first? I thought maybe it was a "left to right" error, but if I do
n = i + x*++i
Then ++i IS executed first, and I get a result of 66. What the actual fug?
>>
>>59661575
don't think you can pull that off desu
>>
>>59661759
that's undefined behaviour
>>
>>59661783
How is order of operations undefined behavior?
>>
>>59661759
That is undefined behaviour.
You can't have an operator with side effects (++) mixed with another use of of it.
If you compiled with -Wall (which you always should), you should have received a warning.
>>
>>59661701
>Data science is a tool and like all tools, it all depends on how it's used
It's the same retarded argument gun owners make about knives. If it's a tool which is commonly misused, and those misuses wouldn't be an issue without it, then the fault is clearly in the tool itself.
>>
>>59661759
>n = i + i + x*++i
altering a variables value and reusing it in the same expression is undefined behaviour
>>
>>59661790
It's not the order of operations, it's the use of side effects on a callee without statement point.
>>
>>59661790
Because you're changing the value of a variable mid equation.
>>
>>59661794
Now that you say that, I do have that warning

>>59661805
>>59661783
thanks. I never really had that problem before.
>>
>>59661759
C doesn't permit this kind of cheap hack, and rightfully so.
>>
>>59661783
>>59661794
It's unspecified behaviour retards.

>>59661790
It's unspecified whether the other instances of i are from before or after the increment.
>>
>>59661823
Order of evaluation is unspecified, but those sorts of uses are explicitly labelled as undefined.
>>
int i = 1;
printf("%d %d %d %s\n", i++, i++, i++, "GO!!");
>>
>>59661762
I'm trying without having T defined now but it doesn't make things any easier
constexpr auto& operator()(vector2i p) noexcept { return const_cast<std::remove_const_t<decltype((*this)(std::declval<vector2i>()))>>((*this)(p)); }

(that doesn't compile either btw)
>>
>>59661245
Representing a float point number as a string in C. I'm afraid I'm doing Pajeet-tier code though.
>>
>>59661845
you sure love to obfuscate your code
>>
>>59661840
Can someone explain this?
Why does it print 3 2 1 ??
>>
>>59661851
>float point number as a string
Then it's not a floating point number anymore.
Did you by any chance wanted to achieve something like fixed point arithmetic?
>>
>>59661959
It's undefined behaviour.
Any result is completely meaningless.
>>
>>59661959
scroll up
>>
>>59661959
Apparently this compiler processes parameters right to left
>>
>>59661837
Should they be? There are just multiple reasonable answers you could get, unlike undefined behaviour where there is no reasonable answer at all.
>>
>>59661959
it don't
>>
>>59661967
No, I want to do it to write a JSON file.
>>
>>59662037
If I start trying to access an uninitialized pointer and incrementing it by a random value, the program might segfault, or it might not.

I can't predict my program will run as intended every time.
That's undefined behavior.
>>
>>59662037
Yes. Those sorts of statements are dubious at best, and I have no issue with them being explicitly forbidden.
>There are just multiple reasonable answers you could get
Considering how wildly different they may be, there is just no reasonable way to write a portable program that takes these into account.
It's just like signed integer overflow. INT_MAX+1 could be INT_MIN or -0. These are REALLY different answers.
>>
>>59662087
>>59662101
I'm not saying it's okay to rely on any one possibility just because that's what your compiler is doing, but what does the specification really say? Is the compiler free to make demons fly out of your nose in this scenario?
>>
>>59662146
the c compiler is free to make any assumptions that aren't explicitly covered in the standard
>>
>>59662146
I looked it up before:
http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1570.pdf
Page 76
6.5 Expressions
>If a side effect on a scalar object is unsequenced relative to either a different side effect
>on the same scalar object or a value computation using the value of the same scalar
>object, the behavior is undefined. If there are multiple allowable orderings of the
>subexpressions of an expression, the behavior is undefined if such an unsequenced side
>effect occurs in any of the orderings. 84)
Footnote 84
>This paragraph renders undefined statement expressions such as
i = ++i + 1;
a[i++] = i;

>while allowing
i = i + 1;
a[i] = i;
>>
>>59662173
That's an irrelevant tautology.

>>59662203
Okay, I'm just mixing it up with argument evaluation order which is unspecified.
>>
File: Poster.jpg (4MB, 3253x4807px) Image search: [Google]
Poster.jpg
4MB, 3253x4807px
Here, /g/. I found this and thought of you. Had to kill the quality to get the file size down, though.
>>
Here's a challenge: write a program that takes an image input, and has a boolean output. The output will signal whether the input was a Twitter post screencap. Maybe you can cleanse the cancer off this website.
>>
>>59661500
>>59661518
>AT&T syntax
Disgusting
Anyway, look at volume 2 of the Intel Developers Manual, it describes all of the x86 instructions in full detail. Once you run imul, you can probably move the contents of RDX:RAX into two different variables and print the contents of them from there to see if it worked correctly. Can probably even create a struct to hold and work with the 128-bit variable afterwords.
>>
>>59662229
>That's an irrelevant tautology.

Incorrect.
>>
>>59662229
>That's an irrelevant tautology.
it's always people who are uninformed who think they know shit. printf("%d", i++); is undefined
>>
>>59662291
>printf("%d", i++);
I'm sure you meant to put another i++ in there.
That's just a normal printf.
>>
File: 1482567631098.jpg (52KB, 424x542px) Image search: [Google]
1482567631098.jpg
52KB, 424x542px
>>59662291
>printf("%d", i++); is undefined
>>
>>59662244
I want that poster on my wall
>>
>>59662291
Does ++ and -- even need to exist if its going to be such a cluster fuck?
>>
How do I convert any given infix expression to an s-expression?

Eg: (1 + 2 * 3) -> (+ 1 (* 2 3))
>>
Visual Studio Two Thousand Seventeen Er Ce Enterprise Edition.
>>
>>59662364
Operator precedence
>>
>>59662354
Many languages don't have them cause they're shit.
>>
>>59662354
They seem useful enough, but I understand why people might not want them.
But the undefined behaviour actually extends beyond that, as it also includes the assignment operators, and you certainly wouldn't get rid of those.
>>
>>59662354
It's only a clusterfuck because of baboons not knowing how to properly use them.
>>
File: thFT9PTT2O.jpg (11KB, 300x225px) Image search: [Google]
thFT9PTT2O.jpg
11KB, 300x225px
>>59662414
Please elaborate?
>>
>>59662538
* has higher precedence than + so you know that it's (+ 1 (* 2 3)) and not (* (+ 1 2) 3).
>>
>>59662538
Look up the shit to write a simple recursive decent parser for arithmetic expressions.
Then just spit out the polish notation when you're done.
>>
>>59662538
https://en.wikipedia.org/wiki/Shunting-yard_algorithm

that one is easy to modify to prefix notation
>>
>>59662244
>mz-700
ik heb nog zo'n ding ergens
nooit geweten dat die basic had.
>>
File: 1445619810295.jpg (81KB, 960x717px) Image search: [Google]
1445619810295.jpg
81KB, 960x717px
Is it possible to use multiple threads in an event based program?

So I create an object, call a connect() function that hooks up my events, then call object.run(). Can I set it up in a way where objects in my events aren't considered to be part of the thread that calls object.run()? idk if this is a stupid question or not
>>
>>59662646
make the event dispatcher spawn more threads.
>>
>>59662646
Sounds like a recipe for disaster.
>>
>>59662646
make the event dispatcher spawn more threads.
Sounds like a recipe for disaster.
>>
>>59662646
Souds like a recipe to spawn more threads
>>
>>59662646
make the recipe spawn more disaster threads.
>>
Today, I finally learned how to draw a concave polygon in OpenGL. I feel fulfilled.
>>
>>59662646
mkea the ntvee dspcaierth apswn (more | oemr) erhtdsa.
suodns eilk a (pireec | eripce) rfo dstaiesr.
>>
File: 1454789215951.gif (1MB, 245x280px) Image search: [Google]
1454789215951.gif
1MB, 245x280px
dont ever le change /g/ xD

my leles are in orbit
>>
>>59662818
upvoted xD
>>
What objectively sounds like a recipe for gitting really gud?
>>
>>59662834
git gud
>>
>>59662834
git clone gud.git
>>
Started learning Visual Basic a few days ago. Its a program that calculates the price of a pizza including a discount if you buy a lot of pizzas. Am a computer engineer yet /g/?

 Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
Dim numPizza As Integer
Dim totalCost As Double

numPizza = CInt(txtPizza.Text)

If (numPizza >= 3) Then
totalCost = (10.5 * numPizza)
ElseIf (numPizza = 2) Then
totalCost = 23.5
ElseIf (numPizza = 1) Then
totalCost = 10.5
End If

If (totalCost > 40) And (totalCost < 59) Then
totalCost = (totalCost * 0.95)
ElseIf (totalCost > 60) Then
totalCost = (totalCost * 0.9)
End If

txtCost.Text = "Your total cost is " & "$" & (totalCost)
>>
>>59662834
learn all the shit your language can do.
Start making programs until you get to know how to solve almost every problem.
Probably won't work but my tiny brain can't think of anything better.
>>
Was going to try to make a GUI text editor with FLTK, but I realized that they literally have a #include file with a text-editor implementation

I'm going to try to move to ncurses to focus more on the text-parts... Quick question: I downloaded ncurses 6.0 and I can't seem to run the test programs

When I run them (after
 ./configure
make

I get the folowing error:
Error opening terminal: xterm.

wtf?
>>
>>59662891
i wish i could be this good
>>
How can I generate an image pixel-by-pixel then display it using Swing + AWT?
I can't find anything clear in the documention for creating the image, I assume displaying is easy though.
>>
>>59662901
wtf
>>
File: That's What I was going to say!.gif (575KB, 500x206px) Image search: [Google]
That's What I was going to say!.gif
575KB, 500x206px
>>59662925
>>
>>59662921
>write a generation program in C
>make wrappers
>make shared lib
>use jna

or use BufferedImage
>>
>>59662958
AWT doesn't have BufferedImage.
>>
>>59663052
Oh, wait, it does.
>>
Why the FUCK do people masturbate so much to CoCs?
>>
>>59663097
What are CoCs?
>>
>>59662943
Nice tumblr gif, fag.
>>
>>59663103
cocks aka code of conduct
>>
>>59663113
I don't know what's it.
>>
>>59663097
The rust post not go well?
>>
File: 1439955449398.jpg (539KB, 1200x1192px) Image search: [Google]
1439955449398.jpg
539KB, 1200x1192px
Is type inference heresy? Should every term be explicitly typed?
>>
>>59663170
Type inference is wonderful.
>>
>>59663170
look at this sentence.
>>
>>59663170
Use types to write programs, dont use programs to infer type. Arguments are fine, type declarations should be explicit.
>>
What book should I get to learn C++?
I have a very basic knowledge of C
>>
>>59663187
What if it's undecidable in certain cases?
>>59663190
It appears to be untyped. Meaning it probably has a lot of paradoxes in it.

>>59663200
But why not make argument types explicit too in the arguments themselves?
>type declarations should be explicit
Of course, that's a given.
>>
>>59663200
I agree that top-level definitions should be explicitly typed but things like let bindings should have inference.

>>59663215
Restrict to a decidable fragment or just give up and ask the user for an annotation.
>>
>>59663215
>But why not make argument types explicit too in the arguments themselves?
if your language of choice doesnt allw this then switch.
>>
File: 1490451897463.png (902KB, 900x1482px) Image search: [Google]
1490451897463.png
902KB, 900x1482px
How do I even get a job in 3D graphics programming? I'm stuck doing shitty fucing web apps. Every position for graphics requires experience and I can't get any. I'm not sure if I should stary lying on my resume or just kill myself, I should have studied physics.
>>
>>59663234
>Restrict to a decidable fragment
Should I even bother though?
>>59663236
My language of choice doesn't have types yet, which I'm currently in the process of adding.
>>
>>59663203
C++ Primer
Bjarne's book(s)

Anything books that are used in college-level courses that use C++

And looking things up when you aren't sure about something
>>
>>59663255
Look into bidirectional typing. It's decidable, doesn't require unification, and typically only requires the user to write top level type annotations.
>>
>>59663279
Is it compatible with dependent types?
>>
>>59663215
>But why not make argument types explicit too in the arguments themselves?
This is what I like about LLVM IR. Even if you're just writing
x = 2 + 2
, you have to annotate it to confirm that it is in fact taking two i32 arguments and producing an i32 result.
>>
>>59663255
Allow the programmer to be as explicit as possible. Allow inference only when it doesn't create unnecessary work in a guise for convenience.
>>59663298
yes
>>
>>59663298
Yes, I believe that's actually where it comes from.
>>
>>59661365
c > lisp > c with lisp-like run-time compiler and macros > c with lisp-like macros > c with templates > c with classes > c++
>>
>>59663170
I recently found out about the expression templating pattern in C++. It produces types like this:
foam::composition::expression<foam::composition::details::binary_expression<foam::composition::expression<foam::composition::details::binary_expression<foam::composition::expression<int>, foam::composition::expression<int>, foam::operators::multiply> >, foam::composition::expression<int>, foam::operators::multiply>>

I hope to never write something like this myself.
>>
>>59663368
literally just include two typedefs
>>
>>59663374
>just patch it up with glue and ducktape
>>
>>59663097
It's an easy way to pad out your github with accepted pull requests.
They're also 100% effective because if they say no, you can just stir up some shit in the issues and report them to github and they'll probably ban him.
>>
>>59663097
It's just a fucking well-written porn game alright?
>>
>>59663169
I used awt.BufferedImage like maybe a month ago

You sure you got everything right?
https://docs.oracle.com/javase/tutorial/2d/images/drawonimage.html
>>
>>59661245
Screen's region to OCR to editable buffer GTK dialog to google translate website.
Based in Python; I hate Python but I thought it was the best language a short script with access to GTK.
It's currently working, but I'd like to add multiple lines support in buffer edit (currently just a GtkEntry) and use a bigger font there. Then it would be nice to avoid using web browser to GET translation.
OCR is tesseract and screenshot dispatcher is any program; but:
xfce4-screenshooter -o <your-program> -r

works nicely.
Purpose? Reading in manga fat kanjis easily.
>>
>>59663426
What are CoCs?
>>
>>59663468
a code of conduct
it's an insulting document that says you have to defend women and people of color and remove "problematic" contributors if they assail women or people of color, even if it falls outside of the scope of the project, like a lone developer making a twitter comment voicing his poltical opinions, completely unrelated to your project.
>>
>>59663374
The point is for the type to be an arbitrarily deep tree of templates representing a computation (e.g. 1+1+1+1+1), so typedefs aren't going to work.
>>
>>59663490
What kind of shit project are you working on?
>>
Just bought a cheap domain name, installed Ubuntu Server on the shitty old desktop no one in the house uses anymore, tightened down the security, assigned a static IP, forwarded my ports, and forwarded my whois. Now it's time to start developing my web app.

The idea is a hardcore automated life coach.

It lets you set goals -- but once you've set a goal, you can't delete it. That way, once you've made a commitment, you can't back out, ever, no matter how misguided you later decide you were -- or, on the positive side, whether you think you need it anymore or not.

Every day, it will email you at an address you supply, which should preferably be one you can't run away from, like your work or school email, or even your SMS proxy -- and it gives you a list of all the goals you have, as a reminder -- sorted from least successful in the past to most, so that the first thing you'll see is what you most need to work on.

Until the end of the day, you're then locked out of your account. After, say, 9:00PM for example, you can log back in and check things off your list for the day, to say, "yes, I succeeded meaningfully at advancing this goal today" -- and each time you do so, you'll be required to supply a note that's different from any such note you've put in over the past seven days, or it won't let you check it off. (The more effort you have to put into lying, the more your guilt will drive you not to. Furthermore, this encourages progress, rather than just cultivating the new habit in the same limited, stagnant capacity every day.)

Once you check a task off, the fact shall be forever recorded, and publicly visible, that you successfully advanced that goal on that day, and shall be added to a pool of past successes from which a random entry will be appended to each morning message; this serves as both a helpful and motivating reminder of your personal strength if you told the truth, and, if you lied, an agonizing reminder not to lie again.

(cont)
>>
rate my library functions, /g/.
io::keyboard keyb { std::make_shared<io::ps2_interface>() };    // set up keyboard

chrono::chrono::setup_pit(true, 0x1000); // set up clocks
chrono::chrono::setup_tsc(1000);
using clock = chrono::tsc;

dpmi::mapped_dos_memory<std::uint16_t> screen { 80 * 50, dpmi::far_ptr16 { 0xB800, 0x0000 } };
matrix<std::uint16_t> m { 80, 50, screen.get_ptr() };
for (auto y = 0; y < m.height(); ++y)
for (auto x = 0; x < m.width(); ++x)
m(x, y) = 0; // clear screen

auto r = m.make_range({ 10,10 }, { 60,30 });
for (auto y = 0; y < r.height(); ++y)
for (auto x = 0; x < r.width(); ++x)
r(x, y) = 0x1000; // draw a blue rectangle

vector2f delta { 0,0 };
vector2f player { 20,20 };
auto last_now = clock::now();
while (true)
{
auto now = clock::now();
float dt = std::max(0ll, (now - last_now).count()) / 1e9f;
last_now = now;

using namespace io;
keyb.update();
if (keyb[key::up]) delta += vector2f::up();
if (keyb[key::down]) delta += vector2f::down();
if (keyb[key::left]) delta += vector2f::left();
if (keyb[key::right]) delta += vector2f::right();
if (keyb[key::esc]) break;
if (delta.magnitude() > 1) delta.normalize();

r(player) = 0;
player += delta * 10 * dt;
r(player) = 0x0701;
delta -= delta * (dt / 2);
thread::yield();
}
>>
>>59663557
(cont)

On the other hand, if there are tasks you DIDN'T check off for a day, counters for those tasks will increase. (The counters are reset to 0 when you successfully complete the tasks for more than one day in a row. Also, if you don't login for a day, all the counters increase.) When counters start reaching critical levels (say, 4) it will start demanding you contact someone for emotional support. If counters reach even more critical levels (say, 7) it will contact a voluntarily stored contact automatically at random to inform them you need emotional support. But it will only do this once per continuous incident, obviously, because to do otherwise would be fucking awful. (If you ever have no such contacts, it will email you constantly until you have one. This is less awful because you'll have consented to this spam-like behavior when you signed up.)
>>
>>59663557
>>59663638
Looks like a hell.
>>
>>59663622
>for for
start over
>>
>>59663644
That's the idea. It prioritizes what the user wants in their life over what would be a comfortable and liberating experience for the user. That's a sacrifice that's necessary for any kind of lifestyle change or personal growth, but it's often one people are more willing to make up front than to stick to. The idea here is an app that bridges that gap, by letting you make the commitments up front and then sticking you to them FOR you, without your continued consent.
>>
>>59663638
If you want a successful app you must provide instant gratification instead of forcing people to put effort

Also such mailing behaviors would probably get you into a lot of mailing blacklists rather quickly
>>
File: 1452471092796.png (372KB, 1280x720px) Image search: [Google]
1452471092796.png
372KB, 1280x720px
>>59663622
>This is idiomatic C++
How do people defend this language?
>>
>>59663658
yeah I need a fill() function there I guess.
>>
>>59663681
Effort is the way forward, and some people need to be forced. This is for people who know that about themselves.

Mailing blacklists could be a problem. I will have to think about how to circumvent that problem. (With the user's consent, of course, so that it won't be illegal.) If users can just mark things as spam and be done with it, then at some point they probably will; everyone's resolve breaks eventually. But that doesn't mean giving up is what they really, deeply WANT to do. It never is. It just means they're tired, and need temporary relief. But if they were in their right mind, they wouldn't want to allow themselves that relief, and so this app must not allow it to them either.
>>
>>59663721
Don't get me wrong, i totally agree with you but don't expect the app to be sucessful, if you don't care about that by all means go for it
>>
>>59663721
it sounds like you are talking about yourself rn tbqh
>>
>>59663622
Are basic inputs the only thing you have wrapped?
You planning a new C++ gamedev library?
>>
>>59663687
>hurr durr C is portable assembler!!!
that's why
retards are too afraid to touch raw pointers
most C implementations don't even let you touch raw memory, just virtual memory
>>
>>59663749
I absolutely am. I'm making this app for myself, really; I'm just talking and thinking about it in terms of a multi-user sort of thing because if I find it's helpful for me, I'll want to help others if I can.
>>
>>59663758
>retards are too afraid to touch raw pointers
Things become miles worse when retards are not afraid to touch raw pointers and they do touch them.
>>
I'm using AWT and Swing, how do I draw an image (belonging to the Image superclass) in Java?
I've found out how to draw text, but the same method won't accept images.
>>
can someone link me to the dpt programming task thing? I need to bookmark it
>>
>>59663754
yeah gamedev is one of the planned uses. right now it does:
-memory access/remapping
-irq handling
-cpu exception handling
-multithreading/coroutines
-clocks
-gdb remote debugging
-keyboard input, optionally event-driven
-serial port i/o
>>
>>59663857
>>59656757
>>
File: hqdefault (1).jpg (27KB, 480x360px) Image search: [Google]
hqdefault (1).jpg
27KB, 480x360px
>>59663792
>shitty ancient OS doesn't have memory protection
>shitty C implementation maps pointers too small to be valid to various device streams
>write data through null pointer somewhere
>accidentally overwrite boot partition
>>
>>59663880
>-irq handling
wew, how low level/broad use you planning?
Currently working on one myself so its nice to get other designs.
>>
>>59663897
What is this wall of greentext supposed to mean?
>>
>>59663930
highly improbable example of why it's bad for ignoramasauruses to use pointers
>>
File: uhh-cover.gif (191KB, 400x508px) Image search: [Google]
uhh-cover.gif
191KB, 400x508px
>>59663930
>>
>>59663886
you the real mvp.
Time to not be a shitter.
>>
>>59661327
Have both those books, how nostalgic.
>>
>>59663978
no hablo ingles
>>
>>59663930
It means that it's better if retards fear doing something wrong rather than touching it and do disasters.
>>
>>59663919
it's for 32-bit dos, which doesn't do all that much for you, so implementing this low-level OS functionality is a basic requirement.
>>
>>59664005
Is the retard in this allegory whoever makes this mistake, or whoever authored the hypothetical C implementation it's possible in?
>>
>>59664002
gracias por la ayuda.
eres el MPV reales
>>
File: 1472601193062.gif (2MB, 320x320px) Image search: [Google]
1472601193062.gif
2MB, 320x320px
For a class I need to make a Sodoku solver using a premade blank project.

I've implemented everything and it works, but I have a problem. I need to find a way to make the recursion stop when a solution is found, instead of continuing to run. The presupplied method is void, and it throws no exceptions.

How am I supposed to do this? He says to use the "Backtracking method given in lecture" but I was sick for that one so I have no idea what he's talking about other than standard recursion fare.

How is it even possibly to unwind the stack if there is no return value or exception thrown?
>>
>>59664074
Why recursion?
Just solve it the same way you'd verify it IRL.
>>
>>59664074
Depending on the language you're using and your personal preference, you need either:
>mutable static local variables
>a single immutable static local variable that's initialized to the current continuation at the top level of recursion
>>
File: 1486399766979.png (342KB, 394x394px) Image search: [Google]
1486399766979.png
342KB, 394x394px
>>59664074
>>
>>59664131
Because that was the assignment

>>59664135
I get neither of these. Wtfe professor
>>
>>59664070
De nada.
>>
I want a list of randomly generated characters for a password. would I be better off with an array or a list?
>>
>>59664074
>Because that was the assignment
just use a setjmp/longjmp
>>
>>59664074
How do you define a solution? All spaces filled? Then keep a counter, Does the algorithm change the board when it keeps running after it's found a solution? If no, compare with the previous board state.
>>
>>59664143
Just store the result in a static variable and return void.
>>
>>59664074
>recursion only using side effects for output
Your professor is an idiot.
>>
>>59664150
definitely an array
>>
File: 1489243348388.jpg (92KB, 336x422px) Image search: [Google]
1489243348388.jpg
92KB, 336x422px
Why do some languages differ subroutines/procedures and functions?
>>
File: Untitled.png (366KB, 484x480px) Image search: [Google]
Untitled.png
366KB, 484x480px
>>59664074
my god it's beautiful
>>
File: AAAAAAA.png (576KB, 531x720px) Image search: [Google]
AAAAAAA.png
576KB, 531x720px
If I wanted to write a sudoku solver, can i get away with randomizing the missing numbers and running them through a sudoku checker until one clicks?
>>
>>59664427
i don't know how to play sudoku but if there are more than 4 numbers it would take too long.
>>
>>59664427
It's just dumb.
>>
When devs use multiple languages for a program do they just use something like json as a liaison to transfer variable values?
>>
Finally getting around to learning ncurses

How do I make a "buffer" around the area I'm typing (I think the proper term is a "virtual" window).
>>
>>59664427
If you are happy with waiting a million years to find a solution, sure.
>>
>>59664303
Generally, a subroutine is like a lower level version of a function, while a procedure is something entirely different that serves a similar purpose.

Subroutines:
>can't necessarily accept parameters
>can't necessarily return values
>can't necessarily be called from anywhere but top level

Functions:
>like subroutines, except they can do all of those things always

Procedures:
>like functions, except often inlined instead of pushed to the callstack
>because of this, they aren't necessarily closures, and might support scope injection, i.e. variables in the calling scope with the same names as undefined variables in the procedure body can provide definitions for the variables in the body
>can often be dynamically built from other procedures
>>
>>59664590
>write a version of lisp intended for quantum computers
>new feature: if you can guarantee nothing with any side effects happened between obtaining a continuation from a given evaluation context and calling it to jump back to that context, the compiler can actually take advantage of the quantum computing technology to have the continuation call jump back in *time*
>use a continuation to return the solution once it's found
>time complexity: O(1) (retroactively)
>>
Finishing up some web work and some SEO marketing advice for my first freelance web development client.
>>
File: brain.jpg (128KB, 612x403px) Image search: [Google]
brain.jpg
128KB, 612x403px
Trying to write a simple perl (Modern Perl) script where the user would enter 6 integers and the script would print out the largest entered and the smallest entered.
Printing the messages and numbers is taken care of, just having trouble figuring a simple way for the script to correctly pick the largest and smallest integers.
Tried using if and else statements, but it's only recognizing the first and last integers entered. Plus, I feel like I'm using way too many if and else statements anyway.
Any help would be much appreciated.
>>
>>59664607
>>59664653
who are you quoting?
>>
>>59664681
>not knowing what greentext is
This meme needs to die
>>
Here's an idea hot-shot, how about instead of shit GC, just make a language without garbage.
>>
>>59664427
That's the same as sorting a list by continuously randomizing the list until its sorted
>>
I'm trying to get an array of characters to return a string to be printed out. I thought

return code.ToString; would work but the output only says "System.Char[]"

not the actual array contents.
I get no errors to help me out, what Might I be doing wrong here?
>>
>>59664667
>the script to correctly pick the largest and smallest integers.
Turn it into a range
sort
return [0] and [0..$-1]
>>
File: Screenshot_20170330-190941.jpg (288KB, 1104x1240px) Image search: [Google]
Screenshot_20170330-190941.jpg
288KB, 1104x1240px
>>59664653
Wouldn't work, you'd cause a time paradox. Classic mistake for a novice quantum programmer.

You need to wrap the call to the random solving function in a thread object to be executed by an alternate universe version of your computer. Pass the continuation into the thread, so that when the function finishes and returns via the continuation, the return value is accessible back in the alpha timeline. No risk of time paradoxes; time travel isn't even necessary, because two distinct universes don't share a parallel notion of time.
>>
>>59664768
okay so I made progress. i needed to use new string(code) instead of to string. but this only shows one character instead of the entire string.
>>
>>59661245
was going to work on my game for a couple hours but came here to shitpost instead
>>
I'm having an issue in C++. A class is functioning as though it's keeping a copy of all member variables for each function. eg:

class test {
private:
uint8_t num = 0;

public:
void do_something() {
if (num < NUM_MAX) {
stuff();
++num
}
else {
num = 0
}
std::cout << static_cast<int>(num);
}

uint8_t get_num() {
return num;
}
};

int main() {
test_class test;
std::cout << test.do_something() << " " << static_cast<int>(test.get_num() << " " << test.do_something());
return 0;

would output "1 0 2". I didn't test what I just wrote up quickly, but it's functionally the same. What the hell is the problem?
>>
File: nani?!??!.jpg (270KB, 1920x1080px) Image search: [Google]
nani?!??!.jpg
270KB, 1920x1080px
Is this bad form?
if (!(fp = (!strcmp(path, "-")) ? stdin : fopen(path, "r")))
abort();
>>
>>59665002
*attempting to understand*
*brain's CPU fan becomes very loud*
>>
>>59665002
Depends. I don't like very terse code styles and tend to be more verbose. Someone who programs constantly, knows multiple languages, etc, might be the inverse. Verbosity becoming either unnecessary or negative for comprehension.

That's why working on a project by yourself is nice.
>>
File: 1490691259603.jpg (151KB, 1189x780px) Image search: [Google]
1490691259603.jpg
151KB, 1189x780px
Rust will replace C++
>>
>>59665002
It's ambiguous, for one thing. If you don't know ? has higher precedence than =, its meaning changes significantly, in such a way that it becomes useless and borders on algorithmically incorrect.
>>
>>59665053
your ass will be filled with cock
>>
Learning haskell because I hate my life

How do you do a pattern with a condition?

like if I'm doing a collatz function I want to check if the initial number is less than 0
>>
>>59664703
Who said that?
>>
>>59665148
That's easy just go stand in the corner of your street at night.
>>
>>59665053
if it had better generics that were in the same universe as templates, maybe
>>
>>59665157
Putting > at the beginning of the line doesn't always mean it's a quote. In fact, on this website, it's more commonly used to denote sarcastic or facetious roleplay as a rhetorical device.
>>
>>59665053
I hope not. I like C++ and dislike Rust.

You can't even tell me I'm wrong, because I am the final authority on my own preferences.
>>
>>59665183
C++ templates are broken
>>
>>59665186
But who did you quote tho'?
>>
>>59665186
>Putting > at the beginning of the line doesn't always mean it's a quote
That's the only thing it can mean, read the rules.
>it's more commonly used to denote sarcastic or facetious roleplay as a rhetorical device.
I don't know where you got this stupid idea.
>>
>>59665204
I didn't, it wasn't a quote.
>>
>>59665203
still better than java-tier generics.
>>
>>59665212
in one of these posts you quoted nonexistent text:
>>59664607
>>59664653
>>
File: laughing_loli.jpg (19KB, 372x351px) Image search: [Google]
laughing_loli.jpg
19KB, 372x351px
>>59665053
>his language doesn't even properly support tail recursion optimization
>>
Future applications for cross platform desktops will be made in pure HTML.
>>
>>59665236
>his language doesn't even properly support tail recursion optimization
He didn't say this.
>>
>>59665236
rust really doesn't optimize tail recursion?
>>
>>59665197
No you're not, I am.
>>
>>59665236
Hey ho, who are you quoting?
>>
>>59665249
Was he talking about Rust? He said "his language" and that poster didn't say that Rust was his language.
>>
>>59665231
No I didn't, those weren't quotes.
>>
File: muhgame.png (14KB, 728x466px) Image search: [Google]
muhgame.png
14KB, 728x466px
almost got a game going
>>
Say I worked for a company for a short period of time (no contract, etc) and wanted to replicate their product. Am I allowed to do this? I didn't have access to their backend, but I did see how they stored all their data and a bit of the front end, but I don't plan to 'copy' their design as it was pretty inane imo.
>>
>>59665290
Why did you quote them tho'?
>>
>>59665290
Why did you quote them then?
>>
>>59665299
>(no contract, etc)
then they have nothing substantial besides a generic" he stole muh thing" petty suit.
>>
>>59665296
>>59665329
>muh
Good post.
>>>/r/ibbit
>>>/v/
>>
>>59664929
Okay, I give up I'm doing something wrong. and I cant find it on google. why is my array only returning 1 value instead of all 8?

    class Passgen
{


public String Generate()
{
char[] code =new char [8];

Random PRNG = new Random();

foreach(int c in code)
{
switch (PRNG.Next(1,35))
{
case 1:
code[c] = '1';
break;
case 2:
code[c] = '2';
break;
case 3:
code[c] = '3';
break;
case 4:
code[c] = '4';
break;
case 5:
code[c] = '5';
break;
case 6:
code[c] = '6';
break;
case 7:
code[c] = '7';
break;
case 8:
code[c] = '8';
break;
case 9:
code[c] = '9';
break;
case 10:
code[c] = 'a';
break;
(and so on)
code[c] = 'y';
break;
case 35:
code[c] = 'z';
break;
default:
break;

}

}
return new string(code);
}
}


I'm sure this is the hardest way to do this, forgive me for that. could anyone point me in the right direction?
>>
File: pet.gif (328KB, 500x517px) Image search: [Google]
pet.gif
328KB, 500x517px
>>59665247
>>59665266
>being this new

>>59665285
Rust doesn't properly support tail recursion optimization.
>>
File: .gif (923KB, 450x259px) Image search: [Google]
.gif
923KB, 450x259px
>>59665236
>his language doesn't even properly support recursion
>>
>>59665342
You're part of your own problem.
>>
>>59665301
>>59665312
I didn't, they weren't quotes
>>
>>59665357
From who did you reference this statement?
>>
>>59665357
C++ doesn't properly support recursion. You have to simulate it using a depth-first traversal of a generated tree of states
>>
>>59665357
>being this new
Who said this? Why are you quoting it?

>>59665372
So according to you prefix notation for "" somehow isn't a quote?
>>
>>59665299
Depends. Do they have copyright on their product? Are they big enough to sic their lawyers on you?
>>
>>59665145
But it's pretty obvious that the assignment from the ternary operator will be assigned to fp and this is checked for null.
>>
ML was robbed
and it has cost us more than we will ever know
>>
>>59665412
ML doesn't even have a real type system.
>>
>>59665394
>So according to you prefix notation for "" somehow isn't a quote?
That's right. Not around here. Or rather, around here, it's only a quote sometimes. Other times it's an indicator for sarcastic or facetious roleplay as a rhetorical device. It can also be an indicator for amused exasperation. All depends on what makes the most sense in context.
>>
>>59665372
But why did you tho'?
>>
>>59665424
>That's right. Not around here. Or rather, around here
what did he mean by this?
>>
>>59665405
>pretty obvious
Yeah, after like three glances.
>>
File: ..gif (421KB, 480x360px) Image search: [Google]
..gif
421KB, 480x360px
>>59665438
>what did he mean by this?
what did he mean by this?
>>
>>59664980
Reposting.
>>
>implying I meant anything at all
>>
>>59665424
Read the rules. They pretty clearly state that I'm correct.
>>
>>59665438
>>59665448

His statement returns false.
>>
>>59665457
Is this from a book or something?
>>
>>59665461
The culture has grown to supersede the rules.
>>
What do I mean by this?
>>
File: 2.png (24KB, 142x132px) Image search: [Google]
2.png
24KB, 142x132px
>>59665457
>what
>did
>he
>mean
>by


>this
>>
>>59665488
Reddit or /v/ "culture" isn't culture at all. You can go to those places if you like quoting something which hasn't been said.
>>
>>59665343
youre not appending,merely setting [0]'s value
>>
if (false == false)

What does this mean?
>>
>>59665343
have you tried this thing called debuguh

>foreach(int c in code)
explain this statement out loud on vocaroo to fine people of /dpt/
>>
>>59665523
It means it's true if false is equal to false.
>>
I don't use a debugger
I use print statements
>>
>>59661602

>ignore the hype

So ignore AI/ML?
>>
>>59665559
>pseudo-debugging
pffffft
>>
>>59665559
Okay anon.
>>
>>59665343
Two things that might really cut down the complexity of your code:
>using a String instead of a char[] for your buffer, and then just directly returning the buffer
>pulling characters at random from an alphabet String, instead of using a huge switch block
Example:
class Passgen {
public String Generate() {
String code = "";
String alphabet = "123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
Random PRNG = new Random();
for (int i = 0; i < 8; i++) {
int pos = PRNG.Next(0, 34);
code += alphabet.substring(pos, pos + 1);
}
return code;
}
}
>>
>>59665559
Me too.
>>
>>59665519
>>59665535

Thankyou.
I should probably be using a for loop.
>>
>>59665612
You could also just set the enums instead of a switch.
>>
>>59665603
>Making 8 substring calls instead of using a char[] to call indexes directly
>Or even just string.charAt()
neck yourself
>>
File: wrog.png (331KB, 1920x1080px) Image search: [Google]
wrog.png
331KB, 1920x1080px
>>59665210
>>59665461
>>59665515
>>
>>59665649
actually the 8 substring calls are a superior method because they don't require converting the retrieved character to a string
>>
Java/programming noob. Two questions:

How are static objects not memory leaks? They can't be garbage collected right?
Is creating field variables more efficient than creating local variables for methods that are called constantly? For example, if you have a loop in a method, isn't creating a local variable "int i" in the loop each time more inefficient than having i as a field variable and using it each time?
>>
File: damnfunny.png (40KB, 675x330px) Image search: [Google]
damnfunny.png
40KB, 675x330px
>>59665603
Thankyou for the help, you set me on the right track.

I copy pasted your code, and I just thought you'd like to have a laugh with me.

i think pos + 1 is supposed to just be 1. but again ty, you made the code a lot more efficient.
>>
>>59665651
>r9k
Good. I suggest you go there and use your "greentext" as you like to call it.
>>
>>59665671
>How are static objects not memory leaks? They can't be garbage collected right?
I don't know anything about Java, but a static object can't be a memory leak unless it itself is allocating memory without freeing it properly.

Static objects are intended to exist for the lifetime of the program.
>>
>>59665671
You use static objects when you want them to be static for loop variables you just int them every loop. The same reason for static method. This prevents potential errors from occurring when compiling or in runtime since it knows a static object should remain static.
>>
ive been writing something small for python 2.7, but i cant figure out this problem

i want to replace a post that has a reply with another random post reply number
so say its originally >>1234567, so anytime it finds such a specific set of numbers in a post, itll replace it with another random post number like >>9999112, there is no formatting just directly replacement in the exact same position

right now all i can figure out is just replacing a hardcoded >>84 part, after that i dont really have any clue how to get the rest of the numbers since they are random and i only know exactly how long the post numbers will be (7 digits)

def check_for_replies():
check_this = str(get_shitpost())
new_check_this = string.replace(check_this, '>>84', ">>" + get_random_reply())
return new_check_this


 Output: 
>>17240998364502
this is a test post
>>
Haskell is the final red pill
>>
>>59665671
For the 2nd question. yea using field variables is easier, but dont make the code stupid wit it. using I for every loop is convenient until you use it 1 too many times and ruin something.

I ususally use int counter as a field variable. but thats just me. as your programs get bigger variables with smaller scope help to better keep track of things.
>>
>>59665671
>How are static objects not memory leaks? They can't be garbage collected right?
Absolutely right, and that's why you should only declare an object static if you know that for the entire duration of the program, you won't necessarily stop needing it. Static objects are never garbage collected, but they are actually freed (i.e. deleted from memory); they're freed when the program ends. You don't need to worry about this being an issue, because there's no way to get more static objects during the course of a program than just the ones the program starts out with, so there's no risk of memory filling up with uncollectable objects over time.
>Is creating field variables more efficient than creating local variables for methods that are called constantly? For example, if you have a loop in a method, isn't creating a local variable "int i" in the loop each time more inefficient than having i as a field variable and using it each time?
Having a local variable that has to be created each time a method is called is indeed less efficient than having a field for it, and having a field for it is less efficient than having a static field for it, and having one static field for it per class is less efficient than having only one static field for it for the entire program, stored in a dedicated class for global variables. HOWEVER, all of these except for the one where the variable is local are TERRIBLE STYLE. Generally, for maintainable and extensible code, it's good practice to strive to have data exist exactly where and when it's relevant, nowhere else and at no other time -- allocation and deallocation overhead be damned.
>>
>>59665757
>no dependent types
>spending more time filling in holes then writing your program
>STL is now just a bunch of X bloat
wew lad
>>
>>59665757
It's a pleb filter. I would even argue it was designed to keep plebeians away from Idris.
>>
>>59665210
Can you please post where is says it is only for quotes? Thanks.
>>
>>59665708
You miss the point. The point is, you keep suggesting it says somewhere in the rules that the > character indicates a quote and can't indicate anything else. That's the entire basis for your superiority complex on this issue, and you're not entitled to it without that basis. I just disproved that basis. Now stop acting superior.
>>
>>59665785
It doesn't, and I have proof right here. >>59665651
>>
>>59665816
It does though, right on that screenshot.
>>
>>59665744
Use regex

Something like this
>>\d{5,}


Which basically checks for >> and the next 5 characters or more being digits.
>>
>>59665784
>>59665777

*laughs*

And how many PhDs do you have?
>>
>>59665820
Actually, the screenshot says the opposite. Not anywhere on the webpage, mind you. Right in the interface of the browser, it clearly says that nowhere on the webpage does it say the > character has to be used to indicate a quote.
>>
>>59665833
Did you even look at the screenshot?
>>
>>59665820
I'm glad to know you're genuinely retarded
>>
>>59665847
Of course I did. I took it.
>>
>>59665724
>>59665727
>>59665761
>>59665770
Thanks anons.

>>59665770
>having only one static field for it for the entire program, stored in a dedicated class for global variables
Oh shit, I never thought about this possibility. I don't know shit about concurrency, but it intuitively seems it would lead to problems. In any case, if there is a trade off between readability and efficiency it sounds like a case by case scenario for what's best.
>>
>>59665832
None.
>>
>>59665853
That's even more disturbing. Why would you not even check your screenshot before posting it?
>>
>>59665876
I did, and it clearly demonstrates that the rules don't say you have to use > for quotes and can't use it for anything else.
>>
>>59665884
He's trolling you
>>
>>59663819
plz
>>
>>59665702
Heh, whoops, that's pretty funny.
No problem, glad it helped.
>>
Languages with (((structs))) and classes are cpmmunism. Don't call yourself Americans if you use them
>>
>>59665884
Are you daft? They literally say that on the left half of your image.
>>
>>59665915
>Don't call yourself communists if you use them
What did he mean by this?
>>
File: cpmmunism.jpg (50KB, 600x600px) Image search: [Google]
cpmmunism.jpg
50KB, 600x600px
>>59665915
>cpmmunism
ah so illegal on two different accounts then
>>
>>59665915
What's wrong with structs?
>>
>>59665923
they don't tho
>>
>>59665827
thank you so much
>>
Retard time: for C++, what is the pros and cons of header + implementation files Vs just header files for Classes?

I assume you use the former when you don't want to expose the implementation and just give out the interface, and the latter is for when you don't care?
>>
>>59665958
It's more than privacy. Separating the implementation into its own translation unit allows you to modify it without recompiling everything that includes the header.
>>
Are people still seriously learning C++? Not giving him a (You) in case this is trolling
>>
>>59665958
One important pro of using both a header file and an implementation file is that implementation files are compilation units. If anything defined in a header file has state, and you have to dynamically link two object files that both depend on that header file, they'll have two separate versions of the state. On the other hand, if you make it so that the header file only DECLARES the state, and then you define the state in an implementation file and compile it, you can have both object files link to the object file compiled from the implementation file, and then there will only be one version of the state. This isn't that important for things like class projects and small closed-source standalone applications, but as soon as you get into developing cooperatively with other people or communities, separating declaration from implementation becomes a necessity for this reason.
>>
>>59665958
having the implementation in the header allows the compiler to inline functions. I generally keep frequently-used and short functions in headers, and move the less-used/large functions to a cpp file.
template functions/structs must always be defined in header files or else the compiler won't be able to create the right instantiations.
>>
File: file.png (1MB, 1057x1824px) Image search: [Google]
file.png
1MB, 1057x1824px
Anybody know what could be causing these types of artifacts in volumetric rendering?

It's extremely strange to me, since the rays are firing straight out from the camera and aren't affected by angle at all...
>>
>>59666034
Link time inlining is common now so you don't need to do that.
>>
>>59661305
That doesn't make sense. You'd need to also build memory allocation into the hardware for that to be possible.
>>
>>59666024
When you say "has state", you mean that if I declare member variables to some value I'll run into the state issues? What about for initialization lists in constructors and leaving the member values undefined when i declare them?
>>
File: OjPmvLg.jpg (131KB, 772x578px) Image search: [Google]
OjPmvLg.jpg
131KB, 772x578px
>writing design specification document for a program that's only 750 lines
>on page 24, 4800 words

fucking kill me
>>
>>59665218
>C++ templates don't even have constraints
>>
>>59661305
Can't be easily updated. Are there any advantages?
>>
>>59666091
I always disassemble and inspect my compiled code, and I've never seen -flto actually inline anything.
>>
>>59665236
>>59665357
Recursion is a meme.
Not missing out on anything.
>>
File: 1426869717732.gif (767KB, 298x298px) Image search: [Google]
1426869717732.gif
767KB, 298x298px
>university wants to give me $12,500 to teach an intro to Python course
>course isn't even in compsci department, it's a business course, first-year, meant for people who have never programmed before

d-do I do it /dpt/? I don't even like python
>>
>>59666097
Class instances having state is fine, I'm talking about the class itself having state, or any friend functions having state. For example:
/* only_a_header.h */
class foo {
public:
static int bar;
};
int foo::bar = 3; // Problem! If one binary increments foo::bar, and another binary doesn't, and they're linked, they'll disagree on foo::bar's value.

/* header-with-implementation.h */
class foo {
public:
static int bar;
};

/* implementation.cpp */
#include "header-with-implementation.h"
int foo::bar = 3; // OK; if two linked binaries both include header-with-implementation.h, and also link to the binary from this implementation file, they'll both be referring to the same foo::bar.
>>
>>59666158
How can it be a "meme"?
>>
>>59666161
is it a one semester thing?
>>
>>59666178
because hes a brainlet using a poolang
>>
>>59666182

Two semester thing. 290 hour requirement.

>2hr lecture 2x a week
>the rest of the time needs to be combination of office hours, preparing work, marking
>>
>>59666205
12,500 is way too little for what they're asking

it depends if you need the experience tho
>>
>>59666205
Is this supplementary income? Otherwise $12,500 is way too low.
>>
File: file.png (4KB, 515x415px) Image search: [Google]
file.png
4KB, 515x415px
How would one find the distance traveled through a given space defined by two planes that are perfectly horizontal by a given vector?
>>
>>59666229
Compute the two intersection points, then compute the euclidean distance between them.
>>
>>59666229

minkowski metric
>>
>>59666229
convert the vector to an angle relative to one of the planes, then find the distance using Pythagorean's theorem
>>
>>59666229
sqrt(a*a+b*b)
>>
>>59666250
This is better, didn't read that they were both horizontal.
>>
>>59666247
Thanks anon, not sure why I didn't think of that given that I wrote this intersection code yesterday for something else entirely that I ended up not using

This should work for ray plane intersection, right?

float3 rayPlaneIntersection(float3 startPos, float3 dir, float3 planePoint, float3 planeNormal) {
float3 planeRelativeNormal = planePoint + planeNormal;
float d = -dot(planePoint, planeNormal);
return((-(dot(startPos, planeNormal) + d) / dot(dir, planeNormal)) * dir) + startPos;
}
>>
>>59666229
distance = sqrt((100*x/z)^2 + (100*y/z)^2 + 100^2)
>>
>>59666161

Yes you fucking do it that's how you become a real compsci department person
>>
File: dollar-sign-symbol-24.gif (233KB, 124x248px) Image search: [Google]
dollar-sign-symbol-24.gif
233KB, 124x248px
>>59666161
>I don't even like python
You do now.
>>
>>59666161
One approach I might recommend. You might not love Python, but you love computer science, right? Take the job, but instead of pretending like you love Python, try to find in Python the things you love about computer science -- even if they aren't represented as strongly as you'd like -- and let *that* inform your enthusiasm for teaching.
>>
>346
>>
WRITE YOUR CODE WITH A FULL UNDERSTANDING OF CONTEXT
THIS APPLIES TO EVERYTHING, WHY DO PEOPLE SUCK AT LIFE
WHY DO THESE PEOPLE THINK THEY CAN HAVE BRAIN JOBS?
>>
is there any way to get python regex.sub to only work once?
>>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp4
{
class Passgen
{
public String Generate()
{
String code = "";
String alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
Random PRNG = new Random();
for (int i = 0; i < 8; i++)
{
int pos = PRNG.Next(0, 61);
code += alphabet.Substring(pos, 1);
}
return code;
}
}
class Program
{

static void Main(string[] args)
{
String[] names = new String[] { "john", "becky", "sara", "Anthony", "Daisy", "bill" };
Random RNG = new Random();
String cont;
Passgen password = new Passgen();

do
{

Console.WriteLine("Your randomly generated name is {0} and your password is {1}", names[RNG.Next(0, 5)], password.Generate());
Console.WriteLine("Would you like a differentname and password? (Y/N");
cont = Console.ReadLine();

} while (cont == "yes" || cont == "y");


}

}


}


I do good?
>>
>>59666598
I think you're looking for a different method.
>>
>>59666616
im not sure what im supposed to be looking for

i only need it to replace text it finds once per call, i dont need it to replace everything all at once like it's currently doing
>>
>351
>>
File: 594854.jpg (50KB, 600x600px) Image search: [Google]
594854.jpg
50KB, 600x600px
>>59666560
>>
>>59666632
google first result

http://stackoverflow.com/questions/12732265/how-can-i-substitute-a-regex-only-once-in-python
>>
>>59665985
How the fuck is asking a question about one of the most popular non-webdev languages trolling?
>>
>>59666605
PRNG should be a member variable. No need to construct it 8 times
>>
>>59666872
I constructed it just before the for loop.
>>
new thread

>>59666918
>>59666918
>>59666918
>>59666918
Thread posts: 359
Thread images: 39


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