/dpt/ - Daily Programming Thread

Good times edition.

Previous thread: What are you working on Jow Forums?

Attached: hibiki_sicp.png (1160x1739, 2.28M)

Other urls found in this thread:

hackage.haskell.org/package/containers-0.6.0.1/docs/Data-Map-Lazy.html#v:update
wiki.haskell.org/Tail_recursion
twitter.com/SFWRedditGifs

whats the best database to use for a cryptocurrency exchange? (all of the matching engines are closed source and no way am i paying for nasdaq's one) so im developing my own...

I need around 10-15ms latency for single writes and reads. im writing this in go btw so ideally a db with a go driver.

blockchain

>decide that I want to try to make something
>have to google how to make it
Is this because I'm a python baby, because I'm self taught, or is it just because im an idiot.

Attached: nyoro~n.jpg (260x260, 21K)

>C++ doesn't have a bottom type
baka

>OOPsies think that in FP when updating a value in a map you have to copy the whole map

I'd say the third option

OOPsies eh, lads? You can lead a horse to water and all that

They're right. It's not FP if you don't.

>have a list
>want to append an element to the front
>re-use the old list
no problem here

I'm sorry, It just feels like I missed something that I was supposed to learn. How do I go from writing functions and doing math calculations to doing network operations?

Attached: 1458626540237.png (240x240, 24K)

>Implying pass by reference
>Another function or thread alters the list in the middle of your function
>Result is different from what was expected.
It's not FP; you don't have referential transparency. You need to copy the list.

Yes it is. You may have to copy a small part of the map but certainly not all of it. I'm not surprised OOPsies are so against FP if they have this level of misunderstanding of it.

>Another function or thread alters the list
How do they do that?

>Another function or thread alters the list in the middle of your function
This doesn't happen. The list is immutable. Prepending an element to a linked list does not affect the original list and requires no copying.

To the user wanting to write a video player from scratch:
Well, you best learn about the formats first because mp4 / mkv etc are typically containers of various codec encoded media, i.e. Mp4 & mkv both can contain x264 video and aac audio, or mp3 audio, or other video codecs

God's programming language is Scheme, not HolyC, which is a false prophet.

You'll have to do some reading, it's inevitable. I suggest looking up sockets.

I'm not sure how to explain what I'd consider basic programming to you.

>The list is immutable. Prepending an element to a linked list does not affect the original list and requires no copying.
>Prepending an element to an immutable list
The original post specifies "updating a value in a map". Do not move the goalposts.

see the post is mocking you for thinking you have to copy the map. it is obvious it wants a new map with a new value at a given key.

Another user talked about lists and you replied to them, so I continued talking about lists because I assumed you were happy to. We can switch back to maps if you prefer, but don't accuse me of moving the goalposts just because you're getting BTFO. The same principle applies to maps: you do not need to copy the whole map when updating a value in it.

It can be. Remember that FP characterizes the programming language, not the compiler -- the compiler is free to translate the program to an imperative form in which the array is updated in-place. Unfortunately, this can result in code which the programmer must lead the compiler by the leash, and it feels less and less like FP...

>it is obvious it wants a new map with a new value at a given key.
That's not what "updating a value in a map" means.
>I was just pretending to be a retard.

>I'm not sure how to explain what I'd consider basic programming to you.
I'm sure we'd find your misunderstanding of basic programming highly entertaining.

Who said anything about an array?

yes it is, in the same way "prepending a value to a list" doesn't need to mean modifying an in-memory list

But you don't understand! FP must use my clumsy misunderstanding of it in which it is incredibly inefficient!

>cons takes O(n) time

In what?

In FP, according to OOPsies

>updating a value
>fp
kek, k tard.

Linear types will save systems programming

>just because you're getting BTFO
If you want to get technical, he specified a list, not a linked list, so he's still wrong.

You can't have referential transparency with containers without making a copy of them in some way, with very few specific exceptions.

>your misunderstanding
If there's any misunderstanding, it would be what should be considered basic or more complicated than basic. While threading and time slicing might not be basic, how they modify values should be very easy to understand.

>doesn't need to mean
A statement that you 'don't need to do something' for parallelograms or rectangles because you don't need to do it for squares is not a valid statement logically. This should be very simple to understand.

By all means, continue to demonstrate your misapprehensions.

>go to Jow Forums
>see OP pic
I know what I'm fapping to later. Also, how long it is before I can master C++?

Stop masturbating

>You can't have referential transparency with containers without making a copy of them in some way, with very few specific exceptions.
The point is you don't need to copy the WHOLE container, as some OOPsies seem to believe.

This.

Attached: Rust_programming_language_black_logo.svg.png (1200x1200, 56K)

>While threading and time slicing might not be basic, how they modify values should be very easy to understand.
That's completely irrelevant here because we're dealing with immutable data.

not real linear types

This can only be true if your function and its output only depends on a subsection of the container. You would still need to copy that entire subsection. If the subsection requires traversing the container to get to that subsection (such as with a linked list) you would need a copy of those pointers to maintain referential transparency.
At that point this argument becomes a semantics argument over the bad phrasing of the original statement, as if you're only sending a subsection of the container as an input of the function then in the scope of the function that is the WHOLE container.

It should be irrelevant because we're dealing with immutable data. I have to keep bringing it up as supportive reasoning because people who call those who tell them they're wrong "OOPsies" think they can always update immutable data without making copies. Just because there are situations in which they can, does not mean that they can in all situations.

I want to make a language that makes heavy use of affine types

>You would still need to copy that entire subsection
>you would need a copy of those pointers to maintain referential transparency.
nobody is claiming otherwise
>At that point this argument becomes a semantics argument over the bad phrasing of the original statement
the original statement was phrased clearly, but OOPsies evidently didn't understand it
>if you're only sending a subsection of the container as an input of the function
the function is applied to the whole container
>Just because there are situations in which they can, does not mean that they can in all situations.
we're not talking about all situations, we're talking about updating a value in a map and prepending an element to a list

fp is about evaluating expressions, not executing statements. __updating__ anything is non sense.

>nobody is claiming otherwise
>the function is applied to the whole container
>we're not talking about all situations, we're talking about updating a value in a ma
>the original statement was phrased clearly, but OOPsies evidently didn't understand it
Don't pretend that you're someone who understands FP and is talking down to OOP-only programmers when your making claims that that something that isn't FP is FP.
You're either making incorrect statements about FP or you're making incorrect/misleading statements with the English language about FP. Pick which one it is and come to terms with it.

Anime girls should not be this cute.
How are we supposed to not like this? It's just unfair, man, fucking unfair. YLYL is rigged.

hackage.haskell.org/package/containers-0.6.0.1/docs/Data-Map-Lazy.html#v:update

EZ mode.
gitgud you absolute faggot.

I've been clear throughout this whole discussion. You have repeatedly tried to twist words, misunderstand things, and bring in irrelevant topics, and now that you have nothing left you claim bad faith on my part? Get the fuck out of here.

Why do these threads always devolve into FP vs OOP shitslinging without any code being posted?
Oh wait, it's because none of you fuckers can program and are bikeshedding like a motherfucker in between your CS101 class and the mandatory swimming class your University makes you take.

Attached: صور 2013 (19).jpg (580x466, 20K)

>stop posting about things I don't understand it makes me insecure!

Something which made it click for me is that programming is just the medium. After you learn your way around a language, the number of choices of what to study explode. If you want to do networking, I'd suggest starting with a textbook on the protocols in use and the measures taken to secure them. I read "Computer Networking: A Top-Down Approach."

>OOPsies think cons takes O(n) time in FP

>people post something FP related or a generic OOP is shit
>wagies get butt-blasted and start shitposting seriously
it's almost always the case, wagies are the problem in /dpt/.

>programming is just the medium
Which medium you choose is important, though. C and C++ are like crawling through a minefield covered in barbed wire. Lisp is like gliding through aether. Python is like wading through treacle. Java is like wading through shit. C# is like wading through shit with bits of corn in it.

>Map k a -> Map k a

congrats, you copied and pasted code. keep this up and you may become a JS artisan

Is this a car, or a crab?
My brain cannot comprehend.

So if I'm writing Haskell, how do I know for certain that my compiler is going to do a tail call optimization and not overflow the stack?

wiki.haskell.org/Tail_recursion

>Lisp is like gliding through aether
So never actually getting anywhere? Good analogy.

>I can't believe I spent all this time wading through shit when I could have been gliding through aether
>I'd better falsely disparage the latter

Wading through shit, but arriving to the destination is better than not getting there at all.
>i can't actually go anywhere
>better celebrate the journey without caring about the destination

BTFO

Gliding gets me there faster and I'm not covered in shit when I arrive.

Magical libraries which 99% of programmers doesn't understand how they work. This is the dirty little secret of programming.

What are some ways programming has been beneficial to you in daily life, anons?
For me, I've written countless little utilities for myself over the years. Knowing Regex is another bonus when I have to edit large text files.

Attached: 1511699413651.png (800x792, 580K)

>B-BTFO!
>now wading through this shit seems worth it!

Ok, has anyone built a statically typed, procedural language with a macro language based on Lisp?

My neat little script for automatically downloading footfag anime porn from the boorus alone has saved me many hours.

I don't think it's possible to fully benefit from Lisp macros without dynamic typing.

You'll need to do some reading up on APIs. At the fundamental level everything is just an electrical device that's hooked up to the address and data bus wires of the processor (i.e. 32 wires for a 32 bit machine).

As a programmer you only need to worry about operating system "system calls" tho

ATS YOU FOOL

just ((((COPE))))

>I don't understand lisp
>so it must be useless

The Lisp could be dynamically typed, with its primitive types including the declarations, statements, and expressions of the main language. I'm going to try it out this evening if I can't find an existing implementation.
I'll take a little peek at ATS.

>OOPsies think cons takes O(n) time

>lispfags think that O(n) getting / setting is fine

>OOPsies think getting/setting takes O(n) time

Attached: Screen Shot 2018-08-31 at 00.56.27.png (444x440, 246K)

I have written so many porn downloading scripts over the years it's not even funny

>lispfags don't even understand how lists work

dumb frogposter

i love ternery operators
if it were possible, i'd fuck it

>thinks lisp doesn't have vectors or binary search trees

Just support (statement; statement; expression) as an expression instead of ternary operators.

just make if-then-else into an expression

go for it, faggot

OOPsies, OOPsies everywhere

Anyone here using kotlin? I'm just getting started and I'm not sure if I like the automatic getters and setters. If I have this
data class Person(val name: String, var age: Int)
Then I absolutely don't want it to give me a setAge method. person.age = x should return an error. The point of having private variables is that they are hidden. If you have a private variable but you give everyone a getter/setter you might as well make it public.

So the question is whether it's possible to choose which properties get their getters.

>kotlin
no

Why are you willingly using Russian Java?

lol i just realized properties are public by default
protected var age: Int will not let you set the value

As much as I like research languages like Idris or Haskell, and as much as I would like to learn a Lisp dialect or even erlang, I want to get something done and Java is proven to work. But I hate Java. Kotlin seems like a good choice, you get the production ready libraries without the verbosity

>Java is proven to work
Well that's certainly debatable. Immeasurable bugs have been created using Java.

>OOPsies
is it just one really autistic guy posting this over and over again?

>Kotlin seems like a good choice, you get the production ready libraries without the verbosity
You could use Scala. You get to keep the Java libraries you think you need, and also pretend you have a real static type system, instead of a complete joke of one.

You sound OOPset, OOPsie.

>thinks you can only get "things done" in certain languages
Where did this wagie mentality come from anyway? Stockholmed shitters who don't use anything else?
There is literally nothing stopping you from doing the same things in haskell or idris that you can do in Java.
> you get the production ready libraries without the verbosity
ah, so you don't actually want to program, you just want to import libraries, call functions and pad your shitty github with generic projects.

I personally prefer POOjeet, OOPsie sounds a bit like a passive-aggressive girl making fun of you.