/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: rin-c.png (1280x720, 786K)

Other urls found in this thread:

softwareengineering.stackexchange.com/a/269896
thehackernews.com/2019/01/php-pear-hacked.html
twitter.com/SFWRedditVideos

who dis bitch

thank you for using an anime picture

You can't spell JavaScript without Java.

bring my post over here

Attached: 1544402750070.jpg (1920x1200, 493K)

JavaScript rocks!

Attached: javascript rocks.png (1000x494, 134K)

Lisp is the most powerful programming language.

Lisp is the worst powerful programming language.

why?

Lispenis the worst powerful programming language.

>Does the internship pay a living wage?
If not, you will be homeless.
>Do you have savings?
If not, you will not be able to move. It costs money to move (deposit for rental, travel, food), even if you're sleeping in a sleeping bag on the floor of an unheated rental.
>Does the internship's pay allow more than the minimum cost of living for the area?
If not, you will be put into a dangerous situation living paycheck to paycheck, and potentially asking for help from family incase anything goes wrong.
>Do I have an opportunity locally which I can explore, without having to take the risk of isolating myself from my family (and presumably support network)?
If so, why are you wanting to start over elsewhere?

There is nothing anyone here can say which will be good advice because you're not providing details of your financial situation. Not even going to mention the LDR this is proposing since apparently you have a gf you'd be leaving.

Help I like Lisp!

dynamic typing
garbage collector
too slow
the lack of syntax
unhygienic macros
70% of the language being legacy shit
outdated standard library
no libs
dead community
the few lispers out there are unbearably smug jerks despite producing nothing of value
no jobs
no tools

but we had this conversation too many times and I have no desire to start it now, don't bother to reply

JavaScript ROCKS!

Attached: js-rocks.png (1000x494, 286K)

someone called me newfag in another thread.
wew lad this place is sinking faster than a stone in the ocean

> being butthurt after being called a newfag
newfag

you sound new

I want to learn funtional just for fun.
Which one do you recommend?

Bug in really complicated JS file, related to backend conditionals and build panini :(

>Does the internship pay a living wage?
Really depends on the salary they offer which based on the range 15-44 per hour could be decent or ridiculous.
>Do you have savings?
Not really, which is my main concern.
>Do I have an opportunity locally which I can explore, without having to take the risk of isolating myself from my family (and presumably support network)?
Unfortunately the only local opportunities are Lockheed Martin and Saab but my GPA is too garbage for them to consider me.

I'm not too concerned about a LDR since it's only a summer and my gf could visit me if she wants (she's already graduated with a decent job)

But all signs seem to point to this being a bad deal so I'll look elsewhere, thanks for the advice!

;)

Haskell

I want to kms.

haskell is fun, it's also going ballsdeep.
ocaml if you want to go fast or if you want to get closer to ML
elixir if you're a w*bdev

I like Lisp :)

>calling someone pointing out he isn't a newfag a newfag
you must be new here

I'm sorry, user.

Good

haskell my dude, it's great

It's not necessarily a bad deal due to your local opportunities being limited. I'm putting a lot of emphasis on the risk of moving and the potential for failure there, but if you have no opportunity to create/further a career locally, then risky moves or telecommuting are viable considerations

Determining the CoL of the new area, the internship's wage, and the potential cost of moving (let's say DP+driving

Lisp

Lisp is not functional tho, at least no more than PHP7 or C++11.

On a technical level, how is this background effect accomplished? I know it takes the colors from the album art and displays them all blurry but I want to know what kind of code is being employed here.

Attached: Capture.jpg (1067x466, 67K)

prove it

What was your biggest brainlet moment in your programming career?

For me, I thought "state" was something literal like Running, Paused, BeingConstructed for about two years of coding, until I found out it refers to the values inside the program

Literally just using the album art and making it the background and applying blur to it

Neither Lisp nor PHP7 or C++11 is based on Lambda Calculus, as opposed to Haskell. Sure you can "emulate" untyped (i.e. obsolete) LC in Lisp, but so can you in PHP7 and C++11 since they too have functions as the first class objects and lambdas.

i think is averaging the colors in the image

For me it was when i found out that shit code makes the world go round.

I assume the banding isn't part of it (I assume that's from your crappy capture method).
It's likely just a Gaussian blur with very big standard deviation. It's one of the most common blur functions. You should expect to see a very smooth blur with little color variation.
You can try it in gimp.

Attached: 250px-Cappadocia_Gaussian_Blur.svg.png (250x499, 174K)

I thought so too but some entries are clearly not just the art.

>averaging the colors

Attached: pensive potabo.jpg (625x628, 58K)

for C, if the command line has gives no arguments does that mean argc =0?

The first argument is the program name.
So you'll have at least 1.
Unless there's some very unique circumstances where that's not true that I don't know about.

argc = 1, there's always the first argument with the name of the binary.

since the readtable of lisp can be directly changed, the language can be reprogrammed to encompass any paradigm. it would not be an emulation, but a realization. see shen, for example.

I'm sure you can use Lisp to create another, better language, but that doesn't make Lisp itself any better.

the point is it would still be lisp.

not so fast there, nerds.

char *argv[] = { NULL };
execv("./prog", NULL);

oops, obviously I meant to pass argv there.

Then "Lisp" has no meaning, anything can be Lisp.

Now you nulled down *argv[]

you have reached satori my friend

I meant to pass that to execv, execv takes a NULL terminated array. That executes a program with argc=0

RAII BTFO

softwareengineering.stackexchange.com/a/269896

>1. SBMM creates the upward funarg problem with first-class lexical closures which is why closures are popular and easy to use in languages like C# but rare and tricky in C++. Note that there is a general trend towards the use of functional constructs in programming.
>
>2. SBMM requires destructors and they impede tail calls by adding more work to do before a function can return. Tail calls are useful for extensible state machines and are provided by things like .NET.
>
>3. Some data structures and algorithms are notoriously difficult to implement using SBMM. Basically anywhere that cycles are naturally occurring. Most notably graph algorithms. You effectively end up writing your own GC.
>
>4. Concurrent programming is harder because control flow and, therefore, object lifetimes are inherently non-deterministic here. Practical solutions in message passing systems tend to be deep copying of messages and the use of excessively long lifetimes.
>
>5. SBMM keeps objects alive until the end of their scope in the source code which is often longer than necessary and can be far longer than necessary. This increases the amount of floating garbage (unreachable objects waiting to be recycled). In contrast, tracing garbage collection tends to free objects soon after the last reference to them disappears which can be much sooner. See Memory management myths: promptness.
>
>SBMM is so limiting that programmers need an escape route for situations where lifetimes can not be made to nest. In C++, shared_ptr offers an escape route but it can be ~10x slower than tracing garbage collection. So using SBMM instead of GC would put most people wrong footed most of the time. That is not to say, however, that it is useless. SBMM is still of value in the context of systems and embedded programming where resources are limited.

This is faulty logic. There is the Lisp everyone knows, described in the standards and books, whatever you can modify it into is irrelevant. I could use C to write a Haskell compiler, that doesn't mean Haskell is a form of C now. Hell, I can use C to write ten macro processors on top of C compiler to turn it into something fancy, that doesn't mean C itself is fancy.

No sane individual would claim that RAII is without drawbacks. Both GC and any form of manual memory management have advantages.

thehackernews.com/2019/01/php-pear-hacked.html

PHP btfo

I'd say the only advantage manual management has are the performance gains. If you don't need them, no need to bother doing it by hand.

Performance gains are not guaranteed. If you have much more memory available than you're using, or if you're doing anything that does not map cleanly to a call tree, especially something with cyclical references, then using MMM can degrade performance.

That isn't relevant. You can directly change how Lisp parses syntax. Again, it is still Lisp at the end of the day.

Well, you manual memory management obviously lets you to build your own GC as well. But that's a good point, it's no wonder how GC'd languages are so popular these days.

thanks, so one argument passing would be argc= 2.

Hi dpt
i had a job application exam today and i couldnt answer one of the problems
input: unsorted integer array
output:true if all the pairs of adjacent elements in ascending order have the the same difference.
example:
input: 5 20 15 10
output: true because in ascending order(5 10 15 20) all the adjacent pairs have a difference of 5
But you're not allowed to perform ANY sorting

Seems sorting would be counter productive since the initial order is vital information.
But I'm questioning if I understand it correctly because you explicitly say sorting isn't allowed.
Seems like you just want a pair wise iteration and see if abs(an-bn) == (a0-b0).
If any comparison fails its false. Otherwise true.

>== (a0-b0)
abs(a0-b0)
Ofc.

i dont get it

C++ templates

It can't be overstated how dangerous it is that C++ changes the meaning of control flow statements. In the presence of RAII, simply breaking out of a loop can end up throwing an exception, writing to a file, sending an email, or really anything at all. (GC is worse, of course, because these things can happen at any random time and are then impossible to track down.)
In C, break means break. Full stop.

Destructors can't throw exceptions when invoked by exiting a scope.

Can it be O(n^2)?

#include

struct Gotcha {
~Gotcha() noexcept(false) {
throw std::runtime_error("What the fuck");
}
};

int main(void) {
while (true) {
Gotcha gotcha;
break;
}

return 0;
}

Actually the question initially didn't specify that I should do any sorting, so I answered:
int[] sorted_array = unsorted_array.sort();
if(sorted_array.length < 2) return false;
int difference = sorted_array[0] - sorted_array[1];
for(int i = 1; i < sorted_array.length-1; i++){
if(sorted_array[i]-sorted_array[i+1] != difference) return false;
}
return true;

But then a follow up question about how to do it without sorting. Not sure why you say sorting would be counter productive or what vital information can be gained from the initial order since they were asking to check the differences of the adjacent element pairs if they were sorted ascendingly.

why is it that whenever c programmers complain about things, it's
>x feature can be abused
it's not like c doesn't have abusable features

i don't disgree with what you're saying, but ultimately, any programming language lets you do things you really shouldn't do
if it doesn't, it doesn't respect your freedom as a developer
the language should not hold your hand and stop you from doing bad things

My mistake, I got confused. Destructors can't throw when being invoked during unwinding.

sure go ahead

If an interviewee gave me this I would immediately have hr send the denied mail. What the fuck is that unreadable mess?

Pseudo code because I'm lazy

For i = 1 to N
For j = i to N
//Search for minimum a[i]-a[j] that's not negative
// Save them to an array b
Loop
Loop
//Check if every element of b[] is the same

Find the minimum diff then find the minimum diff which isn't the minimum diff you calculated before. If it doesn't exist, congratulations all the elements should have the same diff!

>not using the tersest syntax possible
not gonna make it

a good programming language makes it harder to abuse features
destructors are less explicit than defer, for example.

Well defer is bad OOP since it doesn't put all the behaviors of a class in the same place in the code

thanks. that makes sense

They also complain when you can't abuse things like not being able to bitshift in Java

Sorry my brain isn't working, the next minimal diff should logically be 2* the original diff.

I'm gonna make progress on my thing today!

Attached: 1518737423533.jpg (1024x768, 251K)

i got what you meant

C++ is bad OOP too. But if you don't like defer, you can get something similarly explicit that respects encapsulation with downward funargs and traits.

Funargs break encapsulation

akarin from neon genesis ball z

funargs don't break encapsulation any more than interfaces do, you stupid fag

what's the non-brainlet way to
if (i < 7) {
return 0;
} else if (i < 15) {
return 100;
} else if (i < 23) {
return 200;
} else if (i < 31) {
return 300;
} else if (i < 39) {
return 400;
} else if (i < 47) {
return 500;
} else if (i < 55) {
return 600;
} else if (i < 63) {
return 700;
}

?

strict adherence to OOP, or what is normally defined as OOP (didn't the guy who coined the term mean a way to do message passing or something completely different to how it's now defined) is a bad idea anyways

That's reassuring to know

Attached: 1378813226031.jpg (590x500, 44K)

Use a lookup table maybe?

Any feature that allows a method to be called, and have arbitrary code run inside it, obviously does
I'm starting to think what we need is a language where creating an object can just give control of the program to that object until it's destroyed, and during its lifetime, only methods of that object can be called

Switch statements, but besides the syntax it means the same

Never mind I'm retarded
Just whole divide by 8, times 100

No sir, you can't just use defer, You need to use an protected abstract virtual base pure virtual private destructor as outlined in the principles of object oriented programming.

Attached: OOP.png (1938x852, 151K)

>Just whole divide by 8, times 100
what?
i/8*100;

will not do the same

C++ implements sum types with a library template, std::variant, rather than as a builtin feature.
It's shit don't use it. Make your own.