[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 22
File: hime c.png (1 MB, 1280x720) Image search: [Google]
hime c.png
1 MB, 1280x720
old thread: >>53810655

What are you working on, /g/?
>>
>>53813724
i approve of this faggotry
>>
File: cute anime girl 4.jpg (22 KB, 704x480) Image search: [Google]
cute anime girl 4.jpg
22 KB, 704x480
>>53813724
2nd for cute anime girls
>>
lisp brackets remind me of the times i played dota with russians on garena

good times, prosto axuetb
>>
>>53813724
print('{} => {} => {}'.format(rados_object.key, attr[0], attr[1]))
print output
print object_path
with open(d5 + '/Objects', 'a') as f:
f.write(object_path)
f.closed

with open(d9 + '/' + dt, 'a') as log:
log.write('[' + t + '] ' + '{} => {} => {}'.format(rados_object.key, attr[0], attr[1]) + '\n'
'[' + t + '] ' + output + '\n'
'[' + t + '] ' + object_path)
log.closed


What would be the most appropriate way to get the output printed to the console, replicated to a log file?

I would like it so that it's like

[22:19:44] Example output
[22:19:44] Example output
[22:19:44] Example output


I'm not entirely sure about the most appropriate way to do this. Using Python's own log module would be too time consuming to implement

EDIT: I know some of you don't like Python but unfortunately I can only use Python to meet the requirements for this tool
>>
>>53813724
Trying to learn to python so I can write deep learning algorithms for udacity without a language discrepancy.
>>
I got a job as a java junior programmer. It's so bad you guys weren't joking!
>>
>>53813771
If you actually knew what you were doing, you could adapt their example code in your preferred language.

This just tells me that all of your code relies on some black box library code that you don't understand.
>>
>>53813724
interview prep and work
I'm so burnt out on both though.
>>
>>53813787
Trust me I could do that, knowing python makes it easier to translate... Plus I'm learning something new!
>>
>>53813724
Stop this programming fag meme.
>>
>>53813832
>meme
>>
How do I average two ints in JavaScript?
>>
File: girl code.jpg (150 KB, 869x1776) Image search: [Google]
girl code.jpg
150 KB, 869x1776
>>53813832
coding (or as i call it, koding) is an inherently feminine recreational hobby. women are better at language and communication, and those parts of their brains are better developed than in men. koding is just like using any other language, and it's more important to be able to communicate with others than to be able to write fancy one line methods that only creeps understand
>>
>>53814006
tippy top qeq
>>
>>53814002
function avg(x,y) { return 0.5*(x+y) }
>>
>>53814006
Hope you know that on the left its BRILLIANT Carmack's fast invsqrt function: https://en.wikipedia.org/wiki/Fast_inverse_square_root

its a fucking programming gem
>>
>>53814006
Can you provide a link to this tweet? I can't find it. I'm pretty sure this pic is 'shopped.
>>
>>53814006
Wasn't she being ironic?
Either way I wanna fug her
>>
Godlike programmer here I will build you any program you would like
>>
File: gamergate girl code dpt.png (55 KB, 534x344) Image search: [Google]
gamergate girl code dpt.png
55 KB, 534x344
>>53814095
she probably deleted it
>>
>>53814006
I refuse to believe this is real.
I couldn't write a better bait if I tried.
>>
>>53814006
It's true though guys write shitty uncommented code and all the female programmers I met have wrote much better logical comments and are better at logical programming in general
>>
>>53814098
Can you build me a Haskell to Brainfuck compiler?
>>
>>53813769
Please help
>>
>>53814168
Both the left and the right example are bad. It's good to add comments when the code is exceptionally tricky or when you want to document things.
But if you still put a comment on each statements, you need to learn to code.
>>
so we google theme now
>>
>>53814206
It's fucking awful

All because Moot got a job with Google too, load of bullshit
>>
>>53814206
Don't sweat it, only a couple of hours left.
>>
>>53814183
Working on it give me 2 hours
>>
>>53814237
good for him tho
>>
>>53814006
>Bates
>>
>>53813724
>What are you working on, /g/?
waiting for a pull request to be merged and trying to come up with an idea for a new project for this week
i kinda want to do something in a new language/language i haven't used very much and I've narrowed my options down to:
>Rust
>Erlang
>C++
>Perl6
>Ruby
now i just need to think of a project and find the best fit
>>
File: 1447350975973.png (113 KB, 400x400) Image search: [Google]
1447350975973.png
113 KB, 400x400
I'm writing a cross platform disassembler in Rust. I released version 0.14 today. Still need to write a blog post about it.

>https://panopticon.re/
>>
>>53814077
Carmack had nothing to do with the fast invsqrt function. If anybody had any thing to do with it, that would be Michael Abrash but even he has said he isn't sure if he was responsible for it or not. There have been variations of it existing in source prior to its usage in idtech engines.
>>
File: cosynega.png (89 KB, 832x552) Image search: [Google]
cosynega.png
89 KB, 832x552
>>53814098
OK. I'm serious.

Would you write this?

1) A physical simulator that is a compromise between performance and accuracy. A set of standard physical objects and an articulated creature with sensors and actuators capable of interaction with said physical simulation.
2) A virtual machine with short, concise bytecode with the property that any bytestring is a correct program. A fast JIT (maybe LLVM) implementation of this VM. This VM should be able to host arbitrary programs that control creature from 1) via actuators using data from sensors.
3) A modern genetic algorithm capable of running on multicores and clusters (probably natural evolution strategies or CoSyne).
4) A set of benchmarks set in 1) simulator that are designed to require intelligent behavior to solve them. Think about puzzles, navigation, labyrinths, simple games, pattern recognition. A set of benchmarks uses 1) simulator with creature controlled by arbitrary 2) VM software and outputs a fitness number, higher is better.

Then I'd like you to run 3) genetic algorithms on a sufficiently large cluster (perhaps in AWS or Azure) to breed 2) arbitrary VM software against 4) benchmark until it shows signs of general intelligence. Then email me, I'll inform you on our next steps.

You called yourself a god? Do your work then (^:
>>
>>53814296
Pick a project and re-implement the solution in each language instead of cherry-picking ones you think would be "the best" language to learn.
>>
>>53814362
I thought it was William Kahan
>He is an outspoken advocate of better education of the general computing population about floating-point issues, and regularly denounces decisions in the design of computers and programming languages that may impair good floating-point computations
He sounds just about autistic enough
>>
>>53814006
I know this is a troll but programming language is BARELY related to verbal language. You don't solve complex problems with English grammar for example. This is why men are inherently better at programming.
>>
>>53814372
Pay me how much
>>
When is April Fools over in America? I'm sick of this stupid theme.
>>
>>53814441
6 more hours
>>
>>53814441
5 hours-12 hours spanning from east coast to hawaii
>>
>>53814372
Child's play
>>
>>53814439
I don't require you to write everything by yourself, you may use any opensource and closedsource libraries.

If you succeed in evolving general intelligence I can pay you dozens of millions $. [spoiler]In this case you'll be able to earn it via stock trading on your own though[/spoiler]
>>
>>53814098
Oh really?
Build us a ReCaptcha solver, then =]
>>
>>53814487
Actually I can write it by myself. I'm writing a simple prototype right now.
>>
>>53814372
The idea of using random mutations to generate a useful program is not a good one.
Infinite monkeys can make a working program, but that's a lot more time and monkeys than you can afford.
>>
>>53814006
I just love the if(a > b && b < a)
>>
Why be an Alpha male when you can be an alpha shemale?
>>
>>53814404
>William Kahan
Maybe. Nobody really knows though. Michael Abrash did help out the guys at id for some super low-level optimizations which spawned the fast inverse square root in their source. Who is responsible for the original version of it though is still a mystery. Carmack was too busy sperging on affine texture mapping looking like ass to bother with that though.
>>
>>53813769
Anyone?
>>
>>53814536
Mutation isn't the main component in GAs. Genetic algorithms cross-breed these programs, so only the best performing pieces of code survive.

Also my point is that there is no need in breeding a truly complex (say, 1 million bits) program. A general learning algorithm, like any fundamental algorithm, is probably much shorter, max 100 kbits.

It is hard, but it has been done: http://people.idsia.ch/~juergen/compressednetworksearch.html
>>
>>53814602
>>
>>53814441
Press F12 and paste this in console pham.

var css = document.querySelector('link:nth-child(14)');
css.parentNode.removeChild(css);
>>
>>53814599
What's wrong with what you're currently doing?
>>
>>53814621
>>
>>53814602
I believe than in any non-trivial scenario, this will not be worth the cost. You will invariably run in one of two problems: either you are over-conservative with mutations and will stay stuck in a local minimum forever, or you will waste innordinate amounts of time exploring garbage strains of code.
>>
>>53814553
a > b doesn't imply b < a in a partially ordered set
>>
>>53814711
If your operators don't follow natural semantics, your code is semantically broken.
>>
>>53814728
>i don't understand maths but let me lecture you anyway
>>
>>53814750
I understand math, but I also understand that the people who will read your code will make assumptions.

And please don't start patting yourself on the back as if having notions of partials orders will win you a Fields medal.
>>
I don't understand how are you guys so good at programming? I don't even understand half of the things you are talking about
>>
>>53814708
Your conjecture should be proven or disproven by experiment.
So far it is known that with modern algorithms it is possible to evolve simple control programs for various benchmarks. Its unclear were the complexity limit is.
If we could evolve a general intelligence (even a simple one) that would be a very significant breakthrough.

Of course mutation and breeding regime is a parameter of the experiment, it should be tweaked to achieve desirable selection mode.
>>
>>53814778
the same code isn't meant for everyone, and it's fairly easy to observe overloaded operators
>>
>>53814711
preorder* and some that fall halfway
>>
>>53813747
S-Sauce please, senpai.
>>
is there anyone that knows about sorting algorithms willing to help me with comparing them?
>>
>>53813781
why
>>
>>53815055
Just Use Quicksortâ„¢
>>
Node callback hell is real, and not only am I in it, I'm contributing.

                                                        cb (null, item_name);
}
}
}
}
);
}
}
}
);
}
break;

default:
cb(null, item_name);
break;
}
}
}


Whatever. My client is happy, and my bills get paid.
>>
>>53815055

Sure: qsort is plenty good enough.

Thanks for asking.
>>
>>53815055
Without context, use quicksort. If you can provide some background to the problem I can tell you why you might want to use something else.
>>
>>53815090
>Javascript was described as "we want to do lisp in the browser" to get its designer interested, if I remember that interview correctly...

>Indeed, Waldemar Horwat once told me that he viewed JavaScript as essentially Common Lisp with a C-like syntax. In fact Waldemar defined a metalanguage, wrote an interprepter for his metalanguage in Common Lisp, and then wrote the JavaScript spec in his metalanguage, thereby enabling him to actually run the specification. It was a clever technique.
>>
File: logo-qt-company.png (17 KB, 540x240) Image search: [Google]
logo-qt-company.png
17 KB, 540x240
/dpt/
do you think qt is kill now that xamarin is free?
>>
ok well i would be using quicksort but i've got to compare quicksort to other ones
        static void MergeDescending(float[] data, float[] temp, int low, int middle, int high)
{
int ri = low; // result index
int ti = low; // temp i
int di = middle; // destination i
while (ti < middle && di <= high)
{
if (data[di] < temp[ti])
data[ri++] = data[di++];
else
data[ri++] = temp[ti++];
counter++;//////////////////////////////////////////////////////////
}
while (ti < middle)
{
data[ri++] = temp[ti++];
counter++;////////////////////////////////////////////////////
}
}


                if (i <= j)
{
temp = input[i];
input[i] = input[j];
input[j] = temp;
counter++;
i++;
j--;
}

the first part is where i've put the counters for the mergesort one, and the second is where i've put them for the quicksort one. the problem is that it's giving me a very high value for the mergesort one (9454) where i'd expect it to be closer to quicksort's one which is 223. are the counters in the correct places?
>>
>>53815166
if (data[di] < temp[ti])
data[ri++] = data[di++];
else
data[ri++] = temp[ti++];



data[ri++] = data[di] < temp[ti] ? data[di++] : temp[ti++];
>>
>>53813724
whats the problem with casting the return value of malloc()?
>>
What's the best beginner Python textbook
>>
>>53815191
makes you look like a sepples monkey

>>53815193
none at all - then you won't have to learn python
>>
>>53815055

To sort a million lists of 10 elements each, use insertion sort

To sort 10 lists of a million elements each, use intro sort (or quick/merge/heap/whatever as long as it's n log n).
>>
>>53815230
ok but i've got to compare them myself, i'm a uni student, and the counters aren't in the right places
>>
>>53815218
But I want to learn
>>
Can someone link that one picture with the tons of coding projects?
>>
>>53815322
https://better-dpt-roll.github.io/
>>
is /dpt/ kill?
>>
>>53815366
Jesus fucking Christ, I'm fapping right now, do not interrupt me over such trivial matters again
>>
>>53815376
Shut the fuck up
>>
>>53815376
Hope you look at trap hentai while fapping, anon
>>
File: 1454569654817.png (449 KB, 1024x640) Image search: [Google]
1454569654817.png
449 KB, 1024x640
Is the GoF Design Patterns book still worth reading? I've never read it, but every time I read about it on forums it sounds like it's deprecated and a shitty way to do things now.

Pls help
>>
>>53815443
no
>>
>>53815457

What should I read instead?
>>
>>53815502
Nothing > GoF
Design patterns are an antipattern
>>
>>53815502
I read Head First design patterns. I thought it was really good. If you're gonna live in Java/C# land, it's worth knowing.
>>
>tfw two monitors will never be enough
>tfw three monitors will also probably never be enough
>>
>>53815523
true, 3 monitors is nice though.

I used to have 4 in my old office. That shit was sweet.
>>
>>53815523
>multiple monitors
>not a spherical monitor room
>>
>>53815191
something about hiding a potential error
>>
>>53815164
Qt has always been shit-tier for mobile apps, so not really. They just have some competition.
>>
>>53814789
Get off of 4chan, and actually attempt to code some shitty programs for a year or so, you'll talk the same way.
>>
DICKBUTT
>>
/dpt/ is deader than dead
>>
>>53815136
>clever
lispfags everyone
>>
>>53815974
You are free to discuss genetic programming with me, anon.

So, nobody wants to play a god? >>53814372
>>
>>53814708
this

>>53814800
people with a lot (A LOT) more resources than you and i are already (trying to) do this
>>
>>53816013
give me 10 women and 9 months and i'll give you at least 5 general intelligences
>>
>>53816047
>people with a lot (A LOT) more resources than you and i are already (trying to) do this

It may be true but I'm not sure, I haven't seen large scale experiments with similar setup and end goal. Perhaps there is too large a chance that it won't work, perhaps the researchers aren't interested in this path to AGI.

There is heavily financed modern machine learning, but its very different from this approach (not to say it's bad, it's actually very good)

I like the idea that it's quite possible that universal learning algorithm can be expressed in <10000 bits of code, and if you find it (by luck or by cleverness) you have your own strong AI.
>>
>>53816086
Nah, I want intelligences that are easily copyable. Imagine training one AI instance as a biologist and then straightforwardly using 1000 instances of it in the cloud to solve relevant scientific problems.
>>
read http://ttapress.com/553/crystal-nights-by-greg-egan/
>>
File: NothinPersonnelKid.gif (270 KB, 500x468) Image search: [Google]
NothinPersonnelKid.gif
270 KB, 500x468
AHHHHH HOW THE FUCK DO I CONVERT A CHARACTER ARRAY TO A STRING WITHOUT ANY OF THE FUCKING EXTRA GARBAGE CHARACTERS????????
>>
>>53816451
https://en.wikipedia.org/wiki/Null-terminated_string
>>
rate my random name generator
char *random_name(list_t *names, list_t *surnames)
{
unsigned name_sel = rand() % names->total;
unsigned surname_sel = rand() % surnames->total;
unsigned str_size = strlen(names->arr[name_sel]) +
strlen(surnames->arr[surname_sel]) + 2;
char *str = (char *) malloc(sizeof(char) * str_size);
sprintf(str, "%s %s", names->arr[name_sel],
surnames->arr[surname_sel]);
return str;
}
>>
>>53816451
a character array IS a string, you dummy
>>
>>53816471
>unsigned instead of size_t
>+2 instead of +1
>sizeof(char)
>Casting malloc
It's shit.
>>
I just wasted an 8 gb download and 3 hours trying to pirate matlab

what's the best alternative?
>>
>>53816524
Its ok, +2 is right
>>
>>53816164
considering that this is going to be computationally (and therefore financially) expensive to run, I'd need to see some research to suggest that it is possible at all, or that there's some theoretical advantage to this over other methods.
>>
>>53816539
octave
>>
>>53816539
mathematica
>>
>>53816540
Oh right, I forgot about the space. If I wasn't worried about portability, I would just use asprintf.
>>
>>53816471
>char *str = (char *) malloc(sizeof(char) * str_size);
char *const str = malloc(sizeof *str * str_size);
>>
>>53816573
Why const?
Also, sizeof(char) is self-documenting, you're visually reaffirming that you're allocating str_size bytes.
>>
>>53814988
mizugi kanojo ep 2
>>
>>53816643
why the fuck not const, you're not going to reassign it

if all you want to "document" is the number of bytes, then just put str_size. with sizeof *str on the other hand you can change the type in one place and the rest will follow
>>
>>53816668
>sizeof *str

so now it's sizeof(char *) * str_size
good going, fucking retard
>>
>>53816545
>I'd need to see some research to suggest that it is possible at all
Some state of art evolved software http://people.idsia.ch/~juergen/compressednetworksearch.html driving a car from pixels isn't an easy task.
Another example of evolving a brain+body http://creativemachines.cornell.edu/electrophysiological-soft-robots
Another example of neuroevolution http://eplex.cs.ucf.edu/hyperNEATpage/HyperNEAT.html

First one is the most relevant.

>or that there's some theoretical advantage to this over other methods.
There is one advantage: solution search space is equal to set of all algorithms (i.e. Turing-complete). Modern ML techniques mostly work in more constrained search spaces. Of course it leads to disadvantages - huge computational cost.

About resource consumption - with modern low power smartphone ARM socs (people literally throw them away after 2 years of usage) it should be possible to build e.g. 10 million core cluster. GPGPUs are another possibility. Ofc if you have some funding (^:

A prototype should work on any multicore PC or server though.

To me it looks like designing the simulated environment & benchmarks is the most complex part. Environment should drive program search into finding a general learning algorithm instead of overfitting.
>>
>>53813832
Stop coming here
>>
>>53816679
what the flipping fuck you retard

look

http://ideone.com/KbQ03h
>>
>>53816545
desu there is some evidence that this startup is pursuing a research program similar to what I have described: https://nnaisense.com/
Still, playing with this tech as an amateur is fun (^:


>NNAISENSE leverages the 25-year proven track record of one of the leading research teams in AI to build large-scale neural network solutions for superhuman perception and intelligent automation, with the ultimate goal of marketing general-purpose Artificial Intelligences.

Its no joke, they are world-class researchers.
>>
>>53816662
Thanks a lot, anon.
>>
Has anyone gotten Pajeet Pooinloo yet?
>>
I have a cool idea but I'm not gonna tell you guys or you'll steal it :)
>>
https://www.youtube.com/watch?v=9Vyq24V5XFo

am i the only one who thinks this looks like complete shit, at least visually

it needs to tone the lighting effects the fuck down and it can afford to have a little bit of color
>>
Is clojure a meme?
Should I use flask?
Is php THAT Bad?
>>
i make 6 figures and i barely try at my job. it's easy. almost everyone i work with is incompetent. ("enterprise" / large company)

i've had jobs that pay less and are much harder. (companies < 100 employees)

the worst part about my current job is that everyone is old (35+) and they just gossip all day. talk shit about whoever isn't there and just pry into people's lives, since they can't program.
>>
>>53817327
Money is amazing at large companies but it is so hard to get anywhere or get recognized. After having worked in both it's much better mentally to make alright $$ at a small company (which is still a REALLY good paycheck) than to make massive bank and have no satisfaction. Comfy startups ferdajuggski.
>>
>>53817352
I don't know, I save and invest heavily. The extra money will help me retire earlier. I agree that it's much less fun at large companies though.
>>
File: scroll.webm (3 MB, 644x528) Image search: [Google]
scroll.webm
3 MB, 644x528
>>53813724
trying to figure out how to rotate backgrounds
>>
>>53817327
>1) A physical simulator that is a compromise between performance and accuracy. A set of standard physical objects and an articulated creature with sensors and actuators capable of interaction with said physical simulation.

I want your job
>>
>>53817396
Well, to warn you, it's windows.
I had to install a linux VM on my computer to stay sane.
>>
Is it true that only cucks use Python?
>>
>>53814372
>2) A virtual machine with short, concise bytecode with the property that any bytestring is a correct program. A fast JIT (maybe LLVM) implementation of this VM. This VM should be able to host arbitrary programs that control creature from 1) via actuators using data from sensors.

> implementing 256 valid bytecode operations

ughhh
>>
>>53817309
yes
no
yes
>>
>>53814595
> affine texture mapping
> in quake 3
anon pls do your research
only quake 1 and 2 used affine texture mapping, and only for 16-pixel spans at a time, with perspective correction in between each span
>>
File: temp.png (135 KB, 923x558) Image search: [Google]
temp.png
135 KB, 923x558
this is literally what outlook.com looks like in internet explorer? is it an april fools joke or something?
>>
>>53814372
Holy fuck how many times are you going to post this crap here
>>
>"Thanks to MicDrop I just lost my job," claimed one user on Google's product forums.

>"I am a writer and had a deadline to meet. I sent my articles to my boss and never heard back from her. I inadvertently sent the email using the MicDrop send button."

>Another complained that they had been having interviews for a job with a company for three months and then accidentally sent a mic drop email to the HR department.

APRIL FOOLS

https://www.youtube.com/watch?v=sIhe3ZaoSXo
>>
File: badddy.png (57 KB, 1396x692) Image search: [Google]
badddy.png
57 KB, 1396x692
Whoa, I haven't been here for a little bit but what the fuck happened here?

Shock at the site design aside, I was curious if any of you have some experience working with the ddx and ddy functions in HLSL. I didn't understand their functionality well for some time but I think I get it well enough to potentially make some use out of it now. It doesn't seem to be particularly explained in detail in many/any places, at least not at a level I can understand well.

To briefly explain the picture, I just take the surface normals of a simple cube and then take the ddy of the resulting rendered texture's color. I can understand what's going on well enough, except for why it's so messy/hole-filled.

My question is, does anyone know why am I getting the result on the left, and how could I get the function to produce a cleaner result? Is this caused by color banding(or something similar)?

In case it isn't clear the modifications I'm making to the resulting value(abs,*100) serve no purpose other than to aid in visibility for testing.
>>
>>53817375
Like that? that looks like a simple shearing, check this:

http://www.maa.org/external_archive/joma/Volume8/Kalman/Linear3.html
>>
>>53817375
>what is trigonometry
>>
>>53816558
Why do dumb-dumbs think these two languages are comparable? Because their names sound similar?
>>
>>53817614
how are they not comparable for fuck's sake? what's wrong with mathematica? what would be a better alternative to matlab?
>>
>>53817636

R, Python, anything else really...
>>
I just got a copy of C# Step by Step 2015 by John Sharp, just slowly working my way through it.
>>
>>53817636
What about Octave?
>>
>>53817636
Have you used either? I don't think you'd be asking this question if you had.
>>
how do i make a FIFO producer/consumer threads (items that are produced first are consumed first) using an integer array buffer?
>>
>>53817805
In which language? post some code.
>>
Does anyone have a link to that one online course that was about algorithms on 3D meshes? It had a thing where you would generate a prosthetic nose for a face based on the statistics of other faces?
>>
File: WAAAAAAAAAAH.jpg (297 KB, 1280x720) Image search: [Google]
WAAAAAAAAAAH.jpg
297 KB, 1280x720
>go to job interview
>"alright, for this next part, i want you to go up to the whiteboard, and write a function that returns an array of cartesian coordinate points that plot a circle"
>"you can use any language you like, but you only have 10 minutes"
>my face internally
needless to say, i didn't get the job
>>
>>53817555
site layout is april fools
>>
>>53815090
get with the times, learn promises/babel/es7

https://jakearchibald.com/2014/es7-async-functions/
>>
>>53817856
>cartesian coordinate
Just, like, use cos and sin for the coordinates, and multiply the vectors by the radius, add to that the center position and you're done.

You didn't deserve the job.
>>
>>53817856

function test(r){

var values = []
for(a=0;a<360;a++){
x = Math.sin(a)*R
y = Math.cos(a)*R
values.push([x,y])
}

return values

}




assuming the circle is at 0,0
>>
>>53817856
typedef struct {
float x;
float y;
} point_t;

point_t *plot_circle(float radius, float resolution)
{
float x, y, angle;
unsigned count = 0;
for (angle = 0.0; angle <= (2.0 * M_PI); angle += (M_PI / resolution))
count++;
point_t *plot = (point_t *) malloc(sizeof(point_t) * count);
unsigned index = 0;
for (angle = 0.0; angle <= (2.0 * M_PI); angle += (M_PI / resolution))
{
plot[index]->x = sin(angle) * radius;
plot[index]->y = cos(angle) * radius;
index++;
}
return plot;
}


can i have a job now?
>>
Made a thing.
https://www.shadertoy.com/view/Xd3SDM
>>
>>53817955
is it really prudent to do twice the work just so you can allocate an exact fit?
>>
>>53813769
Well, all of your print statements could be combined into a single format string.
>>
>>53817570
Yep, I'm using shearing (horizontal and vertical scroll). I don't think it can handle a full rotation perfectly, but I'm definitely doing something wrong.

>>53817603
> what is using horizontal and vertical scroll registers and not pixel plotting
>>
>>53814006
min(1,1) //5

kek
>>
>>53817955
>malloc
>Not making the caller pass in a buffer instead
>Using a for loop to count the number of elements instead of just using division
>Unused x and y
>Not declaring variables inside the for loop
Don't call us. We'll call you.
>>
>>53816539
Matplotlib
>>
>>53818047
>but I'm definitely doing something wrong.
How are you doing it?
>>
>>53818047
>2016 A.D.
>>
>>53818069
>malloc
i'm going to be filling the entire array, there's no need to zero initialize
>make the caller pass in a buffer
They would also have to pass in the size of the buffer, and the only way to accomodate this is to exit the function as soon as the buffer is full, regardless of whether it's done or not.
>not declaring variables inside the for loop
C89 doesn't like that
>>
>>53818073
Calculating dx per row, and dy per column.

// scroll-offset per 16-pixel column
s16 vScrolls[NUM_TILES/2];

// scroll-offset per scanline
s16 hScrolls[SCREEN_HEIGHT];

void rotateTileMap(fix32 angle, int plane) {

fix32 dx = fix32Div(cosFix32(angle), FIX32(PIX_PER_TILE));

// 2 tile vertical-scroll granularity
fix32 dy = fix32Mul(sinFix32(angle), FIX32(2));


fix32 offsetH = 0;
fix32 offsetV = 0;

for(int i = 0; i < SCREEN_HEIGHT; i++) {
hScrolls[i] = fix32ToInt(offsetH);
offsetH += dx;
}

for(int i = 0; i < NUM_TILES/2; i++) {
vScrolls[i] = fix32ToInt(offsetV);
offsetV += dy;
}

VDP_setHorizontalScrollLine(plane, 0, hScrolls, SCREEN_HEIGHT, 1);
VDP_setVerticalScrollTile(plane, 0, vScrolls, NUM_TILES/2, 1);
}

I fiddled with quadrants a bit earlier but didn't figure out the problem. Tb.h i'm half drunk right now and not working on it but if there's an obvious problem let me know.
>>53818082
> i don't know what gens is
>>
>>53817826
C
>>
File: pajeet on facebook.jpg (126 KB, 1023x623) Image search: [Google]
pajeet on facebook.jpg
126 KB, 1023x623
>>53818142
>>
As the informed technical citizenry of the world, what do you do to help dispel the myth of the technological singularity? We can all agree that the idea is unrealistic and ultimately harmful to technological progress.
>>
>>53818134
>gens
what

i swear what you're doing is deprecated and less efficient than using opengl
>>
>>53818192
>technological singularity
literally what are you talking about

i swear normal people don't give a shit and it doesn't matter
>>
>>53818193
I could run it in exodus if i cared but it doesn't really matter for a simple test
>>
>>53818119
>C89
>2016
I think you should probably kill yourself.
>>
>>53818204
wtf are you on about

>>53818208
also this
>>
>>53818213
why do you have a problem with writing code for an old platform?
i'm doing it for fun so it shouldn't bother you
>>
>>53818217
well i'd love to hear how you're going to do fine-grained rotation without using trigonometry
>>
>>53818208
enjoy your compiler errors, faggot.
>>
>>53818233
i wonder what sin and cosine are, if not trigonometry. I already know you can't do full rotation with only two shears, but damn, can you even read?
>>
>>53818237
I use compilers that have been updated this millennium.
>>
>>53818255
read a fucking textbook

you're not going to be doing any geometry manipulation without at least memorizing some equations
>>
File: 1448870372218.gif (3 MB, 550x309) Image search: [Google]
1448870372218.gif
3 MB, 550x309
>Bdubs only place open for late night dinner
>oh god I hope I don't have to call to order
>tfw they take online orders
Crisis averted lads
>>
>>53818388

Unlimited wings at BWWs is pretty good. Of course, you DO have to talk to people. I guess that's a problem for you.
>>
>>53818365
i already have rotation and scaling routines for arbitrary bitmaps, it's not that hard. i just quickly threw together some code and posted it on here without getting it right first, and you think it's a big deal
>>
>>53818480
hard enough for you to post it begging for help
>>
>>53818442
Naw, it's moreso having to talk over the phone. The person on the other end will always ask a question that I can't understand and have to make them repeat 5 times
>>
>>53818497
I didn't though, someone just asked me what I was doing.
>>
>>53815961
this
>>
>>53818134
Wow, that's really look complex, so i can barely understand it. But, if you want to rotate it instead of shear it, you can try with this:

https://www.ocf.berkeley.edu/~fricke/projects/israel/paeth/rotation_by_shearing.html
>>
>>53818566
>israel
>>
File: args[].png (68 KB, 1454x287) Image search: [Google]
args[].png
68 KB, 1454x287
Kinda was just wondering... should I read arguments as strings? is there anything bad about that? I know a lot of programs usually accept chars, instead.

Also, it seems common to calls the value ", char *argv[]", but I prefer ", *args[]". argc makes sense, because it's a count. argv seems eh to me. Yeah, it IS a vector, but...

Anyway, this is only a test CLI program. I never actually made something that can run with CLI args (or argv ... you see, you can say "args" and it's fine, but you don't SAY "argv").

Just kinda wanted to try a C++ program that can take them, though.
>>
>>53817465
I didn't say idtech3 used affine texture mapping. In fact, it should be inferred that it wasn't because Carmack spent the time to get perspective-correct texture mapping working...
>>
>>53818745
only the signature matters, in C.
you could have
 int main(int count, char** strings) {} 
and it would still be technically valid. they are c strings and the array is null terminated.
>>
lads would any of you say you're fluent in C++? I would say im fluent in C (started writing in 2012) and i want to make the leap to C++ but it seems like a lot of the "best practices" are convoluted things like smart and scoped pointers and being forced to use boost.
>>
>>53818926
hmmm, ok then. Thanks
>>
>>53818988
I wouldn't go so far as to say "fluent". I know a decent amount. I plan to learn a lot more though in the future.

However, if you don't like the way C++ handles a lot of things, and you're already good at C (which I'll be trying to back-learn over time), there's always the "C with Classes" approach. It's essentially using C-style wherever you can/want and throwing in C++ Object-Orientation (classes, encapsulation, polymorphism, etc.) as necessary.
>It also appears to be the actual name for C++ before it had full implementation
>>
>>53817453
what should I use then
>>
What is you guys' favorite book on basic computer architecture concepts?

What should I read to know more about virtual memory, handling interrupts, cpu internals, multithreading, and other stuff in the similar vein?
>>
File: Abstract_Factory-2x.png (75 KB, 1406x1018) Image search: [Google]
Abstract_Factory-2x.png
75 KB, 1406x1018
whats the difference between the outlined arrow heads and the stick ones?
>>
>>53819309
Patterson & Hennessey

>>53819339
Looks like inheritance vs implementing an interface
>>
>>53819358
ah so the stick arrows is class1 implementing those 3 interfaces and the outlined ones are those instances of the interfaces inheriting the interface?
>>
File: So far.png (105 KB, 1167x849) Image search: [Google]
So far.png
105 KB, 1167x849
>>53813724
I'm only starting this assignment and I'm already at a wtf do i do point.

Here's my code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class DollarStoreNope extends JApplet implements ActionListener
{
private JLabel n1 = new JLabel("Enter sales person number (1-4): "),
n2 = new JLabel("Enter product number (1-5): "),
n3 = new JLabel("Enter sales amount (0.01-0.99): ");
private JTextField tf1 = new JTextField(5),
tf2 = new JTextField(5),
tf3 = new JTextField(5);
private JButton b1 = new JButton("Submit"),
b2 = new JButton("Clear");
private JTextArea ta = new JTextArea(7, 25);
private int entries = 0;

public void init()
{
setLayout(new FlowLayout());

add(n1);
add(tf1);
add(n2);
add(tf2);
add(n3);
add(tf3);
ta.setEditable(false);
add(ta);
add(b1);
add(b2);
}
}


<HTML>
<APPLET CODE="DollarStoreNope.class" WIDTH=400 HEIGHT=230>
</APPLET>
</HTML>


How do I make the text area have 8 rows and 58 columns while fitting into a dimension of 400x230? I've tried doing
   private JTextArea   ta = new JTextArea(8, 58);
but that made the text area bigger than the applet viewing area.
>>
Genuinely curious why you guys like to hate on Java so much. Can someone explain to me what's bad about it other than being old?
>>
>>53819358
>Patterson & Hennessey
Just to make sure, is it this one?
www.amazon.com/Computer-Organization-Design-Fifth-Architecture/dp/0124077269

A lot of the reviews complain about typos, though.
>>
Why is stringstream fucking with my shaders?
>>
>>53819309
P&H is the standard if you're interested in CPU architecture and hardware level stuff. Most the topics you listed are usually considered topics in operating systems. There's no canonical book in that field but Silberschatz Galvin and Gagne is pretty popular and pretty good IMO, sometimes it's called the dinosaur book
>>
>>53819466
I'll look into that one too, thanks.
>>
>>53819381
It's a library language taught primarily by universities with CS programs stuck in 1996.

Literally everyone that learns it never learns a second language, and so it has become synonymous with people who only learned programming as a means to an end, and that end is gainful employment, not because they actually enjoy programming.
>>
>>53819381
Object oriented programming is a giant abortion
>>
>>53819486
I agree to some extent, but I mean what's actually inherently wrong with the language itself? I've seen comments like that, and I'm aware that Java coders (esp. who only know Java) aren't the best programmers, but I feel nonetheless that Java is pretty good overall as a language in terms of following and encouraging good software design.
>>
File: Untitled.png (24 KB, 747x506) Image search: [Google]
Untitled.png
24 KB, 747x506
>>53819462
To elaborate. If I insert
ss.str("");

Anywhere in my message loop the first texture uniform I added doesn't work.

I know the colour scheme is physically painful to look at but I was in the middle of doing something else when this shit started.
>>
>>53819521
why
>>
>>53819521

And why do you believe this?
>>
>>53819564
>>53819555
It's called trolling, mom.
>>
Give me three reasons why I shouldn't learn Clojure.
>>
>>53819525
I hate java primarily because of the way it's taught, not because the language is inherently bad.

Java classes will dump tenets of object-oriented design on you without ever explaining why they're good or why you should be doing things in OOP.
It really fucks you up, especially when you're just starting out.
A beginner should always start with a simple language like C and then, in time, learn to embrace the good parts of object oriented design.
the most useful parts can be easily recreated or implemented in a language that doesn't even have OOP features
>>
>>53819381
Generics are weak (poorly expressive despite being pretty complicated and horrendous line noise)
It's very bureaucratic both in syntax and in the access modifiers
Despite a dogmatic in-language commitment to annoying levels of typing stasis any application of any size uses terrible unmaintainable hacks to add the dynamics the language abhors (see: beans, "configurators", factories gone wrong)

But the real reason people hate java is because it's culture is painfully blue collar, people who like it are usually grunt code monkeys who fell asleep in every interesting CS class (or have some shitty non-degree and have never put in the effort to learn some theory) and it permeates the entire development experience: 98% of java code you look at will be written in the dumbest most common denominator way, every API you will use will be verbose and boiler-plate ridden, every conversation you have with other developers will devolve into an argument about object decomposition which is fundamentally meaningless and secondary to any underlying technical challenge.
>>
>>53819573
I can't, have fun.

Incidentally that is exactly what I would say if I hated you and clojure and wanted you to learn it as punishment.
>>
>>53819573
JVM startup times are a pain in the ass when you're testing a small script.
>>
>>53819629

So you use a REPL...
>>
Is it possible to use the C preprocessor to tokenize a string litteral ?

Like, a macro TOKEN, such as

TOKEN("something")

expands to
something


?
>>
>>53819555
>>53819567
Because the textbook definition of an object is "data plus behavior" which plainly means state. On a basic level complexity arises from state. Any thing with state is more complex than with out, so the idea of an object is that whatever member function behavior it has, it's complicated by the state of its data. It's actively discouraged in most OO practices to separate behavior from data and thus it's a fundamentally more complicated approach to design.
>>
>>53819654
what are you asking, exactly?
>>
>>53819670
>which plainly means state.
But that's wrong you fucking retard.
>>
>>53819381
It seems bloated to me. Using it, compiling it, looking at existing code. I've never looked at java and thought "yea, that looks elegant."

I have nothing against it really, I just dislike it as a language and see no reason to use it over C#.
>>
>>53819705
A way to unquote macro arguments.
>>
>>53819573
>>53819629
This. I think you should learn clojure because it's an awesome, well considered language and if it's your first lisp it will blow your mind. BUT the fact that you have to lug around your oversized JVM and an admittedly heavy runtime (and as proven by cljs, not strictly necessary) is the biggest drawback to adoption. REPL helps but it doesn't always work and sometimes you have to make active design decisions either to keep something repl accessible or correct (think things like long-running servers, config loading) which is not a good place to be.
>>
>>53819381
>>53819486
>>53819525

I actually had to get a handle on Java for a Data Structures and Algorithms class.
I already had experience with all the following (to varying degrees):
>C++
>PHP
>JavaScript
>Visual BASIC
>and several other not-really real programming languages: HTML, CSS, Bash, Batch (does this count?), AHK
>and a very basic familiarity with MIPS x64 Assembly (I could do shit like write an adder if I had the ref table handy)

But on learning Java, I realize the following:
>It actually DOES have some good ideas, especially if you need to OOP, such as games, different types of apps, and generally just stuff that would be highly interactive
>the syntax is similar enough to C++ that it's almost like 127.0.0.1
>Given enough time and forgiving the unnecessary level of OOPing FAR beyond what should EVAR be considered acceptable, it's not that unfriendly

BUUUUUUUUUUUTTTTTTT:
The people who write books on how to code it make me wanna slam my head into a brick wall. The For Dummies book I started (will eventually complete that one) is literally the ONLY good Java resource I'd seen. My DS&A book makes me think the language was designed by horse-fucking boonie-dwellers. Where in the Metric FUCK did they design some of this code? What's with the OUTLANDISH level of classing? There's no functional way to utilize Procedural code AT ALL. Why in the fuck is main() a static class method? EVERY FUCKING VARIABLE IS BY REFERENCE. I don't even know what the damn thing is doing with my variables; the VM makes them magically fucking disappear! Efficient? Yeah. Promotes good code? Hell no. I like my local variables and my pointers when I want them. And... fucking Gloat/Double Addition... Just how many online stores overcharged me, I wonder...

But, what is genuinely wrong with Java? Only a few things... a few things that should be fixed when the next VM multi-plat language comes out.
Who the hell knows? Maybe I could be involved in that project.
>>
>>53819381
is it even that old? most languages are much older. C is like 40
>>
>>53819706
How? The behaviour of any object that references its member variables will change with with time and that's what state means.
>>
>>53819555
>>53819564
look at this shit
>>53819339
that's a fuckload of complexity to dump onto your code, and it's completely, 100% superfluous

object oriented programming doesn't make programming easier, doesn't make programming simpler, doesn't make programming faster, and doesn't make programs faster
it does the exact opposite of all of those things
so not only is it pointless, it's actively fucking terrible

when you write code in C, and you need to double the complexity of the program you're writing, you can be safe to assume that the length of the program will double too - code length scales pretty much linearly with complexity - you want to add something in, go and write it
when you write code in a functional language, e.g. lisp, and you need to double the complexity of the program it's like the length of the code scales logarithmically to program complexity, because the abstractions kick in and start to help you out - when you want to add something else in you can start to reuse code in a big way
when you write code in java, and you need to double the complexity of the program, you're going to want to remodel your inheritance hierarchy, split several classes into smaller pieces, separate your interfaces from implementations, encapsulate more of your objects' variables and add in accessor functions, replace half of the interactions between objects with visitors, put several classes in other modules and implement a bunch of 'design patterns' and then when you've done that, you find the size of your program has gone up exponentially, and it's running at half the speed it used to

Java is the only language I've ever used where the abstractions increase the amount of code you have to write
>>
>>53819731
So, overall, I feel Java is actually a pretty good language, BUT it should be much more like C/C++.

The portability is a VERY good concept, but it's like they took the best from similar languages, added a whole bunch of dogshit on top, and still called it an ice cream sundae. Yeah, there's ice cream. There's even sprinkles (such as the high graphical potential and web apps and shit), but it's also WAY too full of random crap and the fact that it ONLY performs as a class pisses me off.

C++ Portable might be a better idea.
>>
>>53814303
>write a blog post about it.
Fuck off and kill yourself.
>>
>>53819773
>OOP is bad because some people go full retard with inheritance and interfaces

Or you can use composition like a real nigga.
>>
>>53816451
>He doesn't use a language where character arrays and strings are the exact same thing.
>>
>>53819773
>object oriented programming doesn't make programming easier, doesn't make programming simpler
This is exactly what OOP does though, assuming it's done correctly. The whole point of it is to increase maintainability and reusability.

It really depends on what you want to do, but most "real world" applications lend themselves really well to OOP structures. Maintaining an enterprise level web application in something like C, for example, would be a complete nightmare.

It ultimately comes down to choosing the correct language/paradigm for whatever you intend to build.
>>
>>53819902
>Maintaining an enterprise level web application in something like C, for example, would be a complete nightmare.

Don't talk about things you know nothing about.
>>
>>53819907
not that guy
tell me more
>>
>>53819902
>assuming it's done correctly
Then I've never seen it done correctly, and I've seen a lot of java
>>
>>53819937
>why doesn't C have 10 billion library functions to do everything for me
>C is a nightmare!!!!!

This is the process thought of all java codemonkeys.
>>
>>53819907
on what basis do you assume I know nothing about this? do you have a counter argument or are you just here to shitpost?
>>
>>53819956
You sound like the "C is portable assembler" type.
Basically the peak of mount stupid.
>>
>>53816539
WHY DON'T YOU JUST BE FUCKING GLAD YOU CAN DOWNLOAD 8GB IN 3 HOURS YOU FUCKING BURGER FUCKER.
UUUUUUUUUUUGGGHHHH FUCK AUSTRALIA THIS PIECE OF SHIT COUNTRY.
>>
>>53819960
>still no counter argument
>ad hominem
not sure what I expected from someone who dismisses an entire design paradigm because they've "never seen it done correctly"
>>
>>53819902

>Maintaining an enterprise level web application in something like C, for example, would be a complete nightmare.

I can only wonder how the guys that make Nginx sleep at night...
>>
>>53820009
Someone has to do it.
Imagine if everyone tried to write everything in scripting library languages because "it's easier".
>>
Yo drop a C compiler gnostic unreachable() macro for me boyz
Thread replies: 255
Thread images: 22

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.