/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?


Previous Thread:

Other urls found in this thread:

strawpoll.me/11810045
youtube.com/watch?v=y9lkxK45IaE
youtube.com/watch?v=eJzp-w8Zuak
twitter.com/SFWRedditVideos

>Old thread still on page 1
Jesus Christ, we don't need a new thread yet.
At least you didn't post forced memes in the OP.

Im currently working on consuming myself in self-pity.

The job hunt is driving me ever closer to despair. I haven't started crying about it yet, but once it gets to that point I'm probably going to have a mental breakdown like the one I had in college that left me miserable, suicidal, and caustic to anyone who happened to be near me

>yfw AoC is some shitty company selling products and they make AoC to get free code

Please don't upset Mr. Ritchie!

>What are you working on?

>Learning any new languages?

>Coding questions?

>How's that job search going?

>janitor throwing a hissy fit over anime
can't say i'm surprised.

how would the world be different if haskell was as popular as java?

would we have noncancerous haskellscript?

>over anime
No, it's obvious that they just got rid of shitposters. Trapfags, frogposters and the like.
We're now in the awkward position where the old thread is below 310 posts now.

Nothing
None
No
I'm not looking for a job right now.

I really need to start doing some shit again. I keep having these ideas for shit I want to do, but I keep forgetting what they were, or I just lose motivation.

>would we have noncancerous haskellscript?
Yes, in fact I don't see what stops us replacing Javascript with Haskell aside from popularity.

>replace shit with shit
fitting

We'd have unreadable, unmaintainable code because people suck too much @ functional programming in general because it's a harder paradigm to get used to, on top of the "name your variables like they're math" haskell syndrome.

Honestly, Java might be a pain in the ass because of the overhead it comes with for pretty much anything, but at least it's somewhat easy to navigate. Haskell is a clusterfuck (in practice) because not every developer writes decent Haskell, but most devs can write half decent Java.

In a perfect world though, we'd have some performant mix of OOP and Functional programming to do things.

>In a perfect world though, we'd have some performant mix of OOP and Functional programming to do things.
In a perfect world, OOP would never have existed.

If FP is so good, then why is it so slow?

>people suck too much @ functional programming in general because it's a harder paradigm to get used to
Because they were cucked by OOP.

Haskell is fast. Much faster than Javascript.

if you think anything that isn't on topic all the time is shitposting then you shouldnt be on Sup Forums

>In a perfect world though, we'd have some performant mix of OOP and Functional programming to do things.
In a perfect world, we wouldn't have OOP at all.
It's fundamentally flawed.
>@
Why the hell did you do this? Was it really such a time saver to press Shift+2 instead of just 'a'+'t'?
It just makes you look like an idiot.

FP has some important ideas, but having a completely pure language comes with a lot of efficiency problems because you constantly have to copy shit.
I prefer to apply functional ideas to procedural code.

But why come Python is the best FP?

is that the best they have to offer?

Your statements makes no sense. Proper OOP (I.e not a clusterfuck of inheritance but properly used composition and abstraction) has its benefits as does functional programming.

Everything being immutable has drawbacks in, for example, the fact that there is overhead in mutating lists when you have to essentially deep copy during every modification.

Instead of being tied to a paradigm, be sensible and use the best tool for the job. You sound like as much of a faggot as the people that shill for a particular language instead of using a language best in a particular domain.

>Defending trapfags and frogposters
I think YOU shouldn't be on Sup Forums. Also, I never implied what you said I did.

Must be a troll.

Javascript as a benchmark for anything....
I remember my first year in computer science too.

It's a useful abstraction when done right, especially to encapsulate components.

It's jsut very hard to pull off properly without it being a clusterfuck of your usual "OMG GUYS you can extend a parent class and a child class xd"

>its no longer board culture when I don't like the joke

Proper OOP IS a clusterfuck of inheritance.
What you want is watered down "not really OOP" OOP, like you'd see in C++

>everything being immutable has its drawbacks
Mutability is nothing to do with OOP, and there are mostly FP languages with mutability.

>deep copy when mutating lists
That's exactly the opposite of the truth.
Because it's immutable, you can just reference the old data structure (it won't be modified).

>best tool
This is a meme meant to reduce discussion.

We're talking about replacing Javascript.

>joke

>>What are you working on?
Secret.
>>Learning any new languages?
Php. Had no idea it was actually as simple as it was. I imagined it was this large interconnected piece that web servers had agreed on or something.
>>Coding questions?
I wish I had stuff dpt could have a cool talk about.
>>How's that job search going?
Not doing any

What could cause an unexpected percent sign in program output? I've had this happen more than once. Also I'm programming in C++.

>Proper OOP
That is just as bad as what we have now.
OOP prescribes shared mutable state. Even if you take OOP seriously, you end up with a massive tower of unobvious and unhelpful abstractions and code that is very indirect.

programming poll
strawpoll.me/11810045

Printing the character '%'

PHP is fun, mang. It's like ice cream. It's bad for you, and you shouldn't eat it every day, and everyone has a million reasons as to what's wrong with eating it, but it sure is a guilty pleasure.

Knowing Haskell should be a criminal offense.

It's not a guilty pleasure if there's no pleasure in it

it's more like shit. It's bad for you, and you shouldn't eat it every day, and everyone has a million reasons as to what's wrong with eating it, and it's fucking shit

The key word in my question is "unexpected". If I had a statement in my code to print a modulus character it wouldn't be so.

Post your code.

What isn't fun about it? Everything is included from the beginning, it's all held together with bits of duct tape and chewing gum, and everything JUST WERKS.
It's like python but even more retarded.

There's nothing wrong with messing around with PHP user, I don't suggest using it for a real project. Why don't you call your_ass.remove("stick")

Yes, but I don't see why else.
Maybe you're converting an integer into a character.

did Dijkstra ever wholeheartedly endorse anything other than expensive fountain pens?

>proper OOP
indeed. It's absolute hell and people have to stop pretending they're doing OOP.
>not a cluster fuck of inheritance
Well that's not the issue with OOP.
>composition and abstraction
Inheritance for composition is an extremely poor way of doing composition.
>abstraction
Well OOP does far more than establish a suitable
>instead of being tied to a paradigm
The idea of FP being the opposite of OOP is something OOP programmers perpetuate a lot. There's no real opposite to OOP. You shouldn't consider OOP in contrast to FP really. Consider it in contrast to imperative programming practices. It's far more sane. Imperative programming principles generally don't much care for encapsulation while in OOP its one of the primary reasons for the design.
So there's a clear contrast there which is worth exploring.

I genuinely want to see 'oop' programmers post some of their code examples. Because I'm pretty sick of all these claims with nothing to back it up. We see tons from other practices here but at most when you look at object oriented code we see someone posting about the very basic shit.

i think i know you. you're the dude in my theory of computation who makes an ass out of himself when you get so angry about how your tiny php brain can't understand the concepts being taught

> What isn't fun about it?
Syntax is awful, code features are horrific. It's like if JS had a stroke (and js is fucking awful to begin with), it would be PHP.

it "just works" but at the same time, for larger projects becomes harder to scale properly and securely.

I said that it was retarded already. I also said you shouldn't use it for a real project.

Nah, that guy sounds like a real sperg. I've been programming for 8 years and I mainly use C and C++. How's your sophomore year going, user?

it's painfully obvious that he's the one in the thread sperging out over it. live feed of him trying to purge /dpt/ of anime posting
youtube.com/watch?v=y9lkxK45IaE
it's a shitheap that is harder to write a program that doesn't run in than the opposite

>fun
It's an incredibly onerous syntax for no real reason. I can quickly see why even new programmers dislike it.
I just hadn't realised what role it fills. I was assuming it was some kind of scripting language for managing all kinds of shit that's integral to a webserver.
My current impression is that it's just a language for programmatically generating html. And naturally I can see how in that process you can kick off all kinds of processes on the server.

It makes C++ web backend development seem much more attainable. Something I've had some thoughts about learning.
But I'm just 10-30 minutes into Php so ill walk that path first.

Look up webAssembly
Soon there will be C++ front end

The zanyness doesn't stop in the webdev world. As for php still a gajillion jobs for php due to Wordpress/Magento/Salesforce, esp Salesforce.

>people complaining about new threads being made
>old thread was actually vacated instantly
Good. You're learning. It doesn't matter.
Other generals aren't Anal about it.

#include
#include //exit()

using namespace std;

/* Class Definitions */
class ArithmeticError{
int operandb;
char operatr;
public:
ArithmeticError();
ArithmeticError(char op)
{ operatr = op; };
ArithmeticError(int opb, char op)
{ operandb = opb; operatr = op;};
int get_bottom() { return operandb; };
char get_op() { return operatr; }
};

int safe_add(int, int) throw (ArithmeticError);
int safe_sub(int, int) throw (ArithmeticError);
int safe_mult(int, int) throw (ArithmeticError);
int safe_div(int, int) throw (ArithmeticError);

int main()
{
int opa, opb, result; //variables for two operands
char opr;

cout > opa >> opb;

cout > opr;

try{
if (opr == '+')
result = safe_add(opa,opb);
else if (opr == '-')
result = safe_sub(opa,opb);
else if (opr == '*')
result = safe_mult(opa,opb);
else
result = safe_div(opa,opb);

cout

Also the functions I removed to fit it into the character limit.

int safe_mult(int operandA, int operandB) throw (ArithmeticError)
{
if (operandB == 0)
throw ArithmeticError('*');
else
return operandA * operandB;
}

int safe_div(int operandA, int operandB) throw (ArithmeticError)
{
if (operandB == 0)
throw ArithmeticError('/');
else
return (operandA / operandB);
}

I ran the code myself. No % here.

./test
Enter two integers (separated by a space) for a math operation: 255 0
Enter an operator (+,-,*, or /): +
255

Thanks for taking the time. Maybe it is some iTerm fuckery.

Make a shunting yard algorithm.

No problem. It may be, I looked over the code and there is definitely no reason for it to be printing that.

we have Purescript already

I spent way more time on day 6 than I should have, but the answers are gibberish and I thought I screwed up with my first solution.

Post your day 6 solutions!
struct freq {
int count;
char ch;
};

int sort_freq(const void *a, const void *b)
{
struct freq *x = (struct freq *)a;
struct freq *y = (struct freq *)b;
return x->count - y->count;
}

int main(void)
{
char *ins = get_filebuffer(DAY(06));
char arr[8][1024] = { { 0 } };
unsigned i, j, idx = 0;
char *tok = strtok(ins, "\n");
while (tok != NULL)
{
for (i = 0; i < 8; i++)
arr[i][idx] = tok[i];
idx++;
tok = strtok(NULL, "\n");
}
idx = 0;
char msg[2][16] = { { 0 } };
for (i = 0; i < 8; i++)
{
struct freq rep[26] = { { 0 } }; /* lookup table */
for (j = 0; j < 26; j++)
rep[j].ch = 'a' + j;
for (j = 0; arr[i][j]; j++)
rep[arr[i][j] - 'a'].count++;
qsort(rep, 26, sizeof(struct freq), sort_freq);
msg[0][idx] = rep[25].ch; /* most common */
msg[1][idx++] = rep[0].ch; /* least common */
}
for (i = 0; i < 2; i++)
printf("Part %d Message: %s\n", i + 1, msg[i]);
free(ins);
return 0;
}

Why would you replace Javascript with Purescript if you could replace it with Haskell?

Purescript is much nicer than Haskell in many ways

>

Should I learn C--?

Isn't that designed to be a low level intermediate language for compilers?

It is, be a bit of a waste of time

It's pretty stupid that they call it that, considering it's not a subset of C.
I suppose it's just a retarded as C++ though.

which mappend is better?

The documentation is really unfun

Funnily enough most of the real documentation is in the comments on the documentation. It's bizarre for documentation for a language to have a comments system like it's some kind of blog, but thank god PHP has it.

try $echo -n test
I'm pretty sure it just signifies there wasn't a trailing newline

>SAXEception: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserilize

Anyone know what the hell is this? Currently getting fron a soap webservice with
>java

neither
(defun concat-map (f xs)
(reduce #'append (mapcar f xs) :from-end t))

>2017
>SOAP

>Well that's not the issue with OOP.
What are you on about? Inheritance is the only difference between OOP and FP.

youtube.com/watch?v=eJzp-w8Zuak

>Want to contribute to big open source project
>Find issues labelled as "easye", "entry level" or "low complexity"
>Still don't understand what I should do to fix them
Being stupid is hard.

Its called being a wagecuck

OpenSSL has some pretty awful documentation

rate my hacker UI

Actually the code is just too retarded to make sense.

If I was smart I'd be able to understand even the most retarded pieces of code.

I did that too.

>tfw core2duo

I know that feel

wow, so cool your apps can do a meme thing
why don't you write real programs instead of jerking about the way texts are written

Why are you so angry?
Here's the no fun allowed version, mr fagtron.

And c#. And Javascript. It's cancerous, they tack onto good languages and have nothing to do with them.

>Java
>Good language

Okay, fair. Popular.

Wait, why did you faggots make a new thread, the old thread is still at 273 posts.

only one faggot did, user

I added colors and blinking text just for you

It was over 310, but then a janitor cleared out a bunch of posts.

What was removed?

Just go look at some Sup Forums archive.

Is it possible to output the program window of a java application into a virtual webcam?

So that it has a inbuilt sharing function that can just plug into anything that uses webcams.

like as a stream cam? for the output to appear youd have to output the webcam feed into the java program or else the the java output would overlay the web feed. assuming you want it streamed. is that what you want?

Where can I find developer's documentation /reference for the 8086 processor with all the registers and instruction?
Bonus points if its all in one pdf.

google it

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.math;

DIR update(DIR d, immutable char change)
{
final switch(change)
{
case 'R':
final switch(d)
{
case DIR.N:
return DIR.E;
case DIR.E:
return DIR.S;
case DIR.S:
return DIR.W;
case DIR.W:
return DIR.N;
}
case 'L':
final switch(d)
{
case DIR.N:
return DIR.W;
case DIR.W:
return DIR.S;
case DIR.S:
return DIR.E;
case DIR.E:
return DIR.N;
}
}
}

struct Coords
{
int x;
int y;
}

void calc(ref Coords c, DIR d, int steps)
{
final switch(d)
{
case DIR.N:
c.y += steps;
break;
case DIR.S:
c.y -= steps;
break;
case DIR.W:
c.x -= steps;
break;
case DIR.E:
c.x += steps;
break;
}
}

enum DIR { N, S, E, W };

void main(string[] args)
{
DIR dir = DIR.N;
Coords c;
int steps;
File input = File("day1input.txt", "r");
while(!input.eof())
{
string[] ins = input.readln.chomp().split(", ");
foreach(string str; ins)
{
if(str == "")
{
continue;
}
auto change = str[0];
str = str[1..$];
steps = to!int(str);
dir = dir.update(change);
c.calc(dir, steps);
}
}
writeln(abs(c.x) + abs(c.y));
}


Just started AoC today, was really overthinking the solution for Day 1 earlier

Already did. That's why I'm asking.

>current year
>still being a wagecuck

Does anyone here program in public? here's my one experience with it
>finish college with friend
>go to mcdonalds
>we decide to write some code
>log onto the wifi
>load up vim
>start writing git push pull etc.
>getting weird looks
>whatever
>manager comes over
>if you don't stop hacking people and leave we're going to call the police
>explain it's just a text editor
>no I'm not stupid its a hacking tool disguised as a text editor please leave
>we leave
is this a common thing or is it just because I live in a small tech illiterate town?

>I live in a small tech illiterate world.
fixed

I got kicked out of a starbucks for using i3 because i had a bunch of shell windows open and I was updating my packages.

Also, you probably handled yourself like a sperg, that's why you were kicked out.

>>What are you working on?
Nothing finished my project list for the year so nothing until next year
>>Learning any new languages?
nope
>>Coding questions?
nope
>>How's that job search going?
getting £1200 p/m in disabilities so not looking for work right now, looking into what certs to get and trying to beef up my resume for the time being

don't think I sperged
>sir stop hacking people and leave before we call the police
>I'm not hacking anyone I'm using a text editor called vim you can google it
>it's a hacking tool disguised as a text editor please leave

You write code in a Starbucks or local coffee shop not fucking mcdicks you uncultured fuck

>text editor
>What the fuck does that mean? is it a hacker tool?

You should have told them you're a CS major and this is your school assignment.