/dpt/ - Daily Programming Thread

No time for love edition.

Previous thread: What are you working on Jow Forums?

Attached: sicp_anime_girl.png (441x421, 176K)

Other urls found in this thread:

github.com/FranklinChen/hugs98-plus-Sep2006/blob/master/src/iomonad.c
monkeycoder.co.nz/
youtu.be/f84n5oFoZBc
github.com/kaleidicassociates/juliad
en.wikipedia.org/wiki/Integer_overflow
twitter.com/AnonBabble

thx 4 anime pic

I'm currently wrangling tensorflow's API. Often when you do stuff it doesn't expect you get internal errors instead of actual validation.

Still stuck on the unholy mess that is dealing with Shift-JIS hash/offset tables of the PC98 era.

Attached: progress2.png (441x210, 12K)

static void Change(ref int[] pArray)
{
pArray[0] = 888;
pArray = new[] { -3, -1, -2, -3, -4 };
Console.WriteLine($"Inside the method, the first element is: { pArray[0] }");
}

static void Main()
{
int[] arr = { 1, 4, 5 };
Console.WriteLine($"Inside Main, before calling the method, the first element is: { arr[0] }");
Change(ref arr); // pass the reference and not a copy of it
Console.WriteLine($"Inside Main, after calling the method, the first element is: { arr[0] }");
}

Attached: result.png (508x55, 3K)

How can I pause and resume a python program from the command line?

Attached: 1514322720247.jpg (720x960, 148K)

Pressing Ctrl-Z will pause and push the program into the background.

still stuck on this

Might be easier with a gui, what's better?
tkinter or processing?

when it gets to "print text[i]" it's trying to print text[-1], maybe?

I wish I had a programmer gf.

Why don't you use dgraph as your database, /dpt/?

Attached: dgraph.png (873x690, 20K)

Cool. What disassembler do you use?

Not worth it, IMO. Programmer girls are pretty masculine, especially if they can actually program. Even girls who major in math seem to be more like girls. Better find yourself a STEM gf who isn't a programmer.

do people really hate sql so much that they had to create this shit?
i need a drink

SQL isn't so hot for querying graph data unless you're using Oracle and have CONNECT BY. They definitely could have made their language easier on the eyes, though.

What's the best drink to code with? I think it is a dark, bitter beer...

Speaking empirically, the world's highest-compensated programmers drink pumpkin spice lattes.

My coworkers drink lattes but not pumpkin spice. I wish I could have one beer at work on Fridays or something but we have a rule because of some incident in the past...

Their loss if they don't allow you to surf the Ballmer peak.

graph databases aren't about departing from SQL, graph databases are about traditional relational databases not being good enough when your data is EXTREMELY relational, and your queries are equally relational.

"lmao let me just join across 10 different tables"
"lol nah senpai fuck you" t. relational databases

Tab spacing is fucked, assuming this is supposed to be Python.

I assume
def reverse(text):
result = ""
for i in range(-1,len(text)):
result = result + text[i]
return result

is what you want and you're using print to follow along with what's happening.

Your issue is simply with range (and, really, splices in general). Range/splicing will, by default, increment up by 1 and do some weird things if you start at a negative index and try to increment up: range will proceed normally, but splices will mess up and only print the element at that index (unless you do, e.g. var[-3:], where it'll then print forward until the sequence ends). The solution to both is to specify that the step is negative -- that is, -1. Knowing that you have to increment by -1, you should realize that your endpoint should be negative, too.

Another way, using most of your code, would just be to swap the "text[i]" with result addend, so that each letter is added to the right of what was there previously. That way, you can just use range as you normally would.

Attached: Heavy-drinking-associated-with-risk-of-violent-death-says-study-624x417.jpg (624x417, 46K)

I've been trying to get comfy with Haskell but the IO type bullshit is just dumb

Attached: IMG_20180708_233423.jpg (1000x1440, 148K)

I appreciated the IO monad more after reading some implementations of it. Here is probably the simplest one:

github.com/FranklinChen/hugs98-plus-Sep2006/blob/master/src/iomonad.c

They could have extended SQL for this.

wtf is goin on here farn

Attached: hwaet.png (205x215, 29K)

That means you don't get it yet. Keep at it.

Joining ten tables isn't really a problem with proper indexes, though joining 100 can be.

OP just needs to debug it himself.
Comment out the result assignment, and put in a print statement so you know at least your loop works.

SELECT movies.* FROM directors
INNER JOIN staff ON staff.id = directors.director
INNER JOIN actors ON actors.movie = directors.movie
INNER JOIN movies ON movies.id = directors.movie
WHERE staff.name ILIKE '%steven%'
GROUP BY directors.director
HAVING COUNT(DISTINCT actors.actor) > 100

dgraph admittedly looks cleaner

Hey /dpt/, do you like free software? Do you like BASIC? Do you like hideous logos? Here, have Monkey2. It's BASIC for multimedia applications and games.
monkeycoder.co.nz/
It has generics.

Attached: monkey2-ide.jpg (1382x958, 159K)

Hey I'm making a functional programming language that wraps SDL2 :P

Sounds pretty interesting. Is your focus on gamedev? How do you handle state and I/O?

I'm using algebraic effects similar to Eff. You write as much as you can with pure functions, then build the front-end using unsafe "methods" which invoke effect handlers.

>I'm using algebraic effects similar to Eff.
Nice, though apparently PureScript might drop Eff because it's a large burden when doing front end development or something. Do you find that it takes more effort to work with than Haskell's IO? You didn't answer my question about the focus.

christ, my issue was it wasnt iterating through the list no matter what combination of start,stop,step in range() i was trying.

turns out the return was breaking the loop because it was indented too far

thanks again

>BASIC
For what purpose?
In my experience, learning BASIC is a net loss. I generally don't believe in the concept of a "first language" actually mattering, but I make exceptions for BASIC.

>but I make exceptions for BASIC
Because of that quote?

>whitespace errors

This is why Python is absolutely haram.

>that quote
I don't know what quote you're talking about.
I've just noticed that kids who learned on BASIC have a hard time moving onto more structured languages.

i wouldnt have this problem if i used a damn editor but im rather enjoying codeacademy atm despite the poor debugging error msgs

Second-generation and later BASIC is usually structured.

Anyone experienced with Kafka?

I'm wondering if it's better to have a consumer per cpu core, or consumer per partition (about 15 atm)

You may want to ask /wdg/.

What does Kafka have to do with web development?

Event-driven service architectures are hot for large web projects right now.

>Apache Kafka

Whenever you want to learn something, all you need to do is go on Google Scholar and search for it. Find a few of it's main papers. Now, search for citations. Whoever wrote a citation likely has an optimized implementation they wrote as a paper somewhere. Read it to find out what can be optimized.

this guy is a knower

How's delphi programming?
I remember being taught it early in highschool.

Attached: .jpg (715x515, 106K)

Oh fuck. The nostalgia.

Lazarus is a whole fucking lot more productive than front end browser shit.

>struggle to fix complicated programming problem for several hours yesterday (very clever algorithm for encoding a certain type of data we're screwed up on certain edge cases)
>stay at work well past 8pm until hunger and frustration make me give up and decide to leave it for later
>go home, eat dinner, think I'll play some vidya to relax and get my mind off work
>hear shouting and fighting next door
>look out my window
>see neighbour's gf nervously pacing back and forth outside with her one year old daughter, unwilling to enter her own house where all the noise is coming from
>apparently her boyfriend was drinking with a friend of his and they started fighting
>long story short, violently drunk neighbour smashed up half the furniture in his flat and his friend's face
>ended up doing some basic first aid and driving neighbour's friend to the hospital to get stitched up
>neighbours gf and daughter stayed the night at my place
>woke up early, made them breakfast and got them to fuck off home (neighbour came by acting very apologetic)
>sit down and fix my programming problem in literally four minutes
>really elegant solution too, didn't simply catch the edge cases but fixed the 'clever' (i.e. barely readable) part of the implementation that led to the issue

Attached: :D.png (446x671, 510K)

>*very clever algorithm for encoding a certain type of data we're USING screwed up on certain edge cases

The original wasn't written by me, which is part of the reason that while clever it was also a piece of code gore. Took me the better part of an hour yesterday to understand how the offending fourteen-liner even works.

Sometimes all you need is a good nights sleep.

Haskellfriends, pls help

what is the difference between

myfunction (_,y) = y
and
myfunction (x,y) = y

?
Both return y regardless of the first tuple argument, don't they?

None.
Yes.

The only difference is that you tell your reader, that you don't use first half of the tuple right from the signature.

Hobby guy back again after two week break.
Yesterday I made text to binary convertor on my own.
I don't know how to feel about it.

I will try and do a hex one today.

The '_' keyword is fairly industry-wide nomenclature meaning "don't care"

>to binary
but it's already binary
>to hex
hex is a representation of binary, so is text

you might as well just do it on paper so that it isn't so meaningless

paper is fine but now i can input whole pages of text and print it out in binary in milliseconds instead of doing it by hand.
it does the same thing those online convertors do,takes a character in decimal,and outputs in in 8bit binary format

Unity a best.

Attached: ユニティちゃん.jpg (1280x720, 106K)

youtu.be/f84n5oFoZBc

Do function pointers have to specify arguments or can I jam void into it and it will eat up anything I pass?

Technically you get away with the "undefined arguments" thing, but just don't.
It's just asking for shit to break.

the fusion begins lads
Julia + D for the ultimate dedlang combo.
github.com/kaleidicassociates/juliad

kek

If I have a datatype in that have possibility to change in the future
should I:
#define MyInt unsigned int

or
typedef unsigned int MyInt;

I think using #define is better because then I can pass a -DMyInt= to the compiler to change it easily without changing the source.
Which one should be used?

Because I don't have need of a database.

Why does this work as indented?
cat separated_zips.zip* > whole_zip.zip
Is regex reliable to "get" the files in the right order( .zip001 , .zip002, .zip003 etc?

The preprocessor is not for type definitions. Use a typedef every time.

On a simple nhentai downloader in common lisp

From the Bash man page, under "Pathname Expansion"

>After word splitting, unless the -f option has been set, bash scans each word for the characters *, ?, and [. If one of these characters appears, then the word is regarded as a pattern, and replaced with an alphabetically sorted list of filenames matching the pattern (see Pattern Matching below).

using MyInt = unsigned int;

Thanks, will read to avoid other stupid questions in the future

Not a fan of the working class.

why is it doing this?
#include

int main(){
char ch;
int array[255];

for (int i=0;i

Attached: _..png (180x152, 3K)

en.wikipedia.org/wiki/Integer_overflow

char is signed.

It's actually possible for plain char to be unsigned, but is signed by default in most compilers.

How do I stop being too tired to read SICP?

Attached: 1525533393006.jpg (494x629, 116K)

bingo.
That fixed it.
thanks user

Iron Pill. Sitting all day in front of a computer sucks life out of you.

Char being signed or unsigned is up to the implementation, e.g. it's unsigned on some compilers for Android (definitely gcc, not sure about Clang). There's usually an option for it if you desperately depend on it being one way or the other (-funsigned-char in gcc, /J in MSVC).

Why are you going through four steps just to print out the characters 0-254? A signed char has the range [-128, 127] if that's what you're asking.

#include
int main() {
int c;
for (c = 0; c < 128; c++)
printf("%d = %c\n", c, c);
}

dont over think it bud im just not very smart

Getting a segfault because of this function. Or at least I suspect it's this function:

int* list_to_array(List* list)
{
int i;
int array_size = list_length(list);

int* array = (int*)malloc(array_size * sizeof(int));

if (array == NULL){
printf("\nFailed to allocate.");
return array;
}

for (i = 0; i < array_size; i++)
{
array[i] = list_at_idx(list, i);
}

return array;
}


And the main:
int* list_arr = list_to_array(list);
if (list_arr != NULL)
for (i=0; i

Learn to use a debugger.

What do I look for?
I know how to open gdb, but honestly I've only used it for watching variables, never for memory

Run it under gdb and have it crash, you can then print the backtrace that lead up to the crash which you can then investigate. Printing variables in the last few frames can help you pinpoint the issue (like a null pointer, out of bounds index, etc), look for any anomalies.

I wrote a pretty big python program, so I decided to split it into a few different files for the different functions it has.
I use a few lists in the main file that need to be altered by imported functions.
What do?

I have a program that always sefault somewhere, but when run in GDB and Valgrind it's working correctly and return success status.
Compiling done with gcc and compiler flag -Og -g .
Tried to compile with clang and also produce similar result: success on debugger and segfault when executed directly.
Tried using ASAN with -fsanitize=address and segfault with

ERROR: AddressSanitizer crashed on unknown address 0x000000000000 (pc 0x000000000000 sp 0x88ef113e021f bp 0x88ef113e0000 T0)
AddressSanitizer can not provide additional info.

Any idea what might cause this behavior?

What is this?

array_size may be wrong, list may be a null and this "i

it was something 10000 times more stupid.
if the list wouldnt get allocated, the pointer would be a zero not a NULL.

Thanks, it worked.

Is there a requirement to call yourself a programmer? Does it have to be your job? If you're very hobbyist about it, can you still call yourself a programmer?

Can you let it generate a core file and then load that?

99% of the time when you have a crash issue that doesn't manifest itself under a debugger it's an uninitialized variable somewhere

Who will stop you from going around and telling people you are a programmer.

All I expect from one is being able to make a calculator.

why cant anybody solve fizzbuzz?

Some countries like canada have laws you have to have a certain license to be allowed going around calling yourself an engineer for example.