/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Previous thread:

Attached: continuous.codes.gif (956x410, 374K)

Other urls found in this thread:

tour.golang.org
youtube.com/watch?v=RdE-d_EhzmA
youtube.com/watch?t=12m48s&v=s-hdZZzMCac
yegor256.com/2014/06/09/objects-should-be-immutable.html
en.wikipedia.org/wiki/Total_functional_programming
twitter.com/NSFWRedditGif

reminder to do the Go tour:
tour.golang.org

Podcast downloader and possibly manager

How can anyone use OOP languages in 2018? The whole OOP paradigm is objectively the worst invention in human history.

fuck opengl

waiting for someone to create a new "99% of pa/gee/tlets can't solve this" thread, so I can fuck around with code for a bit

How can anyone use FP languages in 2018? The whole FP paradigm is objectively the worst invention in human history.

>babby's first interactive development session
It's like non-Lispers are finally discovering 70s tech.

How can anyone use airplanes in 2018? The whole flying paradigm is objectively the worst invention in human history.

redpill me on why OOP is bad and what i should use instead

You should use OODD:
youtube.com/watch?v=RdE-d_EhzmA

It's bad because it's not good. You should use FP.

Why is the paradigm called "functional" when it's far from really being functional? Isn't it a misnomer?

>The whole flying paradigm is objectively the worst invention in human history.
Uhh... No? Flying is objectively one of the best. OOP, unlike flying, hasn't made anyone's lives easier.

Threadly reminder that
>Java can't even cross-platform console beep.

Everything is a function. Unless it's a monad.

I've been trying to work out how to make and rotate 3D models, without reading about how to do it, and without having actually studied trigonometry/maths. This is what I've managed to come up with so far.

Eventually I'm going to read some maths books, but I wanted to see how far I could get on my own.

Attached: ezgif.com-optimize.gif (440x400, 754K)

>it's far from really being functional
What did it mean by this flabbergasting utterance?

You should use whatever is most appropriate for the task at hand, which is sometimes OOP.

Because it's modeled on mathematical functions, which are not the same thing as programming functions.

Good shit. I tried that once but I fucked up the perspective formula. What are you using?

>OOP, unlike flying, hasn't made anyone's lives easier.
And I'm left sitting here wondering how the dense, incomprehensible, esoteric shit you call "functional" could have possibly made anybody's life one inch easier?

I like your balls, user. They possess a high degree of axial mobility.

You're just too stupid for FP, pajeet. Go back to you Jetbrains IDE to work on some epic J*va projects.

By banishing the arcane demons of statefulness and mutability.

Just print the bell character.

>create retarded paradigm
>no one understands it
>"h-heh, you're just too stupid for it..."
Every time.

Attached: only_the_intelligent_can_see_it.jpg (498x352, 35K)

Did you ever look at programs written in functional languages? They're so simple (if you're not a pajeet), so elegant, and they're at least half the length of OOP shit.

>Because it's modeled on mathematical functions, which are not the same thing as programming functions.
They're the same thing. The mistake is that, for some brain-damaged reason, everyone started calling procedures functions instead.

That's not new, you can do that in OOP too. Except it's usually not that useful, so nobody does it. There's literally no demand for the "solutions" you guys provide. They're solutions in search of problems.

>i don't understand it
>therefore no one understands it
Imagine being afflicted by such solipsism...

>Doesn't work here (Win7)
>Doesn't work here, too (Ubuntu 13.04)
>And you can't play a tune like this
rhe absolute SYARE of javalets

You just described literally every single retard bashing OOP ITT.

>no one understands it
We humans understand it. Subhumans have a problem with understanding it.

>That's not new
You're right. Functions are not new.

>you can do that in OOP too
Not really.

>Except it's usually not that useful, so nobody does it
Wrong again.

> There's literally no demand for the "solutions" you guys provide
Wrong yet again.

I'm glad you found a way to feel superior, user.
>Not really.
Just because you don't know how to do it doesn't mean it can't be done, pajeet.

>doesn't understand FP
>openly admits to it
>projects it onto everyone else
>gets called out
>i-i-i bet you d-don't understand OOP!
When will you learn to stop projecting?

Reminder for the folks that care not about muh FPOO autism fights: you can recursively hide the entire subthread by folding the first post if using 4chanx or equivalent.

>console is told to beep
>doesn't beep
>this is somehow not the console's fault

Objects are bundles of mutable state by their very nature.

>write once debug everywhere language
>can't into cross-platform
like pottery

>immutable objects do not exist

Attached: brainlet.png (645x729, 56K)

>And you can't play a tune like this ... unless your users are all completely tone-deaf

/**
* Beeps. Currently half-assumes that the format the system expects is
* "PCM_SIGNED unknown sample rate, 16 bit, stereo, 4 bytes/frame, big-endian"
* I don't know what to do about the sample rate. Using 11025, since that
* seems to be right, by testing against A440. I also can't figure out why
* I had to *4 the duration. Also, there's up to about a 100 ms delay before
* the sound starts playing.
* @param freq
* @param millis
*/
public static void beep(double freq, final double millis) {
try {
final Clip clip = AudioSystem.getClip();
AudioFormat af = clip.getFormat();

if (af.getSampleSizeInBits() != 16) {
System.err.println("Weird sample size. Dunno what to do with it.");
return;
}

//System.out.println("format " + af);

int bytesPerFrame = af.getFrameSize();
double fps = 11025;
int frames = (int)(fps * (millis / 1000));
frames *= 4; // No idea why it wasn't lasting as long as it should.

byte[] data = new byte[frames * bytesPerFrame];

double freqFactor = (Math.PI / 2) * freq / fps;
double ampFactor = (1 > (1 * 8)) & 0xFF);
data[(frame * bytesPerFrame) + 1] = (byte)((sample >> (0 * 8)) & 0xFF);
data[(frame * bytesPerFrame) + 2] = (byte)((sample >> (1 * 8)) & 0xFF);
data[(frame * bytesPerFrame) + 3] = (byte)((sample >> (0 * 8)) & 0xFF);
}
clip.open(af, data, 0, data.length);

// This is so Clip releases its data line when done. Otherwise at 32 clips it breaks.
clip.addLineListener(new LineListener() {
@Override
[10 more lines omitted]

javalets will defend this

>confusing general statements with absolutes
You can have "immutable objects" in some meaningless technical sense, but building the entire application out of them defeats the entire point of your paradigm.

Attached: b90.png (645x729, 91K)

trying to fix my lua stack

Working on a multiple file reader in C# and getting stuck at the openfiledialog().

Does anyone have a working code snippet to read textfiles' contents and transpose them into strings for later manipulation?

I tried all the IO.Stream methods but none can actually read anything (end value is "").

fixed my lua stack

>The functional people in particular, they are reinventing dynamic languages. I mean they are reinventing the stuff that Smalltalk was doing, only giving it a different name, like "dynamic language". They are reinventing things that Smalltalk was doing, calling it "functional". They're reinventing things that Smalltalk was doing, at the programming level, we're talking about detailed programming level, and calling it something else. And they go out of their way to try and say, "oh, objects never work, never work, never work!", whatever! But it's a defense mechanism. And then they have to go and reinvent a whole bunch of other kinds of superstructure to make functions work. So if you look around the world, you know, do you see any functions out there? I don't see any! I see a whole heck of a lot of objects out there!
>Functional programming doesn't make sense. Your design becomes very convoluted and complex in order to translate reality into functions. And that was the biggest advantage of Smalltalk, is that you can take reality and express it directly in your Smalltalk code, without this translation kind of effect.
t. David West, PhD

Sauce: youtube.com/watch?t=12m48s&v=s-hdZZzMCac (starting at 12:48)

FUNCTIONALTARDS BTFO, HOW WILL THEY EVER RECOVER?!?!?

Attached: haskell.png (225x321, 12K)

>There do not exist pure OO languages in which all objects are immutable

Attached: brainlet.png (621x702, 56K)

That entire quote is full of shit

Sure it is, random anonymous blogger in an online Manchurian tapestry imageboard.

>The functional people in particular, they are reinventing dynamic languages.
>I mean they are reinventing the stuff that Smalltalk was doing, only giving it a different name, like "dynamic language"
Pants-on-head retarded. Basically discredits the entire video.

Maximum damage control.

#define F_CPU 16000000000UL
void uart_init(uint32_t baudrate) {

uint16_t baud = (uint16_t)(((F_CPU / 16) / baudrate) - 1);
}


I can't figure out what's going wrong here. If I enter the formula manually it work(decimal 103) as intended. There is some fuckery going on with types but I can't find it.

>t. David West, PhD
Literally who

>all the "objects" are immutable
>this is """OO"""
Just another illustration of how the subhuman cult of POO tries to integrate into its paradigm ideas that are completely antithetical to its original premise because they actually work, and then claim them as a part of POO.

Attached: d04.png (478x523, 14K)

Never mind found it I'm fucking retarded

>FP is reinventing dynamic languages
I'm sure you filthy animals actually believe this... I guess your idea of a functional programming language is JavaScript.

Attached: mfw-you-exist.jpg (246x374, 17K)

Well, your idea of an OOP language is fucking Java (or worse, even C++), so why not?

>integers are just objects d00d
>btw functions are also objects
>no lmao + is not a function

We're achieving retardation levels that shouldn't even be possible...
yegor256.com/2014/06/09/objects-should-be-immutable.html

>your idea of an OOP language is fucking Java
Name any relevant OOP language based on the premise of immutable objects, as opposed to that of breaking down and encapsulating mutable state.

Name any relevant FP language period.

Oh, snap!

> 2 most object oriented languages of all time
> t-they're not object oriented

Wow, it's like these brainlets can't OCaml or figure out how to use dependent types.

They are the exact same thing, you fucking retard. When you realize that (analytic philosophy ⇔ mathematics ⇔ CS) ∧ ¬(analytic philosophy ⊃ mathematics ⊃ CS), you might be able to wrap your head around Coq, Agda, Zombie, Cedille, etc.

I can write specification with FP so that my software is guaranteed to never fail, and do only what it's specified to do, and use the same language for my specification as the program itself. I can do this with basically any functional language, or at the very least extract my OCaml, Haskell, and Scheme straight from Coq, or just use Idris or Agda.

Wow it's almost as if every programming language is just fancypants syntactic sugar thrown on top of the exact same logic gates. What is Turing completeness?

You just described the fucking Haskell agnostic troll that comes on Jow Forums and goes "Nobody has ever used Haskell to do anything!!!" and then gets counterexamples and goes "I've never heard of those businesses/projects" for small companies and "That's just for vanity projects in huge companies that can afford to let people do vanity projects" for big companies, even if you're showing them the specification for seL4 or something. It's fucking annoying.

Please don't be that guy. I have a PhD, but that doesn't mean that I have to be a Pretty huge Dick about it.

Yes, that's exactly the sort of subhuman I'm talking about. Thanks for giving another example of my correctness.

>i can't give you any examples of my claims
Yeah, I thought so.

So you get to say JavaScript is not functional, but I don't get to say Java and C++ are not OOP? Nice cognitive dissonance, you intellectually dishonest piece of shit.

Compare them to Smalltalk.

Name any relevant pure OOP language

JavaScript

Why are they the "most object oriented"? Object oriented features in C++ were an afterthought duct taped to C, and Java is just an imitation of that model.

F# is comfy desu

learn Haskell

Attached: 1472274974829.jpg (10000x10000, 3.14M)

>extract my OCaml, Haskell, and Scheme straight from Coq, or just use Idris or Agda
Bunch of literally-whats no one in the business has ever heard of.
>What is Turing completeness?
Something pure FP languages don't have.

Scheme, Haskell, and OCaml, you fucking mong. Enjoy your 80k/yr webdev job when the big brain nibbas are pulling in 450k/yr to make sure that subway systems don't kill people. Uber killed that lady because their specification is shit (the contracted the same company that Lyft did for theirs, based out of Hong Kong and Manila, and I will tell you that the team they put together for that project was fucking trash and didn't really understand FP OR something like z-spec or b-spec)

B-but I just started learning F#

Here's why JavaSc*ipt is not a functional programming language:

1. Programming languages are made by humans for humans
2. The beings that make JavaSc*ipt are not humans
3. The beings that use JavaSc*ipt are not humans

Q.E.D.

Smalltalk.

>I can't name any relevant FP languages
Yeah, thought so.
>Scheme, Haskell, and OCaml
He said relevant.

finish F#
then learn Haskell

Attached: image (23).jpg (640x573, 77K)

>So you get to say JavaScript is not functional, but I don't get to say Java and C++ are not OOP?
JavaScript is as basic as you can get while still being able to call yourself "functional". It excludes every development in FP from the past 30 years. You literally can't name a single relevant OOP language based on immutable objects. The two main ancestors of modern OOP (Simula and Smalltalk) were based on encapsulating mutable state, almost all OOP literature is based on encapsulating mutable state, every relevant OOP language in existence is based on encapsulating mutable state, most irrelevant OOP languages are based on encapsulating mutable state... You're a genetically malformed, intellectually degenerate liar, just like every other member of your family. Please get sterilized.

>functionaltards are also weebs
Why am I not surprised?

>relevant

#ifndef DLIST_H
#define DLIST_H
#include
#include"dnode.h"
using namespace std;

template
class dlist
{
public:
dlist()
{
head = NULL;
tail = NULL;
count = 0;
}
dlist(const dlist &other);
~dlist();
dlist& operator =(const dlist& other);
typedef d_iterator iterator;
void show();
void reverse_show();
void rear_insert(C item);
void front_insert(C item);
void front_remove();
void rear_remove();

private:
Dnode* head;
Dnode* tail;
size_t count;
};

template
class d_iterator{
Dnode* current;

public:
friend class dlist;
d_iterator(Dnode* i = NULL)
{
current = i;
}

bool operator !=(const d_iterator& other)
{
return current != other.current;
}

bool operator ==(const d_iterator& other)
{
return current == other.current;
}

d_iterator operator ++()
{
current = current -> next();
return *this;
}

d_iterator operator ++(int)
{
d_iterator old(*this);
current = current -> next();
return old;
}

d_iterator operator --()
{
current = current -> previous();
return *this;
}

d_iterator operator --(int)
{
d_iterator old(*this);
current = current -> previous();
return old;
}

d_iterator begin()
{
cout

guess that makes this a functional website, normalfag

Attached: 1522434712203.jpg (1000x700, 66K)

Not an argument.

I'm getting this error:
In file included from main1.cc:11:0:
dlist.h:20:10: error: 'd_iterator' does not name a type
typedef d_iterator iterator;
^~~~~~~~~~
dlist.h: In member function 'd_iterator d_iterator::begin()':
dlist.h:84:22: error: 'head' was not declared in this scope
return d_iterator(head);
^~~~
main1.cc: In function 'int main()':
main1.cc:47:4: error: 'iterator' is not a member of 'dlist'
dlist::iterator it1;
^~~~~~~~~~
main1.cc:48:8: error: 'it1' was not declared in this scope
for(it1=lis1.begin(); it1 != lis1.end(); ++it1)
^~~
main1.cc:48:17: error: 'class dlist' has no member named 'begin'
for(it1=lis1.begin(); it1 != lis1.end(); ++it1)
^~~~~
main1.cc:48:38: error: 'class dlist' has no member named 'end'; did you mean 'head'?
for(it1=lis1.begin(); it1 != lis1.end(); ++it1)


when I try to compile, and I have no idea why. This program is just a simple doubly linked list builder, with an external iterator. The external iterator seems to not be detecting the variables within the dlist class, and I'm not sure why. Any help would be greatly appreciated.

Yeah. Don't use that instead do your own rendering engine with scanlines.

Lisp invent dynamic languages.
Small talk OOP begin real OOP objects talk each to others using messages, category theory is equivalent to OOP.

But C++,Java,C# built shitstorm say OOP means make a lot class and inherente on everything.

In which language?

does adderall help?

Attached: 1368295966140.jpg (2048x1536, 845K)

>brings an example of what i'm talking about to try to disprove it
Just how mentally damaged can a POO monkey get?

show the declaration of d_iterator

>Lisp invent dynamic languages
>what is the lambda calculus

I'm not sure what you mean. That's the class declaration you are looking at. Those are just inline functions.

>Smalltalk
>not relevant
lolwut

Attached: most_beloved.png (685x1002, 45K)

Please don't be a sophist. You don't know the first goddamn thing about how and why proofs should be used.

STOP USING THIS GODDAMN MEME. It's played out, but also when I read "J*va", I see the star as a parsing variable, so my brain looks at that and sees Jafdsadfjshgshdgsjkdfhgsfdhgsdfgjksfhgshfghsdva or whatever. Fuck you guys.
Oh ho ho ho, because of the lack if I/O and mutability? I have an HTML server written ENTIRELY in coq that will blow your mind. Look up Pluto. "FP isn't Turing-complete" is a meme, and for that matter, untyped lambda calculus is a better model for computational logic than Turing's faggoty bullshit ever was. I would have physically castrated him instead of chemically, Turing was a piece of shit who didn't contribute anything worthwhile to the field that hadn't already been done, he just did it in English instead of German.
I net roughly a half-mil a year because of critical systems specification done in all of those languages. Just because you've never heard of it doesn't mean it isn't a super high-paying job. Enjoy your 80k, you peon.

en.wikipedia.org/wiki/Total_functional_programming
>These restrictions mean that total functional programming is not Turing-complete.
Thanks for playing, better luck next time.