/dpt/ - Daily Programming Thread

Old thread: What are you working on Sup Forums?

Other urls found in this thread:

adventofcode.com/2016
paste.installgentoo.com/view/71e7b065
paste.installgentoo.com/view/bdce9efb
gnu.org/prep/standards/standards.html
twitter.com/AnonBabble

I do have a fondness for old dos games. I might do something fun like that, a 3 month project in the future.

How many pictures exist for OP in /dpt/?
This alteration of two pictures is somewhat tiresome.

>just wrote fizzbuzz in a language I'd never seen used or studied before in 10 minutes
And that really filters out 99℅ of programmers? The fuck?

REASKING FROM OLD THREAD:
if I open sourced some malware and put it on my github with a disclaimer i.e this is a proof of concept to only be tested on systems you have permission to use it on, legally will I get fucked? UK

what is a good java book for beginners?

Is there no guide or something to get started?

>ANN with only 1 hidden layer of 30 neurons takes 4 minutes, 30 seconds to train on 60,000 training data, and test on 10,000 testing data
>Produces 0 correct guesses

This'll be a bitch to tune. Or I'm doing something wrong. Not sure.

If you store 16 bits of big endian data to a 32 bit word, where does it go? The start, the end? How about little endian?

no
>UK
maybe

I figured but I read
>the UK amendment to the Computer Misuse Act makes it illegal to “supply or offer to supply [a program], believing that it is likely to be used to commit, or to assist in the commission of [a Computer Misuse Act violation]
so as long as I make it so they'd have to modify the source code to make it malicious I'm good right?

on the left i berieve

Can your favorite language define metohds on functions?

use std::fmt::Debug;

trait Print {
fn print(&self);
}

impl Print for F where
F: Fn() -> T,
T: Debug {

fn print(&self) {
println!("{:?}", self())
}
}

fn foo() -> i32 { 20 + 22 }
fn bar() -> String { format!("{} is a {}!", "OP", "faggot") }
fn baz() -> Vec { vec![true, false, true, true] }

fn main() {
foo.print();
bar.print();
baz.print();
{ || "Just fuck my shit up" }.print();
}

Output:

42
"OP is a faggot!"
[true, false, true, true]
"Just fuck my shit up"

As in casting 16-bit to 32-bit in big endian? Obviously, it gets placed at the end. So if you have the number 420, i.e. 01 A4, when cast to 32-bit, it'll become 00 00 01 A4. In little endian, it'll be represented in memory as A4 01 for 16-bit, and A4 01 00 00 for 32-bit.

My favorite language can define methods on methods. Stick that in your pipe and smoke it.

def add_one x
x + 1
end

AddOne = method(:add_one)
class

#include
#include

#define print_fn(fn, ...) printf(_Generic((fn), \
char (*)(): "'%c'\n", \
char *(*)(): "\"%s\"\n", \
signed char (*)(): "%hhd\n", \
short (*)(): "%hd\n", \
int (*)(): "%d\n", \
long (*)(): "%ld\n", \
long long (*)(): "%lld\n", \
unsigned char (*)(): "%hhu\n", \
unsigned short (*)(): "%hu\n", \
unsigned (*)(): "%u\n", \
unsigned long (*)(): "%lu\n", \
unsigned long long (*)(): "%llu\n", \
float (*)(): "%f\n", \
double (*)(): "%f\n", \
long double (*)(): "%Lf\n", \
void *(*)(): "%p\n" \
), (fn)(__VA_ARGS__));

int foo(int a, int b)
{
return a + b;
}

char *baz()
{
return "asdf";
}

int main()
{
print_fn(foo, 1, 2);
print_fn(baz);
print_fn(puts, "hello");
print_fn(malloc, 10);
}
:^)

Python replaced BASIC, what will replace Python (2/3)?

Very minor correction:
the semicolon on the end of the macro shouldn't be there.

that's not how it was supposed to work

>but abstraction actually makes them harder to debug.
This.
Anything with abstraction just becomes stupid hard even if the underlying issue is trivial.
In straight up procedural code debugging is a breeze.

my favourite languages can create new functions from other functions seamlessly without syntax noise

Why not?
My version even allows you to have arguments.

>create new functions from other functions
so function composure?

because it was supposed to be a function method which obviously cannot be done in C because you can't arbitrarily turn a function into a struct and add a function pointer there

That looks so much better than templates. Of course templates do more, and they do it worse than real metaprogramming so when you need that what's really the point?

hey guys i dont post in many other places if any so ill ask here

i just pooped and it was stunk as all hell so after flushing I added a bit of bleach to the water and diluted it with more water. I noticed it wasn't enough to mask the smell, it didn't occur to me that it could've been in my nosre, so I took my after shave and poured a small splash in. The mixture turned red-ish and I thought it smelled a bit better now but then freaked out because the smell was potent as all hell. I added another quarter gallon of water in a single pour so that the pressure would cause the toilet to flush BUT now the bathroom has this real strong smell like I'm stuck inside a slab of concrete and my nose smells like bleach. Is this okay? Can I do something to the water and or toiler so I don't accidentally poison my cousin when he wakes up to use the restroom?

I dont want to google this.

>Can I do something to the water and or toiler so I don't accidentally poison my cousin when he wakes up to use the restroom?
I'd say kill him in his sleep. This is just too embarrassing.

God would understand.

literally fucking laughed out loud. I'm going to try pouring some honey in there.

Btw the mixture is chloroform, I'm a dummy.

Believe it or not Terry guessed it in his video. How crazy is that?! Maybe it was confirmation bias, though.

>you can't arbitrarily turn a function into a struct and add a function pointer there
It's merely a matter of syntax, but it seems like a pretty pointless thing to do.

it sounds like casting a pointer to a function using a void* and then just treating it like a struct.

maybe a void**?

>naming conventions tier list

GOD TIER: lowerCamelCase
HIGH TIER: snake_case
MID TIER: UpperCamelCase
LOW TIER: kebab-case, SCREAMING_SNAKE_CASE
SHIT TIER: STuDLyCaPS

>mfw people use one of the above dependent on language used

>casting a pointer to a function using a void*
This is not completely portable.
ISO C does not guarantee that you can do this, but POSIX C does.

K&R or C Programming A Modern Approach?

user, you need to vent the air out of the house. You also need to wake your cousin up and make sure he knows NOT to go into the bathroom. Chloroform is not some sort of harmless sleepy making gas. It's an industrial solvent and it will fuck up your kidneys, liver, and central nervous system.

It isn't entirely surprising that Terry might have some basic chemistry knowledge. Bleach + Alcohol = Chloroform.

Even if it was just a splash of after shave in diluted bleach that I already flushed? I'm going to go flush it again.

As for the Terry bit...when it sounded like it I was watching a non live broadcast before I ever even googled it. I would say spoopy but really it doesn't surprise me.

> believing that it is likely to be used to commit, or to assist in the commission of [a Computer Misuse Act violation]

Just say you believed it'd be solely used for research and legal purposes and that you put a disclaimer stating such.

I don't know anything about the UK or its laws but I feel like that'd be sufficient?

>not using the naming convention that suits the use-case
>calling PascalCase "UpperCamelCase"

I use PascalCase for most things, camelCase for method parameters and function-level variables.

"kebab-case" shouldn't even be valid in any sane language.

user, I am not entirely sure on how much you consider a splash, and how much chloroform it takes for the average human to inhale before they start suffering ill effects, but your first response to any amount of toxic gases in your house should be to air that shit out. The fact that this hasn't come to your mind yet is astounding. One of these days your stupidity is going to earn you a darwin award. Given the fact that you thought, "hmm... my shit stinks. I should PUT BLEACH DOWN THE TOILET," I'd bet that that day will come sooner than later.

>putting snake_case above PascalCase

...

>There are people who unironically use camelCase or PascalCase

for a programmer you have an extra-ordinarily lacking sense of value. like literally less than a spoonful. one little sprinkle from the mouth of an after shave bottle. a splash.

I was a bit vague I guess but don't meme over me with that atheist ss bullshit. you darwin award. you, jk,

anyway, i've since started airing it out,

also bleach is a common household item and is generally used in toilets.

>not using PscalCase to easily distinguish variables from functions

Why on earth do you people space your lines like this? It's fucking retarded.
Empty lines are supposed to separate paragraphs.
I'm convinced that you're all filthy redditors, because a lot of them seem to do that for some reason.

>GOD TIER: lowerCamelCase
Wrong, abbreviations don't work unless they're the last word with this one.

>I'm convinced that you're all filthy redditors, because a lot of them seem to do that for some reason.
I've noticed this too but I think even Moot did it since I remember reading his threads bothered me.

thats in an essay.

empty lines or empty spaces between pieces of pure diction can and often do represent breaths. its my way of.letting him taking it so i can use the timing to create a liaison or add a sense of nuance to the next bit of text. I used to love telling jokes. People loved me for it.

I like to pretend people still do love me.


;_;

is "" the same as "!="

Please stop posting anime an a tech discussion board

yes you knew that already

In what language

Befunge

Get out of here, you fucking newfag.

of letting him take it in*


i have good timing for the most part

Moot is a redditor, Sup Forums

REEEEE

>already gone through 2 out of 5 SICP chapters and learn python the hard way
>gone through a HTML and CSS book, typing the examples but it was so boring
>doing the same for a PHP/MySQL/JavaScript/CSS book bit it's so damn boring
>gave up on going through book
>just want to make JavaScript 2D vidya or maybe a website

How do I actually make stuff? It doesn't matter how well i know loops or sorting, it always feels like I'll permanently be one tutorial away from knowing how to do anything.

I could just google everything but it is infuriating trying to find answers and I will never know whether or not I'm missing something big.

>Posts frog
>REEEEE
I don't care what you could possibly have to say; I didn't even read your post past the first line.
However, I am certain that you're a fucking retard and you should probably end yourself.

I'm going to write a 2D game in C, but I'm unsure which library I should use: SDL, SFML, or Allegro?

I've tried out SFML with C bindings (CSFML), and it seems alright, but what would you guys recommend?

Put down the books and just start writing code. There's plenty to learn from just experimenting yourself too.

Hard to say. It's easier for me to read, and it's habit at this point.

For what it's worth, I don't even have a reddit account, and I've likely been here much longer than you, considering I was around for all the Cracky-chan festivities.

Does it only bother you because you perceive it to be a trait of posters on another website, or do you find it harder to read?

It's like moot created Sup Forums and we all hung out on here with him, when I was young...er anyway, and that you guys were invited over and into this humble abode but that when you arrived and saw people talking you stuck yourself in the closet and now who knows what's going on with you.


I remember when bimbos were the butt of every joke.

And I mean
e
v
e
r
y
joke.

>How do I actually make stuff?
Like vidya?
>make game loop
>each time it goes around get some input
>change shit based on input
>change some shit not based on input
>draw some stuff based on shit
I like SFML but it holds your hand and does a lot of stuff automagically. You should use SDL if you want more control. As for Allegro the last time I used it the thing was just a fancy software renderer and it was hell to use. Not sure if usability has gotten better since then.

i read his post
you are correct

For people who want excuses to do something every day, give Advent of Code a whirl.

It's Dec. 1st so the first puzzle just got released:

adventofcode.com/2016

I think he scans it to find some pretense of a pattern and goes off of that. The fact that he has to stop and think might be what bothers him and, my guess?, because now he can't "xor"rect, i mean correct, silly grammar or spelling mistakes in order to feel superior at an a logic level or use the b logic affluence he has memed for himself.

Ivor Horton, beginning java

>I've likely been here much longer than you, considering I was around for all the Cracky-chan festivities
>le i'm such a le oldfag XDD
>i'm chargin lazer desu desu XDD
Only Sup Forumstards think it's important to bring up how long they've been here.

>Does it only bother you because you perceive it to be a trait of posters on another website, or do you find it harder to read?
Both. It breaks up coherent thoughts for no reason, and is just poor writing style. This isn't a chatroom or some shit, where you usually talk to each other one sentence at a time. People's posts should actually have some structure to try and get their points across coherently.
It also seems like you're trying to 'stand out' (like redditors try to do) by making your post take up more space, without adding any actual substance.

thanks user, I guess I might as well stick with SFML then

I don't think you're smart ebough for programming. Look for a good javascript game engine.

he wrote it to me and I read it just fine. But I grew up in a time where "meme"s were just motivational posters and not full fledged ideas. At least out civics and social engineering.

You need institution that bad that you can't pull a reason out of your ass and need everyone to force themselves a level of communication the way your oarents pribably do you? Do you only speak one language?

Does it bother you when a person fumbles in their speech?

I'm not really curious nor do I care about the coming rebuke. I know you need to save face and I know that you're pulling attention into narrower constraints to win what the lucky fedora would call a "debate". I left mommy's straits looong ago, sonny boy.

At least I'm not a fucking weeaboo

He is lying. SFWML is a shit. Use SDL or even GLFW.

>or even GLFW
nodev spotted

is there a python library that makes interactive terminal apps easy?

Click seems to be for command line tools like grep or whatever, Curses seems overkill for what I want.

Something halfway between those?

>taking a programming class online, we've been working with python
>final exam is proctored, no open book or any outside resources
>exam will consist of 3 questions where you have to write a program
>won't be able to debug/do test runs on a computer
Should I just kill myself now? It's not that python is hard it's just I really prefer doing test runs before submitting something.

i didn't think anyone on Sup Forums was cool until i read this post

night you guys

good night user

What kind of stupid class makes you write code by hand anymore?

>won't be able to debug/do test runs on a computer
That's pretty stupid.

Even some of the professional certifications I've gotten even give you a simple syntax check for freehand submissions, to ensure it at least compiles or can be run without errors. They didn't tell you what the error was, but it was still quite important to have for the little things.

I didn't think anyone on earth was human until I joined Sup Forums

It's a class through CC and the teacher is super fucking useless, one of those "use pre-written questions" kind of guys that hardly interacts with students.

You responded in such a way that I thought I wrote this post and forgot about it.

Well said.

it's easier to read, besides a paragraph can be less than a line if it conveys one thought - if you have more than one real thought you want to convey, might as well separate them

you seem to get triggered very easily by small details

It wastes one byte of space per paragraphs. Pretty sure we could save a good chunk of terrestrial ressources and energy by using a simpler language.

Sarcasm? Fizzbuzz is really easy

>wastes 1 byte
There are so many other better things to optimize and this is what you choose?

static List list(params T[] input)
{
return input.ToList();
}

First first, then second.

wtf with guy

>templates
As far as I know, printf uses vardaic functions, not templates.

But templates are my favorite tool in c++ so go fuck yourself.

>the name of the xiu xiu album is (remixed and) covered
Thanks. Fixed to "Covered"; I got rid of the remixes.

>also I'm guessing those are folders because of the death grips/powers that b/jenny death, and thus I conclude you have a garbage folder naming convention
Why is that garbage? Powers that B has two albums with different covers, so I made a parent directory with two folders in it.

Do you guys follow any sort of coding standards when you program?

pastebin if you don't want to register

Problem: paste.installgentoo.com/view/71e7b065
Input: paste.installgentoo.com/view/bdce9efb

depends on the language

Image file formats are cancer.

fuck .png and fuck .jpg

explain?

I'm currently reading the GNU coding standards. Some user was talking about it yesterday, so I started reading it.
gnu.org/prep/standards/standards.html

What's wrong with png?

What would you propose as an alternative to jpg? JPEG2000?