/dpt/ - Daily Programming Thread

Old thread: Lisp is the most powerful programming language.
I don't care about what you're working on.

Attached: lisp.png (2880x1800, 562K)

Other urls found in this thread:

en.wikipedia.org/wiki/Yerkes–Dodson_law
gist.github.com/rjhansen/67ab921ffb4084c865b3618d6955275f
github.com/marchgithub/chan-image
twitter.com/SFWRedditGifs

I care about what you're working on, tell me instead.

Attached: 1547875971957.jpg (1052x1342, 402K)

This is avatar fagging

prove it

reminder not to become a NEET loser like OP who does nothing but tell everyone how little he cares

Attached: when you don't care.png (507x846, 233K)

I like C!

Moving my python scripts which I use personally at work to common lisp.

learn lisp

it's okay user. but you must learn lisp.

have sex

fuck you

Learning Clojure

suave lisp toad

acceptable

It's saturday night

why aren't you leetcoding /dpt/

Attached: 1426743256260.jpg (362x346, 38K)

I'm not gay.

Attached: 1543601157706.jpg (420x331, 42K)

>leetcode
cringe

>cringe
Yikes!

What's the difference between dependent types and refinement types?
The usual example of a dependent type is a list of a certain length. But isn't that just a refinement type?

Attached: ?.jpg (1080x1080, 774K)

static locals break my personal scoping rules

rules are meant to be broken.

>The usual example of a dependent type is a list of a certain length.
Isn't that just an array? How are dependent types even useful?

>Isn't that just an array
the data is no different from a linked list. The type system just knows something about its length.
Likewise, non-dependent array types normally have a single type argument, for the type of the members of the array: array(int), array(list(array(int))), array(map(int, string)), but with dependent types the type system can also know something about the length of the array: array(int, n)

It kinda forces you to think about stacks and heaps when you could otherwise just deal only with scopes and be fine

I know how to write code but I have no idea how to actually make something with it.

Attached: 1485162091903.jpg (640x955, 113K)

sounds like you don't know how to write code

dependent types are just a subset of refinement types.
The difference is you're specifying conditions in the form of types which the compiler must then deduce, rather than giving explicit predicates for a type.
That's why Ada can accomplish much of the same that a dependently typed language can.

I don't understand the last line. A dependently typed language would have the compiler deduce everything?

used to do it then i figured what's the point

>i am a carpenter but i can't make anything with wood

more like
>I know how to use a saw, hammer and screwdriver but I can't make anything with wood

I can write functions that correctly do a thing but I never learned how to actually make large programs

en.wikipedia.org/wiki/Yerkes–Dodson_law

>A dependently typed language would have the compiler deduce everything?
No, but dependent types add massive complexity when having to check for equality due to the nature of allowing first class types. Which are ones that can be ordinary values. That's why type checking in Idris1 is dreadfully slow, or atleast part of the reason. But I'm no compiler writer yet, or idris expert.

a large program is just lots of things in a row

How did Ada avoid it tho?

programming is just typing, anyone can do it

But then isn't that a runtime check?

isn't *what* a runtime check? what are you asking?

The length of the list

I've got a BS in math and I did all the exercises in Bjarne Stroustrup's C++ programming principles. Could I make any meaningful contributions to GNU Octave? I'm afraid all of my code is shit and not worth sharing with the world.

Attached: 1496363027199.png (1080x1488, 697K)

how could "the length of the list" be "a runtime check"? is your mother a predicate?
You don't need to know the exact length of the list. You need to know that it has a length, and you need to keep track of updated constraints to the length depending on control flow.
For example, this is an compile-time error:
val x = something_returning_a_list_of_unknown_length();
something_requiring_a_nonempty_list(x);
and this is fine:
val x = something_returning_a_list_of_unknown_length();
if (list_not_empty(x)) something_requiring_a_nonempty_list(x);
The compiler *still* doesn't know what the exact length of the list is, but it knows (within the 'then' branch of the 'if') that it's greater than 0
list_not_empty itself incurs a runtime check, but now something_requiring_a_nonempty_list can pass its argument through hundreds of other functions that don't need any runtime checks at all because they have the same static requirement that's satisfied, in the program, by this one check.

force them to adopt a code of conduct

numpy and scipy are the hotness, the code is in C++

ada doesn't have first class types.
you refine to define everything first.
first class types just allow you to compose with functions and their arguments instead.
But that means you have to have the compiler figure out equality, so the freedom has cost.

Same as everyone else who can't meaningfully contribute. Dye your hair pink and find an autistic white male in the project to destroy

>you refine to define everything

Attached: 1566897698575.jpg (640x640, 44K)

type Your_Mother is A_Whore (Positive) of Johns;
see it's a refinement of A_Whore

yes?
Ada's whole deal is refining down to extremely granular types. But you have to define predicates yourself, rather then specifying types as conditions and having the compiler figure out everything with the arguments
That's why dep types are just a subtype of refinement types.

(me)
wow, this is disgusting. Why are you bringing shame to Ada developers?
What does the following look in C++ ?
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Finalization;

procedure Final is
type Blah is new Ada.Finalization.Controlled with record
Id : Natural;
end record;
overriding procedure Finalize (Object : in out Blah);
overriding procedure Initialize (Object : in out Blah);
overriding procedure Adjust (Object : in out Blah);

overriding procedure Finalize (Object : in out Blah) is
begin
Put_Line ("[" & Natural'Image (Object.Id) & "] cleaning");
end Finalize;
overriding procedure Initialize (Object : in out Blah) is
begin
Put_Line ("[" & Natural'Image (Object.Id) & "] initializing");
end Initialize;
overriding procedure Adjust (Object : in out Blah) is
begin
Put_Line ("[" & Natural'Image (Object.Id) & "] adjusted");
end Adjust;

Omg : Blah;
begin
Omg.Id := 5;
Put_Line ("hello, world!");
end Final;
output:
[ 26577600] initializing
hello, world!
[ 5] cleaning

What should I do or make to graduate from being a script kiddie with Python?

What is the point of this example?

Make a text editor in Python.

it's an object where methods are called when it is initialized or when members are updated or when it goes out of scope.
I imagine the C++ equivalent is "just use a constructor, "just use methods of instead of public members", and then destructors.

subtype Speed is Integer range 0 .. 299792458;

Attached: 1565904675398.png (657x527, 45K)

Why would you want to do that though?

Common Lisp can do that.
(CLOS is the most powerful object system)

Bit of a C++ noob needing some help.

I have an array of CustomerRecord pointers inside my class CustomerQueue, In the dequeue method, I want to create a copy of whatever's being dequeued into the stack and return that, while deleting the dynamically allocated CustomerRecord from the heap, but I'm getting this error:

conversion from 'CustomerRecord*' to non-scalar type 'CustomerRecord' requested

This is my method:
CustomerRecord CustomerQueue::dequeue() {
CustomerRecord dequeued_record = records[start];
if (!is_empty()) {
records[start]->print();
delete records[start];
start++;
if (start >= 500) start = 0;
}
return dequeued_record;
}

This would work in Java lol, and I still don't have my head fully wrapped around c++ and pointers. Would appreciate any help/tips

Fuck I'm dumb, I didn't even read the error code properly until I was looking over my code. Solved it but adding in a single * lol

*records[start];

dynamic types let you cheat and do it, at the cost of run-time safety.

First of all, why are you using bare pointers in c++? Use unique_ptr, and then someone might help you with this.

70% of problems are solved as soon as you ask them properly.

70% of problems are solved as soon as you rewrite them in Lisp.

>rewrites OpenSSL in Lisp
hooray! No more memory errors at all! It's safe!
>everybody uses the old broken OpenSSL because they've literally no way of using the Lisp version

isn't that what happened with ocaml and the gpg keyservers

Using it would be easy.
Binding to it would be impossible unless you used Lisp.

unless you're talking about something else, it looks like something far worse happened with GPG: gist.github.com/rjhansen/67ab921ffb4084c865b3618d6955275f
>The software is Byzantine. The standard keyserver software is called SKS, for "Synchronizing Key Server". A bright fellow named Yaron Minsky devised a brilliant algorithm that could do reconciliations very quickly. It became the keystone of his Ph.D thesis, and he wrote SKS originally as a proof of concept of his idea. It's written in an unusual programming language called OCaml, and in a fairly idiosyncratic dialect of it at that. This is of course no problem for a proof of concept meant to support a Ph.D thesis, but for software that's deployed in the field it makes maintenance quite difficult. Not only do we need to be bright enough to understand an algorithm that's literally someone's Ph.D thesis, but we need expertise in obscure programming languages and strange programming customs.
>The software is unmaintained. Due to the above, there is literally no one in the keyserver community who feels qualified to do a serious overhaul on the codebase.

how the fuck is ocaml obscure?

it's not ATS, but it's also not C, and what's important is that it's obscure within the small community of GPG people.
which is their fault. They've been relying on an OCaml program for 15 years and nobody thought to learn OCaml?

>Putting the blame in that the old SKS is written in OCaml while writing the new one in Rust seems somewhat counterintuitive for the long-term sustainability.
*spit take*

Is fp a trap to waste time?

>You don't need mathematics to program
t. Jow Forums
>Argue over optimization and true randomness and algorithms, while criticizing working but mathematically wrong solutions
So which one is true?
Thinking logically doesn't mean knowing mathematical properties, matrixes or algebra. Full stack web developers half of the time have art school background, but Jow Forums knows formulas even for fizzbuzz. I'm confused.

Attached: 1541030409866.jpg (600x787, 84K)

No, that's just Haskell.

what's the point in anything user?

still trying to figure that out

What percentage of the people posting in these threads actually write software?

Attached: 1555722754371.jpg (342x279, 48K)

I do and I can tell you at least two thirds look like they don't and 90% of the other third just started within a month ago.

types are for autists

you can make a head function that can never fail at runtime

me

you'd almost think Jow Forums is a pack of retards

styles of error handling
1. panic
2. set an 'error' global
3. return an out-of-bound value
4. set a mutable 'error' parameter
5. invoke an 'error' functional parameter rather than the 'then' functional parameter
6. fail (in a logical language)
7. throw an exception
8. return a default value
9. return an optional type
10. return an additional 'error' value
11. statically guarantee that an error isn't possible
does your language take error handling... to eleven?
for the retard, retardation is not shameful. The retard did nothing wrong--he was merely born.
what *is* shameful is having all the genes for intelligence, but choosing all your life to impair your intellect until you are functionally retarded.
example: letting social media and phones replace your ability to evaluate arguments with a cheap knockoff: an ability to evaluate sources.
>Alice says that Python is horribly designed, but Bob says that it's the most popular language. Bob is a lead programmer at Facebook. Therefore: Python is actually very well designed.
That you can't come to excellent conclusions like this is why /dpt/ frustrates you.

Making an os or compiler is a sure sign of a competent programmer. Jow Forums only has like one of each.

>That you can't come to excellent conclusions like this is why /dpt/ frustrates you.
Not him but that's actually why /dpt/ frustrates me. If I want to seriously discuss real programming I have to go a liberal shithole like reddit.

go back

wrong buddy, i'm one of the retards

define software

>I care about what you're working on, tell me instead.
Decoding DEFLATE encoding with multiple blocks. I am getting closer, but there is something still off.

Attached: scrot.png (1918x1079, 251K)

deflate my anus

true

5 and 8 are isomorphic

exceptions are the only sane option

the default value is usually a valid return in itself. It'd be a case of #3 otherwise.
3. getchar as written, returning an int so that a non-char value can be used for errors
8. a getchar_default that returns a given char on error. so getchar_default('c') returns 'c' either on error ... or when it just read 'c'.
why do you hate performance?

github.com/marchgithub/chan-image

Can anyone suggest tips to make my Haskell code cleaner? This is just a small image-board scraper (Jow Forums only for now, ~50 SLOC). This part might have a more concise or clearer way to write it, but I'm not sure. This is operating in the Scraper monad provided by scalpel.

haskell

data Post = Post
{ id :: L8.ByteString
, content :: L8.ByteString
, imgURL :: Maybe (FileURL, FileName)
} deriving (Show)

{- ... -}

getFileURL =
Just ((,) ((L8.append "http:") attr "href" fileLink)
(spoilered nameTooLong notSpoilered))

-- alternatives below are defined depending on where to find the
-- filename
spoilered = do
filename

Attached: 42527768_p2.jpg (800x560, 293K)

>Hate on GO because lmaogo
>Actually start using it (or more like "using it")
>Create a full rest api with a suprisingly small amount of libraries
>Compilie it
>10 mb
>mfw
Okay, i can see it why some might use this language

Attached: 1548452498881.jpg (500x468, 33K)

Haha! I cannot wait to get micro-managed by scrum teams!

Write some functions, get some libraries, bing, bang, boom, you got a program.

>Get some libraries
mark of a shit programmer honestly, if you do this you end up with python programs where 3/4 of your code is from x import y