/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

codeshare.io/2pJwvV
pastebin.com/T8gbG3CV
nativescript.org/
benchmarksgame.alioth.debian.org/u64q/which-programs-are-fastest.html
twitter.com/NSFWRedditGif

fuck opengl

Fuck DirectX.

fuck computer graphics

Got something real for you guys to look at here:

codeshare.io/2pJwvV

It's a simple maze solver in Java. I wanna:
>>add a way to make the algorithm faster
>>fix my gay ass output
>>add random maze generation.

All help appreciated

How's that project you're supposed to be working on, /dpt/?

currently downloading the Android SDK, going to make a DND character creator

anybody have the programming challenges pics

absolute shit
i want to kys myself
thanks for asking

No. Fuck off.

Prim/kruskal

1. Restrict all code to very simple control flow constructs – do not use goto statements, setjmp or longjmp constructs, and direct or indirect recursion.

2. All loops must have a fixed upper-bound. It must be trivially possible for a checking tool to prove statically that a preset upper-bound on the number of iterations of a loop cannot be exceeded. If the loop-bound cannot be proven statically, the rule is considered violated.

3. Do not use dynamic memory allocation after initialization.

4. No function should be longer than what can be printed on a single sheet of paper in a standard reference format with one line per statement and one line per declaration. Typically, this means no more than about 60 lines of code per function.

5. The assertion density of the code should average to a minimum of two assertions per function. Assertions are used to check for anomalous conditions that should never happen in real-life executions. Assertions must always be side-effect free and should be defined as Boolean tests. When an assertion fails, an explicit recovery action must be taken, e.g., by returning an error condition to the caller of the function that executes the failing assertion. Any assertion for which a static checking tool can prove that it can never fail or never hold violates this rule (I.e., it is not possible to satisfy the rule by adding unhelpful “assert(true)” statements).

6. Data objects must be declared at the smallest possible level of scope.

7. The return value of non-void functions must be checked by each calling function, and the validity of parameters must be checked inside each function.

8. The use of the preprocessor must be limited to the inclusion of header files and simple macro definitions. Token pasting, variable argument lists (ellipses), and recursive macro calls are not allowed. All macros must expand into complete syntactic units. The use of conditional compilation directives is often also dubious, but cannot always be avoided. This means that there should rarely be justification for more than one or two conditional compilation directives even in large software development efforts, beyond the standard boilerplate that avoids multiple inclusion of the same header file. Each such use should be flagged by a tool-based checker and justified in the code.

9. The use of pointers should be restricted. Specifically, no more than one level of dereferencing is allowed. Pointer dereference operations may not be hidden in macro definitions or inside typedef declarations. Function pointers are not permitted.

10. All code must be compiled, from the first day of development, with all compiler warnings enabled at the compiler’s most pedantic setting. All code must compile with these setting without any warnings. All code must be checked daily with at least one, but preferably more than one, state-of-the-art static source code analyzer and should pass the analyses with zero warnings.

...

I'm so lazy! Fuck
I just want to write my virtual machine but I'm so lazy
I can't wait to run out of loan money without finishing college and be homeless

I should just end misery.

That isn't HKTs, that's ad hoc polymorphism

Java

int i = 123456789;
float f = i;
System.out.println((int)f);


That prints 1234567892. Where is the extra 2 coming from?

the poo on the bottom of pajeet's shoe, embrace the poo and become a java master

current project is to get my job to pay for the A+ exam so I can pay rent as a fucking IT slave or maybe a cuck genius at the local faggot store. I wa looking through a study guide for A+ and feel like I know 90% of the study material just because I'm "tech savy" any resources for a young nigga like me?

could you be more specific? I haven't taken an algorithms course.

Working on the game of checkers in racket/scheme

Try double.

Why 10 points?

Working on a budget program, with basic CRUD operations and chart output in COBOL.

Tell us more user

Go seems pretty great for web servers, didn't expect to see so much built-in packages supporting things like HTML templating, routing, http responses, etc. Being able to skip all the nginx shit and just using one compiled exe + static files + html templates seems pretty great.

Thoughts?

What a get

gratz

Vulkan is the way.

At what point is someone employable to program for someone else?

Fail a few interviews and improve yourself from there.

...

All the banking movements are in a big sequential file. I managed to write CRUD subroutines in order to manipulate and sort them. I have my account in an other sequential file, that I can update too.

And then I produce a file that I can pass through gnuplot to output fancy charts.

I got a job writing python scripts for me mums tech company in the bay area.

I read 70% of "How to automate the boring stuff in python" + wrote a script that added watermarks to pdfs (they were printing then stamping and scanning them ) and now I am a :

AN EMPLOYED PYTHON PROGRAMMER.

Sad thing is that at least 30 other people at this company are actually software engineers so I get embarrassed when they come near my screen. I dont want them to know that I am spending days trying to do shit that would have taken them minutes.

They make 3 times more than me, but I am 1/10 the skill.

Tldr: just be urself

>stupid games
>job application
>the actual job involves moving data from one pipe to another

I made an incomplete game/algorithm based on Public Goods game pastebin.com/T8gbG3CV

Game is to be played over discord or similar platform. There is no time pressure for bet placement. Participants are always anonymous and number of rounds is not capped.

Im assuming participants will always be able to cheat GM, group together and communicate strategy for maximum group benefit. Therefore I want the optimal group strategy to not yield much bonus metal. On the other hand, I want to motivate participants to bet metal.

I would be glad for any suggestions regarding metal pool and incomplete variables.

It's a good replacement for Django/RoR. It fails at all other tasks.

Which style is better, /dpt/?

function getMagnitude() {
return Math.sqrt(_x * _x + _y * _y);
}

function setMagnitude(m) {
var d = getDirection();
_x = m * d;
_y = m * d;
}


or

function magnitude(m) {
var d;

if(m) {
d = direction();
_x = m * d;
_y = m * d;
return m;
}

return Math.sqrt(_x * _x + _y * _y);
}

So, got an idea for a project app to teach myself
For one person who's pretty new, is it best to learn basic Java and swift and have two separate apps doing the same thing (talking to a php server) or should I use something like React that can compile to both platforms?

Why does it need state?

Funny you mention Django. That's what I was considering replacing with a rewrite in Go for one of my websites. Little concerned about having Go use an existing postgresql db configured with Django.

Don't those find minimal spanning trees? How are they helpful for solving mazes?

I started learning Haskell. So far it seems it strikes the perfect blend between usefulness of imperative languages and expressiveness of Lisp.

zip' :: [a] -> [b] -> [(a, b)]
zip' _ [] = []
zip' [] _ = []
zip' (x:xs) (y:ys) = (x, y) : zip' xs ys


Zip in four lines (one is optional though) - great!

So, Sup Forums, redpill me on Haskell.

Never heard of it, is that some new hipster language like Go and Swift?

Ugh, those side-effects.

>new
I don't think so, considering it was first written in 1990, 5 years before Java.

it's pretty good

I don't think you know what side effects are.
There are none in the code he posted.

Stay away from the React meme. It's more than likely that your project isn't complex/large enough to warrant using js frameworks. There's usually no need to go so far in to React/Angular rabbit hole, it really isn't hard to have manageable vanilla JS, consider TypeScript as well btw.

_x and _y are not local.

Haskell is an academic research language that has started breaking into mainstream, practical use. You can now find plenty of job listings for it.
And, as you should know, academia and research are many many decades ahead the real world.

Okay thanks, so I could just make a native vanilla JS app that could compile to both platforms, using something like this? TypeScript is there too:
nativescript.org/
I know java and some Android app dev, but no Swift, but it seems worth learning to make one thing for both platforms for maintenance purposes rather than separate doesn't it

>Side effect: a secondary, typically undesirable effect

>setMagnitude
>Does nothing more than simply set the magnitude of the object the method is apart of
>hur dur side effects
Fuck off dumb functional poster.

1. If they are local you are at risk of introducing side-effects.
2. If they are not accessed anywhere else there is no need in the first place for them to be free.

*not

>If they are not accessed anywhere else
Of course they are, dumb fucking retard.

>1. If they are [not?] local you are at risk of introducing side-effects.
M-M-MUH SIDE EFFECTS HUR DUR DUR DUR DMAOMFDAOIEFMESGISEGMEOSAGMESAUO
Throw yourself off a cliff.

>What are you working on, Sup Forums?
tinkering around with ros.
Currently trying to get a ultrasonic sensor to work. It's okay right now, but has some faulty values every now and then. Gotta put a filter onto it.
webm related

Seriously kill yourself.

>Haskell shitter impressed over implementation of trivial function
sasuga
Get back to us when you write something useful in it. You'll be begging for Lisp after the first 200 LOC.

How many decades ahead the real world would you estimate the research coming out of the UCLA department of Gender Studies is?

>Waaaaaahhh muh side effects waaaaaaaaaaahhhh!
People like me typically like their programs to be useful.

>nativescript.org/
I dislike the "Angular" part of this, would probably try out ReactNative first (even though no fan of React for Web)

You can write imperative code without needless complexity of convoluted state.

Looks like you can just use JS on its own here but I'll look at ReactNative as well, thank you
Why aren't you a fan of React for Web?

>needless complexity of convoluted state
>2 data members for x and y
lmao
Perhaps programming isn't your think.

How am I Haskell shitter? I literally said I just started to learn Haskell. Jesus, why am I even coming back here again and again?

I think v.magnitude(0) might cause a fuckup. Besides, .magnitude(someshit) does not scream "SETTING MAGNITUDE" to me, altho this could be unlearned, so I think the first option is more efficient. Finally, the implementation of the second option is more complex, so I'd go with the first, which is already more common anyway.

my wife nodoka is so cute

>all his functions aren't pure
literally uninstall your life

Are you really that dumb or is this straw-man intentional?

Sorry didn't realise two different anons - first user said stay away from react for complexity issues, other said look into it, right?

just ignore him, he's jealous

*the first option is more readable

Explain to me how 2 data members in an object for holding x and y coordinates qualifies as "needless complexity of convoluted state".
Go on.

>How am I Haskell shitter?
>I just started to learn Haskell
See? answered your own question.

I love how autistic you all are, Sup Forums. Never change,

>>Waaaaaahhh muh side effects waaaaaaaaaaahhhh!
>People like me typically like their programs to be useful.
>You can write imperative code without needless complexity of convoluted state.

General statement in response to general statement. Explain me what you don't understand?

Answer the question, retard.

So, everyone should know a priori given language is bad (or good) without ever trying it or they are "shitters"?

he's not worth your time

What do you know about my time kiddo?

Haskell is good for code golfing. It's not good for real world programs.

*pauses for GC*

Oh cool, didn't see that no-Angular possibility, will be checking NS out then sooner or later.

> Why aren't you a fan of React for Web?
For the use-cases it addresses (actually complex intriacate, rather than simpleton, SPAs) I'd prefer the Vue approach, JSX weirds me out. But for Native I'd find it OK because it's a completely different component set in Native vs. HTML/own-WebComponents. If there were a VueNative (haven't checked lately), I'd pick that though, if competetive with RN in all other aspects too

I guess you're right.

Can you elaborate more on why do you think that? I understand that Haskell is historically purely academic/research language but what exactly is holding it back? Performance? I think it's comparable to Java/Python. Or is jut just a blanket statement for functional languages in general?

Is this the absolute state of Millennials today?
You can't be arsed to enter "Kruskal soving maze" into google, eh?


Fuck me, I don't want to live on this planet anymore..

I’m trying to draw a stack program in java, and trying to create methods to be called with a button listener (e.g void push(Graphics g){...} but when I use the method in the listener class it asks for a argument for g... and if I was to remove the Graphics g i can’t g.draw...etc. How do I get around this please?

Show code.

And yet in 2017 Java still reigns supreme.

Say someone has 10% payout but his payout gets increased by 20% so now it is 30%. Is this percentage addition? Or multiplication? Or what is it, how do you express it in words and math?

Not him, but consider the following:

Is a Ferrari Pininfarina Sergio a better car than a Toyota Corolla? Of course.
But you will always see more of the latter type of cars.


Homework:
Figure out why.

Which of the following statements are true:
10+20=30
10*20%=30
None of the above
Both

>tfw it's actually true

Pass in the damn g?

haskell isn't a ferrari, and please leave dumb analogies on Sup Forums.

>Can you elaborate more on why do you think that? I understand that Haskell is historically purely academic/research language but what exactly is holding it back? Performance? I think it's comparable to Java/Python. Or is jut just a blanket statement for functional languages in general?
Functional programming languages are slow in general. If you look at benchmarksgame.alioth.debian.org/u64q/which-programs-are-fastest.html you'll see that Haskell is no different. Haskell is especially bad compared to other compiled languages like C, C++ and Rust.
Performance aside, I consider Haskell to be mental masturbation. Most of the real world problems I've encountered are easier to solve imperatively than functionally. The latter may look more elegant, but the former is easier to write and reason about.
Haskell is cool, but impractical.

>Homework
That's a little condescending, don't you think?

Anyway, I know what you mean, but I don't think using comparisons like this help out the discussion.

Obviously, there are problems that are better suited for von Neumann languages (e.g. OS design) and for functional languages (compilers) but I can't think of any real problem with Haskell (other than initial steep learning curve) which can justify general statement such as:

>It's not good for real world programs.

That's why I'm asking.

the second one is true

>Most of the real world problems I've encountered are easier to solve imperatively than functionally.
lambda's with map/filter etc are harder?
It sounds like you've done fuck all functional programming.