/dpt/ - Daily Programming Thread:

Super Poo in Loo edition

Previous thread: What are you working on?

Other urls found in this thread:

akaribbs.mooo.com/board.cgi
en.wikipedia.org/wiki/Single-precision_floating-point_format
docs.oracle.com/javase/8/docs/api/index.html?overview-summary.html
twitter.com/SFWRedditGifs

First for D

Second for C++ is trash.

Still waiting on that guy to tell me what his preferred language is.

Trying to get a simple demo app working on the Apple watch... Apparently it's more common with Apple for stuff to not "just work"

I just want non-static variables in interfaces in Java. Is that too much to ask?

Finally found a paper that relates internal parametricity with univalence. Brilliant.

What should my bot on akaribbs.mooo.com/board.cgi do? It has like 4 commands but they don't do much, what would some useful or interesting things it should do?

>I just want non-static variables in interfaces in Java. Is that too much to ask?
abstract classes exists you fucking autist.

While that is conceptually perfectly fine, Java interfaces are a leaky abstraction over vtables. Too bad!

English

What am I doing wrong? trying to multiply stock value to commissionRate1 but my main problem is that I get the result of that as a scientific number... which is wrong.

But multiple inheritance

user pls.. beg of you, if anyone can answer the question to me, I finish up. ;_;

What's a good IDE for Mac similar to Visual Studio? I know next to nothing on IDEs but back in high school I learned a good bit of VB.net. I liked being able to draw a program, drag and drop radio buttons and all that and coding each piece. Is that an exclusive thing or am I just retarded

Visual Studio Code.

where is postSale_Commission defined? You're doing all your math to get original_Commission, but then printing postSale_Commission.

Stream formatting. Include iomanip. Read about it.

Goddamn it.

Make an abstract class that implements multiple interfaces.

>iomanip
What an absolute joke. C++ iostreams are pants-on-head retarded.

Does this look like a nice layout for code tags?

Do you have input validation fixed yet?

breddy gud :DDDD

Somewhat, it is kind of a crude fix but I am working on it right now. And what kind of commands do you want? I can do something like "!uptime" that can show you the how long that site has been up or something. Anything for you based Akiramod. Also, why not make the font black, the gray doesn't look all that appealing.

Playing around with an extremely simple binding in JavaScript.

Starts off with HTML that has some data attributes:

hello
tag1, tag2, tag3


View model just needs to call generateDocumentBindings() and wrap the results in properties. Implementation of generateDocumentBindings() about 10 lines right now. You could also just use the results of generateDocumentBindings() directly if all of your properties are trivial.

class ViewModel {

constructor() {
this._view = generateDocumentBindings();
}

// Trivial property.
get title() {
return this._view.title;
}
set title(x) {
this._view.title = x;
}

// Non-trivial property.
get tags() {
return this._view.tags.split(", ");
}
set tags(x) {
this._view.tags = x.join(", ");
}
}


Update the model with whatever:

let model = new ViewModel();
model.title = "goodbye";
model.tags = ["a", "b"];


HTML would end up being transformed to the following:

goodbye
a, b

why are people in /dpt/ so adamant about this? it's not hugely used in industry anymore; you're beating dead a horse.

emacs and lots of add ons

There have been a lot of Sepplesfags on here lately.

C++ is good for perforamnce

C++ does a whole bunch of shit that is terrible for performance.
>vtables
>exceptions
>object code bloat
etc.

inb4 "my subset of C++" argument.

My editor for creating mediawiki tables is coming along nicely.

The last few days have just been focused on getting keyboard controls working. I got shift+arrow keys for highlighting cells working yesterday. It took me several tries to get the behavior right.

Today I added a little status bar at the bottom to tell you if you've successfully exported your table's markup to your clipboard.

I also made it show you a little helpful editing tip every few seconds while idle, but I'll probably take it out because it's distracting seeing the message change out of the corner of your eye.

You're always first for D

How would you accomplish what vtables do more efficiently?
Exceptions are zero-cost unless thrown, and they shouldn't be thrown under normal conditions (obviously).
"Code bloat" is only an issue on the most minimal embedded platforms.

>muh uncommon subset of C++ is terrible for performance
>inb4 "muh subset of C++" argument

>turned io from simple and clean format strings into nasty OOP state machines
bjarneeeeeeeeeeeeeeeee

huge binaries are bad for performance too

>just realized my VM doesn't have a way to store doubles
My data segment is just one large int array. I could add another array for doubles, but I'd rather avoid that. Would there be any kind of alternative?

en.wikipedia.org/wiki/Single-precision_floating-point_format

When discussing languages, it only makes sense to discuss the language as a whole.

>"Code bloat" is only an issue on the most minimal embedded platforms.
>What is an instruction cache?

Another thing that C++ does that is terrible for performance is
>Not having restrict pointers.

>vtables
So don't use virtual functions

>exceptions
So avoid exceptions unless you really need them, in which case your shit is breaking and performance no longer matters

>object code bloat
Elaborate pls

I forgot my other (You):

why couldn't you jsut store the double in the int array

>what is i-cache prefetch
The i-cache gets thrashed by branch misprediction, not lots of straight-line code. Not to mention you get the exact same thing in C if you use macros to simulate templates for generic programming.

>when discussing languages, it only makes sense to talk about the least common and most expensive features

You're an idiot. I said C++ is good for performance.
Which language did you have in mind? C? Assembly? FORTRAN?

And there is the "my subset of C++" argument.
>Elaborate pls
C++ templates cause shitloads of object code to be generated. All of this object code fucks over your instruction cache.

>not having restrict pointers
Every relevant C++ compiler has a restrict extension

Is D better than C++? Does anybody use D? I mostly want to use it to make penis jokes, but it would be nice if it was a good language too.

Do what you need to get the job done.

Also every OS is written in C, C++
Python on occasion in linux.

>!uptime
How would that work?

Also, I made the font slightly darker.

>not doing expensive things when they're not needed doesn't count as using C++
???

>And there is the "my subset of C++" argument.
Not him, but we were discussing the performance of C++.
We aren't discussing that every fucking feature in C++ is on the same performance terms, and it's ridiculous that you ONLY want to talk about virtuals and exceptions, the latter being VERY uncommon, and the former being used in limited circumstances.

and EVEN WITH exceptions/virtuals, it's faster than most other languages.

Nicer to write in than D

*than C++

In my directory i have 1000 images:
1.png
2.png
3.png
....
1000.png


how do i remove the images from 250 to 750 with a script?

pls help

Just wrote a vanilla wow fishing bot in Clojure as my first post-fizzbuzz program, because clearly I am the kind of person who would use a bot on a wow private server which already allows you to vote for gold. Then again, it's really satisfying to watch while it's working.

It activates the fishing rod by pressing the correct key, checks screen pixels to find the bobber by looking for unusually red areas, moves the cursor to the bobber, and shift-right-clicks when it detects a large change in alpha. Rinse and repeat.

I was positively surprised by how easy it was desu. Using Java libraries was super-straightforward. Being able to use Java libraries like java.awt.robot in a language that isn't a horrible clunky monstrosity was really neat.

>a language that isn't a horrible clunky monstrosity
>Java

So your argument is that C++ is bad for performance because some of its features do not perform optimally. If you're correct, this means one of two things

>C++'s implementation of said features is shit
or
>C++ programmers do not understand the performance implications and tend to use features that slow things down

Which one is it?

>I'm totally not paid by oracle
3 beans have been added to your account

disregard that i suck cocks

It's a nice language, tons of great features, cleaner syntax than C++, (almost) optional GC.

Unless I'm missing something VS code doesn't have the drag and drop application stuff, are there add ons for that?

Learn to read faggot. He's talking about a JVM language, not Java itself. He even called java a horrible clunky monstrosity

>i totally hate java too guys! but those libraries, i'd pay for those

BUMP

BUMP

But there are lots of good libraries :^)

[250..750] `forM_` ((\x ->removeFile (show x ++ ".png"))

We won't do your homework today pajeet, sorry

Hey, I'm less likely to be sued by oracle than google.

Either way, I'm making a Tinder auto-swiper next (which actually swipes instead of clicking). Reusing code from the fishing bot should be straightforward.

is that haskell?

i dont have that installed

could you do it in python or perl ?

Idk, most likely just take the first day it started, subtract it by the day that the command is called

No.

thoughts on sourcemaking.com?

Never heard of it before but it's shit and you shouldn't use it

for n in range(1, 101):
if n % 15 == 0:
print "FizzBuzz"
elif n % 3 == 0:
print "Fizz"
elif n % 5 == 0:
print "Buzz"
else:
print n
raw_input()

Am I good enough to get a job now?

Rewrite this to use the writer monad

>still uses python 2
>stuck in the past
>"Don't call us, we'll call you"

>Am I good enough to get a job now?

No. write a program that can detect infinite loops in a program

>>"Don't call us, we'll call you"
('quote Who's quote are you quoting?)

The interviewer

This

it's a common interview question, if you can't do it you may as well not apply

I'm only here to share big laffs m8s
pls no bully
Would you like to see another of my scripts? It's sure to give you a big laff of your own.

s4s write programs as well as they tell jokes

not very well

In python, is there a way to me to extract values from a string using a left and right boundary?

value = find(string='how would one find this',
left_bound='how',
right_bound='one')
// value = ' would '

So I'm moving into management my dudes.

I was ready to fucking kill myself if I had not been promoted.

So there's one more programming position open out there in the American economy for you younger guys.

>In python, is there a way to me to extract values from a string using a left and right boundary?

yes. just a write a function that does that

exactly
usernumber = raw_input("enter a number and I'll tell you if it is a prime number or not. Use only integers.")
number = int(usernumber)
def isPrime(num):
if num == 2 or num == 3 or num == 5:
print str(num) + " is a prime number."
elif num % 5 == 0:
print str(num) + " is not a prime number."
elif num % 3 == 0:
print str(num) + " is not a prime number."
elif num % 2 == 0:
print str(num) + " is not a prime number."
else:
print str(num) + " is a prime number"

isPrime(number)
raw_input()

feast your eyes on my monstrosity

Runtime perf is the only perf that matters and templates are zero overhead when it comes to runtime.

>fucks over your instruction cache
This says nothing, doesn't even make sense, I'll fuck over your mother.

49

trying to do this on arduino. how do I make it so I press a momentary button and each time it cycles through an array of functions, where the functions are driving my motors? Pretty much presets for motors

ebin :DDDDD

you just fucking program it it's not that hard

fixed :^)
usernumber = raw_input("enter a number and I'll tell you if it is a prime number or not. Use only integers.")
number = int(usernumber)
def isPrime(num):
if num == 2 or num == 3 or num == 5:
print str(num) + " is a prime number."
elif num % 7 == 0:
print str(num) + " is not a prime number"
elif num % 5 == 0:
print str(num) + " is not a prime number."
elif num % 3 == 0:
print str(num) + " is not a prime number."
elif num % 2 == 0:
print str(num) + " is not a prime number."
else:
print str(num) + " is a prime number"

isPrime(number)
raw_input()

Are there any books, videos, or sites (even blogs) out there that look into good code and break down - line by line or portion by portion - what is being done and why it's being done the way it is?

I'm looking for great examples of code that also teach you the why behind it. Language doesn't matter.

wow
this passes all the unit tests

121

>Unit tests
>Not formally proving your programs to be totally correct

that sounds too much like academics and not enough like Enterpriseā„¢

Enjoy your incorrect programs.

Now your just making me sad
perhaps its time I gave up

docs.oracle.com/javase/8/docs/api/index.html?overview-summary.html

>four thousand two hundred and forty (4240) classes

usernumber = raw_input("enter a number and I'll tell you if it is a prime number or not. Use only integers.")
number = int(usernumber)
def isPrime(num):
if num == 2 or num == 3 or num == 5 or num == 7 or num == 11 or num == 13 or num == 17 or num == 19 or num == 23 or num == 29 or num == 31:
print str(num) + " is a prime number."
elif num % 31 == 0:
print str(num) + " is not a prime number"
elif num % 29 == 0:
print str(num) + " is not a prime number"
elif num % 23 == 0:
print str(num) + " is not a prime number"
elif num % 19 == 0:
print str(num) + " is not a prime number"
elif num % 17 == 0:
print str(num) + " is not a prime number"
elif num % 13 == 0:
print str(num) + " is not a prime number"
elif num % 11 == 0:
print str(num) + " is not a prime number"
elif num % 7 == 0:
print str(num) + " is not a prime number"
elif num % 5 == 0:
print str(num) + " is not a prime number."
elif num % 3 == 0:
print str(num) + " is not a prime number."
elif num % 2 == 0:
print str(num) + " is not a prime number."
else:
print str(num) + " is a prime number"

isPrime(number)
raw_input()


foolproof