/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous Thread:

Other urls found in this thread:

aframe.io/
backbonejs.org/docs/todos.html
twitter.com/SFWRedditVideos

(defn -main
[composite]
(def vectormap [])
(loop [divisor 1]
(if (< divisor composite)
(if (integer? (/ composite divisor))
(do (def vectormap
(conj vectormap
(hash-map :divisor divisor :number (/ composite divisor))))
(recur (inc divisor)))
(recur (inc divisor)))
(print vectormap))))

Didn't even get a reply last thread, I need to get this to work... please

It works in Cider but it refuses to run after it's been compiled or to run in leiningen

I'm mainly working on a project for university.
We have to translate a play to virtual reality utilizing the aframe.io/ framework.
It's going good since I don't have to do any of the modeling and only the coding part.
First time javascript, so please tell me if anything in pic related is bad practices

What's this mess supposed to be?

Need help with something:
Let's say that I have a State class, think FSM, and let's say that I want to have the transitions as a separate class for reasons.
Now, where would you create that Transition class exactly? I know I want it to have independent instances of it, but I also know that they are not going to be used by anything else than State objects to begin with. So,

1) just create a Transition class in the project and don't give a fuck?

2) create the class inside State for the reasons I mentioned, but somehow doing a -new State.Transition- to create a new instance doesn't feel sexy

3) create a class named StateTransition, that way anyone, understand only me when I come back to the project later, will know at a first glance that this class is supposed to work with the State one. But classes that way can get awfully verbose like : ThisThatThoseThem.class

>let's say that I want to have the transitions as a separate class for reasons.
Just don't.

Less is more.
This is the real thread now

Care to explain why?
I can think of at least one reason why I went this way, to have modules that can be plugged here and there rather than having transitions permanently attached to something:

class Transition
field entryState;
field exitState;
bool Logic()

>tfw POSIX socket programming

What's the best configuration language?

Java properties files?
INI files?
JSON?
YAML?
XML?
TOML?

JSON is objectively better than XML, that must is clear

this is subjective but JSON
also, XML needs to die

Looks like Clojure.

you're mixing jquery w/ pure javascript syntax

#23 you can simplify to
$('#box).on('mouseup', function(evt){ /* your code */});


#29 too
$('my-cursor.on('mouse-up', function (evt) { /* your code */ });

fuck i messed up the quotes, but you get the idea

I'm putting the final touches on a lot of changes I've been making to Ivy, my taggable image viewer. Lately I've been working on not just recording the tags for an image in a database, but also recording the taglist as a dc:subject entry in XMP metadata in the file itself.

I think I might add tables in the database to allow for searching through the XMP as well. Like, search for all images with the tag dc:publisher="user-supplied-name". Well, maybe not. Sounds like a whole lot more work and an incredible increase in size for the database.

"""functional""" programming

kk. thanks

jQuery performance is pretty good though right?
I'm scared of it performing poorly since it's going to run with Google Cardboard VR.

Are there any other good practices I can keep in mind to not fuck up everything performance wise?

See

Why y'all fags always bash XML?, I mean they're better options to serialize/marshalling data like JSON, but I think XML it's really usefull when describing structured trees or nodes, take for example: html, xaml, or wsdl.

>describing structured trees or nodes
A subset of XML would be good for that. The whole thing is way too complex though, and any parser for it has to handle the whole spec, not just the subset you happen to be interested in.

>and any parser for it has to handle the whole spec, not just the subset you happen to be interested in.
Ohh, didn't knew about this.

I prefer the stronger defined subsets of XML. Also it doesn't bloody help that 90% of XML libraries are garbage.

Woah this is one of those fancy PNGs that loads from low resolution to high

Same fambly, I love it. Check out Beej

It's really not that bad. It's verbose, but that's not a problem for me or 90% of other programmers that aren't stupid since it's easy to generate automatically from your programming language.

Can someone explain why this doesn't work?

#include

struct Person {
char name[50];
int age;
} joe;

int main() {

//this works
//char name[50] = "Joe";

//this does not
joe.name = "Joe";
joe.age = 20;

printf("%s %d\n",joe.name, joe.age);
return 0;
}

joe.name is trying to change where the array points.

>transferring several personal lisp libraries to F#

Some things are really nice, some things are awful. One of the bad parts in Lisp was debugging into run-time errors (some errors don't give reference to line-numbers and calling-functions unless specified with contracts so I'd get an error in a 500 line module like "first: error, expects list, given '()" and have to manually check every function involving a list, i.e., all of them), which don't happen anymore due to strong typing. One of the problems I have no though is getting the typechecker to appropriately recognize the nested series higher-order functions that are super-easy to create in a dynamically typed language like a lisp and "just work" but hellish to describe in a strongly typed, more static, language like an ML.

type Line = int -> int -> bool -> int -> int -> Posn -> bool
let shape lines point = ...
> expected list int -> bool -> int -> int -> Posn -> bool> Posn but got 'a (generic type) instead
>expected 'a but got 'a list instead
>expected ....

I tried to make a danbooru randomizer and I ended up jerking it to Haruhi.

change
char name[50];

to
char *name;

strcpy

>first: error, expects list, given '()"
Yep, I've encountered that many times in the past. Today, even. Typed Racket would probably alleviate that problem, but that's basically like just using contracts for everything.

Why does it this work? I don't think I understand C strings. Are they arrays of chars or a char pointer? Shouldn't char * point to an address not a string literal?

why do people rarely talk about the differences of the IEC standard when naming quantity of bytes?

in my university classes I've never heard anyone talking about kibibyte, mebibyte, gibibyte, etc.
they always use the SI prefixes as if they meant pow(2, n*10)

The split didn't really exist until hard drive manufacturers started using kilo-, and mega- to mean 1000 instead of 1024. People were pretty pissed when they found out what they thought of as a 1024-byte drive was actually coming up short, but the manufacturers never changed their ways and it just sort of stuck.

because it's trivial; i learned about it when i was 9 and haven't looked back

I'm addicted to buying computer science books. I already have some compiler books, the dragon book, clrs algorithms, sedgewick algorithms. What should I buy next to add to my collection?

...

>addicted to buying computer
Why you aren't addicted to read them instead? baka desu senpai.
btw, when I land a job, I'll buy the ones I've read so far, I bet that'll make me look smart.

>Why you aren't addicted to read them instead?
I dont know I just want to have a nice reference collection. But you're right I should read them more.

it's not trivial if you have to document your stuff and the wrong prefix can be misleading to your co-workers or clients. that's why people create standards.

How about you read them instead you mongoloid

1024^3 -> GiB
1000^3 -> GB

what's so hard?

you are the one talking about it being "hard".

i am talking about it being not hard, comparable to trivial

"Difficult" and "trivial" aren't antonyms.

"hard" and "difficult" are not synonyms
anyway, why are you arguing with me about language semantics
it should have been apparent to any normal person that i was meaning to say:
1024^3 -> GiB
1000^3 -> GB

this is fairly trivial.

>why are you arguing with me about language semantics
because apparently you aren't following the standards of the english language.

triv‧i‧al /ˈtrJviəl/ ●●○ adjective
not serious, important, or valuable

see? standards aren't trivial.

you are misinterpreting me.
it is trivial because there is virtually no problem if the units are included and that the units are correct
otherwise, i do agree it is fairly problematic if the units are either omitted or used incorrectly

what is the point of denormalized numbers when you could just use a larger precision?

thanks friend

The problem with this idea is that the transition logic is really part of the state's logic. Now, if the states themselves don't do anything, this is okay, I guess. But I don't see how that would be a particularly useful situation.

today i wrote a script that read files in a directory but only reading the 5 first characters, then i stored it in a db. The reason i trimmed the strings to 5 characters was because in the table i stored it in there was an "itemNum" field that matched with the first 5 characters, digits in this case, of the file names, and i inserted the trimmed file name data into a "path" field. So now each itemNum has it's own unique "path" which allows me now display the correct picture next to each itemNum i display.

LONDON
O
N
D
O
N

>mfw that's my code in the screenshot

I've seen employment tests in which it was asked
>how many bytes is a MB?

>std::srand instead of std::random_device, std::generator, std::mt19937, and std::bind
>char *fileDest instead of char * fileDest
>while((...))
so the moral is traps suck at programming?

so you say 1000^2 you retard

can you even read? refer to

if you're really this autistic, say 1MB = 1000^2B and 1MiB = 1024^2B
if the question asks for MB, give MB

it was a multi-choice test, the first phase of the employment test.

do you have any reading comprehension problem? I'm not asking about the meaning of MiB or MB. I'll write my question again for you
>why do people rarely talk about the differences of the IEC standard when naming quantity of bytes?

when I say
>they always use the SI prefixes as if they meant pow(2, n*10)
I'm talking about teachers with phd and decades of experience. it really bothers me that they never talked about the IEC standard.

>I'm talking about teachers with phd and decades of experience. it really bothers me that they never talked about the IEC standard.
just correct them obsessively if you care that much

jquery is pretty good. i'd avoid the plugins like jquery-ui, where you're more likely to run into lag

>Are there any other good practices I can keep in mind to not fuck up everything performance wise?
yeah i noticed you're doing some kind of animation. i would try to find something that uses html5 or svg for animation (like paper.js).

generally you want to avoid shifting around the DOM too much

Currently trying to learn backbone js.
It looks nice and easy in theory, but when i got to the point where I had to use multiple models i started to lose it.
Losing interest that is.
Their tutorial page is kinda shit.
Provides a brief explanation on the left of the code, but doesn't provide a download link for the app to test and manipulate.

backbonejs.org/docs/todos.html

Am I dum Sup Forums?
>inb4 I just got the hang of Java-scripting last month

redpill me about python

shit language for children

I want to make a program where you add your notes with some wizard that extracts structure from them, and than it can basically generate another big database/textfile to use as a recommendation machine. basically be your secretary , but do this in a way that even top tier NSA employees would think is safe enough and not cucking.

there are huge technical problems, for example you would need to test this shit to hell and back, not a good project for a single dude, but this is my dream.

>not a good project for a single dude
You can do this in one day. Search "Malkov chains" on your favorite engine.

what said but the other way around (read our posts and bet the judge)

At least it's not WinAPI.

If you get stuck at one point in object oriented design, it's usually better to go back multiple steps.
Do you REALLY need a State class?
Why don't just stop a layer above, at the StateMachine level?

C is dead.
C++ is dying.
Java is getting old.

What will the next big thing be?

Hi, does anyone have that image where you roll and you get a programming challenge to do? I'm out of ideas on what to make atm.

>Still posting in the shitty fag off-thread
>Not letting it die
Kill you'reselves.

Something more functional but without GC

Is there a common superclass for String and boolean, other than Object?

Why would there be?

Dunno.
So is there a way to specify that an Object may be either a boolean, or a String?

in Haskell you would do
data SoB = Str String | Bl Bool
Java doesn't have unions, so it's kind of awkward. You'll need to make it yourself.

class SoB;

class Str extends SoB { string ... }
class Bl extends SoB { Boolean ... }

Yeah, thats awkward indead. I willrrather not use it and find a way around.
Thanks.

Super mario ripoff... i suck tho

afaik you cant just make boolean and String extend a custom class.
would be multiple inheritance and wrong in many other ways.

That's not what I'm saying, I'm saying new classes that have string or boolean as members

Ah, got it.
That would still be flawed in the sense that you would have to use a getter each time, to get the value stored in the class.

Bout to buy this, can I still program with it?

>hipster keyboards

Sure

One button is enough to do anything. Not very convenient though.

Won't I miss any buttons

That's okay, mine has FN hotkeys as well so I won't be missing anything

>Not NOT operator
No.

So long as you're using vim or another editor with hjkl navigation you should be fine

see

I would just use a .cfg file with the variable name on the left and the value on the other side, so INI would be the closest thing.

However, for actually transmitting data and not just settings, JSON beats everything out.

>no dedicated arrow keys
You can get it to work on any editor, but I use mine a lot
>no page up or page down
Depending on the editor. I scroll around my code with M/C-Up and M/C-Down in Emacs (meta key maps to scrolling line by line).
>no squiggle line
I use temporary files too often to live without mine.

tl;dr choose a standard keyboard

Trying to figure out how to set up validation with IDataErrorInfo and ValidationRule in WPF without any code behind

Does anybody here run a live stream of coding? I saw some while browsing YouTube, and I thought Sup Forums ought to have one.

If nobody does, would anybody be interested in seeing one if I streamed it?

>C is dead.
>C++ is dying.
>Java is getting old.

um, what?

>C is dead
no
>C++ is dying
no
>Java is getting old
being old isn't a bad thing

Email is old, but that doesn't make it not important. If anything, it makes it even more important because it is a standard that pretty much everybody uses.

There is livecoding.tv, but its laggy in my location.

I was looking for one that somebody on Sup Forums runs, but thanks anyways