/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous Thread:

Other urls found in this thread:

tour.golang.org
golang-book.com
pastebin.com/04HQVCPS
pastebin.com/MxMz7pqV
discord.gg/4nerq
twitter.com/SFWRedditGifs

tour.golang.org
golang-book.com

What are the ways you would "kill" portability?
>Platform dependent libraries
>Usage of specific compiler features
>Calling particular shells
>Creating objects with filenames that contain special characters
>Make unique syscalls to allocate memory in certain ways
Now I need some really smart ways.

Trash, fuck off.

Threadly reminder that dlang-chan is not dead; she's going to have her GC tumor removed (eventually); and she's super duper cute and easy to prototype in! Say something nice about her, /dpt/!

Just run everything in the kernel.

>slandering a dead language with literally only ONE (1) known user

FUCK OFF

Obfuscate some code which detects the platform and crashes the program or just introduces major bugs.

Rely on the behaviour of malloc(0).

Allocating a pointer to a memory block of size 0 guarantees a pointer that can be safely free'd, preventing you from having to do stupid shit like free((!ptr) ? NULL : ptr);

I know. You can still add other (probably pointless) NULL checks, that makes the code only fail on some implementations.

if ptr is null, why can't you just pass that to free?
it's a dangling unallocated pointer you need to worry about

His point is that you CAN pass the NULL pointer into free safely.
free(NULL) is explicitly defined to do nothing.

What makes you think he uses it?

But I do.

Now that the dust has settled can we all agree that Fortran is the best language for scientific computing?

Looking for a book or resource to learn C#.

I already know Java fairly well, which should help; as well as a glut of other languages. Just want something structured for a non-novice so I'm not guessing, looking at the documentation every 5 minutes, and writing non-idiomatic code.

I'm trying to roll my own copy constructor / assignment operator for a doubly-linked list in C++

right now my code looks something like this:
// where rhs is the right-hand argument list
if (rhs.head == nullptr)
{
head = tail = nullptr;
count = 0;
}
else
{
head = new Node(rhs.head->data);
Node* lprev = head;
Node* lcurrent = head;
Node* rcurrent = rhs.head->next;
while (rcurrent != nullptr)
{
lcurrent->next = new Node(rcurrent->data);
lcurrent = lcurrent->next;
rcurrent = rcurrent->next;
lcurrent->prev = lprev;
lprev = lprev->next;
}
count = rhs.count;


I'm getting null-pointer exceptions with this, but I'm not seeing exactly where I fucked up, or how I could fix it.

Nevermind, I think I figured it out.

if (rhs.head == nullptr)
{
head = tail = nullptr;
count = 0;
}
else
{
head = new Node(rhs.head->data);
Node* lprev = head;
Node* lcurrent = head;
Node* rcurrent = rhs.head->next;
while (rcurrent != nullptr)
{
lcurrent->next = new Node(rcurrent->data);
lcurrent = lcurrent->next;
tail = lcurrent;
rcurrent = rcurrent->next;
lcurrent->prev = lprev;
lprev = lprev->next;
}
count = rhs.count;
}

Is there an open source license which will repel GNU niggers from my software?

FreeBSD

I am doing my homework.
This time, I have a Textfile that I should read.
So far so good, java can read it.
Now I am tasked with displaying the greatest integer in a Textfile
and quite honestly?
I am stumped.

What I thought about is the following:

Open file
While the file has numbers, compare one number with another, if the first number has a greater value than b, then keep a and assign b another integer.
If b is greter than a, then let a be assigned the value of b and let b take the value of the next integer.
if there are no numbers available anymore, let the biggest number be assigned to the variable max.
So far so good, but the integers a and b are defined inside the while loop.
and they are always reset to zero.
What is the problem here?

Open file
Store all numbers on in a array
Spit out the maximum number on the array

I have seen some of them use BSD-licensed software.

How do I become a systems programmer? Also, what are common job titles for such an occupation?

I don'T know how to work with arrays yet :(

Rare. I thought all GNU niggers derided BSD as being a "cuck license", because you're not forced to give back any changes you make to a source code.

I want to FUCK Kylie Kujo in the Discord.

I was just wondering if there was a good license which their kind is repelled by even more than by BSD.
Should I go with FreeBSD or MIT?

Why? You are finding the maximum anyway.

Post your code

what the fuck are you even talking about

He'll let you fuck as long as you know Haskell

who the fuck is "kyle kujo"

Fuck off back to your containment subreddit.

>everyone who disagrees with me is reddit because i said so

good argument dude
great argument

This is my pastebin.
pastebin.com/04HQVCPS
it is used in conjunction with this provided class i have made readable with a tool.
pastebin.com/MxMz7pqV

somebody PLEASE invite me to the discord

You don't need arrays to solve this.

The discord is counterintuitive to programming, you don't wanna join senpai.

I've got my renderer working with some matrices but the coordinates are in "clip space" I think? They go from -1 to 1, I'd like to be able to have them in pixel coordinates and then just use some matrix to convert them but have no idea how to even begin to do that.

My orthographic matrix does this just fine but as soon as I try the with perspective matrix is changes.

It looks like shit, but C++17 is starting to approach Lisp in power. I'm using Lisp-style fexprs to build an embedded DSL that compiles into byte code. Byte code for what? A parsing machine for Parsing Expression Grammars. In only a few hundred lines of code.

Might try rewriting it with the Concepts Light implementation floating around after, see how it improves it.

template
inline auto operator!(E&& e) -> not_expression {
return {make_expression(::std::forward(e))};
}

template
inline auto operator*(E&& e) -> zero_or_more_expression {
return {make_expression(::std::forward(e))};
}

template
inline auto operator|(E1&& e1, E2&& e2) -> choice_expression {
return {make_expression(::std::forward(e1)), make_expression(::std::forward(e2))};
}

template
inline auto operator>(E1&& e1, E2&& e2) -> sequence_expression {
return {make_expression(::std::forward(e1)), make_expression(::std::forward(e2))};
}

template
inline auto operator action_expression {
return {make_expression(::std::forward(e)), ::std::move(a)};
}

template
inline auto operator capture_expression {
return {make_expression(::std::forward(e)), ::std::move(a)};
}

>make variable called "currentLargest" and set it's value to INT_MIN
>read one number from file
>if greater than currentLargest, set currentLargest = that number
>rinse and repeat for entire file
>print out currentLargest

all the /dpt/-related IRC channels are dead, seems all the kool kidz are on discord these days

I don't see your algorithm anywhere Hitler.

Anyway your pseudocode seems sound. You must have fucked up the implementation somewhere.

Are you cute?

no but my small peepee is p. cute

.. I deleted it out of shame....

discord.gg/4nerq

see

He wants to join because someone is posting trap pics in the discord RIGHT NOW

see

why is it that every general feels the need to have some gay millennial cancerous discord nowadays

why is it that only gay millennial cancer degenerates use discord

why aren't there any discords populated exclusively by regular, sane, healthy human beings

why can't people just use, like, irc, or xmpp, or something like that

int_max = 0
while loop
a = read value
if a > int_max
int_max = a

it is that simple

We have a high functional autism channel in our discord for posts like this, so come on in comrade.

really, really shameful...
I think I am going to college and clear out my head.
Is there a method or way to stop thinking so narrow like I do?

>everyone who calls me out on my gay anal moloch sex cancer degeneracy must be (le autism meme invented by a brit manlet cuck tripfag on Sup Forums in 2009), because i said so

fuck off back to your containment board

Code while wearing knee high socks and start watching anime.

You're literally proving his point desu, my little autismo

...

You should have written it in Haskell

yeah dude totally, and also take these jewish pills that turn you into a fucked up sterile mutant

and also only eat soylent green

and also only drink mountain dew black

and also vote for bernie sanders

and also spend 25 hours every day in the degenerate /utg/ irc reading and writing gay furry moloch fanfiction

and also vote for bernie sanders

and also give lots of money to israel for the missiles

haha yeah dude epic

>LITERALLY everyone who disagrees with me is (le autism meme invented by a brit manlet cuck tripfag on Sup Forums in 2009), LITERALLY just because i said so, lol no proof tho
fuck off back to your containment board (Sup Forums), you samefag gay anal kike.

Leftist hates Israel and supports Palestinians.

Do kids nowadays seriously use CIA-run chat services?

left hates israel, but loves jews, and is brainwashed by jews, and jews love israel, so they make left give money to israel one way or another

Everyone gives money to the jews, like it or not. So long as you pay taxes, you are giving money to the jews.

Good god that shit is unreadable. They should have realized what they were trying to do and done a proper design instead of slowly hacking together the god-awful mess they have now.

>template
>not template

nigga...

Scientifically proven

>So long as you pay taxes
I don't.

Then you are reliant on the Jew for money you NEET

whoever wrote this propaganda image is a fuckin judeo-liberal KIKE who needs to die in the oven

Is /dpt/ the most red pilled thread on Sup Forums?

I'm not though.

>class
>typename
>he picks the one with more characters that need to be typed

haha yeah dude multiculturalism and gay anal sex is so cool

Now that I've finished my masters I'm extremely tempted to send this pic to my supervisor.

>bought thigh-thighs off of amazon
>getting anxious as the delivery date neared
>had a boner when I went to go get package
>the delivery guy flinched a bit when out hands touched as he handed me it
>he could feel how sweaty my hands were
>after he turned away and got back his truck I stood outside the door until he left hoping he would see my erection through my shorts
And this is my 10th order order of thigh-highs too!

>populated at least 90% by fags and mutants and millennials
>actively attempts to brainwash everyone else into converting to fagism, mutantry, and being a millennial
>uses COMPROMISED (((discord))) software
>writes almost exclusively in gay millennial cuckold languages like java, rust, and go

/dpt/ is the most blue-pilled thread on all of Sup Forums

kill yourself kike

what

You should! Just make sure you get a job beforehand so you can still use him as a reference.

>why would jews go through that trouble just to control the (((narrative)))
>why would jews try so hard to make it seem like they are on the "right side of history"
>why would the jews want to take over the world
hmm, i wonder...

They are the chosen one

jews don't want to take over the world anymore

they've already done it

wake up and smell the matza ball, you fuckin sheep drone body

Yeah, it looks like shit, but the resulting DSL is pretty clean compared to the underlying infrastructure. This fragment of a calculator grammar as an example is pretty close to what you would expect for an external PEG DSL to look like, and I've even got support for attributes.

long long variables[26];
long long e, l, n, r, s;
int i;

rule SPACE = *" \t"_ts;
rule EOL = "\n"_ts | "\r\n" | "\r" | ";";

rule NUMBER = +"[0-9]"_ts >= SPACE = SPACE int { return x[0] - 'a'; };

rule ASSIGN = "=" > SPACE;
rule PLUS = "+" > SPACE;
rule MINUS = "-" > SPACE;
rule TIMES = "*" > SPACE;
rule DIVIDE = "/" > SPACE;
rule OPEN = "(" > SPACE;
rule CLOSE = ")" > SPACE;

rule Value =
n%NUMBER < [&]() { return n; }
| i%ID > !ASSIGN < [&]() { return variables[i]; }
| OPEN > e%Expr > CLOSE < [&]() { return e; };

rule Product =
l%Value > *(
TIMES > r%Value < [&]() { l *= r; }
| DIVIDE > r%Value < [&]() { l /= r; }
) < [&]() { return l; };

rule Sum =
l%Product > *(
PLUS > r%Product < [&]() { l += r; }
| MINUS > r%Product < [&]() { l -= r; }
) < [&]() { return l; };

//...

culture doesn't exist
kill your sister
it's okay because the jewish media will make sure you get away with it

very nice

500 points

try rewriting the dsl grammar in the dsl

>culture doesn't exist

i sure hope you don't actually believe this

He's quite well known and the place I'm going to do my PhD at had close ties with him.
I'll probably just send it to the grad students I know or something. That'll be a laugh haha
>hey user you sent me this really gay pic, are you trying to say something
>n-no haha it's just funny right? haha

religion is bigoted and intolerant
we need to remove all religion from the world (except judaism and islam)
it's the only way not to be racist

libcurl's pretty fun. Just wish I didn't suck at C.

>i-it's just a prank bro haha (no homo)
Works every time.

Being a faggot is a sin

fuck off kike.

filtered.

My programming teacher gave us "check if a number is odd or even without using modulo". That's pretty easy and I've already done it, but I have 3 different ways. Which one is going to fuck with his head more?
import java.util.Scanner;
public class Deber5
{
public static void main(String argv[])
{
System.out.format("Inserte un número: ");
double a = (double)new Scanner(System.in).nextInt();
if(a/2 != (double)(int)(a/2))
{
System.out.format("El número es impar\n");
}
else
{
System.out.format("El número es par\n");
}
}
}

import java.util.Scanner;
public class Deber5Alt
{
public static void main(String argv[])
{
System.out.format("Inserte un número: ");
int a = new Scanner(System.in).nextInt();
if((a/2)*2!=a)
{
System.out.format("El número es impar\n");
}
else
{
System.out.format("El número es par\n");
}
}
}

or
import java.util.Scanner;
public class Deber5Bool
{
public static void main(String argv[])
{
System.out.format("Inserte un número: ");
String a = Integer.toBinaryString(new Scanner(System.in).nextInt());
boolean b = (a.charAt(a.length()-1)=='1');
if(b)
{
System.out.format("El número es impar\n");
}
else
{
System.out.format("El número es par\n");
}
}
}

?

>Send gay pic
>People assume you're gay
>Everyone wants to hire you now to fill diversity quotas
Unironically a good plan

donate lots of money to the israeli army.

you can just check if the least significant bit is set.
in c++ it'd be

bool isEven(int a){ return (a & 1) == 0; }

I know, but I'm trying to specifically confuse him because he's not much of a programmer.

Bitwise AND is the same on Java