/dpt/ - Daily Programming Thread

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

Attached: dpt hacka doll 3.jpg (1280x722, 271K)

Other urls found in this thread:

hackage.haskell.org/package/ftp-client
infoq.com/news/2018/05/haskell-user-survey-2018
stackoverflow.com/q/50683786
isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines.html
twitter.com/NSFWRedditImage

you fucking retard

Thank you for posting a programming (anime) related picture.

>not using GitHub
Are you a Nazi?

Attached: DWlJzBVW0AABtr7.jpg (750x766, 64K)

Lisp noob here.
Is it a good idea to VECTOR-PUSH-EXTEND an adjustable character vector in order to make a LENGTH call be O(1)?
Or is it a bad idea and I should just write to an output string and have LENGTH calls be O(n)?
Reason I'm asking is because I heard extending an array is expensive or something.
But I'm not sure, so I need clarification, thanks.

why haven't you learned Hasklel yet, Jow Forums?
this

Threadly reminder that programming is a subset of anime.

Attached: 1523298193224.gif (346x360, 871K)

First for HackaTrap reading C++ book

Because I'm too much of a brainlet for FP.

FP isn't harder than IP, you just think that because you were taught IP first and FP is so different that it practically requires you to relearn programming. Didn't IP also seem hard at first?

There's nothing platform-specific about any of this, except for the hardcoded "31" in there.

see a lot of stuff you consider obvious now you probably struggled with once
the basics of FP are really simple - lambdas, beta reduction

Can you write a driver for a device without spec or help of vendor?

IP seemed perfectly intuitive, unlike FP which has tons of unintuitive language constructs, like currying, and all of the "do X in inefficient, roundabout way, hope the compiler optimizes it back to X", like with recursion instead of loops and such.
I never remember that, just an obsessive checking of the documentation for everything.

what languages do you use? I guarantee you struggled at one point, even if it was when you were really young

>too stupid for FP
>somehow a genius he got all the IP principles under the hood without trouble
>inb4 actually too smart for FP

What are you on about? IP is objectively easier and more readable

You can try to reverse engineer to existing driver.

haskell-fags,

What's the difference between extra-deps in the stack.yaml and the dependencies in package.yaml?
I've always added everything to the dependencies field in the package.yaml, until now I had to add a package to the extra-deps because stack wouldn't download/install yadda-yadda.

Attached: 1516373561210.png (1100x1100, 966K)

extra-deps is external (most of the time C libraries), while dependencies are just haskell libs

Explain code safety to me, preferably in c++ terms.

>he doesn’t test the speed of his program by putting /a at regular intervals and timing the alarm sounds

It uses types to prevent you from invoking UB, just like they prevent you from passing a string where int was required in C++.

it can crash and brick your hardware but at least it doesn't leak memory :)

>hackage.haskell.org/package/ftp-client
T-this looks like a haskell-lib to me, though.
Am I wrong ?

Attached: 1519935642507.png (256x375, 114K)

I think IP is necessarily more intuitive than FP. Telling a computer what to do is a lot easier to understand than describing exactly what you want to happen and having the computer figure it out for you.
Either that or Haskell is just a really painful language to learn.

>she doesn't test the speed of her program by running really fast and trying to keep up

Prove it.

>I think
yes that's just you.
Do FP long enough to unlearn all your IP habits, and you'll think the opposite.

Yeah that might be possible but thats literally the opposite of what intuitive means

C, but I learned that just a few years ago. Before that some Python, which had more syntax to memorize, before that DOS Batch.
Sure, I struggled to memorize the language constructs - putting semicolons on end of lines, which order the parameters go in for(start; cond; inc), if the condition is evaluated before or after the loop, etc, but I never remember finding the concept of, say, a variable or a loop unintuitive.
FP has concepts which are alien to the human brain, it's simple as that. It could be a good language for aliens, but not for us. The "good" FP languages avoid them, and they work almost like IP languages.

you're imagining things
look at the code you wrote when you were just setting off

It's not a "habit", there are fundamental differences in how imperative and declarative programming work. Haskell in particular is extremely terse and impossible to understand without prior knowledge of how it works, you can't just glean how it works like with a C program.

And intuitive is entirely subjective.
If you are used to reason with abstractions, then FP is pretty intuitive.

yeah, it is a haskell lib, what's the problem?

Does openMP offer any significant speedup over pthreads?
I wouldn't want to rewrite my code for anything less than 2x
Prog is a library for finding Pure Strategy Nash Equilibrium in n player games. Input specified by GAMUT.

That would be on a school computer which was wiped 7 years ago. I do remember finding it quite easy, however. It's like maths - the teacher tells you how to solve problem of type X (e.g. if it says a^2 + 2ab + b^2 this can be simplified into (a+b)^2), then you apply it.
What's unintuitive about a variable? What's unintuitive about a loop? I can't answer those questions, but any sane man can see clearly what's wrong with shunning loops in favor of recursion madness, that then gets replaced by a new (unnecessary!) language construct, which we then hide behind the compiler and pretend it isn't a loop.
FP is a lie, the constructs are just codewords for regular programming constructs they consider themselves too good to use. The only thing of value is the pure/impure function distinction, the rest of it is garbage.

>hurrr durrrrr if you don't learn a programming language you can't understand it just by looking at it
Also comparing a language as big as haskell and with C isn't going to do it. I could make the exact same criticism by comparing scheme and C++. Just that C++ restricts the use of operators as opposed to haskell (and their users who seem to love it).

If you learned a language of the ML family, and the concepts behind haskell (which for the majority have little to do with haskell itself), you could understand a haskell program just as easy as a C one.

try adding the following to your extra-deps in stack.yaml:
- ftp-client-0.5.0.0

Won't compile if I don't. All my other dependencies are in `dependencies` of the package.yaml though.

Intuitive is not subjective. Take physics, for instance. The formula for conversion of acceleration, velocity, starting position and time to end position is unintuitive - why the velocity is squared is just handwaved away with "you'll learn it later". The exponential decay formula's lambda is unintuitive - why doesn't λ = 1 mean t1/2 = 0, if it's how much of the quantity decays per second?
On the other hand, the formula for potential energy (mgh) is decidedly intuitive - if you would ask someone to guess which factors play a role and chuck them into an equation, that would be the result. E = Ek + Ep + Ef is intuitive. ΔE = cmΔT is intuitive. You would indeed guess that it's these three which play a role.

If you believe intuitiveness is subjective, you are mistaken. Something is intuitive if it's consistent with the way things work in the head. Abstractions can't be intuitive in the same way, unless they turn it into something able to visualize.

You're being exactly unreasonable.
Today, I don't really see what's intuitive about a lambda or a recursion, even though I forgot the time I struggled with them. When I look at most beginners, they all (in my experience) have a hard time reasoning with loops, conditions and lambdas.

Seems to me like you're just having a hard time understanding TCO, which I don't think I had ever a problem imagining/understanding. See? Weird isn't it, how everybody can perceive things differently.

it might be that your resolver doesn't know how to handle that library and therefore you have to set a hard constraint on it

Goyims please

dont worry about it unless you know its a problem

strings in common lisp implementations are probably implemented in a way where length would be constant anyway.

Of course learning is required either way, but functional languages tend to require much more of it to get past that first hurdle because so many things are implied and tucked away in syntactic sugar.
Lisp, for example, is easy to learn because it technically does not have syntax; all you need to know is what an s-expression is. In comparison, Haskell's type system is a mindfuck to inexperienced users.

>FP is not possible with s-expressions

Attached: 1497035154095.png (207x243, 15K)

>is easy to learn because it technically does not have syntax
It's impossible to have a language without syntax. Lisp's syntax is very simple, but it's there. It's just that data and code are one and the same.

>calling someone a brainlet while failing to understand his point
He brought up Lisp as a counterexample to show that functional languages can have simple syntax, but more often that not don't.

No, recursion exists in civilized languages too, and anonymous functions too. I understand tail call optimization, but it's a decidedly unintuitive way of doing things. Instead of iterating over the array, you send it all over the place in bits and pieces. Function half-application/currying, same thing, it's just a glorified macro.
Also, there is the issue of FP languages being written in a completely alien way, unlike most other languages, even assembly, which at least attempt to resemble English.

>using stack

Attached: snoyman.jpg (357x507, 25K)

So, stick with with-output-to-string?

>FP is hard to learn
>a complex FPL is hard to learn in comparison to this simple IPL
>ignoring complex IPL and simple FPLs, let's generalize that FP is hard to learn
and again, (You) have not point to make.

I never said otherwise. My point was that FP languages tend to convey simple ideas in a convoluted manner.
You get what I mean.

How do I rewrite this cleaner? I want it all as one expression. Is there a good way to do this? I know I can use another ternary operator, but it feels quite stupid. Should I sign extend?
Macros:
#define NEG_2C(x) (0-(x))
#define UINT32_2C_SGN(x) ((x) >> 31)
#define UINT32_2C_ABS(x) (UINT32_2C_SGN(x) ? NEG_2C(x) : (x))

Forgot the image, again

Attached: 1522436558070.png (285x153, 3K)

Nothing unintuitive about partial application. It's completely consistent with lambdas.

I could argue that mapping over a list with a pure function is way more intuitive than incrementing a variable and doing a bunch of side-effects and accessing your array with that variable.

>making a branch to do abs
>hardcoding 31
>using macros instead of inline functions

using inline functions in C is for queers

Is that supposed to be a bad thing?

>he thinks the inline keyword inlines function calls

not if you're an anime girl (male)

Attached: 1505002738186.png (1024x1024, 325K)

is there any good resource for learning sepples that leaves out the useless parts?
i like the idea of shit like generics and smart pointers but the entire language seems like such a clusterfuck

yes

Learning smart pointers means learning exceptions. Learning exceptions means learning OOP. There is no escape my friend, there exists no sane subset of sepples.

>his language overloads parens to be function application

Attached: laghing.jpg (242x208, 10K)

Downloading a page in Python 3 using requests module adds an extra escape to hex, e.g.:

Literal page content: "This is some hex: \x20\x55"

When using text method on requests object: "This is some hex: \\x20\\x55"

Any way I can stop this and keep the verbatim content?

how long until C++ lets you overload putting an expression in parentheses
operator()(this)

those red things are some fucked up ui elements.

I basically render the tiles first and afterwards the ui stuff. now, they have absolutely nothing to do with each other and I use 2 completely different shaders. I unbind the shader and everything but still. what could cause this?

Attached: file.png (2009x1118, 1.19M)

this already exists but only as a member function

i mean (x) being different from x

what a load of shit, i just want memory safety

What did you want me to do? sizeof(uint32_t)*CHAR_BIT?
Completely excessive, since this is hardcoded for uint32_t which is guaranteed to have 32 bits.
I know I can do abs branchless, but it's probably faster this way.
Maybe I should just use a union and static_assert twos complement. It seems much easier than this convoluted nonsense, and if I ever have to change it for a ones complement computer it's easy to do so.

ok solved it. as always wrong order. fuck opengl

Yes, pic related.
C also has generics, by the way.

Attached: 1497777887626.png (767x991, 100K)

>The 2018 Haskell User Survey shows very high satisfaction with Haskell's security, quality, reliability, maintainability, and advanced capabilities, writes FP Complete's CEO Aaron Contorer.
infoq.com/news/2018/05/haskell-user-survey-2018

You are wrong.

You have never used a one's complement computer, you will never use one and your code will never need to run on one.
You don't need to assert anything, you can be 100% sure your C implementations will always be two's complement.
In fact there's a proposal to make it official in the next C standard.

shills gonna shill.

it's unbiased in the category of haskell idealogues, what's the problem?

>stackoverflow.com/q/50683786
So this is the state of java

Attached: 1527989805046.png (800x600, 371K)

wow
i'm pretty sure i made that meme ages ago

Trying to remember how string alignment algorithms work because it turns out you actually do need algorithms for webshit

Attached: Screen Shot 2018-06-05 at 5.02.41 PM.png (2880x1750, 654K)

Make a new one about this

>haskell users like haskell

Attached: 1498698835066.gif (460x259, 1.93M)

this:
isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines.html

do C++ users like C++

Only C users like C++.

A safety property is a "will not do something bad" property. No undefined behaviour is a common safety property. The counterpart to safety is liveness; a liveness property is something that you *want* your program to do, such as responding to all inputs in finite time.

Can the existence of preemptive multitasking be considered a kind of process isolation? i.e. processes in a non-preemptive operating system are not isolated because the failure of one process to yield control will cause the system and other processes to fail.

>the first evaluation is for the store and the second for the load

Attached: leadership.jpg (800x586, 93K)

sublime --> serious pleb

ate you stupid? C user love C for it's simplicity and hate the convoluted nature of C++.
And C++ developers write C++, but don't like the language.
Because frankly it's a cancerous version of C and looks like Micheal Jackson after he turned white.

Attached: michael-jackson.jpg (1000x1366, 570K)

>ate you stupid

thanks for the (You) user :^)

I wish I were a cute trap... I'd masturbate all day.

excellent rebuttal user!

So you are already a cute trap?

this.
I'm not a cute trap and masturbate 2 to 5 times a day, every day.

typing on a piece of shit android keyboard has it's drawbacks.