/dpt/ - Daily Programming Thread

Old thread: What are you working on, Sup Forums?

Other urls found in this thread:

theregister.co.uk/2016/03/23/npm_left_pad_chaos/
haneycodes.net/npm-left-pad-have-we-forgotten-how-to-program/
youtube.com/watch?v=i6Fr65PFqfk
lgbtq.technology
cs.cmu.edu/~adamchik/15-121/lectures/Binary Heaps/heaps.html
twitter.com/NSFWRedditVideo

How difficult would it be to write a script that reads a txt file full of lines formatted such as artist:song, search for a youtube video of that song, send the link to a youtube-mp3 tool, and then download the mp3 and place into a directory?

what's wrong with just nesting my input class inside of my engine class

Better question: why is either a class?

a class is just a grouping of data and behavior, nothing wrong with that

>how do you come up with things to make when you can't really make anything interesting?
The only interesting things to make are things you don't know how to make. Don't try to make something with your current knowledge, make something beyond your knowledge. You have to learn as you go, because you won't know what you will need to learn until you need it. Start with an objective, then figure out what has to be done.

Interested in learning a new toylang.
Gimme your best up and coming langs that aren't nim, /dpt/.

Toy language?
Haskell.

Looking for new and obscurer langs.
Already know a functional.

Eclipse is eating my RAM's ass, I need a lightweight ide. Something with syntax highlighting and a debugger at the bare minimum.

vim + gdb + screen

VS Code

Eclipse is shitty, but you can modify the settings. Disable plugins, etc...
IntelliJ IDEA might be better for performance, I dont' really know.
Sublime is pretty lightweight. If you feel up for a challenge, you can get a vim or emacs set up going.

notepad++

a pull request will always merged with the last commit message right?

even if its "fixed typo"?

Forth
>not new enough
Invent your own dialect. The standard one has a lot of kludges.

Learning about the Curry Howard correspondence between classical logic and functional programming with continuations.

IntelliJ is just as bad and I'm not a fan of viscose for java, guess I'm using vim

not very difficult, YouTube api requires a token and a google account, which is stupid and makes it unnecessary difficult to use

Don't fell like working, but thinking about work. Is this procrastinating or just wisdom in training?

>with continuations
is this
>functional programming with continuations
Why does there need to be continuations? Common Lisp and Haskell are still turing complete. Or is it
>learning with continuations
How?

void conv(uint8_t indx) {
if(indx)
conv(indx/2);
if(indx != 1) {
indx % 2 ? dash() : dot();
}
}

void dash() {
strcat(morse_msg, "-");
}

void dot() {
strcat(morse_msg, ".");
}


I made a morse code circuit with an atmega

Fetch at that point, so you can review before merging.

But yeah, pull is basically fetch and merge. Not anything anybody maintaining should do.

nah, you can change the message on the merge commit senpai

>Why does there need to be continuations?
As a formal reasoning system, lambda calculus alone corresponds to natural deduction and intuitionistic logic, where you cannot e.g. prove the law of excluded middle or do a proof by contradiction. Lambda calculus with continuations (as well as process calculus) corresponds to classical logic, which allows such proofs and proof techniques. This means better expressive power and the potential for a smarter compiler when applied to programming. Linear logic is also classical, not intuitionistic, and I'm working on programming language theory with regard to well behaved mutation and I/O, which heavily involves linear logic.

That seems pretty bad, even from a microcontroller standpoint.

what seems bad?

>Linear logic is also classical, not intuitionistic
I take that back. That's a gross and incorrect oversimplification. Linear logic lends itself much better to a sequent calculus presentation (like lambda calculus with continuations) than a natural deduction presentation (like lambda calculus).

theregister.co.uk/2016/03/23/npm_left_pad_chaos/

Found out about this a year after it happened.


...how was this a dependency?!?

module.exports = leftpad;

function leftpad (str, len, ch) {
str = String(str);

var i = -1;

if (!ch && ch !== 0) ch = ' ';

len = len - str.length;

while (++i < len) {
str = ch + str;
}

return str;
}


This code is utterly terrible in every way from style to readability to number of lines for a simple task to performance. It's going to cause so many unnecessary heap allocations.

Pull requests should never be done in "master", then pushed to everybody.

Make at least a testing branch.

And yet no one cares.
no one wants to rewrite a proper JS replacement.

division by two instead of bit shift by 1

While the recursion is obviously bounded to a max of 8 times, it still seems extremely pointless.

...specifically, how was this downloaded 2,486,696 times a month? Why the fuck does this single function qualify as an actual fully fledged library?

I used to ignore the people who said that webdev and the JS ecosystem was shit since I hadn't touched it much. Now I understand.

Any compiler would optimise those to be equivalent.

are you sure about that? I'm using avr-gcc

For starters, it seems like a bug to recurse without returning until indx is 0, calling this function for every intermidiate value.

Apart from that, a strcat is very likely useless for your scenario. The only hard part about making a morse code terminal is timing and you fucked it up before you started.

Millions of people did care since removing it from npm broke half of the JS ecosystem and caused builds to fail. Big libraries like Babel used it as a dependency.

>sublime
>debugger

caring about their situation != caring about the absolute state of JS enough to start a change.

haneycodes.net/npm-left-pad-have-we-forgotten-how-to-program/

>>There’s a package called isArray that has 880,000 downloads a day, and 18 million downloads in February of 2016. It has 72 dependent NPM packages. Here’s its entire 1 line of code:
1
return toString.call(arr) == '[object Array]';

>it seems like a bug to recurse without returning until indx is 0
I'm traversing a tree and using an array as a container tho.

>The only hard part about making a morse code terminal is timing and you fucked it up before you started.
It seems to work just fine...

>(pure) functions are not packages
What is eval? Fucking jslets.

>traversing a tree
>this tree called uint8_t
Great tree, seriously.

Also, you do realize that every value going into conv() that isn't 0 goes through that useless, stupid recursion, right?

>>
A blank jspm/npm-based app template now starts with 28,000+ files

Why do you have such a hatred for recursion? It's capped at 8 jumps, and any non-toy compiler should get tco that.

Tell me user, where did Lisp touch you?

That would be unfolding, not tail call optimization. Your recursive call is not a tail call.

Favorite web app framework? Torn between Django and laravel for this new project.

>Django
youtube.com/watch?v=i6Fr65PFqfk

His tail call is definitely a tail call. WTF?

>> The absolute state of Sup Forums

>Laurie "Don't let Nazis tweet" Voss
>Down with the patriarchy, up with the pastryarchy. Co-founder/COO of @npmjs, started lgbtq.technology . He/him.

This is exactly like what I always imagine a typical webdev to be lmao

It has an if statement after it.

It's not any recursion, it's by far useless recursion. You ask every input value to be divided by 2 and called again, then proceed with your crappy strcat shit.

As bad as that is, you can't control a buffer overflow with that function. Ignoring that stuff, your "morse code implementation" on a microcontroller should have never used strcat or a string.

Ignore output for a moment, and focus on input for morse code. Outputting dit-dah-dit is easy, you can do it the most retarded way possible, you almost just proved that.

Now try input, time that shit within reasonable boundaries. Now you're closer to microcontroller programming.

>this tree called uint8_t
kek

>you do realize that every value going into conv() that isn't 0
cs.cmu.edu/~adamchik/15-121/lectures/Binary Heaps/heaps.html

you need to calm down

No, your conv() is not even close to a binary heap.

Ah, looking at the code I expected it to be an early return.

Okay, that code is absolutely terrible, with the random mutation of globals and use of ternary to call void functions that are just used for global side effects.

the reason I'm using strcat is so that I can output the string of .s and -s over the usart. that way I can tell the message was converted correctly. please calm the fuck down bitch.

scroll down further...

Oh man this has great copypasta potential. Thanks user. Let me trigger you further:
;wait for NMI
((lambda (x) (x x)) (lambda (x) (x x)))

>scroll down further...
On this page or the 10 line link?

That's not a trigger at all and doesn't apply here.

i've been using sublime for a couple days now to write c++ and i just don't know why anyone would ever write c++ without intellisense. are people like that retarded? is it because they don't know that intellisense exists?

This is referentially transparent and perfectly fine.

>> Bottom type
>> Referentially transparent
Dynamically typedlets gonna typelet.

>using sepples & sublime
Are people retarded?
is it because they don't know better languages and TE's exist?

Y'all niggas know what a 6502 is?

>giving a shit about decidability

That feel when you suddenly realize that true in lisp is the top type and nil or false is the bottom type. Just like on the other side of the curry howard isomorphism.

This guy is completely right, this code is complete and utter garbage. Certainly not fit for a microcontroller, I wouldn't even accept that horrible inefficient code in a desktop application.

>6502
Let's say I didn't, how does that excuse software that would be retarded and slow even on an i386, or a core i7?

>nil or false is the bottom type
disgusting

The bottom type has no inhabitants. False has no proofs.

>False has no proofs
Lisp is disgusting

Do you think you should be able to prove falsity?

you're all bottom types

>Type theory niggers need to prove false
LMAO

That retard isn't a type theorist, clearly.

Of course, else the language's assumptions about "false" are ''''''''''''''''nil''''''''''''''''

What the fuck are you babbling?

I hate these people so much.

Your language isn't sound.

False is an axiom, retards. It's defined to be the opposite of true, and true is defined to be the opposite of false.

Pretty sure unsoundness is when you can prove false, not the other way around.

>these are the people i share /dpt/ with

False = ∀A.A
True = ∀A.A→A
id : True
id = ΛA.λx.x

why?

only applies to common lisp and is an autistic criticism.

...

Because it's shitty innefficient code.
Recursion where you don't need it, doing a reallocation for EVERY character. It's horrible.

In what world is a valid proof ever proof of unsound, unless you're purposely trying to prove in unsafe system?

You don't know what you are talking about...

Has anyone really been far as decided to use even go want to do look more like?

>i know absolutely nothing about the topic but just like shitposting.
Seek help for your (you) addiction.

I want you to explain how being able to prove a false statement is sound.

I know exactly what I'm talking about.
Why don't you come up with some actual arguments instead?

lol, okay when do you use recursion?

Why is that code shitty? It's pretty simple and starts here:

void conv(uint8_t indx) {
if (indx)
conv(indx/2);

If that's how you go through a "8-bit data structure", a loop might have worked better. It's not even in TCO position. Not only that but when you have an 8-bit "data structure"(which you haven't explained), it falls under bruteforce is faster on every architecture.

Data structures are for large data sets, when talking 1-bit values in an "8-bit tree", it's always faster to skip the whatever the fuck you're trying to do.

When I can't use a loop, which is very rare. So I very rarely use recursion.

top kek

>TCO
okay?
>when you have an 8-bit "data structure"(which you haven't explained)
I never said I had an 8-bit data structure though...

I posted the link earlier I used a binary tree represented as an array. Its really simple

Your "binary tree as an array" makes no sense though, especially when you consider your values are binary.

isn't that circular logic

It just means however you're using false, you use true the opposite way.