/dpt/ - Daily Programming Thread

Friendly reminder that dressing like a schoolgirl improves programming ability.
It's a scientific fact!

Also, what are you working on, Sup Forums?

Other urls found in this thread:

channel9.msdn.com/Shows/Going Deep/C-and-Beyond-2012-Andrei-Alexandrescu-Systematic-Error-Handling-in-C
c.learncodethehardway.org/book/
docs.oracle.com/javase/tutorial/
en.wikipedia.org/wiki/Closure_(computer_programming)
xamarin.com/
twitter.com/SFWRedditImages

j-java is best edition

Old thread

>Posting new threads before the bump limit
>No linking the old thread
>Literal faggotry
Delete this shit and kill yourself.

why is she sad user?

>she

Well at least you're having a little diversity in your choice of crossdressers...

Anyways, on the subject of programming... why the hell does print debugging just magically work in 95% of cases?

She's sad because somebody tried to cover up their shitty opinion with a lengthy diatribe, expecting that people would unable to read between the lines. I'm not saying C and Python are bad, but I will skirt the subject.

>Java is best
Are you betraying your love of .NET?

Jokes on you, I'm a math major.
It works with the driver it was given. Beyond that, though....
Just wanted to make sure.
Maybe once the quarter is over.
It's a deque. But, yeah, we fucked.

Just some light shitposting. I'm tired of people thinking they can conceal their inane """opinions""" in endless bloviation and that it somehow makes them sensible or correct, that's all.

Why is this male dressed like a schoolgirl.

>why the hell does print debugging just magically work in 95% of cases
Because most of the time, all you need to know what the state of a couple variables are.

>why the hell does print debugging just magically work in 95% of cases?

I used printf debugging before I even knew what debugging was. It just feels like a natural step.

What is ""this"" all about? I began to see it done """the other day""", but have yet to figure out why.

It's scare quotes taken to the extreme.

it represents an obnoxiously overdone quantification mark hand gesture.

Excessive application of a particular character for comedic purposes. Kind of like LISP.

rekt

Because he fell for the crossdressing meme.

B-but Lisp parenthesis have meaning

Hey guys, who here loves assembly master race like I do?

I'm working on a program that reads in a file, interprets its binary data as colors, and displays it in different ways. I just finished a simple Sup Forums thread downloader so I can more easily archive stuff on /w/, /wg/, and a few other boards.

Tried programming with it once
Never again
Didn't help I was using Gentoo with absolutely no GUI

It can be fun at times, but I wouldn't use it to write anything large. Do you have a favorite ISA to program for?

When you use single quotation marks to sarcastically say something, using lots of marks increases the effect.
So this:
>polish "intellectuals"
turns into:
>polish """""""""""""""""""""""""""""intellectuals"""""""""""""""""""""""""""""
As always, it's an Sup Forums thing.

I know, m8. It were bants. I actually have come to love [spoiler]parens[/spoiler].

When did the C++ committee lose its mind?
channel9.msdn.com/Shows/Going Deep/C-and-Beyond-2012-Andrei-Alexandrescu-Systematic-Error-Handling-in-C
I watch this and I just feel burning rage for all their language syntax masturbation.

Haskell's `$' operator solves it

>When did the C++ committee lose its mind?
They never had it to begin with.

I can't find an explanation worth a damn on google and I know ill get shitposted on here, but can somebody explain how this works?

Prefix notation is patrician

that looks just like Maybe's
why is that bad
exceptions are dogshit for error handling

>read /r9k/
>they're having a programming discussion
These people are seriously damaged..

>caring at all about what /r9k/ has to say

Go read a book. It'll be one of the first things they explain.

>that looks like Maybe's
Yeah. It's a very odd implementation of maybe's intended to pass exceptions instead of nothing in case it goes wrong because they wanted error information to deal with the issue.
See 17:00. He mentions it.

Well its 10 o'clock here so I can't just pop over to the bookstore. Also Should I look at learning java?

>It's a very odd implementation of maybe's intended to pass exceptions instead of nothing in case it goes wrong because they wanted error information to deal with the issue.
That would normally be taken care of with Either.

data Value = Numeric Integer | Boolean Bool | ERROR
deriving Show

data MemVal = Stored Value | Unbound
deriving Show

type Memory = Ide -> MemVal

type State = (Memory, Input, Output)

display :: Memory -> String
display m = "x = " ++ show (m "x") ++ ", y = " ++ show (m "y") ++ ", z = " ++ show ( m "z") ++ " "

update m ide val =
\ide2 -> if ide == ide2 then Stored val else m ide2


I'm doing this Haskell interpreter thing to learn Haskell and there's some pre-existing code I have to build upon.

I just don't get how the update function works with the Memory type, I think the Memory type is essentially a function that takes in a identifier.

And how does the Memory get stored as something that can be passed to the display and update functions?

>#include
Includes functions from the stdio.h header file. Includes things like printf() which you use later.
>main(void)
Entry point for the program.
>printf("..")
A function available in the C standard library which lets you print a formatted string of text.
>return 0
0 is used to denote success. Its a way of telling whatever started your program "I ran fine".

Just go through this:
c.learncodethehardway.org/book/
Or whatever. C isn't a difficult language once you get into it.

holy fuck you're dumb

Condidering the shitshow that was the last thread my mind is just really numb right now

Learn c the hard way is fucking garbage

I'm running into a problem when programming an AF_UNIX server in C.

It's structured so that the user can define a thread pool, and threads from that pool will accept connections from socket IDs stored on a list.
I'm filling the list through another thread which is in charge of running accept on the socket and returns the new ID the other threads will use.

Sounds like a fairly standard producer/consumer problem which I tried to solve with conditional variables.

So my producer thread works something like this:

while(1)
{
do
{
if((chk = pthread_mutex_lock(&connQueue)) == 0)
{
if(queueLength + currentconnections < maxconnections)
// accept on the socket ID I pass the thread and save in a list
if((list.socketid = accept(socID, NULL, 0)) == -1)
{
pthread_mutex_unlock(&connQueue);
exit(EXIT_FAILURE);
}
else
{
// add element to list
pthread_cond_signal(&connectionQueueWait);
pthread_mutex_unlock(&coQU);
}
}
else
{
pthread_mutex_unlock(&coQU);
}
}
while(err != 0);
}

But it works horribly.
This is a test output. The same thread (I have 30 active) handles a ton of connections all at once, and some times it doesn't even process the last connection.
pastebin /KBvrqUWm

You're right about Memory being a function. As for how it gets passed to display or update, functions are first-class members and can be bound to names, so if you had an identifier x of type Memory you could use it as an argument to display or update which would then apply X to an identifier in their bodies.

Thanks for this new artist, OP

I will fap to his work in honor of you

apply x in its body*

>Well its 10 o'clock here so I can't just pop over to the bookstore
there are books and tutorials online

>Also Should I look at learning java?
yes

docs.oracle.com/javase/tutorial/

Also it's 4 in the morning and I fucked up the code snipset. To make it more readable I went on and changed the name of the mutex variable from "coQU" to "connQueue" but then left 2 coQU in that code.
The code to add the element to the list containing the connections waiting to be read is there, I just removed it from this example because it's irrelevant right now.

this

fuck z.s.

>implying user is at the stage where quality matters more than his indecision
It's better he just reads than than procrastinates.

>implying he even needs a book to read about hello world
>shilling this hard

In Haskell, functions can be passed around as values like anything else. You can think of Haskell functions as being roughly equivalent to immutable tables, where you put in your key (argument) and get a value (result).

>shill
I pointed to a free resource. Suggest an alternative. I'm sure it's just as good. I don't feel strongly about learn c the hard way.

lisp also has that feature

Let me tl;dr explain whats going on.

1. First function makes dynamic 2d array and converts 1 and 0's from input file making a board for game. Prints out correctly.

2. Second function I'm trying to pass in the 2d array that is now filled for the game. It's getting correct rows and cols as tested, and should print the exact board as above did, but it seg faults.

Any ideas?

Yes, it does. Most languages do, nowadays, but Haskell makes it much more seamless than most, and so does Lisp.

does lisp even support proper partial application

>functions can be passed around like values
Not him but are you talking like function pointers or can you somehow keep copies of functions and alter them? Haskell seems a lot more rad now.

you are in for a new world called FUNCTIONAL PROGRAMMING
functions being values is only the beginning

>#inlcude
In C, a line beginning with a # is a special kind of directive handled by the preprocessor. Before the compiler even begins trying to make sense of what your program does, the preprocessor is going to do a bunch of text substitutions based the preprocessor directive.

The #include preprocessor directive tells the preprocessor to find a file in the standard include path and copypaste its entire contents into the file you're compiling. This is typically used with what is known as a "header" file to provide type definitions and forward-declared functions (more on that in a bit) so that the compiler can know of their existence. The file stdio.h contains information about C's standard I/O utilities, including the printf function.

>int main(void) {
Here we define a function called main, which returns an integer (32-bits, signed on ARM Linux, which is what I'm guessing you're using), and takes no arguments. In C, the name "main" is reserved for a special function that serves as the program entry point. That is, the function main is called when your program starts up.

>printf("hello world\n");
This calls the function printf and supplies it with an argument that contains a pointer to a block of memory containing the text string "hello world\n". This effect of this is that the message "hello world", followed by a linefeed character, is printed to your terminal.

>return 0;
As mentioned before, main is a function that returns an integer. The integer here is 0, and the return value of main is going to be used to indicate to your terminal the exit status of your process. A 0 is a typical standard for saying "everything went fine!"

Much more powerful than function pointers. Values of function type in Haskell are always closures.
en.wikipedia.org/wiki/Closure_(computer_programming)

>That tab length
Fucking hell man

Man i just tried Java via android development and i wanted to blow my fucking brains out, coming from C#. It felt like every line needed a fucking import, tell me i'm just shit and this isn't reality.

it's android that's shit, if you do android dev with xamarin it's the same shit

also ctrl+shift+o to auto-import in eclipse

C# is better.

Nope. Android dev is shit. Go find a library of some sort instead. It's what anyone willing to keep their sanity is doing. (not that it helps much)

why does printing the board take a Position param

Thanks lads, knew I could count on you lot to reassure my inability.

Sadly it doesn't run on android brother.

Considering you're from C#.
Consider xamarin.com/
I haven't used it but I've been told good things about it by shills. For what that's worth.

>micro$hit
>on a gjewgle platform
shit on top of shit

The linux kernel codebase uses 8-width tabs

> every line needed a fucking import
Please don't tell me you manually import anything? Nobody actually does that you fuckwit.

Eventually when you stack enough shit. You have enough other people to blame to make yourself seem ok.

It's for later use for the game piece, its a struct. Doesn't apply to it atm.

Oh shit i didn't know this existed, fingers crossed it just werks. Thanks.

It was an example, calm down Rajeesh.

Why does everyone have Indian names? Are you all from India or something?

nice try pajeet

I guess in C# you're forced to manually import everything?

Haha. Sorry my friend you're mistaking me for someone else.

Not him but. Doesn't the fact that you have so much stuff to import that you automate the process somehow make you worry?

You should probably off yourself right now and get over it you loser

It's IDE specific.

Looking for a way to run it on Linux, doesn't seem possible. Unless anybody here has a solution?

no? wouldn't it be more worrying to have all kinds of OS stuff all in one scope?

No, I literally write the class name, e.g. Date and IntelliJ shows me a list of packages that include the class Date. I pick the package that contains the right one (it's basically just autocomplete) and it imports it for me. Same when I delete it, the import is gone. It's never been a problem for me or anyone I can think of.

>C#
>Linux
what are you doing with your life mate

Well it's more about the idea that your application is wrapping far too much stuff. I'm not used to that kind of development. I #include GLFW and then I'm pretty much done with external libraries.

Id be worrying sick if I had to keep track of all those things. I mean, if it had to be automated it's likely multiple thousands different imports right?

No, but the difference is that using VS with IntelliSense is comfy. It is the best auto-complete I have ever used. It's better than mere auto-complete, even.. it just KNOWS what I want to do before I even do it. It's like Microsoft is reading my mind.

I appreciate you

I enjoy using Linux, i don't enjoy writing in Java but would like to try android development. Are we up to speed on my retarded dilemma now.

if you use C# with xamarin it's still the same shit, just look at the docs, it's pretty much the same methods but renamed to PascalCase instead of camelCase

I don't have that experience with intelisense at all.. I can be writing simple code and it just gives me random defines from windows.h or whatever. How do I fix that? I'd really like to simply not have it suggest shit from windows.h to be honest. It's not like I ever use a Windows function without reading msdn anyway. They're far too strange to dare do that.

it's not an issue at all, like if you handle input events you import android.view.View.OnTouchListener and override the onTouch method which takes a View and a MotionEvent so you import those as well, and to import it all you just press ctrl+shift+o

>They're far too strange to dare do that.

You mean you don't like like using RtlWriteDecodedUcsDataIntoSmartLBlobUcsWritingContext(...) on a lark?

??

It's much better for C#, though. For C/C++, I use CLion.

Is it any different than IntelliJ autocompletion?