/dpt/ - Daily Programming Thread

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

Attached: unnamed.jpg (900x900, 85K)

Other urls found in this thread:

github.com/edwinb/Blodwen
youtube.com/watch?v=MyjDZhLTxk4
blog.petrzemek.net/2016/09/17/universal-vs-forwarding-references-in-cpp/
en.cppreference.com/w/cpp/header/type_traits
twitter.com/SFWRedditGifs

i want to nakadashi belle-chan

Guess I'll skip this one.

Can Rust ever be as fast as C++?

Attached: 1558097650622.jpg (720x720, 50K)

$100,000+ fucking dollars per month and she isn't even pretty, holy fucking shit.

can't blame her for capitalising on desperate retards. the men that pay these people should be shot

Lisp is the most powerful programming language.

I think she's very pretty, but overrated nonetheless.

Either way, that's free market capitalism for you.

>siphoning weirdo fag's money
Ahh... It feels good to be a ruralfag, that works remote and lives in a big hunting community; where parent's of babies here are in their early twenties.

Attached: Robo Das It Mane.jpg (544x821, 160K)

Yeah sounds like a good idea.>>

Quit your job
Make video games

Attached: maxresdefault.jpg (1280x720, 100K)

/3dpd/

Shit thread
fuck off

Attached: Screenshot_20190526_232527.png (713x372, 64K)

/thread
>sage

Attached: big_1490275708_image.jpg (1280x720, 64K)

>benchmark game
Isn't that the shitty site where you're not allowed to use non-standard lib code or some shit.

that's a fake pic though.
here she is with "minimal" makeup.

Attached: 1558197163107.jpg (1080x600, 95K)

That would defeat the point since you could just link to some hand written assembly linear algebra library or dispatch a GPGPU kernel regardless of language.

Here's some epileptic trash I made with processing.py

Attached: output_0047.png (800x800, 187K)

bump

>supporting the lifestyle of this """person"""
Neck yourself you sad fuck.

Attached: 1549382367241.jpg (789x960, 45K)

Her looks will fade, just let her enjoy it while she still can.
You really should be focusing your scorn on the huge fucking loser men who give her money.

There's a lot of people ITT who need to have sex.

Best way to learn algorithms and data structures while catching up on math?

Someone make another thread.
Nobody has posted anything related to computers in 20 posts.

>related to computers
absolutely disgusting.

How to fit a single rectangle among other rectangles?

I'm trying to write a simple rectangle packing program. I understand the theory behind the various packing algorithms I've read about, but there's one thing I don't understand. They all rely on being able to test whether a single rectangle -- the 'current' rectangle -- fits in any space among other rectangles placed previously. The parameters of that space depend on the algorithm, e.g. for the naive greedy method it's just any space at all but for another one I read about it's leftmost first and highest second. Regardless, how do I even find any such space? Is there a standard way of doing so?

If I knew how to implement finding space for a single rectangle, I could implement any of the packing algorithms I've read about, but I can't think of any way to solve that smaller problem short of just iterating over every position in the enclosure and testing one-by-one if the rectangle fits there with respect to the other placed rectangles. Which is obviously not an option unless it really is the only way.

Have sex.

>make compiler for C-like language for fun
>don’t like it for same reasons I don’t like C
>add nice features like maps and vectors and other constructs I regularly use in other languages
>realize I’m just recreating sepples with different syntax
Now what?

Attached: A5688CBB-979E-4F40-985F-6628156CE6F2.png (300x300, 109K)

use rust

Learn FP.

I don't know, but I can tell you how to reduce the problem even further. For each placed rectangle, add the current rectangle's width to the left and right sides and the current rectangle's height to the top and bottom sides. Then you just have to find a point in empty space.

Rust’s syntax is even worse than sepples.

Correction: half the current rectangle's dimensions, if the point is the current rectangle's center. The point could also be the top left, in which case you'd add the current rectangle's width (resp. height) to the placed rectangles' right (resp. bottom) sides. And so on.

I’m teaching myself Haskell. It’s a weird language but my favorite fp so far. But the only fp I have experience with is Lisp and some esoteric languages. I might learn ML too just because some experienced programmers say they like it.

you deserve it

Drop Haskell, drop ML, install Idris.

You mad, autist?

It's unfair to languages with larger std libs since one's without can write whatever hand tuned shit they want.

I appreciate the thought, but if I'm understanding you right, wouldn't this result in a pretty sparsely packed enclosure? Which, unfortunately, is what I want to avoid by implementing a packing algorithm in the first place.

I might not be understanding you right though.

Idris is even more of a meme than Haskell.

Idris's only flaw is that its libraries are barren &/ outdated. But that's only because people are too time-sunk with haskell to change that. And porting haskell to Idris is pretty trivial.

I don't think you're forced to use the standard library.

No, you only take that into account when placing a new rectangle. There will probably be a lot of overlap between the already placed rectangles when you expand them, but that's okay since that just means that they're too close together to fit the current rectangle in between them.

Fortran’s now slower than Ada and C?

Post more of this little cum catcher.

I wish idris would become independent of haskell
I wish there was a language that was comfy like ruby, typed like idris, with a CRAN-tier package repo

>I wish idris would become independent of haskell
Idris2 soon lad.
github.com/edwinb/Blodwen

Have sex

I want a non-verbose sepples with global inferred typing.
>quick to type
>runs fast
>big standard library
>optional type annotations with the benefits of static typing
This would be the perfect programming language.

D with betterC/@nogc

Okay, thanks, I think I get what you're saying. So if the rectangle we're trying to place is A, then for each rectangle B already placed, we temporarily consider B.w to be += A.w and B.h to be += A.h, and then we just have to find any single point P of free space, and P is then guaranteed to accommodate A when used as its center. I think I understand your reasoning now, and it's appreciated.

However, I still can't think of any way to choose P short of brute-force.

Ok, this wouldn't really work well with your suggestion now that I think about it, but maybe I could start out storing every single point of free space in the entire grid in a list, sorted in an order chosen based on what order I want to find free space in. Then, every time I place a rectangle, I could delete every point from that list that's no longer free after the placement. Out of the points that remain in the list, the first one to accommodate whatever rectangle I want to place next is guaranteed to be the optimal one. Still, not only does this not work well with your suggestion, it also still seems really wasteful.

Today I downloaded library and I compiled it without issues. Please clap.

>compiling other people's code = programming

Attached: qwe_downloadj.jpg (1200x800, 424K)

Just you wait user. This is just the first step in my procrastinated attempt to finally do another project. fetal steps baby, fetal steps.

Why do webshits and science/math people get languages with good syntax like JavaScript, Python, and Haskell while real programmers are stuck with Java and C’s various mutations?

Attached: C3F3AF52-F50D-4795-BB08-1E6E5E773727.jpg (240x240, 44K)

thats fake bro, dont get baited

Is there any way to specify an array with types besides characters in Python's struct unpack?

>good syntax like Javascript
>real programmers stuck with Java and C

Attached: 1547680177227.jpg (1200x1200, 381K)

Add a sane build system, fat pointers, and a better way of doing metaprogramming.
And post a link. I'm trying to write my first compiler and need help.

having fun with cmake

Attached: Screen Shot 2019-05-26 at 11.47.37 PM.png (2604x1642, 784K)

You have to be mentally ill to think their long winded syntax is better than JavaScript’s.

C's syntax isn't long-winded
Java's is though

Your idea would work but yes, it would be rather slow. Instead of starting with a list, you could start with an empty grid and mark cells whose centers are contained within placed and expanded rectangles. Then search through the grid for an empty cell in whatever order you want. For instance if you want to minimize the Manhattan distance to the top left corner then you can search in diagonal stripes starting from there.

There is almost certainly a better way to do this but there's no use in me Google searching for one when you could do it yourself.

I wouldn't call Javascript good syntax by any mile. Either way to answer your question it's because they don't need super performance and the libraries are there for their ecosystems already.

>C's syntax isn't long-winded
That’s the Stockholm syndrome speaking. Compared to JavaScript, Python, and Haskell it’s very long winded.

What do libraries and performance have to do with syntax?

Compared to Python and Haskell maybe, but not JavaScript.

It doesn't is the point, although you could argue that python caught on not only for the libraries but because of how easy it is to train a physicist or mathematician with to do their proofs/simulations.

The reality is they also have to deal with Fortan and C/C++ -> OpenCL when working on supercomputers.

How secure is Ada compared to C?

>tfw I'm a DOD glownigger and have to use Ada, Fortran and C.

about 3 more security units

You can still right vulnerabilities if that's what you're asking. Ada, like Rust, simply eliminates the dumbest ones that Cniles fall for when they are not experiences.

If you're doing anything serious with Ada you're paying for certifications and other toolsets to automatically scan for known vulnerabilities.

youtube.com/watch?v=MyjDZhLTxk4

Attached: 1548469288118.jpg (1003x626, 405K)

By grid cell centers I mean the dual grid (whose cells correspond to cell corners in the original grid).

Ouch, do you ever reach a point where you’d rather write something in Assembly?

Lmao, so if you’re already experienced in low level stuff might as well stick with C, Assembly, and homemade monsters?

What does the signature of std::move mean?
template< class T >
constexpr typename std::remove_reference::type&& move( T&& t ) noexcept;

What is a remove reference? And why is t passed by && (which is an rvalue reference?)
I thought the whole point was to convert a normal reference to an rvalue reference?

I would have thought it would be like this:
constexpr T&& move(T& t) noexcept;

Don't get me wrong there's other benefits to Ada since it simplifies things without taking away all your power (see Access types). Unless you're after a specific feature of Ada or need it for certifications, which your employer would do for you, it's probably overkill. If you're coming from C you'll probably also think the syntax is super verbose so unless you really like the feature set or how it does something probably stick with C.

Why does a language need a borrow checker if making everything except primitives pass by reference and no pointers solves everything?

std::remove_reference is a metafunction that removes references
i.e. int&&, int&, int all become int
then they add the additinal &&

I don’t like C but I don’t like most of the alternatives either. I hope one day I come up with the mythical perfect systems language.

Ok I guess I understand the return type then, why is it passed by && thought?
Intuitivelly this looks to me like you pass an rvalue reference and get an rvalue reference. But that obviously makes no sense, so I must misunderstand it.

For example,
std::remove_reference::type = T
std::remove_reference::type = T
std::remove_reference::type = T
As for why it takes a T&&, see:
blog.petrzemek.net/2016/09/17/universal-vs-forwarding-references-in-cpp/

Because then you need a garbage collector.

It's passed by && because the parameter isn't an rvalue reference, it's a universal reference, in a dependent context && means either an lvalue reference or an rvalue reference, and the compiler deduces it.
Means you don't have to write as many templates.

it doesn't error when you pass it
basically yes

ignore those last two parts that was a mistake

jesus christ I didn't realize processing.py is running on python 2.7 where divisions are truncated to ints by default and it was fucking me over all day god damnit

How am I supposed to use functional style if I have an algorithm that's based on stepping through an input array and breaking it into a hierarchical structure based on regions of the input array (like separating a text document into words, lines, paragraphs) and I want to separate it into functions that correspond to those hierarchical levels, but it needs to remember details about stuff that happened earlier in the array and also sometimes look forward in the array to determine how the current array element/chunk should be processed?

Thx, I get it now.

>What is a remove reference?
welcome to sepples metaprogramming
en.cppreference.com/w/cpp/header/type_traits
get out while you still can

You find or make an algorithm that isn't a piece of shit.

>an algorithm that's based on stepping through an input array and breaking it into a hierarchical structure based on regions of the input array
Otherwise known as parsing.
> but it needs to remember details about stuff that happened earlier in the array
Otherwise known as context-sensitive parsing.
>and also sometimes look forward in the array to determine how the current array element/chunk should be processed?
Otherwise known as lookahead parsing.

Use monadic parser combinators.

The metaprogramming stuff is a bit weird. I have been using C++ for quite some time now but some of the features since c++11 are a bit weird.
I am probably stuck with the language for now though, so I will try to learn the stuff, as weird as it might be.

>Because then you need a garbage collector.
No you don’t. You just deallocate the object once it’s out of scope, like sepples without pointers.

trying to print a an array with a list of initialized numbers. Trying for it to print a random number in the array. etc print 14 or 21 or 28. thx

Random random = new Random();

int rnd;

int[] luckyNumArray = {7, 14, 21, 28, 35, 49, 56, 63, 70, 77};

rnd = random.nextInt(luckyNumArray.length);

System.out.print(rnd);

Thx in advance

wow, this is the power of communism

What sort of github projects are meaningful? I can't think of anything useful I am qualified to do.

it's easier once you start thinking of it as a completely different and more verbose programming language
practical C++ metaprogramming is a pretty good intro