[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: 47
File: DPT.png (389 KB, 934x1000) Image search: [Google]
DPT.png
389 KB, 934x1000
Old thread: >>52096815

What are you working on /g/?
>>
>>52100011
First for synacor challenge
https://challenge.synacor.com/

Why haven't you implemented a virtual machine yet?
>>
I'm currently trying to implement a layout engine for my GUI library.
Does anyone know how I would go about this?
Please don't tell me to look at Qt. Their code is horrendous.
>>
>>52100011
Proof of concept video encoding using remote GPUs for NOSSDAV
>>
Real thread here:

>>52100083
>>
I wish the janny would enforce a one /dpt/ thread at a time rule.
>>
File: 1441953152382.jpg (2 MB, 5000x5000) Image search: [Google]
1441953152382.jpg
2 MB, 5000x5000
I like C. I prefer it to python, c#, c++, java, ruby, d, javascript, clojure, and go.
>>
>>52100130
he does (to the best of his ability), it's just that he's usually not active at this time of day
>>
>>52100139
I like Pascal, I prefer it to any other language.
>>
Both threads have anime garbage, so it doesn't even matter in which one to post.
>>
File: .png (66 KB, 1402x745) Image search: [Google]
.png
66 KB, 1402x745
>>52100011
Learning javaFX and that java a shit. Simulating gravity/electricity and collision(they merge and bounce off window's borders). I think I've seen enough.
>>
>>52100139
I like python the most

lets me prototype shit quickly, solving challenges and riddles people post online

unfortunately we have to use C# and VB at work

not sure what languages the webdev department use though
>>
Why did the real thread get deleted?
>>
>>52100203
How are you posting in it then?
>>
>>52100203
Because it wasn't the real thread. The early thread survived the original thread, and so became legitimate.
>>
Thank you, janny overlords
>>
>>52100011
This thread was posted when the previous /dpt/ was at 290 posts.
By posting in this thread, you are encouraging the shitposting behavior of people trying to race to post their favorite anime pic first.

For future threads, do not jump to new threads created before the bump limit of 310.
>>
>>52100220
You're right, they shouldn't be used immediately. But unless they get deleted, it's not appropriate to create another new thread, either.
>>
>>52100182
Are you Russian?
>>
File: 1438771473501.jpg (12 KB, 251x242) Image search: [Google]
1438771473501.jpg
12 KB, 251x242
>Threadwars literally every time now
>>
Make /dpt/ sticky please.
>>
>>52100228
this lmao
>>
>>52100225
Yes.
>>
>>52100220
posting early threads like this is the only decent option as the autistic trap shill just won't give up
>>
Is there any reason why we can't have an eternal programming thread, the mods sticky it and have the oldest posts automatically delete at 500 or something?
>>
>>52100228
it's literally 1 trapfag forcing himegoto pics and another faggot forcing yuki pics

>>52100238
the trap shill doesn't resort to samefagging his own thread by copy pasting from the competing /dpt/ thread
>>
>>52100234
What is some good quality brand Russian vodka?
>>
>>52100238
what happens when the trap shill makes an early thread?
>>
>>52100250
>it's literally 1 trapfag forcing himegoto pics and another faggot forcing yuki pics
i'm not even an anime fag, i just use it because it's the traditional /dpt/ image that a lot of people can agree is at least better than the himegoto pics
>the trap shill doesn't resort to samefagging his own thread by copy pasting from the competing /dpt/ thread
>/g/ is one person
>>
>>52100243
Unnecessary

Anyone who cries about threadwars hasn't been here long enough
>>
File: 1441577687436.jpg (205 KB, 950x1020) Image search: [Google]
1441577687436.jpg
205 KB, 950x1020
>>52100243
Why don't we just get a fucking programming textboard?
>>
>>52100228
It started ages ago.

https://wiki.installgentoo.com/index.php/Daily_programming_thread#The_Image_Wars
>>
>>52100260
that's what he usually does, which is why we have to make even earlier threads, straddling the line between "too early" (thread gets deleted) and "too late" (after the trap fag has posted his thread)
>>
>>52100243
Ask chink moot.
>>
>>52100256
None. If you want to get drunk quick you're better off making slush out of 96% alcohol anyway.
>>
>>52100274
It's been every thread for over a week now. I haven't seen it this good ever.
>>
>>52100243
>>52100269
Because /prog/ was a shithole filled with spammers, /pol/lacks and Racket memes

>>52100264
This
>>
>>52100277
you can't win
just let the faggot post his thread
he just wants it more
>>
File: c5bcubrc3b3wka.jpg (1 MB, 1200x803) Image search: [Google]
c5bcubrc3b3wka.jpg
1 MB, 1200x803
>>52100256
Not that anon, but this stuff is pretty good. The polish make decent vodka.
>>
>>52100234
Can I store vodka that came in a plastic bottle in the freezer?
>>
>>52100260
We complain in his thread about making a thread too early and we all report him.
>>
>>52100250
yuki has literally been used for years, faggot
>>
File: umaru :D's at your post.jpg (109 KB, 1920x1080) Image search: [Google]
umaru :D's at your post.jpg
109 KB, 1920x1080
multi-threaded linked list stack implementations
>>
>>52100250
>Yuki
>Forcing

All posts by you are hereby disregarded.
>>
>>52100313
What's the point? Just some dark place, it won't spoil anyway.
>>
>>52100274
>Until relatively recent times, Yuki was the only anime girl used in the opening post picture.

Can't we just go back to those times?
>>
>>52100282
It's not about getting drunk quick in this case.
Does that slush like international buying and shipping?
>>
>>52100330
If you put vodka in a freezer for a good while there's no taste when you drink it. Can drink it straight easy. Just i'm not sure about the plastic. I've only done it with glass before.
>>
Conclusion: Hello, Reddit.
>>
>>52100345
Honestly I wouldn't store an organic solvent in a plastic bottle, freezer or not.
>>
>>52100313
Yes, it'll be fine.

The vodka might get hazy, but that's normal.
>>
>>52100355
It's actually the bottle it came in, to my surprise.
>>
Not 1 programming post in 51 posts.

End these fucking threads and let the users scatter.
>>
>>52100387
/dpt/ threads are fun when they're working properly.
>>
>>52100387
What are those:
>>52100139>>52100150>>52100182>>52100186
>>
>>52100297
Thanks for the suggestion, it looks pretty good.
>>
>>52100260
The current situation seems to be:
- new threads created well before the old one hits the bump limit get deleted as duplicate
- threads posted once another "new" thread has been created get deleted as duplicate
- one thread posted around the bump limit stays regardless of OP pic
- people wanting a veto over particular OP pics get butthurt.

tl;dr: all is well.
>>
>>52100274
H-holy shit...
I have no fucking words..
>>
File: mutualfearscare.webm (631 KB, 720x404) Image search: [Google]
mutualfearscare.webm
631 KB, 720x404
Ask your favorite programming literate anything.
>>
File: 1450851058619.png (96 KB, 390x316) Image search: [Google]
1450851058619.png
96 KB, 390x316
Is it possible to have a nice clean float in c++ after a division?
Like 5 / 100 = 0.05000006 instead of 0.0499999996
Or does either affects consequent operations with that result? Like is 0.05000006 * other float different than 0.0499999996 * other float?
>>
Rewriting my stepfile/beatmap generator yet again.
Instead of fully automating the process using the aubio library, I'll be making a hybrid.
The has to edit a config file (I'll later add a normie proof GUI) in order to generate the map. The config file contains some metadata and regions. Regions have a start/end, bpm and a pattern. A region defines a stream of notes. How the notes are placed is up to the pattern.The user can determine the start/end of the region by looking at the waveform of the audio.
Does that sound ok?
>>
>>52100321
When will this be finished?
>>
>>52100516
The config file will look something like this:
{
"name": "song name"
"artist": "song artist"
"types": ["sm", "ssc"]
"regions": [
{
"start": 0
"end" 1000
"bpm": 180
"pattern": "zigzag"
},
{
"start": 1001
"end": 5000
"bpm": 120
"pattern": "holds"
}
]
}
>>
>>52100504
How do we fix the image wars?
>>
>>52100555
Forget about it.
>>
File: dragoncolors.gif (599 KB, 794x795) Image search: [Google]
dragoncolors.gif
599 KB, 794x795
>>52100555
text board
>>
>>52100507
0.0499999996 is closer to 0.05 than 0.05000006

you can set another rounding mode though

http://stackoverflow.com/questions/6867693/change-floating-point-rounding-mode
>>
>>52100228
>newfags
>>
>>52100591
Text boards were slow and boring, the only redeeming features were rare moderation and no captcha.
>>
>>52100507

yes but you're missing the point of floats if you want precision

if you want precision use double or long
>>
>>52100507
use double, never use float. 99% of C and C++ functions that deal with floating point numbers do their maths in double and return floats anyway. Using the float type just adds an unnecessary conversion.
>>
>>52100662
float are much faster than double.
>>
>>52100693
At the cost of accuracy.

You can't have both at the same time but the speed impact doesn't usually matter nowadays so the default is to just go for the doubles for computation.
>>
File: 1449245458353.jpg (17 KB, 320x320) Image search: [Google]
1449245458353.jpg
17 KB, 320x320
I'm working on clover
Haha jk update won't be soon xD
>>
>>52100693
Go look at the standard library, every function that uses floating point uses doubles for input and output.
>>
>>52100728
this is actually a big issue, especially with gpgpus

>>52100733
c99 and c11 requires math.h to provide procedures for both float and double. optimizing compilers vectorize better with floats.
>>
quad precision float hardware support when?
>>
https://www.codingame.com/games/puzzles/

even better coding website, much more creative challenging puzzles simulated through games
>>
>>52100591
That's a neat image, anon.

How do I make this?
>>
File: dragon3.gif (183 KB, 650x510) Image search: [Google]
dragon3.gif
183 KB, 650x510
>>52100924
google knuth dragon curves
>>
Do you faggots actually use a makefile for every little one-off script? This is retarded. I asked for advice on how to set up a fast C environment that lets me quickly compile and execute toy programs on Windows using MSVC and everyone's just tells me to use a makefile. I'm not fucking writing a makefile for a script that took me 2 minutes to write.
>>
>>52100968
Visual Studio > Empty Project > Code > Click run button
done.
>>
>>52100968
They're fucking annoying tb h fa m
>>
>>52100968
always used
gcc *.c -o foo.elf
>>
File: boost.png (6 KB, 277x86) Image search: [Google]
boost.png
6 KB, 277x86
>>52100968
Boost.Build

always
>>
>tfw submitted my first pull request and the smelly brown person who said he'd look it over still hasn't merged it.
>>
Reminder that only the following languages are not memes:
- OCaml
- ATS
- Bash
>>
File: loop.png (5 KB, 522x76) Image search: [Google]
loop.png
5 KB, 522x76
why doesn't the loop stop at i == 0?
>>
>>52101168
good one

size_t cannot hold negative values. it is an unsigned type, see wada mean?

so you get a negative overflow (NOT an underflow, other anon), and you end up at 2^32 or something, which is a positive number, so the loop continues.

Use reverse iterators.
>>
>>52100297
Can confirm, it's really good.
>>
>>52101199
yeah, that makes sense
thanks
>>
>>52101199
Or you could set i to size() and not size()-1, compare against 0 and use i-1 in the body.

But no, use iterators

Or pointers if you're like me

>>52101211
You're welcome
>>
>>52100858
With GPGPU, 99% of applications use float32 only because float16 aren't a thing.
>>
>>52100885
Never because nobody needs that shit and float64 is already prohibitively slow for almost any task.
>>
File: images.jpg (6 KB, 241x209) Image search: [Google]
images.jpg
6 KB, 241x209
>finish project at work
>it was a piece of shit that I had to fix
>assigned to a new piece of shit
How can I get some fucking respect in the software dev world? I'm tired of fixing the work of retards, my boss just keeps assigning newfags to new projects, and 6 months down the line he assigns me to fix them.
>>
>>52101255
Maybe you just aren't as good as the new guys? I mean you post on 4chan.
>>
>>52101255
Because the retards can get the base functionality working, but it's up to someone with more experience to make it efficient and work out harder bugs.
>>
>>52101241
screencapped to scratch off another internet argument won in 2030
just you wait
>>
>>52100968
>little one-off script
Scripts don't need compiling so a makefile is only useful if you need to do some preprocessing.
>>
>>52100693

most libraries take doubles as the input and output of floating point arithmetic operations and do auto conversion

floats should really only be used during the calculation or actual computation, otherwise use a double. why? because doubles effectively are floats they're just more accurate

it goes without saying that if you're just doing 5+5 etc then use an int

it depends what you're doing, but if it's a number that needs to be stored or retained, or will be iterated over, use a double. because altho float is faster the lack of accuracy is magnified best case Olog2n every time you run an operation, worst case if your operation is O(n) to the power of whatever, that inaccuracy will cause real problems potentially
>>
>>52101350
>they're just more accurate
because they take up more space and more time to read from dumbass
>>
If % returns the remainder then WHY THE FUCK DOES 5%2=1 AND ITS NOT EQUAL TO 5???? SINCE 5/2=2.5?????
>>
Trying to better understand data structures, made a simple little program that uses a tree to see if a number you've entered has been entered before. Once you decide to stop entering numbers it prints the tree rather half assedly and then frees up the memory.
>>
>>52101458
Because it doesn't return the remainder, it's the modulo operator.
>>
>>52101458
2
2
1
>>>/global/rules/2
>>
>>52101458
>>52101499
Both of you are retarded.
>>
>>52101505
https://www.4chan.org/rules#test
>>
>>52101476
Here's my program, anyone have any tips on how it can be improved?
http://pastebin.com/Jj45yeGV
>>
>>52101458
the remainder of 5 / 2 is 1
5 is 2 * 2 + 1
>>
File: meme triangle.png (44 KB, 602x515) Image search: [Google]
meme triangle.png
44 KB, 602x515
What other memes are there, /dpt/?
>>
>>52101590
FizzBuzz is a critically endangered meme, we need to reintroduce it to /dpt/ lest it go extinct.
>>
File: workdesk.png (1 MB, 3360x1050) Image search: [Google]
workdesk.png
1 MB, 3360x1050
Just for fun, doing login/register system
Learned some OOP in lua, and code is organized waaay better
>>
>>52100693
> float are much faster than double.
Only on a GPU, or if you're using SSE (etc) to perform multiple calculations in a single instruction.

Otherwise, the FPU performs the calculation as double (or long double for x87) and only converts to float when the value is stored in memory.
>>
>>52101609
What do I need to download to run lua code senpai?

I've always wanted to get into lua since I've heard it's lightweight desu.
>>
>>52101590
fp meme
>>
>>52100968
prog: prog.o other.o things.o


Damn that was time consuming.
>>
>>52101626
It's an interpreted language like Python or Ruby, just download the interpreter.

http://luabinaries.sourceforge.net/download.html
>>
>>52101622
If your program is even slightly performance-intensive, then you're using SSE or a GPU.

It only makes "sense" to use a double if you're doing physics calculations that need to be more accurate than what float guarantees. FP is inherently inaccurate, be it double or float. The 50% performance penalty for using double means it's never worth it when you're doing things like ray tracing, physics sims for gaming, movement code, etc.

If you write game code and you use doubles for all your vectors, you deserve to be shot.
>>
>>52101590
NIGGERNIGGERNIGGERNIGGERNIGGERNIGGERNIGGERNIGGERNIGGERNIGGERNIGGERNIGGERNIGGERN
R|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||I
E|||||||||||||||||||||||||||||||MEMEMEMEMEMEMEM|||||||||||||||||||||||||||||||G
G|||||||||||||||||||||||||||EMEME EMEME|||||||||||||||||||||||||||G
G||||||||||||||||||||||||EMEM ER MEME||||||||||||||||||||||||E
I||||||||||||||||||||||MEM TL MEM||||||||||||||||||||||R
N|||||||||||||||||||||ME HI EM|||||||||||||||||||||N
R|||||||||||||||||||EME IL EME|||||||||||||||||||I
E|||||||||||||||||||M HE EH M|||||||||||||||||||G
G||||||||||||||||||ME IL LI IL EM||||||||||||||||||G
G|||||||||||||||||ME HI IH HI EM|||||||||||||||||E
I|||||||||||||||||E TL LT TL E|||||||||||||||||R
N|||||||||||||||||M RE ERE ER M|||||||||||||||||N
R|||||||||||||||||E LT TL LT E|||||||||||||||||I
E|||||||||||||||||ME IH HI IH EM|||||||||||||||||G
G||||||||||||||||||ME LI IL LI EM||||||||||||||||||G
G|||||||||||||||||||M HE EH M|||||||||||||||||||E
I|||||||||||||||||||EME LI EME|||||||||||||||||||R
N|||||||||||||||||||||ME IH EM|||||||||||||||||||||N
R||||||||||||||||||||||MEM LT MEM||||||||||||||||||||||I
E||||||||||||||||||||||||EMEM RE MEME||||||||||||||||||||||||G
G|||||||||||||||||||||||||||EMEME EMEME|||||||||||||||||||||||||||G
G|||||||||||||||||||||||||||||||MEMEMEMEMEMEMEM|||||||||||||||||||||||||||||||E
I|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||R
NREGGINREGGINREGGINREGGINREGGINREGGINREGGINREGGINREGGINREGGINREGGINREGGINREGGIN
>>
File: opcodes.jpg (318 KB, 671x715) Image search: [Google]
opcodes.jpg
318 KB, 671x715
>tfw synacor progress, 6 out of 8 codes acquired
So now, other than running my virtual machine, I have to go through the instruction list and at the point where I "use teleporter" I have to see how it checks against the 8th register, and then manually set the 8th register to the correct value to win.

Fuck, it's microcorruption.com all over again
>>
>>52101590
Python, the ultimate meme.
>>
>>52101458
I don't think you understand what "remainder" means.

5/2 = 2. 2*2=4, 5-4=1

It's what's left over after you've removed as many multiples of the denominator as possible.

For all a and (non-zero) b, b*(a/b)+(a%b)=a.
>>
>>52101673
not this "python is a meme" meme again
>>
>>52101669
Looks difficult tbqh.
>>
>>52101660
Acshully, doubles are useful for shadows because float errors on shadows in the distance are extremely noticeable. There are techniques to fix this like cascading shadowmasks and soft shadows, but using double can provide good mileage with less of a performance hit in some cases (in particular in closed environments).
>>
>>52101364

so just don't fucking use them until you're finished a computation if performance is that important to you, but i doubt whatever you're doing is going to require that level of optimization
>>
>>52101697
Python is a meme. There is literally no advantage to writing Python over, say, a modern language.
>>
>>52101590

>that code

holy fuck that's unreadable
>>
>>52101705
cascading shadowmaps*
I knew I should've drank my coffee first.
>>
>>52101706
Doubles are half as slow as floats. Converting doubles to floats is actually a really easy performance win 9 times out of 10, especially with fp:fast.
>>
>>52101626
>arrays start at 1
>tables everywhere
>no unicode
It's shit
>>
>>52101706
>until
there's no fucking need dumbass, and you're better off thinking the other way, not using doubles until it's absolutely essential. Don't promote this "just use everything if your computer can handle it" mentality because you will not be building big programs anytime soon
>>
>>52101730
It's all on one line for extra meme cred.

var triangle = function(str, n) {
var val = "\n";

for(var i = 1; i <= n; i++){
val += " ".repeat(n-i) + str.repeat(i * 2 - 1).substring(0, i * 2 - 1) + "\n";
}

return val;
}


Is that better, anon.
>>
>>52101697
But really, virtually everything is better than python. The only reason to use python is the 2 worthwhile libraries it has that aren't as readily available in other languages (so basically machine learning and that's about it), and even then those libraries can be ported most of the time fairly easily for niche domains like ML (although theano would be a bit hard, at least there's tensorflow now - if it gets opencl support which they'll do if enough people say "me too" in the relevant issue according to a google rep, then python will no longer be useful to anyone).
The thing with python libraries, just like haskell libraries, is that there are tons, but 99.9% of them are absolute dogshit, and the rest are at this point where there's no alternative and it's always usable, but it's never nice to use and if there was any alternative everyone would take it.
>>
>>52101739
On the flipside, it's fast, it's small, and it's consistent (because tables everywhere, in the same veins as python's dicts everywhere).
>>
File: merryXmas.jpg (128 KB, 1067x535) Image search: [Google]
merryXmas.jpg
128 KB, 1067x535
>>52101730
Agreed, he should have used Python
>>
>>52101769
Where are your comments?

Why aren't you using superior Allman-style?
>>
>>52101733
This, plus converting back and forth from double is slow and memory intensive; absolutely not viable in practice.
>>
>>52101793
Small really is its biggest advantage. Python and Ruby are bloated messes.
>>
>>52101793
>>52101815
It's really easy to use as a scripting language, too. API is nice and simple.
>>
>>52101815
I'd argue that fast is its biggest advantage. It is over 10-20x faster than python or ruby but remains at roughly the same abstraction level.
>>
>>52101733
>>52101759

no because accuracy matters in most cases, especially if there's iteration

technically doubles are more than half as slow, but converting all doubles to floats is not an operation you should undertake lightly in a complex system

you both do realize that doubles are basically floats but basically the conversion process is taken care of automatically?

https://en.wikipedia.org/wiki/Double-precision_floating-point_format
>>
>>52101830
Which has a lot to do with how compact it is.
>>
>>52101660
And the goalpost-moving begins ...

> The 50% performance penalty for using double means it's never worth it when you're doing things like ray tracing,

So you don't actually understand GPU programming, you're just fishing for some context where you're not completely wrong.

I'm interested in what algorithm you recommend for finding quartic roots (i.e. raytracing a torus) that actually gives sane answers with single precision. Hint: there aren't any.
>>
>>52101769

yes thank you based anon for scratching that itch
>>
>>52101857
Why on earth would you iterate over a fp value? Restructure your code to use integers.
>>
>>52101871
>And the goalpost-moving begins ...

You're on /dpt/, the goal posts are in constant motion.
>>
>>52101830
No, it's just more self contained which makes it easier to integrate in other projects.
Apart for a few projects like the neural network ones speed isn't that critical.
>>
File: Flower-of-Life-61circles.png (46 KB, 699x778) Image search: [Google]
Flower-of-Life-61circles.png
46 KB, 699x778
MEME IDEA:

Write a function that returns the flower of life, it should take two parameters, a string that will be used to draw the circles and an integer that will be the number of circles it draws.
>>
>>52100507
Stop thinking in decimal. If you need exact fractions, use a rational arithmetic library. If you don't, the fact that certain fractions could be exactly represented in decimal doesn't really matter; most fractions can't be represented exactly in either decimal or binary so there's really no difference between the two.
>>
>>52101897

approximation, there's a lot of general mathematical functions that have iterations to increase accuracy

better performance wise to iterate over a fp value then to store as a double, then return it to a fp, iterate, store, return, iterate etc
>>
>>52101902
Is it "python is a meme" hour again?
>>
>>52101911
Are memes going too far?
>>
>>52101902
With NN, you don't care much about the host language's speed because you'll offload the work to the GPU.
On the other hand, for webservers, for game AI, for processing large amounts of data just once, for just about anything that's not purely IO-bound in other words, speed does matter, if only because it means you'll use less resources for the same task. That is to say; you might be OK with using 30 minutes to process your data once, but if it could take you 3 minutes instead, that's still a big win, even for a single task, when you don't lose out in ease of development. For anything meant to last or to scale, the performance difference becomes more and more obvious, too. I think what's app used to use python and switched to erlang, allowing them to scale down their hardware by 50x, for example - all because python is very slow, so if you could use lua for the same task from the get go, it would take a lot longer until you need to reimplement a complex codebase due to poor performance.
>>
>>52101911
There is a very strong chance letters will overlap. Hopefully that wouldn't be an issue?

Also should it not take the number of circles per side? Otherwise you might not have the right number of circles to make the whole thing.

Additionally, what should be the pixel radius? Fixed or also modifiable as a parameter?
>>
>>52101967
This thread is too memeful for my tastes, can't we go back to post_count/2.5
>>
>>52101897
That's rather hard if the iteration involves square roots (libraries for constructible numbers exist, but they make rational arithmetic look fast by comparison) or transcendental functions.

Even if you only need division, if you're doing many iterations, either a) the number of digits (and thus memory) grows exponentially and the processing time grows even faster (even the best multiplication algorithms aren't O(n)), or b) 99% of your CPU time goes to the GCD calculation, or c) some combination of both (i.e. reducing fractions to their lowest form only reduces growth, it doesn't prevent it).
>>
>>52101946
Why not just use fixed point instead of floating point, then?...
>>
>>52101997
The number of circles to draw completely describe the shape.
>>
>>52101911
You're probably need a minimum string length of like 30 to make it work, or I guess you could repeat the phrase enough times to meet a minimum number of 'pixels' per circle.
>>
>>52102009
That's what people do sometimes depending on algorithm and value range; i.e. working in 1e6 base instead of 1e0 base.
>>
>>52102017
>The number of circles to draw completely describe the shape.
So it might not even be a flower in the first place? I thought the challenge was drawing the flower of life?

>>52102022
Probably like our other meme projects, it would entail cycling through the word
>>
>>52101997
>There is a very strong chance letters will overlap
Don't quote me on this, but thanks to meme magic I think the letters will line up perfectly.

>>52102022
If the string isn't long enough, the string repeats.
>>
>>52102009
Most languages don't include fixed-point arithmetic, the CPU doesn't support it natively, and it's a pain to implement it yourself without dropping down to assembler.

It also requires fixing the scale of your values up-front, which is a problem if you're trying to write generic code.

Also, sometimes you do actually need the greater precision as you get closer to zero.
>>
>>52101622
sse is the default with the x64 calling conventions, tard. now, the old x87 fpu is emulated on the simd unit, tard. you tard.
>>
>>52102057
>meme magic
I have tapped into this meme magic, and you are right, with bresenham's circle algorithm, you could easily adjust the circle such that the pixels from one interweave through its adjacent circles.

Keeping that in mind, this becomes a meme too big for me to manage
>>
>>52102009

usually refining your approximation doesn't always mean you'll have a fixed point operation to do that approximation, some approximations are really unintuitive

that said if you can do a fixed point operation over a floating point operation from the start then yes absolutely restructure using ints, but in most cases people go with floating point operations for a reason
>>
I need to implement database functionality to my c++ application.
Whats a simple effective tool for accomplishing this? I want the user to be able to log in and have some number stored associated with their account.
>>
>>52102071
It's not whether you use SSE (rather than x87), it's whether you're actually using it for parallelism, i.e. packing two floats into one SSE register and performing the same operations on both.

If you're not doing that (and most FP code isn't), then there's no advantage to using float over double. The CPU will just load one float into a register, expanding it to a double, and perform double-precision arithmetic. The only saving is memory (assuming it was actually stored in memory rather than in a register).
>>
>>52102017
would valid input be 1, 7, 19, 37, 61, 91, 127, etc or any positive integer?
>>
Working out the implementation of codata.
codata Stream : Set -> Set
Head : Stream a -> a
Tail : Stream a -> Stream a

nats : Int -> Stream Int
Head (nats m) = m
Tail (nats m) = nats (m + 1)

Non-recursive fields (Head) can simply be stored. Recursive fields (Tail) are thunks. In C++:
template<class a>
struct Stream {
a Head;
std::function<Stream<a>()> Tail;
};

Stream<int> nats(int m) {
return {
m,
[=] { return nats(m + 1); }
};
}
>>
>>52102210
> you're not doing that (and most FP code isn't),

Citation needed.

You basically just said that most FP code doesn't run in loops, which is false. Have you ever optimized for SSE before?
>>
>>52102214
Any positive integer, if the integer isn't 1, 7, 19, 37, 61, 91, 127, etc it just returns an incomplete flower of life.
>>
>>52102229
Of course, it might also be interesting to have inlining happen, say if you mapped a function onto a stream. Instead of having a thunk within a thunk, the structure could be joined with the code spliced together.
>>
Is there a real difference between having a global struct that a bunch of functions use, vs. explicitly passing that struct to literally 99% of my functions? I'm dealing with some relatively low-level input code, and the keyboard state is a giant struct that almost every function needs access to.

Is there a compelling reason (e.g., optimization?) to pass it as an argument vs. leaving it as a global variable?
>>
File: uu7.png (139 KB, 917x871) Image search: [Google]
uu7.png
139 KB, 917x871
>>52101911
I wouldn't even know where to start.
>>
>>52102331
If you force yourself to pass dependencies like that, which is annoying, you will tend to structure your code so that it's decoupled.

>the keyboard state is a giant struct that almost every function needs access to
Like, this is a big red flag for me. Why do 99% of functions need access to the keyboard?
>>
I downloaded Clang for Windows here: http://llvm.org/releases/3.7.0/LLVM-3.7.0-win64.exe

But it doesn't come with a C standard library. Where do I download one?
>>
>>52102331
Your code will break once you introduce another keyboard state. If that'll never be the case, go ahead.
>>
>>52102331
It's better to keep it as a global struct because it will be mutated between function calls. Passing it by value will cause copies all day err day, passing it by reference will require copying an int in every function call which is a lot more reasonable but not without performance impact. The reason you would pass the struct as an argument instead of keeping it global are 1- to make it explicit that this is what can be modified, and 2- if the struct cannot be modified in most cases, especially if it can't be modified between calls, to adopt a functional style which allows easy multithreading without having to create or acquire locks (which is relatively expensive). Since C is not a functional language, though, it wouldn't apply functional language optimizations such as structure sharing.
>>
>>52102375
>he uses windows
>>
File: 2015-12-28-2135-23.webm (308 KB, 652x368) Image search: [Google]
2015-12-28-2135-23.webm
308 KB, 652x368
Fuck, I broke my meme triangle.
>>
File: 1428353112994.jpg (37 KB, 286x256) Image search: [Google]
1428353112994.jpg
37 KB, 286x256
>>52102375
>he can't even write his own standard library
>>
>>52102410
moderate kek
>>
>>52102354
By calculating the center position for each circle.
>>
File: 1414734592784.jpg (71 KB, 720x540) Image search: [Google]
1414734592784.jpg
71 KB, 720x540
How important are algorithms for software engineering?
>>
>>52102406
>It's better to keep it as a global struct because it will be mutated between function calls.
Is it opposite day or something?

>passing it by reference will require copying an int in every function call which is a lot more reasonable but not without performance impact
>what are calling conventions that use registers
>>
>>52102443
Yes.
>>
>>52102443
Programming is easy, it's algorithms that's the hardest and most important part, anon.

That's why plebs should focus on understanding algorithms rather than learning to program.
>>
>>52102467
>tfw you can't even implement A* in C from scratch

Should I switch majors?...
>>
>>52102459
>>52102467
wow, so its not possible to program without using algorithms?
>>
>>52102450
>I'm retarded!
>>
>>52102482
Absolutely.
>>
>>52101673
>>52101697
>>52101708
>>52101967
Python is not a meme, but "Python is a meme" is a meme.
>>
>>52102518
I've been working on this assignment for like 6 hours and I just don't understand how I'm supposed to translate the pseudocode to C code. A* is fucking retarded.
>>
>>52102493
You can program things, and make things run, but you are not going to do well in a software engineering job if you can't grasp how to think algorithmically. The projects you work on, even in smaller companies will require you to know how design patterns, idioms, anti-patterns and algorithms can be used to make the day to day more productive
>>
>>52102549
Sounds like you're retarded.
>>
>>52102210
lel, no. an example

SQRTSS 16 cycles (sse float)
SQRTSD 27 cycles (sse double)
FSQRT 35 cycles (x87)
>>
>>52101911
Is anyone attempting this? I'd like to see this meme.
>>
>>52102521
If it was a meme, at least it can still pass the averaging 2 ints meme with ease

>>52102561
To add to productive, I mentioned smaller companies because even then your code will still run slowly at times for your clients, especially if it involves connecting to your servers, you will need to have good running time algorithms
>>
>>52102409
>>52102416
Thanks for nothing jerks. Also >implying I'm a guy
>>
>C++ exception handling has no overhead if you don't ever throw an exception.
Bullshit.
int main(int argc, char *argv[]) {
try {
Application app(argc, argv);
return app.Run();
} catch (const std::exception& e) {
Logger().Log(Logger::Level::Fatal, {"Unahndled exception in ", __func__, ": ", e.what()});
} catch (...) {
Logger().Log(Logger::Level::Fatal, {"Unhandled exception in ", __func__, "."});
}
}

clang++ and g++ can not optimize the Run() call into a tailcall. Without the catch clause they can. What now seppele-fags.

Exceptions were a mistake.
>>
>>52102609
For realsies, try downloading Visual Studio Community and using their C library.
>>
>>52102621
>Unahndled
Learn to type.
>>
File: 1451235134521.png (77 KB, 694x801) Image search: [Google]
1451235134521.png
77 KB, 694x801
What is the best programmer meme?

inb4 stack implementations
>>
>>52102609
Use GCC. Clang is the work of the devil.
>>
>>52102645
>he thinks using a linked list for a stack is a meme
>>
>>52102549
mental (cock)block or something. You are able to translate something decent out of a natural language description of something simple (like read characters and make them uppercase), adapting it a bit when necessary, right? So go on, what is it that you don't get?

> how I'm supposed to translate the pseudocode
with your intelligence duh. you've done this before
>>
>>52102609
>>implying I'm a guy
he doesn't know that "he" can be used as gender neutral pronoun when the gender of person we are talking about is not known
Why can't you just kill yourself Rajeev
>>
>>52102660
OK but the data structures that A* needs are a pain in the ass to implement in C. Our prof literally gave us a printout of the pseudocode from Wikipedia and said "Convert this to C over your break."
>>
>>52102645
why a 1000??
>>
>>52102509
Explain yourself.
>>
>>52102621
>
__func__


Won't that expand to hardcoded
"main"
? What is that information useful for? Serious question I genuinely feel dumb right now
>>
File: algs_3rd_edition.png (17 KB, 490x92) Image search: [Google]
algs_3rd_edition.png
17 KB, 490x92
>>52102594
algorithms are only for effeciency
using fast language would compensate for it though
>>
>>52102685
sleep in most languages that have it typically runs on milliseconds

>>52102652
>linked list
>for a stack
>>
>>52102712
Explain why you can't implement a stack using a linked list. I'll wait.
>>
>>52102727
He didn't say you can't, you autist. He simply greentexted it.
>>
>>52102692
Yes it does in the code I posted. I stripped it down from the actual code.
>>
>>52102754
Ya rite thanks for clarifying
>>
>>52102707
If you're using an infinitely fast computer you would still need to use algorithms.
>>
File: 2015-12-28-2153-54.webm (128 KB, 646x368) Image search: [Google]
2015-12-28-2153-54.webm
128 KB, 646x368
It keeps happening
>>
>>52102727
Of course you can, but why would you ever want to?
>>
>>52102707
You would still need to know the basics of algorithms to land a good job and perform it well. Even if all you do is change functions that run in O(n2) time where possible
>>
>>52102779
>Using floating points
>Integer grid
Stop.
>>
>>52102772
For what?

>>52102784
But why?
>>
File: 2015-12-27-0627-08.webm (514 KB, 640x346) Image search: [Google]
2015-12-27-0627-08.webm
514 KB, 640x346
>>52102820
Dude, it's a rasterizer.
Of course you're supposed to use floats.
>>
>>52102820
>>52102846
#REKT
>>
>>52102830
>But why?
Nigga even in my job where our software on the surface looks relatively simple, sometimes when we connect into our client's sites, it can run very slow just because of things like connections and basic functions that could be implemented faster if we had the time.

For even bigger companies like Google, Microsoft and Facebook, their interview process involves algorithms a lot because of much more complex and extended functionality.

If you don't see the importance, then stick to your calculator apps
>>
>>52102682
Yah those heap things... rite...

Never done that

But since heap sort exists, I would say the way to go is an array, let's not do stupid sparse datastructures with pointers shit.

So
top element
1st generation
1st generation
2nd generation
2nd generation
2nd generation
2nd generation
3rd generation ⨯ 8
4rd generation etc...

Should be able to move around with just indices
> highest bit/floor(log2(i)) (don't know how to best access it) -> generation
> rest -> yourself within this generation

tree is binary, blablabla

https://www.youtube.com/watch?v=H5kAcmGOn4Q know this vidya? You should be able to implement the sifts in a contiguous array

Just saying, I have no actual idea
>>
>>52102830
For anything.

For example, shuffling an array.

An algorithm is just a set of instructions to do something.

An infinitely fast computer still needs to know how to do something.
>>
>>52102591
I'm attempting it.

>>52102633
Thank you, that worked.

>>52102662
Maybe you can if you still live in the 20th century.
>>
how do I into haskell?
>>
>>52100011
Wrote an ε-equilibrium solver. Used it for modified forms of RPS, but might extend it to stuff like one-card poker and Kuhn poker.
>>
>>52102900
Not him, but I think it's implied we were talking about algorithms as a subject and not by definition. It's obvious a computer needs to know how to do something
>>
>>52102970
You were literally saying you don't need to use algorithms if you use a fast programming language.

Don't try and samefag your way out of this.
>>
>>52103030
I was the other guy arguing against him actually
>>
>>52102210
>The CPU will just load one float into a register, expanding it to a double, and perform double-precision arithmetic.
Not with sse and avx, you actually have different instructions for single vs double precision (ss, sd, ps, pd suffixes meaning one/single, one/double, packed/single, packed/double)
>>
File: calc.jpg (453 KB, 2880x1800) Image search: [Google]
calc.jpg
453 KB, 2880x1800
> unironically not using Swift
Don't you love yourself?
>>
>>52103134
t. Alberto Barbosa
>>
>>52103134
I don't speak worst language.
>>
>>52103134

You are supposed to program in English.
>>
>>52103161
Nigger loving burger boy <3
xoxoxo
>>
>>52103161
this desu senpai. The shittiest company I worked at wrote everything in my native language.
>>
>>52103161
That's rich, coming from a nigger lover.
>>
https://github.com/vinheim3/synacor-challenge/blob/master/challenge%20with%20comments.py
>he hasn't finished a virtual machine implementation challenge yet
Don't you love yourself?
>>
>>52101168
>use i>0 instead?
>>
>>52100024
I did. In 10th grade.
>>
>>52103234
>he doesn't have an anime avatar
>>
File: opcodes.jpg (93 KB, 671x711) Image search: [Google]
opcodes.jpg
93 KB, 671x711
>>52100024
lads, please save me from this nightmare

>>52103243
are they teaching that early nowadays?

>>52103275
>having any avatar other than default ones
Good luck being employed
>>
>>52101799
>Why aren't you using superior Allman-style?

Nice meme
>>
>>52102682
ok here's what you do.

you goto github

you search A*..in C
if you can't find it in C..find it C++

test to make sure their code works

then you translate C++ into C, and explain how you did it.

done.
>>
I hate the "fan service is bad" meme desu.
>>
>>52102846
nice
>>
>>52103171
>>52103181

t. Balberto Arbossa
>>
We have a serious obsession with memes that needs to end senpais
>>
>>52102682
Here you go, an implementation of the pseudocode from Wikipedia in C

https://github.com/enfiskutensykkel/a-star
Thread replies: 255
Thread images: 47

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.