/dpt/ - Daily Programming Thread

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

Attached: dpt.png (2000x2810, 155K)

some fizzbuzz without modulo

rolling

Attached: programming challenges.png (3840x2160, 1.19M)

Last night I wrote some more boilerplate perl

Attached: screenshot.png (2560x1400, 203K)

>notepad++
>that color scheme

Attached: only the dead can know peace.jpg (500x490, 41K)

It's a fantastic color scheme. I wish notepadqq had it, or even had compatibility for notepad++ themes.

I used epsilon a lot at my last job. I wish notepad++ had more than two panes.

Trying to make a graph from an array of point objects in java. So far what I have is I can make the points print out as ordered pairs in a string like this "(1,28)(2,33)(3,37)(4,25)(5,21)(6,25)(7,25)(8,25)(9,19)(10,18)" and from there I don't know what to do.

Also I would really prefer that the points be able to hold doubles, but I don't know what utility to import for that.

>point objects
what are they?

points = pair of x, y coordinates?

import android.graphics.Point;


public class PowerfulAutoplayerVersionTwo extends AppCompatActivity{

String GrapherString = "";
Point[] DiceGrapher = new Point[99999];


DiceGrapher[Day] = new Point();
DiceGrapher[Day].y = (int) DicePrice; //This is the variable I am trying to graph, it changes every time 'Day' changes.
DiceGrapher[Day].x = Day;

if (Day == 100){
int boogle;
for (boogle = 1; boogle < Day; boogle++) {
GrapherString = String.format(GrapherString + "(" + DiceGrapher[boogle].x + "," + DiceGrapher[boogle].y + ")");
}
}
}


Then I throw a break point on the GrapherString = ... and it lets me copy the ordered pairs.

Point objects are just a way to hold a coordinated X and Y value.

i'm not sure i get what you're trying to do. it seems you're not showing full code. i don't see Day is declared or assigned a value.

I just put what I thought was relevant, Day counts up from 1.

I'm enjoying K&R so far, as someone who has been using C++ for around a year without a fantastic understanding of C.

currently working on a Jow Forums themed text rpg in python but i'm getting errors already :(

the way you use string.format is unusual. it doesn't use the string.format feature. you're just concatenating some strings like:

GrapherString = GrapherString + "(" + DiceGrapher[boogle].x + "," + DiceGrapher[boogle].y + ")";
or
GrapherString += "(" + DiceGrapher[boogle].x + "," + DiceGrapher[boogle].y + ")";

More fully it would be something like this:


import android.graphics.Point;


public class PowerfulAutoplayerVersionTwo extends AppCompatActivity{

double DicePrice = (new Random().nextInt(20)+40);
int Day = 1;
String GrapherString = "";
Point[] DiceGrapher = new Point[99999];


for(Day = 1; Day < 99999; Day++){
DicePrice = ((Math.ceil((DicePrice * 100) + ((new Random().nextInt(700) - 300)))) / 100); // add or subtract up to 3.00 from DicePrice
DiceGrapher[Day] = new Point();
DiceGrapher[Day].y = (int) DicePrice;
DiceGrapher[Day].x = Day;

if (Day == 100){
int boogle;
for (boogle = 1; boogle < Day; boogle++) {
GrapherString = String.format(GrapherString + "(" + DiceGrapher[boogle].x + "," + DiceGrapher[boogle].y + ")");
}
}
}
}

Needed more teal text

Thats a really good point, I don't really know what I am doing on any front. I do use string format for things like "Your name is %s". Concatenation of strings is all I need here and I didn't realize you can do it the way you just pointed out.

Im making a game written in Java

But some users download it and they dont have Java installed so they cannot run the .JAR , or they open it with winrar etc.....

Whats the best solution? Is there some kind of recommend way to install Java automatically? Like Minecraft has? Is there a premade solution for this problem or do I have to make my own .EXE somehow?

How do I into programming for android? What kind of compiler/packager do I need?

string.format is better visually when you're concatenating many strings. if you only concate like "Your name is %s", it's usually enough to use "Your name is " + name.
example:
String result = "";
int[] scores = { 50, 70, 80, 60, 90 };
String[] names = { "Alice", "Bob", "Charlie", "David", "Eve" };
for (int i = 0; i < scores.length; i++) {
result += String.format("%d. Score of %s = %d\r\n", i + 1, names[i], scores[i]);
}
System.out.println(result);

I use android studio for everything, it is an IDE and a compiler, also it has phone emulation. I use a cable and a physical phone, but you don't have to.

result += String.format("%d. Score of %s = %d\r\n", i + 1, names[i], scores[i]);

is simpler than
result += i + 1 + ". Score of " + names[i] + " = " + scores[i] + "\r\n";

...

>Android studio
They have command line, so I can skip the IDE. Thanks, user!

haskell is a meme

Should I learn Haskell or Common Lisp?
I'm interested in these for autistic reasons, but which is more usable/marketable?

common lisp is gay you should learn haskell instead
if you still want to learn a lisp then try scheme

Attached: 1535350288943.gif (320x236, 2.93M)

Barely-beginner here.

Is this an issue for more obscure programming languages?
I thought programs sort of contain their own requirements when they're presented as a completed product. A sort of autonomous island of code running inside itself.

Working with B2B integrations this week. The more I work with EDI docs, the more I realize how based the X12 standard is

Scheme is the most elegant dynamic programming language.

I'm working on a Python assigment for a class wherein I have to make a Caesar cipher with only three functions (define as alphabet_position, rotate_character, and encrypt).
Although, for some reason when I put the code below in the alphabet_position function, it doesn't seem to loop, but it did loop while I had it in the rotate_character funtion. I'm not sure why, but it isn't looping and I can't find any logical reason for it not to be looping.
Can anyone help me figure this out?

while ord(char) > ord("z") and char.islower():
char -= ord("z")
char += ord("a")
print(ord(char))

while ord(char) > ord("Z") and char.isupper():
char -= ord("Z")
char += ord("A")
print(ord(char))

You could go the Electron route and bundle a copy of the JVM with every game you make. That would be bad though so don't do it

Some of those challenges seem like a good way to waste your time.

Is the second loop supposed to be inside the first?

yes, something like me and your mom

is there a reason not to use kotlin over java?
aside from the learning time?

Attached: Java_vs_Kotlin.png (1920x1592, 141K)

the learning curve is a lot steeper yeah
otherwise it's just java in drag

No, the second one is supposed to be a second on that checks for uppercase, while the first loop checks for lowercase.

Whenever char = | (which has a value of 124) it doesn't run in the loop, weven though "z" has a value of 122, making | > z, but it just ignores the loop entirely.

why doesn't java support property? the getter/setter are not always needed unless you need custom logic when assigning/fetching values.

yea, by now I'm aware of it

so what you say, HtDP (racket) then clojure to learn fp? or should I go with something else like scala after I read HtDP?

rolllllllllign

I FIGURED IT OUT
Also, I formatted the code wrong when I posted it in here. The actual problem wasn't even in the loop, too.

i like c# and it has fp feature.

roll

Is a hypervisor too hard for an intermediate programmer?

Attached: rs-247083-RS-Office-Space.jpg (1200x630, 136K)

>lead software engineer wants me to look into this particular soap service the company signed up for
>ok sure
>read documentation
>seems straight forward so far
>grab wsdl from the service api
>load into vs
>set up proxy class
>get login credentials
>the service returns a JSON
>what
>reread documentation
>realize this companies soap service is breaking the standard soap api by returning a JSON instead of XML
The only way I can get past this shit is by writing my own XML request generator and response parser. What a load of shit.

>no anime girl
I won't be contributing to this thread.

Attached: 1533493379405.jpg (750x750, 86K)

lol

request in xml, response in json?

...huh? Why can't you just send JSON instead?

why Jow Forums likes mieow/rustle?

Attached: images.jpg (235x215, 9K)

What version of Openjdk do you use for android studio? 10, 8, or 7?

yeah
It's a SOAP service API, SOAP is strictly XML format. My C# code threw this run time error
System.ServiceModel.ProtocolException: The content type json of the response message does not match the content type of the binding (text/xml; charset=utf-8).

about to get bodied but rolling

>tfw made a version of a toy program in my language of choice that's faster than the one on the Benchmarks Game website

have I finally ascended?

Attached: nerdvana.gif (1000x307, 51K)

>making shitty program that's faster than rigged benchmark

>my language of choice
No, it has to be in your toy language

>faster than the one on the Benchmarks Game website
Are you testing on the exact same hardware/OS/etc. they use? Otherwise, being faster just means you have a faster system.

I mean why can't you just use JSON instead of XML? There are dozens of JSON parsers for C#. Not sure why you need to roll your own thing.

Good languages for learning FP:
>Scheme
>ML
>Idris
>Agda

Bad languages for learning FP:
>JavaScript
>Python
>Scala
>Haskell

functional langs are better poolangs than poolangs discuss

>Haskell
false

Is Lua good

rolling

>Faskell
halse
also when programmers use "false" to mean "you're wrong" they sound fucking retarded discuss
you're a human being not a function, when you answer questions you answer them with sentences, you don't fucking return booleans you retard

The problem is the wsdl generated classes expect XML, even though the service returns JSON for some functions. I could use the builtin JSON classes for the parsing, but that means I have to drop the wsdl classes and roll with my own XML request generator, make GET and PUT calls to their API server, and have to essentially test to make sure my XML data works with every possible end point.

The word false wasn't invented by programmers you fucking idiot

Wow, sounds like a nightmare for what should be such a non-issue. Is this the power of Enterpriseā„¢ Development?

>The word false wasn't invented by programmers
false
^^see, that's how fucking stupid you sound
>duuurrrr false false false

jesus christ

Attached: brainlet.png (621x702, 56K)

>use the broken API and get nothing done
>reinvent the wheel for what the API should already handle
Enterpriseā„¢ development at it's finest

Using Haskell to learn FP is like using C++ to learn OOP

This is some next level autism.

Testing the existing program from the website on my machine got roughly the same time. Mine is a solid 10 seconds faster, so I'd assume the speed benefit on the four-core computer that they use will be similar.

how stupid are you

rolling

i concede that programmers didn't invent the word "false" but they did invent the usage you're invoking when you respond with "false" to claims you disagree with. false is only the proper opposite of true in the context of programming. for an interpreter or runtime to respond "false" to a failing query makes just as much sense as a human being calling a mustache "false" if it's part of a beaglepuss. but for a human being to respond "false" to a failing query is fucking stupid. a more appropriate term would be "untrue." or better yet, "i disagree."

false

reroll

What was meant by this?

what do you think about elixir? does anybody use it? I haven't seen any job offers around me that would require this lang

Attached: 1518564979587.jpg (480x391, 17K)

Why?

>DURRRRR FALSE FASLE FLASE FALSE FOLSE DURP DURP

Attached: ku9feaz.png (3840x2160, 403K)

w, what?

Depends if you use premade things like kvm.

I'm making a python program and need some help.

I've got this class that I defined. The attributes of instances of this class are created based on user input and setattr().
When I actually do stuff with them, it's (just for example's sake) print instance.attribute
This works fine when the user's input is okay, but when he doesn't input the right shit I get an (understandable) ValueError.
Problem is, users are retards. They'll see the traceback and won't bother reading or trying to understand it.
What I thought of doing is somehow overriding the class' inner getter methods, so that when I type instance.attribute_that_does_not_exist instead of raising an AttributeError it will do stuff that I want it to (print something more user friendly, return 'NOT AVAILABLE', etc.)
How can I do this?

As a platform yeah (because embeddable and love2d). As a language, not really but good enough.

Correcting myself: I get an AttributeError, not a ValueError.
Basically I want a default return value without using retarded shit like instance.getattr('name', 'default')

i'm disregarding your shitty opinion until you can communicate like an actual human being and not like a javascript implementation

welcome to soap, where nothing is simple

try:
print instance.attribute
except AttributeError as ex:
print ('Oh shit nigga, thats an error. ' + ex)

You might be barking up the wrong tree here with trying / wanting to try overriding the getter methods. It would work, but it would be uglier than the alternative, which I recommend: you could just handle the AttributeError exception.

user absolutely devastated by this post

see:

obviously I can use a try/except block, but that's a real pain in the ass when I have to add 3 lines for every other line in my 600line+ program

Haskell and C++ are both 'kitchen sink' languages. You have to know all sorts of tricks and patterns to program in them at scale. It's more obvious in C++, but Haskell is also noticeably creaking at this point. Look at how lambdas were bolted onto to C++ and how dependent types are being bolted onto Haskell.

false