/dpt/ - Daily Programming Thread

Previous Thread: What are you working on, Sup Forums?

Other urls found in this thread:

github.com/RogueException/Discord.Net
twitter.com/SFWRedditImages

D

D2

>Dependent Haskell
>ETA 2018
>earliest

COBOL?

>What are you working on, Sup Forums?
Fooling around with making a Discord bot in C#.

Right now it just does some basic things, like serves up music and images from my machine if I'm online, dicerolls, and tells you it loves you if you're feeling lonely.

If they release a Tay API, I'll hook it up to that so any Discord server can have their own literal Hitler.

finna write the world's most vulnerable telnet server in C, for a half-baked MUD that nobody will play and which I will abandon in about a week

Syntax is pretty simple, too.

It also will just swallow fuckups and log errors instead of breaking if you want it to, which makes it "just werk" when people try to break it.

github.com/RogueException/Discord.Net

Just use Idris.

>Vectors are linked lists

If you want to find out what arguments you can pass into Scapy functions, you can use the function ls(), to provide you with that information.

Does anyone know if there is a ls() equivalent for generic Python? Pycharm is pretty useful at telling you what arguments can be passed in?

Anyone?

Implement your own contiguous vector if you don't like it.

>Actually C++ is more type safe then Java and C# because of const correctness.

>Actually C++ is more type safe then Java and C# because of const correctness.
What the fuck.

Link to the poster of this so I can laugh at their expense.

...

no one actually says that tho

kek

...

How did you guys memorize all of the built-in functions of Haskell? I find myself rewriting them sometimes because I forget it already exists. Should I literally just use flash cards etc?

regular use + auto complete

Which style of editing would you prefer?

>top
When you click the edit button, the editable elements are replaced with text boxes. A submit/cancel button appears at the bottom of the side-bar.

>bottom
When you click the edit button, an overlay appears containing text boxes and submit/cancel buttons.

I just hoogle the type signature of any function that I think should already have been written

Hoogle is a good help. You enter a type signature and it finds functions that fit a similar signature.

>using auto-complete

That sounds pretty smart, thanks

>using a text editor
>not using punch cards with a hole punch to program

>the occasional time when a function doesn't already exist

Maybe I'm blind, but I can't find a function that removes all instances of an element from a list. They all seem to only remove the first occurrence.

I thought you were trolling based on an apparent typo.

Didn't realize "hoogle" was a thing.

use filter

removeAll :: Eq a => a -> [a] -> [a]
removeAll a = filter (/= a)

import Control.Concurrent
import System.Directory (doesFileExist, getAppUserDataDirectory,
removeFile)
import System.IO (withFile, Handle, IOMode(WriteMode), hPutStr)

oneInstance :: IO ()
oneInstance = do
-- check if file "$HOME/.myapp.lock" exists
user

>What are you working on, Sup Forums?

I'm trying to learn a bit more about bash, so I've been making random scrapers with it. I wanted to do something simple so I decided to make a script that goes through a board on here and downloads all the images in every thread.

So far all I've done is wrote a function to download every image from a thread, but I still need a way to get all current thread links (or numbers), but I'm not too sure how to get them. Can anyone point me to the right track here?

It's not hard to implement, but I dislike having to make a Data.List.Extended module and then import that everywhere

just use filter (/=x) inline

as we established in the last thread, having more features = simpler, so don't worry about it

Or just write filter (/= x), it's not hard. If you want it as a combinator, you can write filter . (/=)

I changed two raw pointers to std::unique_ptrs and my applications load time increased by 3 seconds. I-Is that supposed to happen?

Did you post this in the right thread?

sounds like a good time to me

>new Random().Next(images.Length)

I don't like this at all.

How do you feel about chaining several C preprocessor macros together to avoid using magic numbers?

What programming language should a geologist/geophysicist learn?

I've had two courses in matlab...

coq and agda

game maker

Python probably. Best libs for you.

Sounds silly, but I guess that's the """right""" way to do it

I wish people would stop recommending Python to people

What is coq I'm just getting pictures of chickens.

how do you expect anyone to know what you're talking about if you don't provide an example

i'm talking about using something like &str[i + max(dbl(len(a)), dbl(len(b)))] instead of &str[i+8]

>&str[

plz help

I have some JS that needs to store a two strings, and an int for some number of entities. I was storing everything in one object with an array for each field. The example seen later stores it as an array of separate objects. Is one of these more correct than the other? What's the difference?

>What I did
var data = {
string1 : ["entry1a", "entry2a", ... "entryna"],
string2 : ["entry1b", "entry2b, ... "entrynb"],
int : [], // gets initialized to zero to match other arrays elsewhere
current : 0


>Example
var data = {
current = 0,
entity : [
{
string1: "entry1a",
string2: "entry2b",
int : 0
},
....
{
string1: "entryna",
string2: "entrynb",
int : 0
},

>dependent types
>some kind of proof/functional/autist/I've-never-written-good-software language
Why? Why can't I have a normal imperative language which does dependent types?

The former statement seems much more robust but is considerably less readable.
I'd be more likely to assign that value to a local variable and comment as appropriate.

>I want dependent types
>but I don't want a proof/autist language

u wot m8

>Dependent Haskell
>imperative
In any case, dependent types don't play nicely with informal mutation (so, without linear types, monads, etc.)

>tfw mom started there
[spoiler]she's not what you'd consider a 'good programmer' but she is and has been writing software that's praised in her industry for never failing and being top of the line[/spoiler]
Conflicted if I want to be like her or if I want to be someone who never gets that kind of amazing reputation yet produces large masses of usable software.

>full dependent types in an imperative language
that sounds awful

double longestLength = max(dbl(len(a)), dbl(len(b)));
&str[i + longestLength]

>inb4 it's the next OOP-tier plague

Seems less useful.

>I proved that this function returns a sorted list
>but it also might do literally anything else, too

Standard. It's another fault of the language. It'd be nice if you collected them rather than spreading them all over the place like tons of API I use.

Just write them as you would knowing there's a 'go to definition' function.

Dependent types are considerably harder to delude yourself into understanding, so I doubt it.

>multiple virtual inheritance _at runtime_

Few people know and understand OOP. Doesn't stop them from thinking they do and writing their 'safe' code using their 'OOP'.

Top, no question, but the submit and cancel buttons ought to be in the same place as your edit button.

WGET is the right path, I actually did a scraper for a startup there this summer that worked really well.

There's other software out there but honestly WGET makes things very simple and efficient

They believe that they understand it, though.

>implying any programming language isn't imperative
>do

You sure? What's the advantage of using wget here instead of doing a curl | grep line?

>hasklel
>strings are linked lists of chars

We're both reiterating the same thing. My point is that I don't think it's possible for Mount Stupid to apply with dependent types. I mean, people could say stupid things about them, sure, but you have to really understand them to use them, unlike objects.

Well, I suppose when you declare what happens after something else, that's imperative programming. You know what we both meant, though.

Common Lisp or Racket

I want the address of the 9th character in a char array.

m8 that's already around with CLOS

lazy immutable potentially optimised linked lists
what else should they be?

linked lists are elegant, if not fast

str+9

Well the same could be said about OOP if there were enforced capsulation and all that. It'd be a mystery to people if that was enforced.

Same with dependent types, if you're allowed to do iterative nonsense and simply claim things are proven all the time you'd have a very similar situation to what we have with OOP imo.

that's not nearly as clear tho

&str[x] == str + x

MUMPS

That's a good point. I suppose there are still lots of ways to lower the bar.

Linked lists are significantly slower than arrays.
They have terrible locality of reference.

arrays are elegant, linked lists are filthy pig disgusting

(puke)
Wrong on both accounts.
I disagree. Also if you have a reason to use a 9, specify why rather than hiding your reasons behind large amounts of macros that don't really give the full picture for the specific instance.

lol no

Linked lists can kind of work in Haskell since they lend themselves well to lazy evaluation.

This is a proper answer.

I suppose that's a good reason.
It's still pretty shitty though.

Yes, since lazy evaluation already slows things down with runtime allocation, linked lists wouldn't make much of a difference.

My statements often look like &str[i+j].
str+i+j looks stupid

Never thought of it like that. If you use vectors, you need to actually hold the real list in its entirety, etc.

Python.

>UNIRONICALLY using haskell
KILL yourselvles

But then you're storing the result an intermediate calculation that you only need once, and then retrieving that same result from memory after storing it. We must optimize every CPU cycle!!1one

>Mine looks like x, and I'm not stupid, so x isn't stupid

yes it is

>I can't wrap my mind around the concept of pointers or iterators, so they must be stupid

>i+j
What does this usually signify? A number of elements after another element? That seems fine.
If it's just a pitch and a stride that's usually:
ptr+j*stride+i
Just don't bake the stride into the index.