/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread:

Attached: ppu.gif (723x324, 76K)

Other urls found in this thread:

pastebin.com/k2Ayij1R
twitter.com/SFWRedditGifs

C is the greatest programming language

Attached: kissa 6.jpg (432x650, 68K)

+ + + +
+ +
+ + C + +
+ +
+ + + +

perl is the most powerful programming language

Anything C can do C++ can do better.
C++ can do anything better than C.

which variant of C though

it makes better garbage

cont.

well, what is it?

>no implicit casting to void *
C++ literally can't into the basics of comfort

Attached: lmaonade.gif (150x207, 14K)

C-you-later XD

nth for fuck openai
showing off that dota bot developed using reinforcement learning and then blueballing us by not releasing any info on it

Attached: 1513365558396.jpg (400x288, 26K)

English and Japanese

java

linear types will save systems programming

anime

>linear types will save systems programming
Explain your rationale.

no no, /dpg/, not the battlestation threads.

Anyone know how to load data from a binary tree to an ArrayList? My algorithm gets the first generation right, but then the next generation is out of order. Help a brainlet please
public static ArrayList loadOverToArrayList(BinaryNode root,
int startingIndex, ArrayList arrayList)
{
//Handle the special case of an empty root
if(root == null){
arrayList.add(startingIndex, null);
return arrayList;
}

//Base case: root data
arrayList.add(startingIndex, (E)root.getData());

//Recursive step
TreeFactory.loadOverToArrayList(root.getLeft(), 2*startingIndex+1, arrayList);
TreeFactory.loadOverToArrayList(root.getRight(), 2*startingIndex+2, arrayList);

return arrayList;
}

Implicit conversions a shit - but if you really want this cancer in your code, make your own weakly typed pointer.
struct anyptr
{
void *data;
anyptr(void *data): data{data} {}
template
operator T *() { return data; }
};

int x;
int *iptr = &x;
anyptr aptr = iptr;
double *dptr = aptr;

imagine Rust's BC but actually good.

With a binary tree
root
left
leftLeft
leftRight
right
rightLeft
rightRight

my algo returns an arraylist out of order:
root
left
right
null
leftLeft
rightLeft
rightRight
leftRight

I too watch Ricky and Morty.

Yes I really want to make code harder to read with this template stuff. Or, you know, I could just use a proper language like C instead.

What traversal are you trying to do? You code is doing preorder.

To be fair, you have to have a very high IQ to understand C. The undefined behaviour is extremely subtle, and without a solid grasp of the C standard most of the undefined behaviour related bugs will go over a typical programmer's head. There’s also C's simplistic outlook, which is deftly woven into the specification - the design philosophy draws heavily from Unix and BCPL, for instance. The C programmers understand this stuff; they have the intellectual capacity to truly appreciate the depths of the C programming language, to realise that they’re not just writing programs - that they directly communicate with the hardware. As a consequence people who dislike C truly ARE idiots - of course they wouldn’t appreciate, for instance, the humour in C’s existential catchphrase “SIGSEGV”, which itself is a cryptic reference to ridiculing programmers that do not know C. I’m smirking right now just imagining one of those addlepated simpletons scratching their heads in confusion as Dennis Ritchie’s genius unfolds itself on their computer screens. What fools.. how I pity them.

And yes, by the way, I do have a Dennis Ritchie tattoo. And no, you cannot see it. It's for the ladies' eyes only - and even then they have to demonstrate that their algorithms are implemented within 5 CPU cycles of my own (preferably higher) beforehand. Nothing personnel kid.

>all these years and still no good java orm

Attached: 1521765294443.gif (268x231, 1.16M)

Delimited continuations will save system programming

>What is Hibernate

>If I don't understand it, it's bad
C truly is for brainlets.

Pic related. By the way this is a homework assignment, so don't give too much away. Just need a nudge in the right direction because I've been stuck for a while

Attached: Screen Shot 2018-03-24 at 1.53.55 PM.png (1300x410, 95K)

Trying to learn tensorflow.

Turns out Google constantly depreciates older code, meaning it's a coinflip to see if tutorials actually work. I just want to learn it maaaan.

>so what do you do, bro?
>I'm a machine learning engineer
>really? that's so cool bro!
import tensorflow as tf

just learn the basics and then hop to keras

How can I iterate over a std::vector such that I can dereference the iterator and return the entire int* at any given index??

>keras

have you played with it?

Are you asking to transform an iterator of int* -> int* -> int* into one of (0, int*) -> (1, int*) -> (3, int*)?

What's up with software people putting "engineer" in their job title where "developer" or "programmer" belongs?

>thinkpad
check
>programming socks
check
>gcc installed
check
>K&R book
check

I'm ready to learn C !

That's just a title user.

Programming socks?

No, I'm quite literally asking how I can iterate over a vector of int*.

vec = { {0000}, {0001}, {0002}, etc, }

When I use a standard old std::vector::iterator object and I dereference the iterator at any index, ({0001 for example), it only returns the first number, 0, instead of the entire int*, 0001. Why?

because it sounds more prestigious.

Attached: 1491179331251.png (1005x330, 59K)

are all your pointers pointing to the same int?

I regret everything

Attached: 2018-03-24-183943_1920x2160_scrot.png (1920x2160, 984K)

I don't understand.
std::vector vec;
for (int *ptr : vec)
{
/* ... */
}
Is that not good enough?

they help you focus you fucking homo

Attached: 90138498123482.jpg (300x300, 13K)

Looks cool

Oops, I didn't see those on your list. I was asking to make sure. Good!

from the pic it looks like you've written you're own language and then made a game in it? Looks bretty good dude

>Women Socks
user.

Women (male)
It's type inference...

>inferring someone's type without asking them
rape culture

types are a social construct

I primarily use ansi C, but K&R is good too

Calling it a game at this point is kind of a stretch, but yes

Didn't expect to kek this early.

Attached: file.png (1200x1698, 3.63M)

Anything C++ gets right is borrowed from C. Anything C++ can do that C can't, it does so poorly that it's not worth using.

Gotcha, does your code need to handle incomplete trees? i.e. trees with a different shape from the image?

templates, constexpr are good features that are worth using and not present in C

There's a strange infestation of idiots who struggle with Rust's borrow checker because they don't understand it and the inherent limitations of Rust. For some reason they always project their own perception of its imaginary complexity onto people who understand it fully and see that it's too simplistic to be useful .

Attached: rust-dev.jpg (400x400, 19K)

>templates, constexpr are good features
Templates and constexpr are utter garbage. If you actually need them, use a language that has actual thought out and usable equivalents.

nigger you're speaking to people who complain about anything, speak english and cut the bullshit

So, something entirely other than C.

>So, something entirely other than C.
It's cute how your only defense is sperging out about the lack of equivalent features in a language invented 50 years ago. There are few reasons to use C these days, but there are still things where it's the right tool for them job. There's not a single thing out there for which C++ is the right tool.

The most baffling to me is people going to Rust from C or C++ and complaining about needing unsafe code for certain things. Those entire languages are unsafe.

>Templates and constexpr are utter garbage
why? string hashing in the static environment is great.

C++ is widely used in the industry, what makes you think that they would have chosen it had there been better choices suited for the task that C++ wouldn't be the right tool for?

>The most baffling to me is people going to Rust from C or C++ and complaining about needing unsafe code for certain things.
There's nothing baffling about it. They just fall for the meme and then discover that the only code Rust makes "safe" is fizzbuzz code, so they get disappointed and salty.

Yes, needs to handle full trees and imbalanced trees

Which languages do what templates and constexpr do in a better fashion while also conferring the advantages of C?

Because Rust hypes itself up to be the perfect solution. And then when you actually use it, you realize it's perfect™ with a million caveats.
unsafe being a prime example.

love the ever-so-spicy fizzbuzz mémé

COBOL is widely used in industry, what makes you think that they would have chosen it had there been better choices suited for the task that C++ wouldn't be the right tool for?

C is widely used in the industry, what makes you think that they would have chosen it had there been better choices suited for the task that C wouldn't be the right tool for? (This one, specifically, you should address to your C++-shilling buddies who insist that there's literally no reason to favor C over it)

Javascript is widely used in the industry, what makes you think that they would have chosen it had there been better choices suited for the task that Javascript wouldn't be the right tool for?

Etc. etc. ad infinitum. Even retards can usually see that popularity has nothing to do with quality, except when it comes to the abominable garbage they personally approve of.

what the fuck

Attached: file.png (181x162, 8K)

>Which languages do what templates and constexpr do in a better fashion
All of them. C++ has hands down the worst implementation of the broader themes behind these features.

Please read to the end of the line, user.

>Because Rust hypes itself up to be the perfect solution.
I don't think this is the official stance. The idea is not to forbid unsafe code, but to delimit it so that there's a clear division between the responsibilities of the compiler and the programmer.

I accept your concession. Maybe you shouldn't shill your pet language as a cure for cancer when all it offers are some bandages for surface cuts.

Grow up, boys.

>Please read to the end of the line, user.
The rest of your line is nonsense. Those features are completely orthogonal to the "advantages of C".

>Maybe you shouldn't shill your pet language as a cure for cancer when all it offers are some bandages for surface cuts.
Who are you quoting? Where was I shilling it, where was I even praising it? It's just the same idea as unsafePerformIO in Haskell - provide what guarantees you can but still allow the programmer to do whatever they want, but make it easy to audit escape hatches.

Another brilliant refutation by the resident Rust shill. Thank you for demonstrating why people don't even bother to engage with CoC soyfriends anymore, and just go straight to the insults.

Have you completely missed the point of my question or what? You said that there's not a single thing where C++ would be right tool for the job to which I replied that industry giants would like to disagree with you to which you're saying that there are other programming languages that are better suited for other tasks. I don't disagree with that - there are certainly many tasks where there are better languages than C++ for the job but there are also many applications where C++ is the right tool for the job and most of the industry leaders do agree with that. Please take your meds so you can follow a simple conversation next time.

No, I don't know what Rust is or what it does.

>It's just the same idea as unsafePerformIO in Haskell
The resident Rust shill also has this odd propensity to try to use Rust and Haskell in the same sentence whenever possible. I didn't know Steve Klabnik had a communications degree.

Seek help.

>Have you completely missed the point of my question or what?
You clearly didn't understand my response, because it completely derails your question, and the inherently and demonstrably fallacious line of thought behind it.

I don't see how exactly the utility of C is dampened by something as simple as, say, symbolic constants.

>because it completely derails your question
Exactly, which in turn makes your original post merely a shitpost at best if that was your plan all along.

>I don't see how exactly the utility of C is dampened by something as simple as, say, symbolic constants.
Did I say the utility of C is dampened by symbolic constants? I said the core ideas behind templates and constexpr are orthogonal to the basic design of C. They neither complement it, nor conflict with it.

Rate my Python:
pastebin.com/k2Ayij1R

>There's not a single thing out there for which C++ is the right tool.
then how come c++ has replaced c everywhere, even in embedded?

You're seriously retarded, so I'll spell it out for you: appeal to popularity is a logical fallacy. "But muh industry adopted X, so it must be suitable for the job" is easily refuted by observing how often the industry adopts garbage that is grossly unsuitable for the task, and how long it sticks.

But they do present advantages in the application domains where C is still used extensively. For example, constexpr is ideal for generating lookup tables at compiletime. The utility of this on an embedded device should be obvious.

So instead the usefulness of a language and how it's suited for a task should be based upon a random user's opinion instead? Tools are oftentimes adapted for a specific reason, you don't see carpenters hitting nails with a sponge.

Looks like a nice skeleton. Adding some stuff to it should be a fun project.

Are you arguing with yourself about something? I wonder what my posts say in your hallucinations, because you seem to think I'm arguing that being able to execute code at compile time and embed the results in the binary would make C worse.

No but nearly all carpenters lost at least one finger or part of a finger.
Because they all do the same fucking bullshit, despite being proven again and again by what they call "a bunch of intellectuals who never get work done" that they should work in a different way.
Some need to have at least 2 or 3 accidents before changing.

>So instead the usefulness of a language and how it's suited for a task should be based upon a random user's opinion instead?
In an ideal world, it would be based on an objective evaluation of a language's technical merits, but that's clearly not the case in reality.

>you don't see carpenters hitting nails with a sponge.
No, but you do see "the industry" adopting garbage like Javascript, PHP, Cobol, C++ and other horrors, and in every single one of these cases, the magnitude of the error is obvious to everyone except the retarded monkeys whose careers and self-esteem depend on perpetuating the use of hitting nails with rocks to do carpentry.