[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 320
Thread images: 58

File: 1485002137932.png (704KB, 2015x2204px) Image search: [Google]
1485002137932.png
704KB, 2015x2204px
What are you working on, /g/?

Old thread: >>59233370
>>
First for Idris
>>
C == God
>>
rewriting the haskell kernel in linux
>>
>>59235813
false
>>
I want to use printf to debug my ncurses program

Can I set ncurses to open in a new window?
>>
File: 1488596030334.jpg (157KB, 1070x1070px) Image search: [Google]
1488596030334.jpg
157KB, 1070x1070px
QUICK, NAME A GOOD INTRODUCTORY BOOK ON COMPUTER GRAPHICS.
>>
>>59235840
book with a tiger on the cover
>>
File: 1460408499126.png (23KB, 600x850px) Image search: [Google]
1460408499126.png
23KB, 600x850px
>>59235813
C==3
>>
If we represent the C programming language as the string "C", then what is C++? Well, C is a char*, so C++ increments its address by sizeof(char). C is now the empty string, and the result of the expression is "C".

We can therefore say that C++ is the new C, and that it has destroyed C.
>>
>>59235864
>Making the same joke for 30 years
Sad!
>>
>>59235864
Post-increment returns the old value and later increments.
It means we will program in old C with C++, because we don't know the value of C++.
>>
File: 1462302954820.jpg (79KB, 1280x720px) Image search: [Google]
1462302954820.jpg
79KB, 1280x720px
C is trash.
>>
File: d lang.png (909KB, 1280x720px) Image search: [Google]
d lang.png
909KB, 1280x720px
>>59235789
excellent image
>>
>>59235905
And yet it's better than Go.
>>
>>59235789
>>59235813
>>59235861
>>59235864
>>59235895
>>59235905
>C(ancer)
>C(ancer)++
Fixed that for you.
>>
What's with all the anti C shilling lately?
Was it too hard for you to understand or something?
>>
>>59235918
>t. frustrated memelang programmer
>>
>>59235861
it looks like a dig XD
>>
>>59235905
anta baka
>>
>>59235936
Who are you quoting?
>>
>>59235910
>better than Go
Well it's not a hard thing to be.
>>
>>59235930
when I was little my uncle would close the curtains and make me do pointer arithmetic
>>
File: index.jpg (5KB, 192x185px) Image search: [Google]
index.jpg
5KB, 192x185px
started learning programming (java) as a hobby few days ago. pls no bully
i know it is baby stuff but here is program that makes a triangle of odd numbers im pretty proud
public static void main(String[] args) {
for (int line = 1; line <= 5; line++) {
for (int j = 1; j <= (line * -1 + 6); j++) {
System.out.print("-");
}
for (int k = 1; k <= (line * 2 - 1); k++) {
System.out.print(line * 2 - 1);
}
for (int j = 1; j <= (line * -1 + 6); j++) {
System.out.print("-");
}
System.out.println();
}
}


output:
-----1-----
----333----
---55555---
--7777777--
-999999999-
>>
>>59235951
>t. frustrated memelang programmer
>>
>>59235966
Who the hell are you quoting, redditor?
>>
>>59235960
stupid frogposter no wonder you chose a shitty language
>>
>>59235960
Congrats anon!
>>
>>59235960
>line * -1 + 6
6 - line
>>
>>59235960
Good for you!
>>
>>59235979
>t. frustrated memelang programmer
>>
>>59235999
Who the hell are you quoting, redditor?
>>
>>59235864
C++ stands for C Cross Cross, obviously
i heard the author was heavy inspired by the ideas of cemetery, god and duality
>>
>>59235909
I can't wait to start posting this ironically
>>
>>59235959
Pointer arithmetic is simple shit.
>>
>>59236010
That's HolyC though.
>>
>>59236007
>t. frustrated memelang programmer
>>
File: skilled.webm (3MB, 720x404px) Image search: [Google]
skilled.webm
3MB, 720x404px
/dpt/-chan, daisuki~

Ask your favorite programming literate anything (IAMA)

>>59235930
C is an obsolete programming language for the programming techniques of the past.

>>59235840
http://www.scratchapixel.com/

>>59235813
God of the mediocre

>>59235789
Thank you for using an anime image.
>>
>>59236017
not when you're three, it's dark, and your uncle is shouting
>>
>>59236024
whom are you quoting tho?
>>
>>59236042
>C is an obsolete programming language for the programming techniques of the past.
You mean techniques like writing performant code?
>>
File: 1488646807083.png (201KB, 2015x2204px) Image search: [Google]
1488646807083.png
201KB, 2015x2204px
>>59235789
your png is now optimized
>>
>>59236042
What should I use to draw pictures with instructions like box(100, 200)?
>>
>>59236055
>t. frustrated memelang programmer
>>
Good job /g/ out of 41 replies there's a single thread-related post. >>59235960
>>
>>59236043
Yes it is.
>>
>>59236058
What's the trick?
>>
>>59236057
Did you know that, with strong type systems, safety, efficiency, and maintainability go hand in hand?
>>
I'd be perfectly happy to use things other than C if they offered comparable performance.

Meanwhile I feel no urge to transform my 800,000 CPU hour problems into 4,000,000 CPU hour problems.

t. HPC programmer
>>
>>59236088
Get rid of the soul
>>
>>59236092
Or you could just write the efficient code in C, without having to wait for the promised "smart compiler" that we're told will be able to produce code equivalent in performance if we only wait a little while longer (they've been saying that for decades now)
>>
File: kek.png (26KB, 303x129px) Image search: [Google]
kek.png
26KB, 303x129px
>>59236074
Who are you quoting?

t. C programmer

>tfw captcha is pepe
>>
>>59235852
Fundamentals of computer graphics by Peter Shirley.


Is this a good book?
>>
>>59236088
magic

post one so i can reduce the file size
>>
>>59236102
Ada? Pascal?
>>
>>59236129
>t. frustrated memelang programmer
>>
File: ride.webm (3MB, 720x404px) Image search: [Google]
ride.webm
3MB, 720x404px
>>59236062
Processing

https://processing.org/
http://processingjs.org/
https://p5js.org/
>>
>>59236102
Fortran though.
>>
File: jesuslang.jpg (496KB, 1375x861px) Image search: [Google]
jesuslang.jpg
496KB, 1375x861px
C is the language that was promised
i will burn at the cross every single one of you heretics
come back to the dark side
>>
File: 1482735454352.png (818KB, 1280x719px) Image search: [Google]
1482735454352.png
818KB, 1280x719px
>>59236141
I don't want any colors got reduced
>>
>>59236149
Fortran serves the good job of number crunching.
Nothing other it doesn't seem to serve good, though.
>>
>>59236092
>with strong type systems, safety, efficiency, and maintainability go hand in
This has never been shown to be the case.
>>
File: 1488648093668.png (731KB, 1280x719px) Image search: [Google]
1488648093668.png
731KB, 1280x719px
>>59236160
not much reduction in file size
>>
File: 1480546174720.png (102KB, 1000x1071px) Image search: [Google]
1480546174720.png
102KB, 1000x1071px
>>59236199
In what it got reduced then?
Is it some imagemagick?
>>
>>59236125
>>59236185
http://cantrip.org/rust-vs-c++.html

>The Rust program turned out close to the same length, but only half as fast. As I made the Rust code more idiomatic, it got faster.
>In 90 ms on modern hardware, it performs some 190 million basic operations (at an astonishing 1 cycle per iteration), filtering to 5 million more-complex operations (at an astonishing 28 cycles per bit). Meanwhile, the Rust program does about the same operations in about the same time: just a few percent faster or slower on various hardware. Many variations that seemed like they ought to run the same speed or faster turned out slower, often much slower. By contrast, in C++ it was hard to discover a way to express the same operations differently and get a different run time.

And this is just crunching, too. It doesn't go into memory management or threading, at which Rust blows away C and C++.
>>
C is the language of Christ.

D is the language of the devil.

Python is the language of the serpent.

Be led not into temptation.
>>
>>59236102
How much does a CPU hour cost? Two cents? Congratulations, you have saved (3200000 * $.02 = $64000) six months of a competent programmer's salary and are now stuck with a shitty unmaintainable C codebase.
>>
Coding a genetic algorithm to control the thrust on the engines of a spacecraft (2D) so it can go in a given direction.
Tried with a simplex solver but to dumb to get it to work.
>>
File: 1488648342140.png (41KB, 1000x1071px) Image search: [Google]
1488648342140.png
41KB, 1000x1071px
>>59236231
double bypass on this one
>>
File: 1485633700505.png (661KB, 600x600px) Image search: [Google]
1485633700505.png
661KB, 600x600px
>>59236280
Color indexing?
Is it the secret?
>>
>>59236311
He's using google's png optimizer or something
>>
>>59236264
What are the inputs?
>>
>>59236329
Inputs are:
- for each thruster, I've got the thrust vector and torque
- acceleration vector and torque requested
Output:
- thrust level [0-100]% for each thruster that satisfy the request as close as possible, priority goes to the torque
>>
File: output.webm (3MB, 1920x1080px) Image search: [Google]
output.webm
3MB, 1920x1080px
building a menu
>>
>>59236383
You're gay, I can tell from your hands.
>>
You guys just gave ma program idea.

I'm already using a deduplication tool so that when I download images I don't save duplicates (checked via hashes).

I'm gonna make an option to to save only the most optimized version for PNGs.
>>
>>59236405
Thank you very much, my friend.

https://www.youtube.com/watch?v=JGM5a6-77o4
>>
File: IMG_0962.jpg (132KB, 510x346px) Image search: [Google]
IMG_0962.jpg
132KB, 510x346px
Someone redpill me on OOP. I've studied Java for 6 months and recently started with c#, but I feel like I have what I'm doing, even after making several functional programs.

Am I just retarded or is OOP thrash, and I should stick with a simple and functional language like PHP?
>>
File: 1461444393999.gif (2MB, 320x180px) Image search: [Google]
1461444393999.gif
2MB, 320x180px
>>59236444
>simple and functional language like PHP?
>>
File: rover dangerfield.png (131KB, 344x247px) Image search: [Google]
rover dangerfield.png
131KB, 344x247px
>>59236444
>a simple and functional language like PHP
>>
File: 1481520154924.png (974KB, 900x900px) Image search: [Google]
1481520154924.png
974KB, 900x900px
>>59236426
I used a script on all my pepe images that change a random pixel color by almost nothing so I can post duplicates and fuck with people like you
>>
>>59236471
>frog poster
>>>/trash/
>>
heeeeelp /g/

I just write a program thats creates moving rectangles when i press space and it supposed to not remove other moving rectangle when creates and adds new rectangle to the ArrayList.

What do i need? Can somebody test my code and say what is wrong?

package ArrayLists;

import javax.swing.*;
import javax.swing.Timer;
import java.awt.*;
import java.util.*;
import java.awt.event.*;

public class test extends JPanel implements ActionListener,KeyListener{

private ArrayList<Rectangle> rec_list;
Iterator<Rectangle> rec_iterator;
private Rectangle test_rec;
private int rnd_1,rec_y = 0;
private Timer timer1;
private Random rnd = new Random();
public test(){
rec_list = new ArrayList<Rectangle>();
timer1 = new Timer(10,this);
timer1.start();
}

public void add_rec(){
rnd_1 = rnd.nextInt(400)+10;
rec_y = 0;
test_rec = new Rectangle(rnd_1,0,25,25);
rec_list.add(test_rec);
}

public void actionPerformed(ActionEvent event) {
rec_y++;
repaint();
}

public void paintComponent(Graphics g){
super.paintComponent(g);
rec_iterator = rec_list.iterator();
while(rec_iterator.hasNext()){
test_rec = rec_iterator.next();
g.fillRect((int)test_rec.getX(), (int)test_rec.getY(),
(int)test_rec.getWidth(), (int)test_rec.getHeight());
test_rec.setLocation(rnd_1,rec_y);
}
}

public void keyPressed(KeyEvent key) {
int k = key.getKeyCode();
if(k == KeyEvent.VK_SPACE){
add_rec();
}
}

public void keyReleased(KeyEvent arg0) {
}
public void keyTyped(KeyEvent arg0) {
}

public static void main(String args[]){
JFrame frame = new JFrame("Title");
test t = new test();
frame.add(t);
frame.addKeyListener(t);
frame.setSize(500, 500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
>>
>>59236471
All my pepes are artisan-sourced and manually curated.
>>
File: 1480825427081.jpg (83KB, 788x685px) Image search: [Google]
1480825427081.jpg
83KB, 788x685px
>>59236485
There's absolutely nothing you can do to stop me
>>
>>59236509
So?
Enjoy being disrespected.
>>
>>59235789
Why is there 3 /dpt/ threads, OP?

Anyway, here’s my question:
Why can’t I do something like this in C90 aka ANSI C:
int main(void)
{
const int size = 42; /* size is a constant */
int array[size];
return 0;
}

even though size is a constant?
>>
>>59236531
I don't give a fuck about what others have to say about me. If you're triggered by a fucking frog picture then you're the autist anon :^)
>>
>>59235905
>>59235826
>>59235918
Fuck y’all motherfuckers hatin’ on C. C is the best language I have ever learned.
>>
>>59236545
>C90 aka ANSI C
wrong
>>
>>59236471
I hash chunks not entire files so it won't work on me. I auto-discard at 100% similarity and otherwise get a pop-up above a set similarity threshold.

tl;dr: The random pixel will not avail you, flame of Udûn.
>>
>>59236247
Rust doest not have a strong type system - 'unsafe' completetly undermines it.
>>
>>59236566
>C is the only language I have ever learned.
>>
>>59236545
noob here but doesn't (void) mean a method that doesn't return a value?
but you are trying to return 0
>>
>>59236550
>I don't give a fuck about what others have to say about me.
It's not the problem with frogposting.
Frogposting just won't give you quality responces, that's all.
>>
>>59236471
>script
Which language?
Also, post the script, don't just say that you've used a script with no evidence.
>>
File: floatcomparison.webm (197KB, 815x185px) Image search: [Google]
floatcomparison.webm
197KB, 815x185px
what the fug man
>>
>>59236600
Fuck off it's literally a one liner
>>
>>59236606
nobody can tell what is happening in your webm
>>
File: 1472621975483.png (8KB, 882x72px) Image search: [Google]
1472621975483.png
8KB, 882x72px
>>59236569
I know it’s wrong, but... See pic related, which is from `man gcc`.
>>
>>59236573
It does not. The only time a Rust program can do bad things is in unsafe code. Hence you only need to look at unsafe code (and examine the preconditions and postconditions of your unsafe blocks) to find a problem.

In addition, unsafe blocks don't turn anything off. They simply permit pointer dereferencing, static/union access, and FFI.
>>
File: caracalla.jpg (26KB, 400x462px) Image search: [Google]
caracalla.jpg
26KB, 400x462px
>>59236629
I bet you do debugging by printing to stdout.
>>
>>59236584
No, void is in the arguments list. This means it doesn't take any arguments. It returns an int.
>>
>>59236629
lhs is about -0.4, rhs is std::numeric_limits<double>::min(). It's saying lhs is not greater than rhs
>>
>>59236648
-0.4 < 0
false
>>
>>59236618
You haven't answered any of my questions. Good job.
>>
>>59236648
rhs is positive you faggot
>>
>>59236486
Is it supposed to spawn a new rectangle and keep the other at the same position?
>>
>>59236658
i mean it's false that -0.4 > 0
because -0.4 < 0

0 is effectively what the rhs is, 2...something... e^-308
>>
>>59236659
script is in bash, I loop through all the files given and just use image magic, wew that's hard
now stop being a retard
>>
>>59236665
oh I'm a fucking retard
>>
>>59236643
Wrong. I do debugging in GDB. Or if it's a simple thing, I print to stderr, never to stdout.
>>
>>59236668
yes same y axis but different randomly x axis
>>
>>59236703
std::cerr << "ok1" << std::endl;

best debugger in the world
>>
>>59236569
This is not my point.
>>
>>59236042
W H O
H O W
O W H
>>
>>59236720
 test_rec.setLocation(rnd_1,rec_y);

 test_rec.setLocation(test_rec.x, rec_y);


try changing that. I dont know if thats what u want or not.
>>
>>59236745
>OOO
what did you mean by this?
>>
>>59235015

>using Go
>2017
>>
>>59235960
>started learning programming (java) as a hobby few days ago.
Not bad for a few days. Could do with a bit more polish, but you gotta start somewhere.

Next, think about whether there's any bit of code that could be factored out and given its own name instead of just being copied around. Doing that (which is one of the big things that refactoring is about) is a big step to making you a better programmer.
>>
>>59236762
I mean who is the owner of that fantastic pair of jumpy tits
>>
>>59236545
>Why can’t I do something like this in C90 aka ANSI C
Where did you read that, or why do you think that?
It compiles on gcc. Not saying gcc is the end all be all, but I'm curious to know why you think this.
>>
>>59236759
wow little close i can spawn more than one this time but they are moving at the same time with same position and when i press space they start falling from top. I looking for falling squares.
>>
>>59236426
>checked via hashes

You dumb fuck.
>>
I am making a virtual reality application for ios and android which uses image filtering for women to take pictures of themselves with different clothing and jewelry on
>>
File: 1485136773653.jpg (69KB, 497x732px) Image search: [Google]
1485136773653.jpg
69KB, 497x732px
>>59236471
>when I download pictures on 4chan I might be downloading an unpure version that's been artificially altered by some troll just so he could spam it
>I can never tell which are the original pristine version and which are the troll version

Holy fucking shit m8 what kind of hell have you just unleashed
>>
File: cat on CRT 3.jpg (94KB, 540x405px) Image search: [Google]
cat on CRT 3.jpg
94KB, 540x405px
what should i read if i want a detailed breakdown of how to impliment goal based agents? norvigs AI a Modern Introduction is pretty light on details on this as far as i can see
>>
>>59236850
You're only doing this to get lewd pictures

>>59236868
an abstract kind of hell m8
>>
File: irq.png (79KB, 1332x783px) Image search: [Google]
irq.png
79KB, 1332x783px
>>59235789
Still stuck on this shit. It's not firing any interrupts for some reason.
>>
>>59236879
no I am doing it because women I talked to love the idea and it will make a lot of money but holy shit it is very difficult to program to get it to run properly on mobile
>>
>>59236833
If what youre saying is each triangle is separate in the actionPerformed you need to iterate each triangle and increase the y value and in the setlocation method use the triangles location and not the rec_y.

I dont know what the use of rec_y.
>>
>>59236092
Did you know that, with divine intellect, writing in C, you can't go wrong?
>>
>>59236948
rectangle not triangle.
>>
>>59236948
for starting new rectangles from 0 y axis. Thank you i will try that.
>>
>>59235789
I'm going to write malware that will boot all of you weeaboo cucks off of the internets
>>
>>59235960
Don't listen to them. They are haters.
>>
I've come up with a beautiful solution to my current problem, but it's so general that I don't even know what to name it. I'm not sure it's even a tangible thing, just a series of middlewares.
>>
>>59236948
>iterate each rectangle

how i am going to do that? I am new to this.
>>
>>59237022
Here: http://pastebin.com/wTfMYSyH
>>
>>59237018
what's your problem?
post solution
>>
File: bunny.png (415KB, 616x478px) Image search: [Google]
bunny.png
415KB, 616x478px
>>59237036

THANK YOU so much its realy helpfull i will working on this more. Here is a cute judy.
>>
>>59236042
>C is an obsolete programming language for the programming techniques of the past.
What a good way to make me ignore everything you have to say.
>>
Is there an established name for a function like this?

 def winner(seq, evaluate_fun):
max = seq[0]
prev_maxvalue = evaluate_fun(max)
for e in seq[1:]:
curr_value = evaluate_fun(e)
if curr_value > prev_maxvalue:
max = e
prev_maxvalue = curr_value
return max
>>
>>59237217
>not using standard functions to do this
>>
>>59236643
Print debugging is the single most effective and scalable method of debugging.
Enjoy wasting time stepping through hundreds of lines of code.
>>
>>59237217
max . map evaluate_fun
>>
>>59237256
Post your version then.
>>
>>59237217
Given your context, perhaps a fitness function?
>>
File: 040317-1634.png (655KB, 4000x2560px) Image search: [Google]
040317-1634.png
655KB, 4000x2560px
Reverse engineering this software, trying to make a keygen for it.

I wonder how the people in the scene used to make keygens as they would often get stuff released within days, it's so cumbersome to hunt through the binary finding encryption and obfuscation routines to generate valid serials, and then replaying those algorithms it in your own binary is no easy task.
>>
>>59237279
I want the original value not the value it has after the map.
>>
>>59237282
Anon posted it, but if you can't come up with a solution for something as simple as this you should stop programming immediately
>>
>>59237303
What's your current progress Madara?
>>
>>59237306
You mean >>59237279? That doesn't do the same thing.
>>59237289
That seems related but more general.
>>
File: 1461443855988.png (32KB, 1376x747px) Image search: [Google]
1461443855988.png
32KB, 1376x747px
>>59236141
Here, anon: https://i.imgur.com/EW055iY.png
I tried to post the image here, but I couldn't because of slow internet. Try to optimize it.

>>59236813
Look at pic related.

>>59236745
>>59236792
I personally don't watch anime, but here's the title of that webm, it might help you find out who is she: "[HorribleSubs] Musaigen no Phantom World - 01 [720p]"

>>59237303
I read once that they run the programs in some kind of virtual machine, and watch its RAM to see which string it compares their serials to to see if they're valid, and then just copy what it's trying to compare it to.
Keygens, on the other hand, require more work, because they have to find out the algorightm to generate those serials, and then implement it in a small program (the keygen).
>>
>>59237304
seq.map(|x| (x, f(x))).max_by_key(|(_, y)| y).map(|(x, _)| x)
>>
>>59237057
It's redux specific.
The need to clean up our redux state tree by not tying data grabbed from an asynchronous source to particular branches, but instead store it all in one branch which is cleaned up on route change.
Basically you build a reducer using layers of middleware that does this, with the ability to switch out how actions are matched to branches of state, how you store and respond to metadata, and how you apply functions. It doesn't even need to be used for asynchronously fetched data, it can be used for any reducer where you need to store shared data in redux and don't want to create new branches.
>>
>>59237410
Scratch this, you can just do
seq.max_by_key(f)
>>
File: this guy.jpg (126KB, 1211x1210px) Image search: [Google]
this guy.jpg
126KB, 1211x1210px
>>59237384
>[HorribleSubs] Musaigen no Phantom World - 01 [720p]

Thanks
>>
>>59237437
ty
>>
File: 457edd24cde85b152411e7f93d32f699.png (851KB, 752x1211px) Image search: [Google]
457edd24cde85b152411e7f93d32f699.png
851KB, 752x1211px
Parsing HTML with regex.
#!/usr/bin/env python3

# ./wiktionary.py https://en.wiktionary.org/wiki/Appendix:JLPT/N5 > n5.flash

import urllib.request
import re
import sys

url = sys.argv[1]
res = urllib.request.urlopen(url)
body = res.read().decode('utf-8')
for line in body.splitlines():
line = line.strip()
ja = re.findall('title="(\S+)"', line)
en = re.search(' -(.+)</li>', line)
if ja and en:
sys.stdout.write(', '.join(ja))
sys.stdout.write('|')
sys.stdout.write(en.group(1))
sys.stdout.write('\n')
>>
>>59237582
> Parsing HTML with regex.
Sounds like a recipe for disaster.
>>
>>59237623
I wanted to use the built-in HTML parser, but it's complete shit. This just works without 3rd party libraries.
>>
>>59237582

Just use beautifulsoup

def getRandomPage():
req = urllib.request.urlopen('https://en.m.wikipedia.org/wiki/Special:Random')
soup = BeautifulSoup(req, 'lxml')
return soup
page.find("div", {'id':'mw-content-text'})
>>
>>59237623
How does one write a simple (X|HT)ML parser from scratch?
>>
>>59237682
You don't, you use a library instead.
>>
Why do people even use XML? You look at even JSON for 10 seconds and you realize it's leagues ahead.
>>
I usually write C programs for Linux that print colored output like so:
char *red = "\033[0;31m";
char restore_color = "\033[0m";
printf("This text is %sred%s\n", red, restore_color);

Does this approach work if I wanted to make portable programs that also work in Windows?
>>
>>59237728
Not all terminals support it. Your best bet would be to write a wrapper for it and change it depending on which system you're targeting.
>>
>>59237437
>>59237518
apparently you can do max(seq, key=f) in python
>>
>>59237728
Not in the default console aka cmd.exe, you'd better off with some specialized library.
>>
File: EW055iY.png (644KB, 680x680px) Image search: [Google]
EW055iY.png
644KB, 680x680px
>>59237384
simple optimization
>>
>>59237728
*restore_color
>>
File: 1456827875842.jpg (57KB, 466x411px) Image search: [Google]
1456827875842.jpg
57KB, 466x411px
>>59237723
>tfw no JSON-based HTML6
>>
>>59237810
*restore_colour
>>
>>59237682
Study context-free grammars and how to parse them. This is typically introduced in a theory of computation course, and then expanded on in a programming language theory course.
>>
File: 1487528725688.png (2MB, 1079x1399px) Image search: [Google]
1487528725688.png
2MB, 1079x1399px
>>59237805
>>
>>59237814
HTML specifically should be replaced with something like Markdown. A format like JSON doesn't handle text formatting that well, just document structure. XML for serialization is just cancer.
>>
>>59237723
Yes JSON is superior in every way, I always use it over anything else, especially with all the C++ JSON parsing lib that are pretty gud
>>
https://docs.python.org/3/library/threading.html
Python doesn't provide a method to cancel/kill a thread. The programmer has to design the task/worker in such a way that the task can stop if that request is made.

At first look, it appears that Qt provides some ways to cancel a thread.
https://doc.qt.io/qt-5/qthread.html

The functions exit(), quit(), and terminate() are supposed to cancel threads. But in my simple tests they don't work.

http://pastebin.com/Qhf8MZVC

I know I can add code to the worker in my example. But I am in a situation where I cannot add code to the worker I am actually using.

For the time being, I am going to be using QThread for the thing I'm working on. Not being able to cancel the thread is a minor issue. But what would be the best way to accomplish cancelling a long running task that I can't add code to? Maybe QThread is the wrong answer.
>>
>>59237840
>1.63 MiB
Your image really needs optimizing.

>>59237805
But what did you use, Anon?
>>
>>59237837
Thamks anon
>>
>>59237869
you do have exit() in python
https://docs.python.org/3/library/_thread.html#_thread.exit
>>
What language has the most beautiful syntax?
>>
File: 1488655507732.png (457KB, 1079x1399px) Image search: [Google]
1488655507732.png
457KB, 1079x1399px
>>59237840
meh
>>
>>59237889
No problem. If you're looking for books to read, try the Sipser book, as well as the Hopcroft/Ullman book.
>>
File: 1488655855212.jpg (16KB, 1079x1399px) Image search: [Google]
1488655855212.jpg
16KB, 1079x1399px
>>59237915
meh
>>
>>59237951
lossy as shit

kys
>>
>>59237915
Is this process lossless though?
>>
>>59237955
I don't see a difference
>>
>>59237951
I like the blocky effect.
>>
>>59237959
not quite but close

if it was lossless the file size would be 1.4MB
>>
>>59237910
Lisp
>>
>>59237909
Hmmm, let me see how this works with my other Qt stuff.

Thanks.
>>
>>59237993
(((kek)))
>>
>>59238007
Lisp did nothing wrong.
>>
File: lifeIsAgony.jpg (45KB, 1280x720px) Image search: [Google]
lifeIsAgony.jpg
45KB, 1280x720px
>>59235905
>>
>>59237910
Forth
>>
File: 1477373966401.png (208KB, 398x399px) Image search: [Google]
1477373966401.png
208KB, 398x399px
>>59235905
>>
>>59237915
>>59237951
Stop
>>
>>59237951
DENHANCE
>>
File: 1488655855212.jpg (564B, 100x130px) Image search: [Google]
1488655855212.jpg
564B, 100x130px
>>59238039
No
>>
>>59238056
can you get this down to 1B
>>
>>59237955
you only say that because you can see the filesize you could switch them and you would say the same
>>
>>59237849
Ah the React/JS generation. Enjoy devising intricate, fine-tuned main templates with just headings and bullet lists. HTML is *fine*. Separating actual textual-content blobs out into markdown or restructuredText is *also fine*.

Sure you can rephrase any domain-specific language (such as HTML or SQL) into some generic nested-s-expressions language (json or xml or lisp) but it practically never aids anyone other than the occasional lone coder who can skip writing (or finding) a parser.
>>
>>59237849
HTML should be replaced with s-expressions.
>>
>>59238109
<b>Foo<i>Bar</b>Baz</i>
>>
File: 1474219799870.jpg (26KB, 499x499px) Image search: [Google]
1474219799870.jpg
26KB, 499x499px
Rust is a meme language with absolutely no future
>>
>>59238237
https://crates.io/crates/futures
>>
>>59235789
Decided to learn javascript cause fuck it, might as well do what's popular after wasting years on hipster and obscure shit. Also HTML5 and CSS cause I guess they're pretty inseparable, though obviously neither is programming.
>>
File: 1488534619276.jpg (524KB, 886x1002px) Image search: [Google]
1488534619276.jpg
524KB, 886x1002px
>>592382537
btfo
>>
>>59238258
It's a good choice if you decided like me to stop fucking around and want to find employment (although I do not know your situation). It's usable in non-web settings too. I'll meet with an agency soon, I'm so nervous.
>>
File: vbox.png (55KB, 970x1042px) Image search: [Google]
vbox.png
55KB, 970x1042px
oh shit I just discovered this.
should make my life a lot easier, if only I could figure out how to use it.
>>
File: 2017.jpg (876KB, 2356x2976px) Image search: [Google]
2017.jpg
876KB, 2356x2976px
>>
Hi, /dtp/. I know a little bit about programming because im a telecommunication engineer student. I thought about learning something more popular than matlab, maybe c++? I started a couple of days ago and got through some basic stuff like loops and shit. But where do i go next? And just reading won't help me remembering the sintax of language, right? Where can I do some exercises? Or maybe I should study some other language?
>>
>>59236571
Ok my script now take a merchant meme and scale/rotate it randomly and then add it on top of the image with very low transparency
>>
File: pap.jpg (29KB, 356x475px) Image search: [Google]
pap.jpg
29KB, 356x475px
>>59238452
pic might be worth a try
>>
File: challenges.png (549KB, 1920x1080px) Image search: [Google]
challenges.png
549KB, 1920x1080px
>>59238452
Stick with C++ and get a good exercise book and also take a look at pic related
>>
>>59238510
>>59238493
Thank you a lot, anon.
>>
>>59238510
>Turing machine simulator
not hard at all desu
>>
>>59238452
>>59238493
>>59238510
C++ is awful
>>
>>59235789
Always makes me feel good when someone uses something I made in a post.

Is c# a good language or should I not waste mu time on it?
>>
File: vbox.png (7KB, 818x199px) Image search: [Google]
vbox.png
7KB, 818x199px
wtf is this shit.
>>
>>59238665
It's okay. Why do you want to learn it?
>>
>>59238658
But c++ is quite in demand, isn't it? Only java is more popular i think.
>>
>>59238740
A rule of thumb is to ignore anyone smearing a language, that goes double when it's done with no argument at all (and even triple on /g/).
As for C# it is largely used in the industry.
>>
>>59238735
Starting uni in September and just want to fill time between now and then with something that might be productive.
>>
>>59238740
C++ is good with clear advantages in performance and standard library over any other languages.
Java is slow and the only thing it has is code portability
>>
>>59238767
>ignore anyone smearing a language even when they have an argument
...
>>
>>59238785
Binary portability. Java has no more code portability than C++.
>>
>>59238767
I see. Can you, anon, tell me who uses java and who uses c++? There should be a discrete fields of usage for them, right?
>>
>>59238786
>>59238658
>they have an argument
>C++ is awful
>argument
>>
>>59238795
>A rule of thumb is to ignore anyone smearing a language, that goes double when it's done with no argument at all
Implying that the former still applies when there is an argument.
>>
>>59238793
>Java
pajeet code monkeys
>C++
real men
>>
>>59238793
If you are going to use Java you might as well go with C++ because you have everything Java does (except garbage collection but if you're not completely retarded it's not a problem) and C++ is faster and prettier
>>
>>59238785
>muh performance
This doesn't matter in most cases. Java is often pretty much as fast as C++ and the compiler can do more optimizations than a C++ compiler can.

C++ is also one of the ugliest and most annoying languages to use.
>>
File: tls.jpg (33KB, 381x500px) Image search: [Google]
tls.jpg
33KB, 381x500px
>>59238772
>Starting uni in September
That means you have plenty time to learn enough scheme to be the annoying lisp elitist.
>>
>>59238853
>C++ is also one of the ugliest and most annoying languages to use.
Java is worse.
>>
>>59238853
t. Java code artisan
>>
>>59238793
Some examples of typical cases where I've seen these languages used.

C++:
Real-time interactive applications (Medical training, video games)
Userspace modules of operating systems, this is true for Windows where the API is written in C++
Digital signal processing algorithms

Java:
Web services
GUI-based management tools

Of course you can do these with either but what I'm saying is these are real world examples I've seen.
>>
>>59238874
>this is true for Windows where the API is written in C++
The API is C. Even COM.
>>
>>59238866
>>59238869
I'm not trying to defend Java (I never even really used it).

>>59238869
t. ignorant C++ fanboy
>>
>>59238886
Your post isn't wrong, I'm just saying that Java is worse than even C++ when it comes to ugliness and usability.
>>
>>59238886
I'm not going to give you an elaborate answer when you say that C++ is shit you little faggot
>>
>>59238854
>mfw I understand Lisp and ideas beneath it but Iknow neither real use of Lisp, nor what to program
>>
>>59238885
You're right. I was thinking about WinRT.
>>
Btw, how much time do i need to study a day to be able to do easy tasks on pic >>59238510 ?
Im not monkey, but I've never done anything other than some researches on signals using matlab.
>>
>>59238953
>>59238953
Isn't that managed C++ or whatever Microsoft calls their abomination nowadays, so .Net?
>>
>>
>>59238955
Depends on how soon you want to be able but I'd say overall 20 hours should be enough to start doing any green task (keep in mind some of them require non-programming knowledge such as math too).
>>
>>59238353
Use vmware, and have windbg kernel debug through a com port, if your targeting a windows machine that is.
>>
>>59238853
>Java is often pretty much as fast as C++
only given a fairly lax definition of "pretty much as fast". the difference may not generally be noticeable for an event-based GUI app or some such thing, but C++ is suitable for real-time applications while Java is realistically not. that puts them in somewhat of a different league
>>
>>59238955
Not very long, depends on what you already know.
Also some of the yellow problems should be green in this chart.
>>
>>59238964
wtf i like pascal now
>>
>>59238976
I'm debugging my own "kernel" that runs on top of dos. currently working on implementing the com port interface, and then the gdb remote protocol, but before I get there I need some way to debug all that stuff.
>>
>>59238988
>>59238975
After 2 hours i have just put i realised that the most confusing thing after matlab is that i need to know what library i need to use to get this or that command to work. What's the point of this? Maximizing performance?
>>
I made a python script to generate this code

#ifndef SHITTY_ENU_H_INCLUDED
#define SHITTY_ENUM_H_INCLUDED

enum SHITTY_ENUM{
SHITTY_ENUM_SHITTY1 = 0,
SHITTY_ENUM_SHITTY2 = 1,
SHITTY_ENUM_SHITTY3 = 2
};

SHITTY_ENUM str_to_SHITTY_ENUM(std::string s){
if(s == "shitty1"){
return SHITTY_ENUM_SHITTY1;
}else if(s == "shitty2"){
return SHITTY_ENUM_SHITTY2;
}else if(s == "shitty3"){
return SHITTY_ENUM_SHITTY3;
}
};

std::string SHITTY_ENUM_enum_to_str(SHITTY_ENUM e){
if(e == 0){
return "shitty1";
}else if(e == 1){
return "shitty2";
}else if(e == 2){
return "shitty3";
}
};

#endif


from a file that looks like this

SHITTY_ENUM //name
shitty1 //enum1
shitty2 //enum2
shitty3 //enum3
>>
Hey /dpt/

I'm working on something more complex than I usually do.
I wrote the "architecture" on a piece of paper and what I thought my program should use, is this one good way to do it? Or are there any proven "methods" to sketch the basis of your program?
>>
>>59239092
You should use the C++ standard library whenever you can.
Take a look here http://en.cppreference.com/
The <algorithm> header is also your best friend.
>>
How do I make my own programming language?
>>
>>59239204
Yeah this is something I'd like to know about as well. Ask the same question no /r/softwareengineering and hackernews, they might know a bit more
>>
>>59239222
>http://en.cppreference.com/
That shit is amazing, thanks, anon.
>>
>>59238964
C++ is shit and you can write OS with it
>>
>>59239225
http://zacstewart.com/2013/09/15/learning-cpp-a-brainfuck-interpreter.html
github.com/harc/ohm
http://www.buildyourownlisp.com/

In that order
>>
>>59238493
But this is second edition, the 4th edition is out!
>>
>>59239225
First get a PhD in type theory. Otherwise, you will create nothing of value.
>>
>>59239204
maybe I'm just bad at planning ahead, but that never worked out for me. now I just start writing, eventually it turns into a mess, rm -rf * and start over with a better idea of what the program structure should look like.
>>
Trying to make a script to steal money from starving artists

In bandcamp, you can go around paywalls by clicking "Inspect element" on the Play button for a song, seeing the largest file (or an mpeg file that shows up once you press the button), and click "Open in other New Tab"

My question is, given the URL for a song, how would I simulate this? I would need the location of the mpeg file (and I could easily download from there), but I'm not sure how to go about actually finding the "request URL". I'm thinking of doing a button press and checking for resources, but that might not be what I need...

Thoughts?
>>
>>59239300
reported.
>>
>>59239229
>>59239281

I'm actually taking a Software Engineering course, but since this will be a pet project of mine I think it's kind of a stretch to apply all SE knowledge on it (Requirements,Architecture,development,etc).

I guess I'll just start writing it and make what changes I see fit.
>>
>>59239300
>256 kbps preview rips
I don't even pity you.
>>
>>59239300
>>59239329
Actually, more like 128. Even better.
>>
>>59239245

t. didn't try googling it
>>
>>59238510
Has anyone on /g/ done some of the hard ones? (red/purple, or even some of the yellow ones)
>>
File: valium.jpg (55KB, 540x694px) Image search: [Google]
valium.jpg
55KB, 540x694px
noob question:

is there a way I can keep track of how many times a loop has run? Like let's say I want my while loop to run once, then start over, and repeat that process 10 times. How would I go about keeping a tally of how many times it has ran through the code
>>
>>59239204
Try it and see if it works for you.
>>
my cat can out program all of you
>>
>>59239204
There exist things like UML that are designed to "standardize" the sketching up of program structure, but they are a huge headache and exist for the benefit of the reader, not the writer (and also for the benefit of some HR Rep's checkbox). Certainly not something worth doing for solo projects.
>>
>>59239372
I've done 13, it was shit but working
>>
>>59238975
>20 hours
>ANY green task
Nah, I don't think that's possible. Some of them are actually hard to come up with if you don't have experience or if you're not working in a very high level language.

>>59239000
Real Programmers Don't Use PASCAL
>>
>>59239261
I only care about optional typing at best.
>>
File: finewine.png (240KB, 512x512px) Image search: [Google]
finewine.png
240KB, 512x512px
>>59235960
i'm proud of u anon keep at it
>>
>>59239436
real programmers use Java
>>
>>59239436
Not an acronym
>>
>>59239449
So why bother? There are lots of existing languages with option types.
>>
>>59239329
>>59239348
I can't tell the difference and this is more of a project to work on webscraping.

>http://lifehacker.com/5810575/does-bitrate-really-make-a-difference-in-my-music

>Some people may just not care enough, or may just not have the more attuned listening skills to tell the difference between two different bitrates. This is something you can develop over time, of course, but if you haven't yet, then it doesn't particularly matter what bitrate you use, does it?
>>
>>59239225
>How do I make my own programming language?
Here ya go son http://dev.stephendiehl.com/fun/
>>
>>59239470
I don't like them. Wanna make my own.
>>
>>59239489
If you're okay with your language never being touched by anyone else then be my guest.
>>
>>59239375
count = 0
while (foo) { bar(); count = count + 1 }
print (count)

pseudo code obviously
>>
>>59239225
http://llvm.org/docs/tutorial/LangImpl01.html
>>
>>59239429
I've done 10, 31, 33 (it's the same as 31), 44, 46 (no unicode support), 56, 66. I could see myself doing most other green ones, and maybe some yellow ones too.
>>
>>59239204
Just plan it in your head and write the features you want to have in a TODO file.
>>
>>59239327
https://news.ycombinator.com/item?id=13793035
>>
>>59238964
I know a guy who writes his toy OS in fucking NIM.
>>
>>59239637
kek
>>
>>59239375
sounds like you're looking for a for loop
>>
File: wizard.gif (142KB, 384x241px) Image search: [Google]
wizard.gif
142KB, 384x241px
How do I into Go?
>>
>>59238067
There is no valid .jpg file that small.
>>
>>59239806
https://learnxinyminutes.com/docs/go/
>>
>>59239827
sounds like someone isn't trying hard enough
>>
>>59236545
Just use dynamic memory. It's not worth the hassle.
>>
>>59239834
God this lang is so kawaii
>>
>>59236545
Variable length arrays (terrible name) were introduced in C99.
>>
>>59239953
>Terrible name
Literally how?
>>
>>59239979
Their lengths are not variable in the most obvious sense.
>>
Can someone recommend me some decent books on C#.
>>
>>59236545
Const variables are not ICEs (integer constant expressions), which a statically sized array requires.
All you have is a normal variable that you can't modify.

The next C standard has a proposal to allow true named constants of any type in C, but we'll have to see.
>>
REEEEEEEEEEEEEEEEEEEEE WHY IS MY INTERNET CONNECTION SO SHIT FUCKING HELL I HATE MY LIFE
>>
>>59240063
>REEEEEEEEEEEEEEEEEEEEE
This is not your blog, you fucking redditor.
>>
>>59240022
>The next C standard has a proposal to allow true named constants of any type in C, but we'll have to see.
Those would be just like #defines, right?
>>
>>59240076
>REEEE comes from leddit
just end your life right now you pleb
>>
New thread:

>>59240106
>>59240106
>>59240106
>>
>>59240087
Defines aren't scoped and play poorly when interfacing from another language.
>>
>>59240087
It would also work properly for things like structs, and hopefully allow the compiler to omit debug information about them.
http://www.open-std.org/jtc1/sc22/wg14/www/wg14_document_log.htm
>>
>>59236383
are you by any chance belgian?
>>
I want to learn how to code
Is it too hard?
>>
>>59241122
Learning syntax is easy, If you pick a language with many users/ good docs you'll be able to just read them and do whatever you want.

The hard part of programming is when you want performance, implementing data structures, writing programs in lower level languages, graphics, complex math etc.
>>
>>59241259
I started in html5 and I have arealdy started to be able to make a simple wikipedia-like article,and it seriously doens't seem too hard,but it looks like I'll need to write down what each command and line does
>>
>>59236383

> let me just fall for every sparkfun meme in this one webm
>>
modding a game while i wait for a render to complete.
in the process to upgrade to win10pro, gonna finish the upgrade when the render is done.

Why is GPU acceleration so poor on my 770? only using 12-24% of the gpu.

currently modding the steam client's skin, wish it was more flexible

captcha:ademe victoria
Thread posts: 320
Thread images: 58


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.