/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

instagram.com/p/5c1WXeESvD/
0xbeef.coffee/posts/post4.html
google.com/#q=php memory leak bug
github.com/erikd/libsndfile/blob/master/src/sndfile.c#L300
twitter.com/SFWRedditGifs

1 1 1 GO!!!

life
u?

fourth for lisp

fourth 4 forth

ch3.core=> (first (hash-map :a 1 :b 2))
[:b 2]
ch3.core=> (rest (hash-map :a 1 :b 2))
([:a 1])

nigga... this shit aint right

Trying to find a library for creating OPC DA servers that doesn't cost hundreds of dollars.

expecting any specific order from that datastructure is not right

hey ruby why don't you get a real job?

oh, makes sense

...

good luck!

Currently installilng VS2017 for c++.
So excited to try it out!

Well, what the fuck?

Why is WinAPI such a piece of shit?

I've decided I want to become a professor and do research. That is a real job, although it takes fucking ages to be qualified for that job. In the mean time, I've got a research assistantship.

what is there even to research?

Is there any way to implement custom handlers for 'implement interface' in Visual Studio 2017 or Resharper? Given the special 'Implement IDisposable' and 'Implement INotifyPropertyChanged' routines, it must exist somewhere, but is it exposed anywhere? I'd love to rig up some additional common patterns (IValidatableObject that automatically scaffolds out with all of the properties of the type for example).

Plenty of shit, mostly in cybersecurity and machine learning though.

Quantum Assembly

>Win
Found it.

That brings up a question I've often wondered... what SHOULD an assembly language for a quantum computer look like?

I need to make a method in scala that executes given code with probability. But it needs to return value type T and I have no idea how I do that.
def withProb[T](prob: Double)(choice1: => Any): withProbElse[T] = {
require(0.0 Any): T = {
if (1.0-prob/100 > rand.nextDouble()) {
choice2
}
else choice1
}
}
}

You have an error detection/correction algorithm that is capable of producing 512 valid, 10-bit codewords.
How many data bits are in each codeword produced by this algorithm?

log2(512) = 9, so would it be 9 data bits??

I'm learning c++ and people keep giving me examples where they use . and -> (seemingly) interchangeably.
What's the difference between them?

>I'm learning c++

. accesses a struct member
to access a struct member in a pointer to a struct, you'd have to do (*ptr).a
this is such a common thing that it has it's own operator, ptr->a

Why do they no longer support this in long mode?

OT & random, but are you a coffee shop coder?
Do you have a well groomed and waxed beard and wear flanel shirts with designer jeans?
Do you drink beverages with verbose names?

10/10 thanks

Did they ever? I thought it had been soft deprecated back in the 386 days.

Can anyone recommend some good sources for learning React? the codecademy courses seem a bit out of date

I have basically nothing but allocated arrays.
What I have assumed:
i, j
00 01
10 01

i, j:
00 01 02
10 11 12
20 21 22

So, we have to compare
1.
00 = 00;
01 = 01;
10 = 10;
11 = 11;

2.
00 = 01;
01 = 02;
10 = 11;
11 = 12;

etc. So, I understand what is meant by overlaying. Am I on the right track? Shit, these loops drive me insane. I have just done matrix multiplication and sorting by row/column, but can't do this shit. Hilarious.

>10-bit codewords
>How many data bits are in each codeword produced by this algorithm?
really makes you think

just the standard tutorial for react & redux should be enough, after that just use the documentation/google

I don't visit coffee shops that often. When I do, I often get hot cocoa or an Italian soda. I've found that most coffee shops offer this on the menu, but can't make them right, either due to not using enough syrup or not stirring the damn thing properly.

My beard looks kind of like a rat's nest, minus the part about being filled with garbage and insects/animals. I don't bother to brush it much, and I never trim it. I don't wear flannel shirts or designer jeans. I do wear a lot of second hand clothes, except of course for my boxers which I buy new for obvious reasons.

I drink a lot of soda, juice, tea, and cocoa, and occasionally a large quantity of milk when I have acid stomach. Not necessarily the most healthy of choices, but everyone has their vices. I don't do any drugs, and I can't stand alcohol, and I can't stand a number of sweets, so I might as well let soda and fried foods be my poison in life. I don't think anything I eat or drink has a super verbose name, except for maybe Sauerbraten and Spatzel around Christmas time.

>lisp
too verbose
>sml
no good implementation
>c
manual memory management, not that it's bad but when prototyping it slows down the development
>sepples
convoluted cluster fuck that no sane person would touch
>every jvm or .net language
requires fuckhuge vm

There just is no good statically typed and compiled language.

What is OCaml?

ml with propably the ugliest syntax.

...

>convoluted cluster fuck that no sane person would touch

>i dont understand it, lets blame the language

fake as always
post the actual tweet

You judge a language by the less relevant part.

>>i dont understand it, lets blame the language
The language is standardized and it's not that hard, it's really big though.
But sepples enables programmers to write the most unreadable code mess with templates.

fag
instagram.com/p/5c1WXeESvD/

Ah, the wonders of legacy code.

> be me
> working on timesheet program
> boss says I need to use company's legacy framework
> no documentation
> no comments
> fuck with the API until I get the hang of it
> finally patch a fatal error after almost two weeks
> compile, run unit tests, everything looks good
> open program to double check
> mfw all my date/time components are stuck in Japanese

thanks for the link bro couldn't be bothered finding it myself

If syntax was not relevant propably everybody would be using sepples.

i was bored so i wrote something up, it probably doesn't work tho

int matmat(mat2 *hs, mat2 *n)
{
if (n->size > hs->size)
return 0;
size_t i, j, k = 0, match = 0;
size_t items = n->size * 2;
for (i = 0; i < hs->size; i++)
{
for (j = 0; j < hs->size; j++)
{
if (k + hs->size < (i > j) ? i : j)
{
if (hs->mat[k+i][k+j] == n->mat[k+i][k+j])
match++;
else
match = 0;
}
}
if (match == items)
return 1;
k++;
}
return 0;
}

Java and The Kingdom of Nouns

Read it it's good article

Yes, that is the right track, you can make your life easier by breaking up the task into more than one function. My loops would walk down each i,j of the larger matrix. Then, I would have a function to check if the current i,j is within bounds for checking (i.e. i - small_i > -1, i + small_i < len(A[i], ect), then a function that that passes in i,j for the larger matrix and does the actual looping through the smaller one (if valid to check).

who are you quoting?

# macro square = x * x >>;;
macro square : (int -> int) expr =
Pervasives(*global*).( * ) x_1 x_1 >>
# macro n = >;;
macro n : int expr =
Pervasives(*global*).( * ) x_3 x_3)
(Pervasives(*global*).(+) 42 1) >>
# $n;;
- : int = 1849

oh yeah, the offsets probably shouldn't be applied to the needle matrix
also the nested for loops should probably stop at the limits of the needle matrix and not the haystack matrix

>manual memory management, not that it's bad but when prototyping it slows down the development
You know what?
It's your chance.
Make your good statically typed and compiled language. At first you gotta write out where allocate and deallocate memory manually, but when you've set all conditions of memory allocation and deallocation, you can just use your language, because it will do all the work.
It's time to shine for you!

What does this mean, reddit

0xbeef.coffee/posts/post4.html

trash

>trying to program
>suddenly this shit starts popping up every few seconds
>dont even use vc++ compiler or their package shit

a codeword is made up of data bits and error detection bits

cl is fucking easy to use

Who said this though?

...

There is no real alternative to C++.

Yes, stay with C++.

yess stay with C++ goyi- i mean pajeet

I will stay with C++.

>what is rust
inb4 le functional syntax meme

It's been a while, that would make sense. The error code can only detect if a word is bad, not necessarily which part, thus 1 bit per word is needed, so 9 bits of the 10 are left for actual data.

>le
>meme

Rust will have to wait for a bit. It's a better language but it has less libraries than C++

Convince me that rust is better.

Rust is a meme lang created by meme people for meme people

that was ironic newfriend

It's templates are not broken

>meme
Ironic shitposting is still shitposting, newfriend.

Reminder that Rust devs are perfectly okay with memory leaks in their language.

Stick with C and C++, no need for that useless meme language.

>plebbit spacing
>meme

>over 16 and still no STEM degree
literally LMAOing at you
Ruth Lawrence earned her degree in Mathematics at the age of 13, at Oxford.

>over 16 and still no STEM degree
Cool. Who said that though?

i live in a third world shithole tho

C++ is a barely manageable language. I think that was one of those misunderstood points. My point was that there is no clear flow to work with the language. That can be a blessing, it allows a lot of freedom. That can be a curse. Let’s discuss the downsides.

The split between source and headers, which makes project management quite slow. If you make all header libraries you’ll have a lot of copied code – the binaries will be larger. You’ll have to recompile that code every time you want to use it. And the split between the two is always troublesome – you can’t add a new field to your class without a few CTRL-TABs until you find where to write the proper definition.
You still can’t write template code in .cpp files. You have to write code in the headers. If you mix that with some #ifdef & friends, it becomes a mess quite fast. Not to mention that you include content that is really implementation dependent.
C++ still uses the C preprocessor. That is the first feature that should’ve gone from the language. If you think about it, the header should represent the features that your object offers and not a letter more. However, people ended up delivering these huge files that can be used everywhere even if they will be used in one place and one place alone.
Namespaces are useless and make the code way too verbose. Instead of making your code cleaner and clearer, the programmers will end up doing a using namespace xxx. If you don’t believe me, look at how the code for using the duration_cast looks without some usings (auto only hides the dirt under the rug).
Lack of ABI makes it impossible to deliver C++ components without a C interface. If you don’t, you’ll crash quite fast when you use the flag -fsuper-duper-new-feature because you should’ve used the flag -fsuper-duper-extra-cool-newer-feature.

>2017
>Undefined behaviors
>Treat memory leaks and UBs as features
What’s really unfortunate is that “undefined behavior” is part of the language and its specifications. Initially, some aspects were left undefined in order to be able to efficiently deal with different hardware and to avoid unnecessary overhead due to over-specification.

Do note that programmers often confuse the terms “implementation-defined” with “undefined behavior”. Parts of the language that are “implementation-defined” still allow the developers to write perfectly specified code as long as the target machine is known3.

Again, as it is with all the other bad parts, this will probably never be changed – it can’t be changed. Even Bjarne Stroustrup agrees in an interview over at MSDN that way too many things have been left undefined or implementation-defined. If C++ was redesigned from scratch, there would likely be no undefined behavior at all.

However, I don’t have a time machine and we just cannot break hundreds of millions of lines of code by picking a set of resolutions today

t Bjarne Stroustrup

"I dun wanna write C no no no it bad, it bad, no good, no good"

Joan Carmichael

How can a language have memory leaks?

>>Undefined behaviors
everyfucking time

He is an idiot

Shit garbage collector and heap manager.

How can a language have a garbage collector or a heap manager?

Ctd.
Some of the semantic elements that have been left undefined involve even simple concepts like the execution order of function calls:

foobar(foo(), bar());

It is not defined, whether foo() will be called before or after bar() has returned. That’s just silly.

Operations, such as division by zero, integer overflows or out-of-bound memory access will also result in undefined behavior. Granted, these things should not occur and can generally be avoided if the code offers even a slight hint of quality. However it would still be nice to have a well-defined behavior here, especially when talking cross-compiler and cross-platform.

1 1 1 GO!!!.jpg

>How can a language have memory leaks?
google.com/#q=php memory leak bug

PHP "developers" just restart Apache every 10 requests

Is that a "feature" every compiler has to implement?

>PHP "developers" just restart Apache every 10 requests
now that's why i don't want to learn php

>dpt
>programming

who are you quoting?

woh rae oyu nqouitg?

enum traffic_lights {
RED = 1,
YELLOW = 2,
GREEN = 4
};

As you may expect, this is just an int with some named constants. You can declare multiple values with the same value, you can assign int value to it. And if you do YELLOW++, you don't end up with GREEN, but with a value that isn't defined in the enum (but doesn't raise an exception either). You also cannot iterate over existing enum values. At this point, this is just useless syntax sugar for
#define RED 1
#define YELLOW 2
#define GREEN 4

However C++11 does introduce enum class. It fixes none of the issues described above, but makes you prefix the enum values with the name of the enum.
Well(!) done.

Do you know that OCaml exist?

github.com/erikd/libsndfile/blob/master/src/sndfile.c#L300

What in the fuck...

Yeah python does too. What's your point?

Yes, I also know that it's trash.