/dpt/ - Daily Programming Thread

old thread: What are you working on, Sup Forums?

Other urls found in this thread:

docs.oracle.com/javase/7/docs/technotes/guides/language/assert.html
hastebin.com/usixixeroj.js
twitter.com/SFWRedditVideos

How can pajeet code if pajeet doesn't even know english?

dumb frogposter

she's cute

>draw a girl
>call it a boy

this meme needs to stop

struct Girl *girl = malloc(sizeof(struct Boy));

Enjoy your memory corruption.

very poorly

they just run the code through google translator

use std::mem::transmute as crossdress;

struct Boy;
struct Girl;

fn main() {
let girl: Girl = unsafe { crossdress(Boy) };
}

I imagine the same way a dog learns how to follow commands.

Pic very much related, my good girl

what the fuck I didn't even phonepost why did my pic rotate

Unidiomatic!
use std::gender::Boy as Girl;

error[E0432]: unresolved import `std::gender`
--> src/main.rs:2:10
|
2 | use std::gender::Girl as Boy;
| ^^^^^^ Could not find `gender` in `std`

That's because Rust's STDs are gender-neutral.

How can rustfag speak English if English doesn't have a proper gender neutral 3rd person singular pronouns?

Learning Python 2/3...my first experience with coding. going pretty well so far

hello fren, i know much english and also write vry fast O(logn) code on jvm and clr. india IT superpower 2020

I'm no master on cursive writing.
But I'm pretty sure that the paper was signed by Bill Dates.

Learn c my dude it will blow your mind soecifically pointers

it'll also blow up his computer

I have done 5 exercises of SICP chapter 4. What is my motivation for this chapter? Why is it implementing scheme in scheme?

/* sanity check */
if (item->type == CLOTHES)
if (player->sex != item->sex)
return NOT_ALLOWED;
return player_inventory_add(player->equip, item));

what are you trying to say

>all items have sex
>this is how Cniles actually code

obviously items have a transparent union member, where different kinds of items store different information

what does this java code do?
assert var22 < 10 : var22

Nah, that's actually a cursive G. I unfortunately know this because we still had to learn this shitty writing system growing up.

Python is a fun language to learn. The nice part is that you can do a lot of practical work right from the start with really minimal knowledge of the language.

>it'll also blow up his computer

what did he mean by this?

>all items are weakly-typed
>this is how Cniles actually code

learn to search for information in the documentation:
docs.oracle.com/javase/7/docs/technotes/guides/language/assert.html

UB

>she

a gonad is a monoid in the category of endofunctors

monads are for typelets

Fact: languages with "idioms" aren't worth wasting time on them.

>Fact: languages with "idioms" aren't worth wasting time on them.
Fact: your dumb opinions aren't facts.

>tfw funcfags shit on OOP even though a monad is an instance of the Endofunctor class
>tfw the GHC is written in C++ and translates Haskell code into C++ code, which is then translated into into native machine code by the GCC
I want to kill these dumb motherfuckers

Fact: we know you are upset that you have to waste your time with a subpar language, user.

why do these threads move so fast when there's only 50-odd people posting in it on the most popular Sup Forums board

...

*translated into native
Too many 'into's

>these threads move so fast
I've already seen /dpt/ die before reaching the bump limit.

>Sup Forums
>the most popular Sup Forums board
wat

I'm trying to write a program in java that takes a string and textfile from the commandline and removes every occurence of the string parameter from the file. i run into problems when i try to run the code; i get
Exception in thread "main" java.io.FileNotFoundException: tempFile.txt (Access is denied)
Is this because my program doesn't have permission to access or modify files in the temporary file folder that this method writes the file to?
here is my code
hastebin.com/usixixeroj.js

Only second to /po/.

>if a language has idioms, it is subpar
Are you retarded or something?

I may be retarded but the important point is that I'm right.

>typeclasses are like shit-tier OOP classes
>GHC is written in C++
>GHC translates into C++
2/8, made me reply.

what line does it crash at

>0 argument
The eternal h*Skelet

Can someone post the >guy looking at degree meme? Google just gets me the one of the guy staring at the chick while his girlfriend looks disgusted.

int main(String[] args)
{
for (*(auto *i) = 1 : 15) {
if (*i % 3 == 0) {
printf("Fizz");
}
else {
printf("Buzz");
}
} end;
}


Is this right? I'm in my second month of computer science at uni and my marks are abysmal. I never programmed before coming here so I'm having a lot of trouble. Please help, I'm absolutely fucked if I flunk uni.

Oops, didn't mean to make that a reply.

you're creating a file in the OS's temp files directory and then you're trying to read "tempFile.txt" from the program's directory

what language is this supposed to be?

File.createTempFile returns a file so you should do
File tempFile = File.createTempFile("tempFile", ".txt");

Here's a less retarded way to do it:
if(item->methods.match(item, player)) {
if(item->type == CLOTHES) {
Clothes *c = get_clothes(item->id); // asserts that such clothes exist in debug mode, returns a generic default on failure in release mode
player_wear(c);
}
}

C++

...

My friend says this and he's top of our compsci class. :S

not sure, it didn't say. it compiles successfully but then i get the error when i try to run it
is there a way to create it in the same directory? that was the only method i could findthat would make a temporary file

Just bring up restrict.

#include

int main(int argc, char **argv)
{
for (int i = 1; i < 16; ++i)
{
bool has_fizzed_or_buzzed = false;
if (i % 3)
{
has_fizzed_or_buzzed = true;
printf("Fizz");
}
if (i % 5)
{
has_fizzed_or_buzzed = true;
printf("Buzz");
}
if (!has_fizzed_or_buzzed)
{
printf("%d", i);
}
printf("\n");
}
}
Any questions?

File temp = new File("temp", "txt"");
temp.createNewFile();
//
temp.delete();

nigga what the fuck are you even trying to do. You don't even need pointers in fizzbuzz, you're way over thinking the problem. Just declare i as an int, and use standard for-loop logic.

>I'm in my second month of computer science at uni and my marks are abysmal.

Are you attending classes? Do you have shitty profs? Because there's no way you should be approaching the problem the way you're doing it.

aweseome, thank you. i didn't realize createTempFile actually returned the file it created. thanks
unfortunately my code does not work though; for some reason the file that gets passed to the program gets wiped

#include
int main(int argc, char * argv[]) {
// Print out the phrase "Hello World"
printf("Hello World\n");
return 0;
}

My intro to prog course doesn't declare argc, char * or argv[] , but one online course uses this in their hello world, and while trying to learn how possible it is to make a simple game in C, when trying to set up my environment to use SDL, SDL itself uses those in the main

What is it for? And on that note, what is return 0 for? I heard it's to terminate, but I run my programs just fine without that line. I'm sure I would learn this in a proper C course but I'm curious all the same

Are they teaching you three different languages in three different courses? Stuff like that seems to happen when new students are introduced to different programming languages at the same time

argc and argv are the arguments to your program. argc is the number of them, argv is a pointer to the arguments.
return 0 means successful execution. Returning something other than 0 is a failure.

C programs like that are usually run from the command line. The return value indicates if everything went ok or if an error occured, and the argc and argv provide your program with the argument it was called with
if you were to call your program like so:
./program --option hello
argc would be 3, and argv would contain the strings program, --option and hello

>tfw people are taking this retarded bait
You're the same faggot from the last thread who was trying to "prove" to everyone that CS grads can't handle fizzbuzz. Why are you so butt-blasted about people with an actual education? Feelings of inferiority?

Will a course in mathematical logic improve me as a programmer? i realize it isn't likely i will learn any technical skills i can directly apply to my code, but i always hear people say taking more math classes improves your reasoning abilities, and this is a course i can take that sounds the most interesting to me

its for program arguments
argc is the argument count and argv is an array of strings that are the arguments

used when you run the program from command line

the return value is the exit code
0 means it's successful

uwotm8

int argc, char * argv[] is how commandline arguments are parsed to your program. Some people like to include it by default even if it's not doing anything.

>pic
who's she?

dumb frogposter

>just """finished""" my biggest project in java yer( uni project)
What a fucking nightmare. Who in their right mind uses Java out of their own free will?

>Pascal
Master race

>who

Thing is a single math course is not going to get you the kind of Mathematical Maturity that'd help you above the kind of math you already SHOULD be picking up in your 4 years of Computer Science and your required Math classes for it.

But if you were going to pick one to help I'd go with Linear Algebra (especially if you EVER plan on dealing with anything graphical) or Number Theory. Formal Logic is really something that you're essentially being taught in CS already. You DO understand bitwise operators, right?

>anything that compiles in C will compile in C++
And this is wrong how?

int *ptr = malloc(sizeof *ptr);

>Will a course in mathematical logic improve me as a programmer?
>i always hear people say taking more math classes improves your reasoning abilities
If you're dumb, it won't make you any smarter, but if you're not in the habit of rigorously checking your assumptions and have no idea how to actually prove something formally, it may help you cultivate those skills. Will it make you a better programmer? I don't know. It helps, occasionally, when you're doing something very complex and want to make sure your approach is sound. Trying to apply mathematical rigor to every small programming task is unrealistic, though.

...

>gonad

This doesn't compile in C++ tho?

>error: invalid conversion from 'void*' to 'int*'

dumb frogposter

>Formal Logic is really something that you're essentially being taught in CS already. You DO understand bitwise operators, right?
>Formal Logic
>bitwise operators
What did he mean by this?

Yet it does compile in C.

I already have linear algebra as well as modern algebra. Number theory was my second choice actually. Yes i understand bitwise operators.

What's your point?

...

C is not a subset of C++ because there exist valid C programs that are not valid C++ programs.

Guess I win the argument?

that was an unnecessarily hurtful thing to post

Many math courses, particularly logic related courses, will give you practice in writing theorems and proofs. That is what is important for software verification.

Can you say that in a less portentous way?

Read an introductory book on topoi if you want to go down the rabbit hole.

that makes sense. thank you