/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Previous thread:

Attached: Alleluia,_Alleluia!.jpg (690x1036, 710K)

Other urls found in this thread:

arxiv.org/abs/0904.3036
en.wikipedia.org/wiki/Indeterminacy_in_concurrent_computation
dangermouse.net/esoteric/piet.html
docs.racket-lang.org/ts-guide/types.html#(part._.Polymorphic_.Functions)
docs.julialang.org/en/stable/manual/methods/#Methods-1
en.wikipedia.org/wiki/Simula
gigamonkeys.com/book/object-reorientation-generic-functions.html
godbolt.org/g/YZW2Ms
twitter.com/SFWRedditGifs

How important is ABI stability for a library?

please use a programming (anime) related image next time.

If it's meant to be a shared library that you can update without updating things that depend on it, it's necessary.

(print "hallo werld")
(+ 2 2)

(defun depression (world)
(let ((go (subseq world 0 1)))
(if(or
(string= go "a") (string= go "e") (string= go "i") (string= go "o") (string= go "u"))
(concatenate 'string go "way")
(concatenate 'string (subseq world 1) (subseq world 0 1) "ay"))))

Attached: 2012_11_02_vengeanceart.jpg (533x250, 135K)

Thank you for using an Easter image.

arxiv.org/abs/0904.3036
en.wikipedia.org/wiki/Indeterminacy_in_concurrent_computation

Depends on language.

Most languages have build chains to resolve this shit.

Post a screenshot of your code, in this fine day

Attached: ss.png (3092x1756, 432K)

>makes me believe learning something esoteric will improve my worth to the world in someway or make my more special.
If you want to learn something esoteric, don't chicken out. Learn an actual esolang.
I personally recommend Piet, as Piet programs can genuinely be beautiful works of art.
dangermouse.net/esoteric/piet.html

If just learning an esolang isn't enough for you, then you can just go a step further and create one. Esolangs are actually much easier to create than normal languages, as you don't need anything other than the bare minimum. Like, remember how I mentioned Intfrick earlier? The specification for it is 361 words long, and one of those words is an example program included to "help" people.

Attached: pietpiet.gif (168x168, 19K)

So i can't even learn SML?

I want something practical because I lack the ability to do anything.

True supermen are Julians. They accept multiple dispatch and generic programming as their lord and saviour.

Attached: Julialogo.png (320x216, 11K)

Attached: 1510802090447.png (577x231, 12K)

last time i had a look at julia, it was being designed by plt illiterates.

still is. they use words and concepts that mean entirely different things. worst kind of pseudo-intellectuals

Attached: signal-2018-03-10-074617.jpg (1280x720, 68K)

Name a single dynamic language with a better type system.

types could have prevented this.

>> MIT CS PhD's are computer illiterates.

>I want something practical
Then learn a useful language instead of something esoteric. C++, Java, Python, something that you'll actually get paid to use.
[spoiler]There's also the secret hidden option of learning COBOL. There's a lot of COBOL code out there that needs to be maintained, updated, and so on. Since there's like, three people who know COBOL and haven't died of old age yet, it's a very viable career. The only downside is you have to learn COBOL.[/spoiler]

>having a Ph.D in CS guarantees you are knowledgeable in plt
kys brainlet

typed racket

thank you for using an Easter image

Has no extensible ad-hoc polymorphism.

There are libraries that work only on specific systems and then there are good libraries that work everywhere.
Apples and windows ecosystem are bad in that they tend to make libraries that only work in their system.

something duck something snek.

fuckkkk that was dumb.
here you go
(defun fib (n)
(loop for i from 0 to n
for j = '(0 1) then (list (cadr j) (+ (car j) (cadr j))) do
(parse-integer (format nil "~:[~:[1~;~a~]~;1~]~@*" (= 0 i) (= 1 i) (+ (car j) (cadr j))))
finally (return (cadr j))))

No generics.

docs.racket-lang.org/ts-guide/types.html#(part._.Polymorphic_.Functions)

brainlet here.
Why would you need generics with duck typing.

>> Implemented using a case statement in the same module.
>> Can't extend the function in the same module.

If-based polymorphism is not polymorphism.

*can't extend it from a different module.

docs.julialang.org/en/stable/manual/methods/#Methods-1

Attached: wow anon.jpg (884x574, 78K)

This is fine.

>m-m-muh t-type safety
Threadly reminder that every expression in JavaScript has the static type "Any", so runtime type errors are impossible. inb4 tags are types.

Type safety, control over memory layout, specializing a function for arrays of a specific type (i.e. using radix sort instead of introsort on AbstractArray{T} where T

Random question. Am I the only one who feels like Python made them a better programmer? I ask because before I learned Python, I used to be one of those assholes who would occasionally put all their code on one line, and in general my formatting was all over the place. I'm talking
codeline;
{
codeline; codeline; {codeline; codeline;}
codeline;}

kinda shit. Python, because it was whitespace dependent, wouldn't let me get away with that shit, and as a result it became enough of a habit that now my non-python code ends up formatted similarly, even though in most other languages the whitespace doesn't matter.

Attached: python.png (200x200, 8K)

a method is part of the interface of an object. a method has access to the object's attributes and is bound to that object. a method abstracts its implementation.

f(Object x) :=
x.foo() // you don't know what's behind foo. the implementation is unknown.


Method foo = x.foo

foo() // call the method bound to the object x

jeez what an unreadable mess

This is exactly what they are called in Common Lisp and Dylan?

>a method is Java POO

just idiomatic lisp guys, what's the big deal

no method is from Simula, the language that has introduced concepts such as objects, classes, methods, ... only a plt illiterate would confuse procedure overloading with methods.

t. premature optimization cuck

en.wikipedia.org/wiki/Simula

Simula has been the inspiration behind both smalltalk and c++

What the fuck is this garbage code

Why is it unreadable

if you need to ask, then you're part of the problem

Simula called them virtual procedures. Smalltalk coined "method" as a particular METHOD of responding to a message (resp. implementing a function) based on dispatch.

Pleasant user I want to prove

[spoiler]i lost my motivation and confidence to keep coding anons[/spoiler]

>> Can't into use proper algorithms cuck.
Yes, I'm sure you want to use an exponential time algorithm on that graph, rather than automaticlaly select a linear time algorithm because it's planar.

>C++ is a multi-paradigmed language
so which is the most commonly used?

let quick_sort arr =
let swap i j = (* swap two elements by their indices *)
let tmp = arr.(i) in
arr.(i) i then
let midpt = partition i j in
sort i (midpt - 1);
sort (midpt + 1) j
in
sort 0 (Array.length arr - 1);
arr

take a break m8
burnout's no joke

Pleasant user I wish to improve

>methods are muh POO
>muh irrelevant dead shitlang owns the label
This is what retarded Java monkeys actually believe after stealing the label for their entire cult ideology from Alan Key and subverting it.

>muh exponential algorithm on N

Alan Kay*

mlcucks will defend this

Ancel Keys*
fat is bad for you, mkay?

(defun depression (world) (let ((go (subseq world 0 1)))(if(or(string= go "a") (string= go "e") (string= go "i")(string= go "o")(string= go "u")(concatenate 'string go "way"(concatenate 'string (subseq world 1)(subseq world 0 1) "ay"))))

Procedural, with elements of OOP and functional.

kek, stumbled on one of the first programs I wrote.
I feel disgusted by my own.

Attached: 1503960717182.png (584x571, 32K)

Algorithm selection is a thing of beauty.

Attached: backslash.png (593x941, 30K)

Doesn't look that bad. Why the fuck is "key" a string, though?

I'm glad your code has gotten cleaner. Ugly code is a plague on our industry. Love it or hate it, Python's syntax does almost always lead to code that's at least somewhat readable, which I appreciate.
For me it wasn't Python that got me writing clean code, it was Uncle Bob's Clean Code. This book should be required reading for all progammers.

>Uncle Bob
>required reading

Attached: wtf-am-i-reading.png (404x404, 67K)

I have the opposite opinion. Significant whitespace make automatic formatting difficult. Languages should just bundle an automatic formatter and linter with their compiler, that prevents you from compiling a file without autoformatting.

bandwagoners gon bandwagon

This is the client of a "keyboard over internet" with an arduino on the receiving end (connected to computer that should receive the keyboard inputs).
Since I wanted the client to be scriptable, I used strings instead of real inputs in an interactive-mode. So you could enter the read-eval-loop mode or pass in the keys through the arguments.

no.

Apart from the slightly annoying overuse of nested syntax instead of using the scope of the first let block, what's wrong with it?

I'm not saying that Python's syntax is the best solution or that it results in the cleanest possible code. What I'm saying is that practices that Python enforces, most of the time, result in code that at least at first sight appears organized and neat.
Things like golang's go fmt go a step further. With them there's no need to waste time on setting out coding guidelines as there is a single style that everyone has to follow, and most sensible editors will help you out with this by running go fmt every time you save your code or linting in real time.

>Things like golang's go fmt go a step further
cue^Wque dozens of complaints re unused imports

I'd rather work on a codebase written by crazy perlmonks over FOI anyday, everyday.

>m-m-muh bandwagons
Go read the articles on his blog about type systems, test driven autism, women in the industry, or anything else, really. I just don't see myself reading an entire book by such a turbo autist. Too many "required reading" books and too little time to give Uncle Bob the benefit of the doubt.

that's what I mean
the guy's a brand, and his main expertise is developing said brand
there's been plenty of very reasonable criticism against his sometimes stubborn views

I suddenly realized that I like dumb languages.
I spent years trying to comprehend all the complex things that you can have in a programming language. I am able to explain my junior colleagues everything about monoids in category of endofunctors(or strangle them with a barbed wire).
But the most pleasant experience I had was in Erlang. In the language that can offer you only pattern matching and message passing. In one of the least flexible and smart languages.

Why did I spend years on irrelevant things instead of being productive and happy?

Attached: tumblr_ow9f48gNcA1wwga3uo2_500.gif (500x284, 696K)

Legit question, I know that the elses before the ifs do nothing in this situation, but does it still have an impact on execution?

>Why did I spend years on irrelevant things instead of being productive and happy?
ultimate fate of dpt-posters right here

you know I can't help myself

Attached: Screen Shot 2018-04-01 at 2.09.55 PM.png (2880x1702, 898K)

Hypothetical product idea: a USB device that you attach to your computer. Whenever you name a variable something like "x" or "y" a boxing glove pops out of the device and punches you in the gut.
If you name a variable something along those lines while also having a variable in the same scope with the same name whose existence you have forgotten about, it punches you twice.

So what's the problem with that code? If it was something other than C, you could've used a hash map for it, but if you're stuck with C, what you did is more or less reasonable. Guess you could've done this instead:
char *key_names[KEYS_MAX] = {NULL};
key_names[F1] = "F1";
key_names[F2] = "F2";
// etc.

for(int i = 0; i < KEYS_MAX; ++i) {
if(keys[i] && !strcmp(key, keys[i]))
return i;
}

// error

But it's not a huge improvement.

>how should I name my 2d point's coordinates
>guess it's gotta be eks and hwy

There's literally nothing wrong with naming a variable "x" or "y". Next thing you're going to sperg out about people using "i" for counters...

Attached: fioc.png (800x400, 101K)

swap(T* x, T* y) {
tmp := *x.
x* = *y
*y = tmp
}

Your terminology isn't universal.
gigamonkeys.com/book/object-reorientation-generic-functions.html

Simula predates CL by +20 years, Smalltalk by +12 years.

Use code blocks retard.

>> Not understanding what a format tool is.
>> Not wanting your editor to indent your code for you.
>> Having a man do a machine's job.
Whew lad.

See

Simula and C++ use the virtual function/procedure/member terminology. The only C++ users who use the word method are former Java pajeets.

Wtf is this, are you trying to make lisp people look bad?

Why should anybody care? Common Lisp has functions that are generic, so it calls them generic functions. Turning phrases into misnomer idioms is not constructive.

(defun depression (world) (let ((go (subseq world 0 1)))(if(or(string= go "a") (string= go "e") (string= go "i")(string= go "o")(string= go "u")(concatenate 'string go "way"(concatenate 'string (subseq world 1)(subseq world 0 1) "ay"))))

ayy

A very basic & very dumb compiler could have added an extra jump everywhere, but in real life ? nothing.
proof:
godbolt.org/g/YZW2Ms