/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Old thread:

Attached: iyuiw062b1s11.png (500x656, 159K)

First for gradual typing.

Threadly reminder:
You can't spell trust without Rust.
Lisp IS NOT the most powerful language.
Thinking a girl(male) is cute and willing to suck her dick isn't gay.

...

The most powerful language is actually C++ because you can embed Lisps in C++ template metaprograms.

>you can embed Lisps in C++ template metaprograms.
No, you can't, but you can actually embed C++ in Common Lisp.

>* and &
Sometimes you can't use either and have to replace them with ref. I don't know why but it was the only way to make the compiler shut up in some match statements.

Works on my machine. Post more code.

fag

Forth is the most powerful programming language.

Does Forth have metaprogramming?

Does Forth even support dependent types?

str8

you're all fucking idiots

we're just funposting

Sorry, I'm retarded.

Found the JavaScripter.

you couldn't be farther from the truth

Post a screenshot of your code you fucking idiots.

what are you afraid of?

Attached: scrot.png (1889x1135, 455K)

Violating NDA, you would know if you had a job.

>what are you afraid off?
>selectively censors text

Attached: 1499534692545.jpg (492x492, 41K)

>implying this is not the same poster

>DateTime::now().year()
>Perl5
>$$
>$$
>$$
Sucks to be you.

>tfw making $110K + bonus to maintain this shit

>1 second apart
He's fast!

>Does Forth have metaprogramming?
Yeah, that's the entire point of it.

You can reprogram both the parser and compiler in Forth, so yes, the most powerful kind of meta programming.

Cool. What's it like?

Yeah, but do the humiliation and slow mental retardation really worth it?

Do NOT learn Rust before you learn C. I'm talking from experience. Rust has twisted me into a mindset that pretty much prevents me from understanding C.

But why. C is brainlet-tier easy.

Easy to learn, hard to master :

I just don't understand any of it. In Rust, you pass a reference using &. If you want to pass a mutable reference, you use &mut. Yet in C, you've gotta use weird inconsistent combinations of *. Not to mention that there's not even strings.

>he doesn't call functions in his for-loop
void foo() {
puts("foo");
}

int main() {
int i;
for (i = 0; i < 10; i++,foo());

return 0;
}

let foo : &mut T is the same as T *foo. let foo : &T is the same as T const *foo. You don't need to use separate operators to get each, a T* automatically converts to a T const*.

I know a guy who first learnt C++ and now thinks push_back into a std::list is faster than push_back into std::vector because std::list "just needs to create an object, this must be cheap”, and std::vector "needs to reallocate".

>What's it like?
It's like cross-armed juggling.

>learn Rust
>prevented from understanding C.
So win-win

So say you pass one of those references to a function. How do you dereference to get the value? &foo?

>Rust has twisted me into a mindset that pretty much prevents me from understanding C.
Rust refugee here. Can conform that Rust cripples the mind and prevents one from learning any decent programming language. I'm forced to work as a transgender Walmart cashier thanks to Rust.

First for Python

Ye.
void foo(int *p)
{
*p += 1;
}

void bar()
{
int x;
foo(&x);
}
This is the same as Rust, except Rust implicitly inserts & or * as is necessary inside method calls depending on what the type of self is so you often don't need to write & or *.

> a transgender Walmart cashier
Is that the actual job description? Does the health plan cover HRT?

>his std::vector has infinite capacity
>his std::list doesn't use ropes

First for Haskell

>Is that the actual job description? Does the health plan cover HRT?
Yes. it's a San Francisco Walmart.

You can't spell std::transform without trans. And STD.

> > his std::list doesn't use ropes
Nobody's std::list uses ropes, it’s effectively mandates by the standard that it’s a naive doubly-linked list, you retard.

>mandated
Fix

: bar ." hello" ;
: (comp-bar) [ ' bar ] literal postpone literal postpone compile, ; immediate
: comp-bar (comp-bar) ; immediate
: foo comp-bar ;


Colon starts a definition of a word (function) and stats compiling
[ switches to interpreter mode while compiling
] switches to compiler mode
' X essentially returns address of X
immediate marks the last word to be executed at compile time.
postpone essentially "delays" whatever the word was gonna do - postponing an immediate word makes it act like a non immediate word, i.e a compiler will emit "call X" instead of executing X.

Thus:

Executing bar prints "hello"
Executing (comp-bar) emits code which compiles a call to bar at compile time
Executing comp-bar runs (comp-bar) at compile time and thus emits the code for compiling bar, i.e becomes a compiling word.
Executing foo prints "hello" (foo becomes a call to bar).

Becomes mind bending very fast when you postpone multiple levels.

>it uses the actual vendor-supplied standard library
>it thinks its C++ code is "performant"
>it calls itself a coder unironically

wat? If & dereferences then how is it passing a pointer to foo? Fuck this shit, Rust has crippled my mental capacity. REEEEEEEE

& references, * dereferences. It's the exact same as Rust.

>>it uses the actual vendor-supplied standard library
Well, we talked was about std::list, not third_party::list.

You are miserable in your attempts to troll.

>what we talked about was std::list
Fix again

>her std replacement doesn't use the std namespace
>she's expected to do search/replace all over her project

If we say that & means 'reference', then why doesn't foo have int &p as a parameter? So it reads 'foo takes a reference to an int'.

Congrats, (re)defining anything in namespace std is undefined behaviour.

namespace MyNiggerliciousLibrary
{
struct list;
}

using namespace MyNiggerliciousLibrary;

std::list list;
Should have specified ::std::list!

Perl is piss easy once you understand its dynamics

Declarations in C are read as they are used.
A declaration int *ptr means that *ptr is an int.

>(re)defining anything in namespace std is undefined behaviour.
Using C++ is undefined behavior. What's your point?

*namespace MyNiggerliciousLibrary::std

> Using C++ is undefined behavior
No, by any of the C++ standards it is not.

H-hey, user, wanna hack llvm with me?

Attached: Dq4aja0V4AAONdQ.jpg large.jpg (960x1278, 186K)

It doesn't even look alive.

Okay, show me any library that does this (let alone having std::list with semantics other that the standard specifies).

My personal library which is closed source.

>denies your pull request
wyd

Rude

Attached: fiora.jpg (833x859, 264K)

So, nothing, as expected.

By the way. it’s not actually about the existence of such libraries; it’s about poor insight about how it actually works in the low level that you are guaranteed to have if you start with C++; that’s what I wanted to illustrate.

In GoD, we tRust

i seriously hope you dont do this...

No argument there. Nobody who knows anything about C++ pretends that the standard library containers are optimal. Many of those containers are very clearly not fit for purpose.

It was just shitposting.

Nice one.
Go is braindead and D is dead tho.

When Bjarne has literally given an extremely famous talk called "Why you should avoid linked lists", you can't really blame C++ for this. In my experience, linked list boosters are mostly relics who grew up with slower processors and not as slower memory and don't realize that an unpredicted main memory access is a 500-1000 cycle CPU stall nowadays.

That's what unrolled linked lists are for.

If you're actually concerned about performance you'll be using custom optimized data structures and not just prebaked, universally suboptimal junk.

>When Bjarne has literally given an extremely famous talk called "Why you should avoid linked lists", you can't really blame C++ for this

But you can. Best practices should be communicated through the language, not through famous talks.

And, by the way, you can not outperform an std::vector with "ropes", without resorting to realloc (which wouldn’t work for objects with non-trivial assignment operators) or preallocating more than std::vector does.

Which language is it that prevents you from using linked lists again?

Sure
>what are you afraid of?
unhandled exceptions

Attached: Screenshot from 2018-11-08 01-39-47.png (3840x2160, 603K)

>his language doesn't check exceptions

>t. NPC

Yes it does, just add a nothrow.
But checking all the exceptions is very tiresome.
Thank you for recognizing me.

Checking all the exceptions is what leads to robust code. If you're concerned about what exceptions are being thrown, you check them.

>unrolled linked lists
Don't use these either obviously. Dividing your O(n) cache misses by some k is not how you fix this problem.

Rust doesn't have this problem.

What are panics?

>ok now you handle Result instead
Can you even create a new error type?

inline linked lists where the link to the next object is part of the actual content is the most efficient way to do linked lists

what the hell do you call this then
struct list { struct list *next; int data; };

You don't care about panics, you won't recover from them anyway. Like, exceptions won't handle SIGKILL for you.
Of course, you can.

As in all things, it depends on your application. Asymptotic complexity is just one metric.

yeah that's what I'm talking about, except it's an actual data structure you're using instead of just an int

When would you ever not do that?

most people use generic data structures that encapsulate the object instead of being a part of it, languages don't really have great support for inline components

>about to start a programming interview on interviewzen
>bit nervous
hope it goes well

Attached: 1528899926175.jpg (1150x1080, 76K)

Should I learn Forth or APL?

Attached: 1487268694091.png (736x598, 564K)

Rust

IDK why you'd even bother writing data structures in a lang without value types. Everything fast should be FFId from C.