/dpt/ - Daily Programming Thread

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

>inb4 politics

Hitler did one thing wrong!

kill all animes

Post your programming environment!

can somebody create a non-anime thread
by non-anime i mean without fucking anime

VSCode 2bqh

I was wondering how would you go about subtracting generic types. For example, the function (let's call it "without") should be able to pass the following tests:
assert([12, 23, 23, 11, 5, 23].without(23) == [12, 11, 5]);
assert("ccxi".without('x') == "cci");
assert("abcderfiibcne".without("bc") == "aderfiine");
assert(["siwwo", "lkaiwmn", "diw"].without("iw") == ["swo", "lkamn" "d"]);
assert(['c', 'd', 'd'].without('d') == ['c']);
assert([234, 301, 322].without(12) == []);

look at the banner you stupid reddit transplant

In JavaScript this is easy
> Array.prototype.without = function(arg) {
... return this.filter(item => item !== arg);
... }
[Function]
> [1,2,3].without(2)
[ 1, 3 ]

How can you stand to use that shit, it's literally a web browser for editing text.

Typeclasses.

>subtracting generic types
How can you "subtract" a "generic(?)" type?

You seem to want to write two different functions

1) List -> x -> x
2) List -> List -> List

in the first, you are simply removing elements that match the value you give
in the second, you are deleting any subsequences that match the list you give

>it's literally a web browser for editing text.
But i can make it as minimal as Vim if i want. But the bonus is, everything just works without fucking around with my RC. And anything i need i can get right. Not to mention quick suggestions and multiple debuggers at hand.

Its really nice.

*Bjarne intesifies*

(defun without (element list)
(cond
((not list) nil)
((equal element (car list))
(without element (cdr list)))
(t (cons element (without element (cdr list))))))

(cont from ) wait crap this is wrong
fixed version:
(defun without (element list)
(cond
((not list) nil)
((equal element (car list))
(without element (cdr list)))
(t (cons (car list) (without element (cdr list))))))

>you just don't understand, I NEED 2GB OF MEMORY TO OPEN A TEXT FILE!!!

and for strings
> String.prototype.without = function(c) {
... return this.replace(new RegExp(c, 'g'), '');
... }
[Function]
> "abcderfiibcne".without("bc")
'aderfiine'


Instead of combining with the array function, to solve this test:
assert(["siwwo", "lkaiwmn", "diw"].without("iw") == ["swo", "lkamn" "d"]);

I would suggest doing:
let strings = ["siwwo", "lkaiwmn", "diw"];
strings.forEach((str, i) => strings[i] = str.without("iw"));

instead

And this test:
assert([234, 301, 322].without(12) == []);

just seems wrong

>inb4 Sup Forums eats one of my code tags or thinks this post is spam

Let's see your assert tests

Idiot, he told you to write 1 (ONE) function

With 3 tabs open im currently sitting at 17.0MB which is unironically lighter than vim.

you know chromium opens like 200 threads, right?

>>it's literally a web browser for editing text.
Aren't we all doing the same thing right now?

didn't write them but here's one
(assert (equal (without 2 `(1 2 3)) `(1 3)))

proof:

7 background processes equaling ~200MB
Granted i could kill the heavy ones but it really doesnt make a difference. It even has a VIM extension i could get if i wanted. All the bonus features it comes with more than make up for it.
No reason to use Vim anymore, imo.

gedit

D.

REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

Programming a Texas Instruments CC2541. It's a strange Bluetooth Low Energy chip with an 8051 on it. It was somewhat of a hassle to get the tooling set up to work with the chip.

They are pretty cheap and seem ok so far. Having to deal with these arcane proprietary C compilers is less fun.

I'm writing a posix shell script and I need my script to wait until a process has been disowned and fully opened before it continues.

How do I accomplish this?
if ! pgrep $PROG > /dev/null
then
$PROG &
while ! pidof -s $PROG > /dev/null
do
sleep 1
done
fi
This doesn't actually wait.

Threadly reminder that dlang-chan is not dead; she's going to have her GC tumor removed (eventually); and she's super duper cute and easy to prototype in! Say something nice about her, /dpt/!

I'm sorry; I didn't notice it.
C++ suffers from its long history and identity searching. What I mean by that is it's more of a federation of languages than just a single one. (Credit goes to Effective C++; which is a really good read.) This can be good and bad depending on how you look at it, but in my opinion the language and the community suffers for it. D was made with the purpose of re-doing C++ but with modern paradigms and designs in mind. And for the most part it accomplishes that. Sadly, the GC stood in its way for complete domination.
I don't know much about Rust other than some tidbits here and there. Thus, I want comment on that.

I can't believe I forgot the picture! This language is kawaii as fug.

F

Please choose a different character

>while ! pidof -s $PROG > /dev/null
Don't you need [ ] for that shit to work properly?

Does she have templates that can inherit from their parameters without spitting "typename" everywhere?

>inherit

>>inherit
>

Isn't it pretty much impossible to program without an Object Oriented style in mind?

please tell me you are joking

I'm genuinely curious.

You could say the same thing about a functional style. What makes a language functional or object-oriented isn't about which style it can be semantically reduced to -- for, in all cases, the answer to that is both of them -- but which style it presents as syntactically.

rofl

what do you think object oriented even means?
do you think anything with structs is OO?

>FP and POO are somehow mutually exclusive.
Bad post.

You just interpreted my post to mean exactly the opposite of what it means.

>what do you think object oriented even means?
It means what "object oriented" means in English.
>anything with structs is OO
No.
Explain please?

>defacing akari-chan with an emoji
Get the fuck out.

Metaprogramming using dlang-chan is superior compared to C++.

I don't even program in OO most of the time (even when using dlang-chan). Step it up, senpai.

>No reason to use Vim anymore, imo.
I've invested WAY too much time into my RC and learning all the keyboard commands. NO.

You bringing up FP when someone mentioned POO already makes it blatantly obvious.

So why is it hard to program without using OO?

>vimlets literally stockholmed

I'm just asking if it's possible or not.

why is inheritance so bad?
hard mode: you can't google it real quick
just wondering if the OOP haters can articulate themselves or if they have merely joined in on the circlejerk

That's simply incorrect. My post was intended to mean that FP and POO are one and the same and differ only in presentation, and that's that.

>eventually
Well until that eventually happens, I'm going to be flirting with Rust-chan, who never had a GC to begin with.

Javascript is a functional programming language

>OOP haters
Where did I claim to hate OOP? I'm simply stating the truth that it's fucking garbage and belongs on

Of course it's possible

OOP is better than functional programming.

Turing Machines
or
Lambda Calculus

Choose wisely

>FP and POO are one and the same
Which is comically wrong. You are claiming that the set of all FP and POO languages is the same set, yet I can show you at least one language which is in one, but not in the other.
This is as retarded as saying "Procedural programming is better than imperative programming". It doesn't make sense on any level since FP is a subset of POO.

lc

why though? why is OOP garbage? I want to hear YOUR personal opinions about it.

>Lambda Calculus
Which lambda calculus?

I hope it's in the near future at least. I mostly use C, so the moment they take the GC out of the stdlib, I'm going to jizz my pants.
Also didn't you say Rust's type system is most likely broken?

I pick quantum Turing machine

any of your choosing

It's impossible to create non-broken software with it. Which is why I love it.

>You are claiming that the set of all FP and POO languages is the same set,
No, I'm actually not. I'm claiming that FP and POO are ultimately the same style of programming, independently of the languages that use them as labels.

I don't know, but i figured out the problem.
I just needed to figure out when a program actually appears on the screen before trying to continue.

Now, how do I write a while loop that does nothing while a specific boolean is false?
Right now I have this
while ! wmctrl -lp | cut -d ' ' -f4 | grep "$(pidof $PROG)" > /dev/null
do
true
done

how do I into python Sup Forums?

>Any questions?
Why does she have tails?

Does it have to be Turing-complete? You implied this, but that wouldn't be "any of my choosing".

I implied no such thing

"style of programming" doesn't mean anything concrete. I don't really care what you think as long as you don't make retarded statements about the sets "POO" and "FP".
>labels
They aren't labels, they are sets.

She's a nine-tail fox but also a superquantumcomputer that can solve the halting problem

>the sets
>They aren't labels, they are sets
Lol what horseshit

>She's a nine-tail fox
But she looks human except for the tails.

You implied this by saying "Turing machines or Lambda calculus (not calculi)". The most well known lambda calculus is Turing-complete.
>superquantumcomputer that can solve the halting problem
You wouldn't need one for that. You just need a non-shit language.

You have no choice but to poll, unless you you can receive a message from your WM.

If you want to avoid turning your processor into a space heater you can replace true with a sleep. GNU sleep allows floats, so you can sleep 0.1 or something.

You were tricked into thinking that she looks human*

It makes a lot more sense than ill-defined buzzwords like "style of programming" and "labels".

Damnit

>You wouldn't need one for that. You just need a non-shit language.
No language that currently exists can solve the halting problem. Including assembly for any processor architecture.

Object oriented java in VS (that I paid for)

My language can trivially solve its own halting problem.

Behavior can be modeled with composition.
Data cannot.

That is, assuming you are referring to the OOP we come to know and hate in C++, C# et. al.

There's also this thing called the expression problem (all about thing.member). This isn't an issue when using free functions and opaque identifiers. Harder to debug, yes - but, you should be writing correct code to begin with.

>My language can trivially solve its own halting problem.
Not if your language is Turing complete. And if it isn't, it's a shit language anyway, so it doesn't help your argument.

>Not if your language is Turing complete.
Of course it isn't. Why the hell would it be?
>And if it isn't, it's a shit language anyway
You have to be a drooling pseudo-intellectual retard to believe this.

>currently

If what I heard from that professor's presentation was true, then yes, there is at least one fundamental flaw in the Rust type system. Although honestly, I don't really care if Rust's type system can't guarantee the safety of my programs. The language features are still nice, particularly for bare metal programs.

>mfw you share a thread, and indeed a whole PLANET AND ITS RESOURCES with people as fucking stupid as this

Did this post have a point? I'm not expecting a reply though, you're clearly delusional.

The point was to call you stupid, which is redundant now since you're even stupid enough to not realize it.

In what way am I "stupid"? I don't think your post had a point really.

>I don't think
Obviously

So I was right. Your post didn't really have a point and now you're just trying to save face since you realized you said something meaningless.