/dpt/ - Daily Programming Thread

What are you working on?

Old thread:

Other urls found in this thread:

amazon.com/Engineering-Compiler-Keith-Cooper/dp/155860698X/ref=sr_1_3?s=books&ie=UTF8&qid=1485499275&sr=1-3&keywords=engineering a compiler
youtube.com/watch?v=rWDNwN0h0LM
youtube.com/watch?v=rkcXRBhYZHU
boost.org/doc/libs/1_63_0/doc/html/boost_asio/tutorial.html#boost_asio.tutorial.tuttimer1
twitter.com/NSFWRedditGif

First for C++ is the best language and "Modern" bullshit like java and C# and other meme languages(go, lisp, haskell, javascript, etc) are destined to die

Many thanking you for animated picture

on a virus that will delete all animu from the internet

you can't delete anime from our hearts

And where am I supposed to search?

data Expr = Var Natural | Abs Expr | App Expr Expr

>Java
>modern
You kek

thinking of writing an arm assembly lexer. Just the lexer. Where should I start? Wheres some reading material on implementing one in something like C++?(as opposed to using one of those generators out there)

Dragon book?

Ok now write eval

I usually reply to this thread or focus in on it, but
>WHY
>THE
>FUCK
are there 3 "Daily Programming Thread"s every day. Hardly any reach bump limit. Theres currently 2 of them within the first 2 pages.

>What are you working on?
php project for uni exam that i've been procrastinating on
unlikely to make it in time but i'll try

seconded

eval = head . dropWhile ((/=) simplify) . iterate simplify

What languages can you think as used not as indented about?

How the fuck do I set up a Go workspace with multiple projects in it? I can't seem to run build or install for the life of me.

I hear about this book so much but I also hear people scorning it in this "stop recommending this old-ass book" kind of tone

This book is at my uni library though. The first edition and not the second.
amazon.com/Engineering-Compiler-Keith-Cooper/dp/155860698X/ref=sr_1_3?s=books&ie=UTF8&qid=1485499275&sr=1-3&keywords=engineering a compiler

Well memed
Now write type inference

some fag posted a new thread before the bump limit a couple of threads ago and janitors didn't delete it. just wait for it to die

install go 1.8 and mkdir -p ~/go/{src,bin,pkg}, then put your project folder in ~/go/src/yourproject

this

>C++
youtube.com/watch?v=rWDNwN0h0LM

>python, etc
youtube.com/watch?v=rkcXRBhYZHU

Do you download books?

Does it make a difference if it's in the home folder? I have all that shit set up and even set the GOPATH, but all I get is errors.

And just to be clear, you're saying that I should keep all my different projects in the src folder right?

I do but digital books are easier to "shelf" indefinitely than having a physical book to touch and interact with and taking up space. I'll check out the first edition I guess as the library only has the second edition available digitally-only as well

>links to videos
fucking niggers
I'm an intellingente purson, not ill literate, I know, how to reed, give me links to articles

yea they all have to be there(there are other hacky ways), just get over it and keep everything in GOPATH/src/

machines are fun
why did i become a computer scientist?

One thread at a time you autistic faggots.

t. OP of other thread

The other thread should've been deleted ages ago.

30th for ActionScript 3.0

second dragon book

youre writing a finite automaton so the most brute force version would be using while loops and switch statements to change state upon reading a new char, then for each lexeme you want to be writing tokens (defined as an enum for e.g.) to memory for the parsing stage.

Flash is dead, user. Use JavaScript for all of your browser applications.

What makes IO asynchronous?
I'm messing around with boost::asio async timers, but not really sure what the difference is between the synchronous timer and asynchronous timer.
boost.org/doc/libs/1_63_0/doc/html/boost_asio/tutorial.html#boost_asio.tutorial.tuttimer1
Pls explan.

Then finish it autismo

I don't have a problem with the workspace structure.

Now how do I import other files from a main file? I can't seem to get the file path right. They're in the same damn folder... how hard can it be?

Synchronous I/O: Thread is blocked completely on a read.

Asynchronous I/O: Thread continues to execute on a read, handling other requests. When the read is finished, a callback function is executed.

Parser monad

But what if prototypes give me cancer, and i write desktop apps
>implying im not aware the platform died a long time ago

If you're writing desktop applications rather than browser applications, that is twice the reason to not use Flash. You have a hell of a lot better options. Fuck, if you want to use a bytecode language, try C# or Java. If you want decent performance, use C++.

There is not a single valid reason to continue producing Flash applications in 2017.

i became an expert on this one fluffin random software package just by fiddling with it and they went ahead and hired an official "lead programmer" who is completely incompetant so it's gone without release for over a year and no pull requests get merged

open source=meme

fuckin finally I got it working. MAN there are some shitty answers to this shit on google

For mingw64, SJLJ vs SEH? SJLJ allows for 32 bit version generation as well correct? How big of a need is there for 32 bit versions for windows?

guys this might sound crazy but since Ive began studying programming a month ago I have a lot of very vivid dreams each night

>There is not a single valid reason to continue producing Flash applications in 2017.
When Javascript games are easier and faster to program than Flash games.

My main language is C++ ruby-sama, but my school refuses to use anything other than AS3 for the programming course, its shit and a toddler could get an A in the class. Anyway, im quite aware of the limitations, although i must say its quite fun to write in, this being the reason i mentioned it

>tl;dr im a faggot

The async timers still seem to block though when io.run() is called.

MinGW-w64 uses SEH by default (64-bit platforms), and SJLJ when the -m32 option is used (32-bit platforms). As a programmer, you shouldn't really concern yourself too much with which exception model is used, unless you are doing something weird. As for whether 32-bit Windows applications are still relevant... I'd like to think it shouldn't be, but I do see people who still use it, so you might as well compile two binaries.

I'm trying to make a function that returns the min value in an array that is not less than a specified value.

I need 2 local variables to accomplish this: a MinValue and a ValueFound bool.

Normally if I needed to find the min value in an array, I would just assign MinValue to the first index and wouldn't need the bool

But the problem is there's no guarantee the first value, or any value for that matter is greater than the specified minimum, hence the need for the bool.

Is there a clever way to make this work without the boolean?

If you seriously think JavaScript can be considered anything other than "easy as shit", you need to stop calling yourself a programmer.

Yes, well, that may just be an odd quirk of the Asio library. In typical asynchronous I/O setups, there is no blocking.

Lovely. Your university has decided it is absolutely necessary to impart unto you knowledge that is already obsolete.

Initialize MinValue to the largest possible value.

>minimum value in an array that is not less than a specified value
What does it return if it doesn't find one?

see You're basically looking for a monoidal property - an identity element / a zero.

If you want a well typed system, then you can't guarantee that their is a minimum (empty array) above a certain value (all elements below that), and you'd have to return something like Optional or Maybe.

What does " free(): invalid next size (normal): 0x00000000025d2e50 " errors generally mean?

Maki poster was rare lately.

Sup Forums loves maki

I see your point. What I'm actually trying to do is calculate the closest value to a specified value in an array, with a boolean to decide on a tie (I.E. specified value is 5 and both 4 and 6 exist in the array). The min thing was only part of my solution.

So when I install it just go with SEH?

maki is Sup Forums's favorite slut

graphical coding was a mistake

...

I knew I was going to get shit for posting that

Not really

More really

What is this that you are using?

do you feel like you can relate to her user? like her love for cocks and femininity?

that's ue4 right? the problem with graphical programming is that it enables shitters to "code" and use those blocks (which are black boxes for them) without any understanding.

Graphical programming is superior

I fail to relate even to anime girls

Something like this (pseudocode)?

/* Distance between two values */
function distance(a, b):
return abs(a - b)

/* Return closest element in array to value
* Boolean argument uselower tells if we should prefer the lesser of two values
*/
function closest(array, value, uselower):
x = first element of array
for y in rest of array:
dy = distance(y, value)
dx = distance(x, value)

if (dy < dx):
x = y
else if ((dy == dx) and (y < x) and uselower):
x = y

return x

UE4/c++

I don't disagree but if you actually are experienced I find it's much easier to debug and harder to make logic errors.

Are you making a game or what?

Kind of a stupid question but I couldn't find out information about this anywhere so here goes:
Suppose I have a Python script that spits some output, and I want to use that output as a (((command line argument))) for a program. How would I go about that (on Unix)?

I tried ./program python3 -c 'print("something")' but that clearly doesn't work and argv[1] becomes "python3" instead of "something" which is what I was intending.

Naive implementation (for a naive problem):
#include
#include
#include

int find_bounded_min(int array[], int length, int lower_bound)
{
int key = INT_MAX;
for (int i = 0; i < length; ++i)
if (array[i] < key && array[i] >= lower_bound)
key = array[i];

return key;
}

int main(void)
{
int array[] = {100, 4, 33, 21, 0}, lower_bound = 6, rv;
rv = find_bounded_min(array, sizeof(array) / sizeof(int), lower_bound);
printf("%d\n", rv);
return EXIT_SUCCESS;
}

./program $(python3 -c 'print("like this")')

That or ./program `python3 -c 'print("something")'`

if you keep the array sorted you just have to return the first element that's above the threshold

Many thanks, this works. Sorry for the stupid question.

sorting is more expensive than just iterating it

>try to get PHP working in NetBeans
>gives you numerous options for everything, some of which are undocumented
>get stuck at "Composer must be selected", and the only thing I can find on "Composer must be selected" online is an unanswered stackoverflow question
Why do programmers love modular stuff so much?
>gee I'm glad I spent hours on configuration to save 2 seconds on my compile times

This helped make it work. In your psuedo in the else-if it needed to be
else if ((dy == dx) and (y < x) == uselower):


Yes

I just got back from an interview and one of the given problem is:
I have 2 large files (TBs) with sorted strings (line delimited)
How to combine the 2 large files and only keep unique strings?
Requirements/Assumptions:
-Can only use standard API
-Can't use external database solutions
-The contents of the files are already sorted, though not necessarily distinct

I answered by reading all lines from the 2 files, transfering them to an output file, but making sure to only write unique strings (via binary search check)
The interviewer told me that I can do it in linear time. What did he mean by this?

it's really cheap if it's almost sorted (which is usually the case in games) and the sort can be useful for other things as well

In the same way you do the "merge" step from merge sort.

Make two variables representing the current indices of both files. Have a while loop compare the string at each index. If one is less than the other, write that one to the output file and advance that index. If they are the same, write either of the two strings and advance both indices.

While loop ends when either index has reached its max. Then you just loop through the remaining file.

This assumes there are no duplicates within each individual file.

really depends on the use case. if you need to find more than one value sorting might worth it, sure

>This assumes there are no duplicates within each individual file.
>-The contents of the files are already sorted, though not necessarily distinct

>it's really cheap if it's almost sorted (which is usually the case in games)
Good guess. It actually is sorted and that's what I ended up doing.

Fug you got me. If the strings were the same you would need a nested while loop to advance both indices until they reached a new string

>malloc can fail
when is this ever a real concern in normal programs?

Also, how am I supposed to solve the "Composer must be selected" issue?
As far as I can tell, there are no composer related options in Netbeans.

That should be how it works if you're getting an up to date version of mingw-w64. Target triple should be x86_64-w64-mingw32 or x86_64-pc-mingw32, I think.

modularity isn't about compile times you dumb nigger

When Windows Update starts, eats all your memory again, the system starts swapping and at some point Windows refuses to allocate memory for you.

pumbing

See: Pseudocode (C/Python-like because it's hard to be language agnostic), O(n) solution:
declare integers (i1, i2, i3) = (0, 0, 0)
while stringfile1[i1] != EOF and stringfile2[i2] != EOF:
if stringfile1[i1] < stringfile2[i2]:
if i3 > 0 and stringfile1[i1] == stringfile3[i3 - 1]:
i1++
else:
stringfile3[i3++] 0 and stringfile2[i2] == stringfile3[i3 - 1]:
i2++
else:
stringfile3[i3++] 0 and stringfile2[i2] == stringfile3[i3 - 1]:
i2++
else:
stringfile3[i3++] 0 and stringfile1[i1] == stringfile3[i3 - 1]:
i1++
else:
stringfile3[i3++]

>/dpt/ - Daily Pseudocode Thread

No one wants to do your homework.

how fast is a bitshift?

I don't study.

I can tell.

I see the problem.
There is supposed to be an option for choosing the composer, but I don't have it despite having the latest version of Netbeans.
What the fuck, Netbeans?