/dpt/ - Daily Programming Thread

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

Attached: K&R himegoto waifux2.png (1000x1400, 1.31M)

Other urls found in this thread:

wiki.haskell.org/User:Michiexile/MATH198
android.jlelse.eu/google-just-terminated-our-start-up-google-play-publisher-account-on-christmas-day-5cb69a454da0
youtube.com/watch?v=J5Ug3Cr8RUE
upx.github.io
youtube.com/watch?v=Ih1ZWE3pe9o
all-things-andy-gavin.com/2011/03/12/making-crash-bandicoot-gool-part-9/
swtch.com/~rsc/regexp/regexp1.html
pastebin.com/aLnrDNf1
en.wikipedia.org/wiki/Overview_effect
youtube.com/watch?v=0TZd95BCKMY
docs.oracle.com/javase/7/docs/api/java/lang/Class.html#getMethod(java.lang.String, java.lang.Class...)
docs.oracle.com/javase/7/docs/api/java/lang/reflect/Method.html#invoke(java.lang.Object, java.lang.Object...)
twitter.com/SFWRedditImages

Name one modern useful project written in C that isn't the kernel or a unix util.

nginx

fuck off with your gay shit

>when you take the pair programming while crossdressing meme too far and you both go on a date for some quality peer bonding and you get lost in the moment and kiss him?!? >///

Attached: kissu8.jpg (1280x1815, 441K)

>Initial release 4 October 2004
>modern
Doesn't count. If it wasn't released during the JS/Rust boom of 2014+, it's not a useful metric.

>logical fallacies
>shitposting
Go back to your containment site.

Attached: mtgp.jpg (1600x1064, 417K)

encapsulation is for fucking pussies
make everything a struct

Recommend me some quick material to learn basic AI, I want to prototype some shit in python and see if I want to continue

Trips of truth right here folks.

Name a JS/Rust program that isn't total shit.

What language should I learn?

wtf...

Nevermind guys I decided I'm going to learn C++.
Wish me luck

google chrome

>tfw your compiled binary jumped from 1.7mb in size to 7.8mb when importing reqwest and regex

What is encapsulation exactly?

Google Chrome is written in C++.

Please don't learn c++. It's literally the worst language. Learn C# instead.

how do you know? it's not even open source

C# is a botnet
learn haskell instead

>He don't know category theory
wiki.haskell.org/User:Michiexile/MATH198

Considering that it uses the same engine as Chromium...

JavaScript rocks!

Attached: js_rocks.png (1433x779, 473K)

I have a function that deals with some objects managed by smart pointers. There's also some raw pointers flying around.
Is it a smart idea to just initialize a copy of those smart pointers at the start of the function and leave them there? I won't be using them for anything, I just want to guarantee the objects they manage stay alive for the scope of the function.

Will the compiler optimize them away or something?

C++26 is the most powerful programming language on Earth.

Attached: 1520403923913.png (659x752, 579K)

Android question
I start foreground service from mainActivity and close the app
Now every few minutes when I use smartphone, mainActivity just randomly popups, any idea why?

Attached: 1527018510582.png (2048x2772, 2.29M)

roll

Lets say you have a random string S over an alphabet A. You also have a dictionary D consisting of some random words W1, W2, W3, ... over the same alphabet A.

How can you find a factorization F of the original string S so that it has the maximum number of matches to the words in D?

Like:
S: abcbbcab
W1: ABC
W2: BC
W3: AB
W4: CAB

F1: ABC + b + BC + AB -> 3 matches
F2: AB + cb + BC + AB -> 3 matches
F3: ABC + bb + CAB -> 2 matches, no good

3 and 5 are the cutest.
6 also cute.

Study lifecicle android, android apps need explict close,if not just sleep in memory, foreground service maybe reenter mainActivity.

I want to write an emulator.

Beyond rereading up on the Von Neumann model of computers, and the spec of the system I am trying to emulate, what other things might come in handy? Any tips or tricks? Will OpenCL help me with GPU acceleration?

in that case qutebrowser is also written in c++

Are there any good alternatives to learning c besides reading K&R?

a good way to learn C is to write programs in C.

Post code.

>not prefix free
>can't code "aa"
That a total difficult ho

Google developer account terminated. S02E12 a startup got fucked edition.
android.jlelse.eu/google-just-terminated-our-start-up-google-play-publisher-account-on-christmas-day-5cb69a454da0

>Mobile development
That shit is basically just as bad as webdev, but even more of a walled garden.
They got what they deserved.

>Despite this I thought that I had been in the past smart enough (3 years before all this happened)
Translated
>oh no my sins finally caught up with me, I was finally caught breaking the rules but how could this be my own fault?

Social amnesty through time, I get it.
Responsibility amnesty through time, no.

Eureka ! Go for a non-deterministic finite automation. This is basically a regex matching, so check the complexities of that on wiki.

Right now I'm doing a "shortest dominated" kinda thing where I get the shortest W from D, substitute it as a character outside of alphabet A. So, for W2: BC it becomes

W2: %
S: a%b%ab

and then I work my way to the longer words in the dictionary. It works, but not for all inputs for some reason.
I'll look into NFA but can't see how I'll implement it in this case.

Shit looks kinda convoluted and not really workable tbqh, whereas if you just fed that into any NFA regex engine it would sort that out in time O(length of S). Geniuses have solved the regex problem for us a while ago so it's probably simplest to just read their papers (which are very accessible iirc) and implement the relevant bits of it.

>multiple ancient societies had better notations for human computation than today
This really messes with my head when I consider how little (in volume, not in frequency) they probably had to calculate.
However it makes me appreciate functional programming somehow.

Why did the Greeks even care about an infinite list of prime numbers.

Attached: Ybc7289-bw.jpg (338x315, 20K)

Any pointers where I should start? Kinda new to this.

what am i looking at exactly?

Babylonian notation.
youtube.com/watch?v=J5Ug3Cr8RUE

Haskell is useless and academic only.
Learn Rust instead.

>what's upx

not much what's upx with you

delete this

i almost laughed
good pun user

Attached: 1479343445650.jpg (592x480, 130K)

upx.github.io

Oh, I got it now.

I defined x as "" btw

I want to lift Nico.

Thank you.

This is not true. I write games in Haskell and it is very performant.

Maybe it's better for them considering Android will die soon.

youtube.com/watch?v=Ih1ZWE3pe9o

Attached: WE.jpg (2200x1668, 2.24M)

Take it back Anonymous.

no

Attached: namefagging.png (308x144, 5K)

>games
>GC'd language
>lazy evaluation
>perfomant
Stop telling lies, user.

Attached: doubt.png (419x238, 84K)

Attached: me irl.jpg (686x441, 210K)

ok

Crash.
Bandicoot.

For most 2D games and less resource-intensive 3D games, it's totally fine to use Haskell.
You cant write a triple A title in Haskell, just like you can't (or shouldn't...) write on in C#. I think Haskell could happily replace C# in the indie games industry.

Thanks Anonymous.

Attached: me irl now.jpg (686x441, 116K)

cybermaid = best maid

no u

What, but crash was written in a scheme-ish language that IIRC compiled into C. It wasn't even functional.
all-things-andy-gavin.com/2011/03/12/making-crash-bandicoot-gool-part-9/

>what's unity

Looks like I FUCKED up.

>I think Haskell could happily replace C# in the indie games industry.
Never gonna happen, it's extremely tedious to do copy paste oriented programming (or as I’ve recently taken to calling it, CPOP) in haskell.
Also anyone who wrote a fizzbuzz in any mainstream language can start to write some C# right away.

Unity isn't used for many AAA titles. The subtext of my post was that Haskell should replace C# in Unity.

swtch.com/~rsc/regexp/regexp1.html
I'm thinking of this guy. Just skip the performance comparison parts. I'd that's not your taste tho maybe wiki or random googling could do it.

>Haskell should replace C# in Unity
Actually I'd like that became true, because what keeps me from actually diving into Unity is that I have the only option of using C#. They even ditched JS away.

I implemented that algorithm last year. It's a pretty simple recursive construction to get the NFA ( under 300 lines for my bare-bones version).

>GC'd language
so is C#
>lazy evaluation
you can enforce strictness where it matters
>inb4 it's too hard to reason about performance
anything is hard if you're ignorant

haskell compiles to Cmm

pastebin.com/aLnrDNf1

I am working on this. IN C language
I have to manage a square matrix (not bigger than 12x12)

- I need to create it from keyboard input (done)
- create it by taking data from a file (I do not know how to do it)
- transpose the matrix (done)
- print the matrix (done)

Code is above. Its in italian but names are very similar to englando.

I know basic fopen, fwrite and such. But I do not know how to read data from a file. It's not specified if I have to write on file, or have a file already written (if so, how formatted??)

I am doing exercises to make a C language exam in uni but I can't do this. IF you wanna help I thank you.

Okay I'll look into it, thank you.

Are you still ? If so my guess is that they expect you to use that which you learned last year, which means we've found the solution. Fantastic!

>Mathematics (from Greek μάθημα máthēma, "knowledge, study, learning") includes the study of such topics as quantity,[1] structure,[2] space,[1] and change.[3][4][5]

I'm having some kind of epiphany right now at the idea that math is basically the transcription of concept, any concept, into physical record.

en.wikipedia.org/wiki/Overview_effect
youtube.com/watch?v=0TZd95BCKMY

In reality, I'm just sleep deprived though.

I mean if you do not have the instructions about how the data file looks like then how in the fuck can anyone help you? Do you expect me to magically figure out your prof's mail and ask him about it?

These are great! Thanks for sharing.

Haskell has a lot of problems. I knew one of the leading Haskell community people who built and ran the websites all the Haskell people used; and he was sorting array and it took 60 GB of ram and he could not even predict how much ram a simple operation would take; and something that took 1 ms in C would take minutes in Haskell and it took like 1 meg of ram in C and in Haskell, it took gigabytes of ram and was crashing the server. I lost all interest in Haskell, once I learned that the top Haskell people did not even understand Haskell or how it did garbage collection or how much memory an operation would take, or even what the program was doing.

Basically, all of the Perl programmers who wrote shit code, lost their jobs to PHP and then Python developers; then the worst Perl programmers who could not use a sane language, moved from Perl into Haskell.

nice copypasta

On a Java program I'm modifying there's a method that takes a .class as a parameter.

I've modified that class (another file) with a print method for one of the variables inside. How would I call that method if I'm just passing the .class into a function and that's it?

docs.oracle.com/javase/7/docs/api/java/lang/Class.html#getMethod(java.lang.String, java.lang.Class...)
docs.oracle.com/javase/7/docs/api/java/lang/reflect/Method.html#invoke(java.lang.Object, java.lang.Object...)
learn to use docs

0/1
try harder

So when I pass the .class everything in the class is initialized for the whole program to access?

We are learning cpp next semester. What am i in for?
I know some C from my previous course, but i'm far from good.

you'll probably just be learning C with classes which sucks but is at least easy to understand if you know Java aswe ll

When the class is loaded static initialisation is performed.

what's the simplest library for rendering ligatures?

Even if the class isn't static in the file? It's just public class

My prof does not answer. She provided an example which is not even made by her and does not work...

I want to make my own RotMG from scratch.
What language should I learn?

Attached: 15461776083850.png (593x595, 20K)

Lisp is the most powerful programming language.

dark and eldritch tongues

is the method static?
you can't actually put the static qualifier on a top level class, only inner classes

And I'm free, free fallin'
Yeah I'm free, free fallin'
use std::collections::HashMap;
use std::io;
use std::io::BufRead;

struct Counter {
items: HashMap,
}

impl Counter {
fn new() -> Counter {
return Counter {
items: HashMap::new(),
};
}
fn add(&mut self, st: &str) {
match self.items.get_mut(st) {
Some(x) => {
*x += 1;
}
None => {
self.items.insert(st.to_owned(), 1);
}
}
}

fn render(&self) {
for (key, val) in &self.items {
println!("{}\t{}", val, key);
}
}
}

fn using_read_line_with_reuse(c: &mut Counter) {
let st = io::stdin();
let mut stdin = st.lock();
let mut line = String::new();

loop {
line.clear();
let r = stdin.read_line(&mut line);
match r {
Ok(0) => break,
Ok(_) => {
c.add(line.trim_end());
}
Err(err) => {
println!("{}", err);
break;
}
};
}
}

fn using_read_line(c: &mut Counter) {
let st = io::stdin();
let mut stdin = st.lock();

loop {
let mut line = String::new();
let r = stdin.read_line(&mut line);
match r {
Ok(0) => break,
Ok(_) => {
c.add(line.trim_end());
}
Err(err) => {
println!("{}", err);
break;
}
};
}
}

// uses lines() iterator
fn using_bufread_lines(c: &mut Counter) {
for r in io::stdin().lock().lines().filter_map(Result::ok) {
c.add(r.as_str());
}
}

fn main() {
let mut c = Counter::new();
// using_bufread_lines(&mut c);
//using_read_line(&mut c);
using_read_line_with_reuse(&mut c);
c.render();
}

Attached: 1545908128690.jpg (567x699, 87K)