[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: 26
File: daily programming thread2.webm (2 MB, 600x338) Image search: [Google]
daily programming thread2.webm
2 MB, 600x338
old thread: >>52962646

What are you working on, /g/?
>>
Daily reminder that Javascript is a mental illness
>>
>>52967786
kill yourself?
>>
>>52967786
Could you stop reposting the SAME FUCKING IMAGE IN EVERY THREAD. Thank you.
>>
>>52967898
everyone should try to post a new thread at around 290 replies because spergs like OP will never give up
>>
How do I programm good stuff?
>>
the fuck is up with google's logo for valentine's day? a tissue box giving a box of chocolates to a paper towel roll? am i missing something here or isn't it disgusting because those things are associated with cleaning up bodily fluids
>>
I just spent all day in a LaTeX editor working on a take-home midterm, writing proofs of equivalence for some programs in a made-up stack-based language. I can now understand half the shit Haskellers are talking about, but what I can't understand is why they subject themselves to such torment.
>>
Does Rust have something like extension methods from C#? I want to write a function that can transform any Iterator<Item=u8> to an Iterator<Item=char>.
>>
>>52968113
I think all methods work like extension methods in Rust. Isn't that how the 'impl' syntax works?
>>
>>52968183
Can I use impl on a trait, though? I figured since Iterator is already abstract I couldn't add a function to everything that implements Iterator<Item=u8>.
>>
>>52968253
Oh yeah, sorry.
Rust is functional, just make a function for it?
It would be ideal if you could add a method to a trait though.
>>
>>52968113
>>52968183
>>52968253
and you say java is disgusting then what is this lmfao
>>
>>52968394
People say rust is disgusting as well don't worry.
>>
>>52967786
E A R L Y
A
R
L
Y
>>
Oh shit niggas. I just understood F-algebras and the significance of the initial algebra to the definition of recursive data types.

Take the endofunctor F(X) = 1 + A x X. An algebra of that endofunctor is a set W, an element w : W, and a function f : A x W -> W. The initial algebra is the set of finite lists of A, so that's how you'd encode that set. Notice the similarity between F and the Haskell definition:
data List a = Nil | Cons a (List a)

"List a" is the set, "Nil" is the element, and "Cons" is the function. To do recursion over the list, you have to specify another such algebra. The significance of the data type being defined by the initial algebra is that it's an algebra for which you can define recursion to any other algebra (an object in that category for which there is a unique morphism to every other object, i.e. the initial object). And that unique morphism is the catamorphism, parameterized by the algebra (all other recursion principles can be defined in terms of the catamorphism).
>>
>>52968113
It already exists: it's called map. Well, it exists as a "framework" of sorts, you just have to specify the function from u8s to chars.
>>
File: 084.png (102 KB, 300x256) Image search: [Google]
084.png
102 KB, 300x256
>>52968571
>recursive data types
>>
File: 1420225215089.jpg (9 KB, 225x225) Image search: [Google]
1420225215089.jpg
9 KB, 225x225
HOW IS PROGRAMMING EVEN REALTED TO TECHONOLOGY? GO GET OUT FAGGOTS >>>/pol/
>>
>>52968619
I agree, we need to make room for more consumerism threads and WHAT PHONE DO I BUY THREAD #384732987
>>
>>52968616
Indeed. More generally, they're inductive data types, I suppose.

In your plebian languages, a recursive data type looks like this:
struct List {
int element;
List *next;
};
>>
>>52967975
Haskell doesnt actually take *too* long to get the swing of! give it a solid month and it starts to get much easier!
>>
Why are you here in /dpt/? What are you studying? Do you like it?
>>
>>52968619
!TopkekZdoc #塒ネ「J4H@
!topKekj2RI #璉h佐Id、
!topKekpCkI #qM0/~wU|
!topkekgoTw #qM0R|ュ_如@A
!topkek0sp. #垪オ:pL^=
!topKekCC6A #攀ツ 闢U劇
!topkekdRAo #ェiンj晋\、
!topKekXdhw #゙ヌk轡HiJ
!topKekKjoc #゙ヌk頻6}x
>>
>>52968635
why?
>>
>>52968819
adonbilivit
>>
>>52968832
!topKekphEc #H暾櫚r~;    
!topKekQGyE #ェiンjXO:蓮@A
!topkekjM5U #↑メ嶌蜥沃
!Topkeksk.Y #゙ヌkmV~Vャ
!TOPKEKOFsY #ア塙>{>塩
!TOPKEKzB4A #ア塙MォWNM

>>52968662
>Why are you here in /dpt/?
because I'm terrible at managing my time
>What are you studying?
most effective shitposting methods
>Do you like it?
yes, immensely
>>
>>52968662
To spread programming literacy.
>>
>>52968819
How do you find tripcodes with knowing salt?
>>
>>52968875
what's the algorithm for generating tripcodes?
>>
>>52968898
they're just regular tripcodes, not secure tripcodes (secure tripcodes have an unknown salt)
>>52968908
https://github.com/vichan-devel/vichan/blob/master/inc/functions.php#L2350-L2384
>>
Is there a point in my Qt career where I should ditch the Qt Designer in favor of something else?
I'm only starting my first proper GUI, but there's already a slight feeling of impending restrictions and missing features.
>>
Trying to split data read from a text file in to a linked list where each line is in a node of it's own. Works pretty nicely, that is to say it doesn't crash, but there has to be some errors with memory handling since printing collected lines gives some strange characters for some lines. Those characters are not to be found from original
*fileContent
.

http://pastebin.com/W3QsEc9A
>>
Why am I not allowed to pass a function pointer expecting typed pointer arguments to a function expecting the function pointer to take void * arguments ?

For example:
int cmp(const int *a, const int *b)
{
return *a - *b;
}

...
qsort(..., ..., ..., &cmp);
...



I mean, void * are supposed to be implicitly convertible to any kind of pointers ?
>>
I hate Perl, it's gibberish. If you write Perl, I hate you too.
>>
File: fuck.png (13 KB, 644x177) Image search: [Google]
fuck.png
13 KB, 644x177
how am i supposed to debug this? it only happens somewhat infrequently. does the 0x00000058 imply that the program was trying to use a null pointer (NULL + 88) or is it irrelevant?
>>
>>52969019
Oh I see. I need to add '\0' to the string I'm about to copy. Or at least that seems to fix things.
>>
File: cucumberbatch.png (203 KB, 312x480) Image search: [Google]
cucumberbatch.png
203 KB, 312x480
How the fuck do I into qt?

>hurrrr no valid kits found
what does it mean by this?
I have tdm installed and made a perfectly fine profile for it in qt but I can't create a fucking new project because
>no valid kits found
what does it want
>>
Has /g/ gotten over the fact that women have a higher approval rating on github, which suggests women write better code yet?
>>
>>52969571
pls go away already
>>
>>52969571
(You)
>>
>>52969571
fuck off, you're worse than 100 trap shitposters and leg shaving threads combined
>>
File: WIN_20160214_11_32_37_Pro.webm (3 MB, 1280x720) Image search: [Google]
WIN_20160214_11_32_37_Pro.webm
3 MB, 1280x720
I bought some shift registers and I dont even fucking know what to do now.
Any ideas?
>>
If reparations were ever given out, should Europe help fund some of it?

The Atlantic Slave Trade was started by Europeans, at first the Spanish and Portuguese, this is a fact that can't be refuted. Even after abolition occurred in the European countries, the slave trade still continued with slavery still persisting in the colonies. I'm not strictly talking North American colonies, this was occurring in South America and Africa itself as well. As Europeans began to take over large parts of inland Africa starting in the 1870s, the colonial policies were often confusing on the issue. For example, even when slavery was deemed illegal, colonial authorities would return escaped slaves to their masters, I will repeat that again for emphasis, as late as the 1870's this was still happening. The European countries profited from human slavery, there is no doubt.

Karl Marx in his economic history of capitalism, Das Kapital, claimed that "...the turning of Africa into a warren for the commercial hunting of black-skins (the slave trade), signalled the rosy dawn of the era of capitalist production." He argued that the slave trade was part of what he termed the "primitive accumulation" of European capital, the "non-capitalist" accumulation of wealth that preceded and created the financial conditions for Britain's industrialisation

The French Slave trade was more profitable than alternative domestic investments, and probably encouraged capital accumulation before the Industrial Revolution and Napoleonic Wars.
>>
File: 1420224629420.png (44 KB, 200x200) Image search: [Google]
1420224629420.png
44 KB, 200x200
>>52969674
yes, this is programming related :^)
>>
>>52969664
blink more leds
>>
>>52969664
Some kind of shift register?
>>
>>52969664
What's that tiny board on the right?
>>
File: 1442196462772.png (121 KB, 300x183) Image search: [Google]
1442196462772.png
121 KB, 300x183
>>52969674
>>
>>52969734
that's an arduino mini pro. Same shit as an Arduino Uno, just smaller.
>>
>>52969571

http://slatestarcodex.com/2016/02/12/before-you-get-too-excited-about-that-github-study/
>>
>>52968263
It's not as simple as making a function, since I would need to make a new type to hold the iterator state. Works but not ideal.

>>52968593
Map applies the function for each element, but a single char could require up to 4 u8s. Is there a function like map that works on multiple elements?
>>
>>52969412
so you can't get the tombstones without root which is pretty cancerous. i had to reproduce the error to get the partial trace in logcat. i think i figured out the problem now anyway
>>
File: MMM.jpg (18 KB, 197x300) Image search: [Google]
MMM.jpg
18 KB, 197x300
Anyone else read this? It's not a long one but I'm honestly having to force myself to finish it. I was quite excited about it too since it's recommended in so many places.
>>
File: 18211.png (98 KB, 400x300) Image search: [Google]
18211.png
98 KB, 400x300
>>52969571
kill yourself
>>
why does this shit oveflows
function trishit(number){
var temp = number,
finalstring;
if (number % 2 == 0 || number < 3) return 'gimmiesomthinggud';
for(i = 0, j = 0; j < number; i++){
if (i == 0 || i == temp){
finalstring += '*';
}
else if(i == temp || i == temp*(-1)){
finalstring += '/n';
j++;
temp -=2;
i = 0;
}
else{
finalstring += ' ';
}
}
return finalstring;
}
>>
>>52969852
fuck that was stupid, both
 i == temp 

messed that up
>>
>>52969759
>Among insiders, women do the same as men when gender is hidden, but better than men when gender is revealed. In other words, if you know somebody’s a woman, you’re more likely to approve her request than you would be on the merits alone.
basically women aren't better and just get a free ride because guys are SJW beta faggots. there is no """"""""muh oppression"""""""" or """"""""muh patriarchy"""""""" here since women actually get treated better than men
>>
>>52969883
>since women actually get treated better than men
Only among insiders.
>>
File: emacs@arch_061.png (373 KB, 2556x1039) Image search: [Google]
emacs@arch_061.png
373 KB, 2556x1039
>he doesn't compile to pdf
>>
>>52968571
>endofunctor
stopped reading
>>
>>52969930
Babby is all proud of his first latex document :')
>>
>>52969930

>not compiling to pei-x86-64
>>
>>52969852
I bet j is not being incremented because it is always falling into your else statement.
>>
File: 20120727.gif (68 KB, 612x644) Image search: [Google]
20120727.gif
68 KB, 612x644
Hey, /dpt/. Have any fun bikeshedding lately?
>>
>>52970863
>bikeshedding
bikeshed + -ing. The term was coined as a metaphor to illuminate Parkinson’s Law of Triviality. Parkinson observed that a committee whose job is to approve plans for a nuclear power plant may spend the majority of its time on relatively unimportant but easy-to-grasp issues, such as what materials to use for the staff bikeshed, while neglecting the design of the power plant itself, which is far more important but also far more difficult to criticize constructively. It was popularized in the Berkeley Software Distribution community by Poul-Henning Kamp[1] and has spread from there to the software industry at large.
>>
Working on my C# wrapper library for the Vichan API, currently works with 4chan and 8ch.

I have literally no idea how to post though, I can't find any documentation or any information at all, and then I'd have to figure out how to handle captchas as well. Doesn't seem like something that it's reasonable to implement.
>>
>>52970946
Look at the Clover source britbong.
>>
>>52970946
It isn't. Why do you think there's so few chan clients?
Dashchan's existence is a miracle in and of itself, but that it works with every chan is nothing short of holy.
>>
>>52970863
yep. apparently lua is a better stepping stone into C/C++ than java is, because we all know how incredibly shitty the #1 programming language in the world is.
>>
>>52970975
I tried to have a skim through it, but goddamn what a fucking mess it is internally, I couldn't find anything relevant after about 15 minutes of being lost in the ludicrously dense directory structure.

>>52970983
It's really easy to read from them, the Vichan API means that implementing a new Chan is remarkably simple, but yeah posting is pretty fucking horrendous, I can't find a single bit of documentation or any explanation at all.

I imagine handling recaptcha should be quite simple, it's big enough to have some kind of detailed write-up.
>>
>>52971033
>I tried to have a skim through it, but goddamn what a fucking mess it is internally, I couldn't find anything relevant after about 15 minutes of being lost in the ludicrously dense directory structure.
That's actually how any modern Android project is structured. Managers and helpers extravaganza.
>>
How hard would it be to write a federated voice and text chat program with a slack-like ui without JS garbage?
>>
File: JAcVtEs.png (36 KB, 1757x330) Image search: [Google]
JAcVtEs.png
36 KB, 1757x330
>>52971100
Yeah I thought as much, I didn't think that a rational human being with a pulse and a couple braincells would actually structure a project like that.

It's handy that it's in Java, if I could find the related bit of code I could more or less copy paste it because it's almost identical to C#.
>>
>>52971123
if you have to ask, you won't be able to pull it off
>>
>>52970325
nope it got stuck when i was equal to temp in the first if statement
>>
>>52971131
>https://github.com/Floens/Clover/blob/66bfb7f615e7f95678505f346992888bc5387933/Clover/app/src/main/java/org/floens/chan/core/http/ReplyHttpCall.java
That's the class that performs a post to the 4chan API.
>>
File: Untitled.png (103 KB, 1920x1080) Image search: [Google]
Untitled.png
103 KB, 1920x1080
How do I get rid of this dumb 1pixel transparent border?
>>
File: liberty-stops.png (4 KB, 276x386) Image search: [Google]
liberty-stops.png
4 KB, 276x386
>>52971187
install gentoo
>>
File: LKYECDF.png (63 KB, 1411x496) Image search: [Google]
LKYECDF.png
63 KB, 1411x496
>>52971181
Thanks, It'll probably take me a damn long time to figure out how it works, I shall endeavour to give it a go though.
>>
>>52971249
Does gentoo have vulkan/directx12 support yet?
If so I would.
>>
Can I realistically write an android app in C++, or do I have to use Java?
>>
>>52971255
>Does gentoo have vulkan/directx12 support yet?
>Does gentoo have 'not even released'/'literal meme' support yet?
That's how stupid your question sounds.
>>
>>52971255
Vulkan doesn't exist yet. Gentoo obviously has OpenGL support and thus will get Vulkan support as soon as such a thing becomes possible.
>>
>>52971259
Yes.
IIRC you need some java (a static void main that just JNI calls your C++ main) and have to JNI call back to java to talk to the OS.
>>
>>52971251
Why are 8ch's board names so meme-tier?
>>
>>52971251
What IDE is that?
>>
>>52971276
>>52971279
Well then. When vulkan is released I will install gentoo. Until then I'm stuck with meme apis.
>>
>>52971259
You could write an app in C++, but you're missing out on a lot of features the SDK has to offer. The NDK is a complete joke and you'll fall off your chair when you see JNI.
>>
>>52971259
Yes - in fact you can even write them "natively". In fact-in fact, this is the only real way to do it without weird hacks.
Because of the nature of C++ you'll have to compile it on Android, unlike Java which can be cross compiled. Because of this you'll probably end up do most of your programming on an Android device itself. There's a few IDEs on the Play store - I like CPPDroid because it comes with native Android ports of gcc, clang, and make.
>>
>>52971304
Emacs, duh.
>>
>>52971259
yes but the android NDK is really shitty and it's generally not recommended to make an app solely with the NDK

>>52971290
you can make it without any java code
>>
>>52971297
User defined.

People make their own boards, the list itself is actually vast, takes a few seconds for me to download and parse it. -8ch dot net/boards.json

>>52971304
Visual Studio 2015 with a theme plugin. (I use the Solarized Dark theme that's bundled with it, and I just set a couple of the colours myself)
>>
I'm well versed in C# and I know it's basically microsoft's version of Java
But now I need to "learn" Java

What's a good way to learn the main differences between the two? I'm writing stuff and it'll mostly work, but then I'll randomly get exceptions or errors and have no idea why because I know how C# works, not Java.
>>
>>52971330
what the fuck lmao? you compile it with an IDE on desktop. who the fuck does any serious programming on an android device
>>
>>52971351
...wtf? That's a terrible idea. Might as well literally be using reddit at that point.
>>
>>52971364
...me
>>
>>52971369
Well 8ch is still around, so it seems to work just fine.
>>
>>52971358
RTFM

seriously - the documentation is great and it says exactly when exceptions get thrown etc
>>
>>52971388
save up for a real computer you can build a fairly good one for for a few hundred dolleridoos
>>
>>52971393
Well, yes, okay, when I get exceptions or errors spring up I just look it up.
But I'm having to do that constantly and it's a pain in the ass for a language that I basically already understand.

I mean mostly shit like having to initialize a List object as an ArrayList or why strings have to be declared as String instead of string
Just all that tiny nuanced shit.
>>
>>52971391
that's because the most active 8ch boards are full of pedos trading cp
>>
>>52971419
https://docs.oracle.com/javase/tutorial/
>>
File: 1366633657192.gif (2 MB, 176x144) Image search: [Google]
1366633657192.gif
2 MB, 176x144
>>52971438
>>
>>52971427
This. Look at /cuteboys/ and /hebe/
Cripplechan is quite nice though. It's slow and the people are less inane.
>>
>>52971419
The first thing you have to understand is that C# is not "Microsoft's version of Java".
J++ was Microsoft's version of Java.
Microsoft realized early into the development of J++ that Java is a convoluted, illogical, inconsistent pile of steaming shit that simply cannot be saved, so they created C# to be what Java wants to be without any of Java's shittiness.
Going from C# to Java is like going from C++ to ALGOL: You're going to realize very, very quickly why the new language was created.
>>
>>52969521
It means no valid kits were found.
>>
>>52971494
cuteboys is the trap board
>>
>>52969521
Are you using Linux?
>>
>>52971523
Oh, you're right. I know there's a male /hebe/ board somewhere. CBA to look it up.
>>
>>52969130
Because it doesn't 'unnest' types.
Neither int (*)(int *, int *) nor int(*)(void *, void *) are void pointers, so the implicit conversion doesn't apply.

It's the same reason as why you can't do int **ip = vp; where vp is a void **.
>>
>bored
>scrolling through /r/programming
>come across http://topjavatutorial.com/java/how-to-convert-a-string-to-number-in-java/
>posted by Sekhar_Ray
Daily reminder to steer clear from Java.
>>
>>52971634
holy shit
>>
>>52971634
>0 score

Based reddit
>>
>>52971634
>"f off b2 reddit" is detected as spam by the filter
what the fuck hiroshimoot

and of course the #1 programming language in the world is going to have people from various nationalities using it, including people from india
>>
>>52971712
>6 QUINTILLION DEVICES
>>
>>52971712
>my shitpost got caught in a spam filter
>wtf

GEE I WONDER WHY
>>
>>52971728
Stop shitposting.
>>
>>52971728
i want reddit fags to leave
>>
>>52971712
Tell me, India lover who wash/shit and dumb corpses in the same river, why all those horrible tutorials are written for Java? I don't such shit tutorials for C++ or any other language.
>>
>>52971634
http://www.c-sharpcorner.com/members/sekhar-srinivas
>Sekhar Srinivas ( Microsoft Certified Trainer ) Well known for his good track record as one of the best I.T faculty in imparting his unique techniques in training from past 18 years and trained more than 1Lakh students on various Microsoft Technologies Platforms incl. VB6.0, ASP, VB.NET, C#, ASP.NET , Silverlight , ASP.NET MVC, SharePoint 2013, Azure, Xamarin.Andriod, Xamarin.iOS, Xamarin Forms and JavaScript Frameworks.
>>
>>52967786
I'm working on a touchpad driver for X11. I hate the bogus 2finger scroll in the builtin synaptics driver.
>>
>>52971772
see >>52971773

there are horrible tutorials for everything that isn't an obscure "literally who" programming/scripting language. C#, python, opengl you name it
>>
>>52969130
> Why am I not allowed to pass a function pointer expecting typed pointer arguments to a function expecting the function pointer to take void * arguments ?
Because the pointers have different types.

> I mean, void * are supposed to be implicitly convertible to any kind of pointers ?
Not relevant.

If you passed "const void*" as arguments, it wouldn't complain, because that implicit conversion is allowed.

Note that simply casting the function pointer to the correct type will work on "mainstream" architectures, because converting int* to and from void* is a no-op (i.e. the compiler doesn't need to generate any code for the conversion, it just needs to be told to ignore the fact that the types are different).

However, there are architectures where the conversion requires actual code (mainly word-addressed architectures, where sizeof(int*)!=sizeof(void*)). If you pass a void* where an int* is expected, the compiler will generate the code to perform the conversion. But it can't do that if the conversion is happening inside a function which has already been compiled (e.g. qsort), so casting the function pointer won't work on those architectures and the standard doesn't allow an implicit conversion.

If you wanted the code to be maximally portable, you'd need to write an explicit wrapper, e.g.
int cmp_wrapper(const void *a, const void *b)
{
return cmp(a, b);
}

qsort(..., ..., ..., &cmp_wrapper);
>>
>>52969831
I got the impression it was more about business management than about programming itself. I passed it over and picked up Pragmatic Programmer instead, which was well worth it.
>>
File: output.png (73 KB, 999x788) Image search: [Google]
output.png
73 KB, 999x788
Wrote a simple processing.py script that takes an image, and pixelizes it using whatever pallet you've specified. Wrote it because I find it therapeutic to copy pixel art on paper and I've only a limited number of colours.

def setup():
global pixelSize
pixelSize = 10

global palatte
palatte = []

#various shades of gray.
palatte .append(int(color(238, 242, 243)))
palatte .append(int(color(194, 199, 202)))
palatte .append(int(color(149, 166, 176)))
palatte .append(int(color(123, 114, 131)))
palatte .append(int(color(105, 118, 134)))

size(983, 750)
global img
img = loadImage("viet.jpg")
img.filter(GRAY)
noStroke()

def draw():
for x in range(0, img.width, pixelSize):
for y in range(0, img.height, pixelSize):
col = img.get(x, y)

#Whatever colour is at x and y, find the palatte approximation in the array.
fl = min(palatte , key=lambda x:abs(x - int(col)))

#Make the rectangle the colour of the closest approximation.
fill(fl)
rect(x, y, pixelSize, pixelSize)


How does it look?
>>
File: tumblr_mlzvi0ktxI1qai61bo1_500.jpg (38 KB, 500x750) Image search: [Google]
tumblr_mlzvi0ktxI1qai61bo1_500.jpg
38 KB, 500x750
What level of mathematics do I need to be proficient in in order to study machine learning and/or AI?

I'm looking at doing MSc Advanced Computing in September and would love to learn machine learning, but I suck at statistics atm. Would have ~6 months to get up to scratch.
>>
Any C# devs here built a library before?

I'm implementing intellisense into my entire library, which was fine with most of it, only took a few minutes to get the entirety of a class worth of methods done.

But now I'm onto my vast data classes, trying to write a summary for each and every single property. I assume there's no real way to make this go any faster but I'd like to know who else actually bothers with them in the first place.
>>
>>52972326
>mathematics
>2016
lel
http://qr.ae/RO3UKz
>>
>>52972267
>global variables
>inconsistent formatting
>>
>>52972388
1. The globals are required in processing.py.

2. The inconsistent formatting I think you're referring to is accidentally leaving a space when replacing variables.
>>
>>52972361
In my work we don't bother. Instead we ensure that the name of the method entirely encapsulates exactly what the method does, which means you have to do one or both of the following: Write smaller, more encapsulated functions or have long method names.

Some scenarios where intellisense comments are genuinely useful include:

> Summary tags to describe specific quirks of functionality, such as "can this function return null?" or "what does this function do if I return a zero instead of a number?"

> param tags to describe the specific nature of a particular parameter, where it is not possible to do so with the name alone. Needing to do this usually means that your business or project has a convulted vocabulary.

>>52972267
Looks pretty cool, nice results. For readability I'd get rid of the comments and replace them with method calls that describe what is being done, like "ApproximatePalletteColour(col)"
>>
>>52972267
I suspect that abs(x-int(col)) isn't going to give a very good approximation to the distance between colours. You need to compare the length of the RGB vector (using Manhattan or maximum metrics would probably be good enough; for the Euclidean metric, comparing the square of the length works, and avoids a sqrt() calculation).

From an efficiency perspective, you would want to use a spatial index rather than iterating over the entire palette for each pixel. The difference will be more significant for larger palettes. If you were processing a lot of data with the same palette, the optimal solution would be to use a 256x256x256 lookup table to map RGB to nearest palette index.
>>
>>52972445
Well the problem of the properties of these data classes is that they're defined by the JSON, I could write new classes which contain the exact same data but with better, more verbose names but that seems like a less productive thing to do.

I'm trying to avoid writing documentation for the API and having that be the only way to know what any of it does.
>>
File: tumblr_m4tpf8MSBI1rq8qyf.png (276 KB, 500x500) Image search: [Google]
tumblr_m4tpf8MSBI1rq8qyf.png
276 KB, 500x500
>>52972381
Cheers for the link it's really interesting. Not sure I believe her though, certainly heuristics are easy to do but what little I've done of machine learning I've found really difficult and super statistics heavy.
>>
>>52972431
spacing between
palatte .append(...)
>>
>>52972609
Yeah, that's what I mean. Palatte was renamed before posting here and I didn't double check. Accidentally put a space after "palatte" when doing the replace.
>>
>>52969823
Bampu.
>>
>>52969852
Read the style guide pls
>>
>>52972449
I calculated the euclidean distance between the color at x, y and every color in the list to find the lowest distance (and then use the color with the lowest distance as the pixel color).

It made absolutely no difference except for like 10 pixels in the whole image.
>>
>>52968113
People other than Mozilla are actually using Rust? What are you using it for?
>>
>>52972914
In fact, yeah it's a good bit better on images that are more diverse.
>>
>>52972956
Compiler design.
>>
I'm having trouble using reentrant locks to manage multiple threads without using synchronized in Java. Got any tips or guides that can help?
>>
File: pKlUG78.png (12 KB, 1005x468) Image search: [Google]
pKlUG78.png
12 KB, 1005x468
Noob here. Why does Eclipse give these redundant errors?

The first error says "Syntax error on token ";", { expected after this token"

The second error says "Syntax error, insert "}" to complete ClassBody"

I also can't debug or compile anything. It says "The selection cannot be launched, and there are no recent launches."
>>
>>52972985
It's not a redundant error, you've just fucked up and put all your code outside a method.

The compiler expects you to at least know a little bit of what the fuck you're doing. Read a book.
>>
>>52967786
Please stop this programming trap meme.
Thanks.
>>
>>52972985
POO IN LOO
>>
>>52972985
create a main method
>>
>>52971783
>for X11
Why would you make anything for X NOW when Wayland is soon taking over?
>>
>>52972964
For practice? Cool.

>>52972985
What they're trying to tell you is that your if doesn't belong there. You can't type code inside class context.
You need to put a method, constructor or main method in there to put your code in.
>>
>>52967786
What's this anime anyway?
>>
doing a program for the birthday paradox. i generate a set of 23 random numbers between 1-365, but i want it to display as a table, like this:

 january 2     Janurary 5   January 12
January 25 (2) February 3


and so on and so forth for all 23 numbers, where the (2) represents the date that was generated twice. any ideas? im drawing a blank for some reason. heres the function that displays it

int DisplayTable()
{
int j, count, p_count, p1_count = 0;
int *a;
int option;
srand((unsigned)time(NULL));


a = (int*)calloc(SAMPLE_SIZE, sizeof(int)); //each element is a person

do
{


printf("\n");
p_count = 0;

for (int i = 0; i < SAMPLE_SIZE; i++)
{
j = rand() % (365 + 1); //random number generator
a[i] = j;
cout << setw(4) << a[i];
}

cout << endl;
cout << "Date that appeared twice: ";
for (int i = 0; i < SAMPLE_SIZE; i++)
{
count = 0;

for (j = 0; j < SAMPLE_SIZE; j++)
{
if (a[i] == a[j] && a[j] != NULL)
{
count++;
if (i != j)
{
cout << a[j] << endl;
}
}
}
if (count > 1)
{
count = count - 1;
p_count = p_count + count;


}
}

cout << endl;
cout << "press 0 to display menu again: " << endl;
cin >> option;
} while (option != 0);
return 0;
}


inb4 format autists have a fit
>>
>>52973124
That's some serious shitty code you got there m8.
>>
I have finally realized that
if (condition)
{
// blah
}

Is superior in readability and aesthetics to
if (condition){
// blah
}
>>
>>52973173
Congratulations
>>
>>52973173
The only correct way. The second style is absolutely disgusting.
>>
>>52972985
that shit needs to be inside a function, this isn't main shit like gayplusplus.

Only variable declarations can be outside functions in java.

>there are no recent launches
you need to make a debug run, click on the arrow besides the debug button.
>>
>>52973173
Enjoy a wasted line xoxo
>>
>>52973196
Sparse code is better than dense code.
You'll come to realize that when you start to work on larger projects.
>>
>>52973139
im aware. im not trying to be a programmer for my entire life so im not too concerned
>>
>>52973196
don't blow kisses faggot, blow my cock instead
>>52973173
degenerate
>>
>>52973204
Dense code is better than sparse code.
You'll come to realize that when you start to work on larger projects.
>>
>>52973187
>>52973185
Depends on the language.
>>
>>52973209
>im not trying to be a programmer
So why do you even bother with C/C++? Just use Python. It just werks.
>>
>>52973218
Do you also put all your code in a single line and minimize all whitespace and have single character variable/function names?
>>
>>52973117
Himegoto. Source in question is [&] Himegoto - 06.
>>
>>52973248
do you write more whitespace than code
>>
>>52973246
its what the cs course at my school requires. ive made pitches to the head of informatics to focus on python but he's not having it
>>
>>52973273
I keep a good balance between whitespace and code.
I don't try to cram as much code into one space as possible, that is bad practice and your co workers will hate you, and you will hate yourself further down the track.
>>
File: 1438297252547.png (77 KB, 662x382) Image search: [Google]
1438297252547.png
77 KB, 662x382
>>52973218
I bet your code looks like pic related.
>>
>>52973304
i didn't say to do that
>>
>>52973336
Like a newline after the '{' will make that more readable faggot.
>>
>>52973336
I wouldn't repeat that much code
>>
>>52973360
No, but that combined with newlines between groups of statements and whitespace between operators will make that code a while lot more readable and pleasant to the eye.
>>
>>52973173
No it isn't. Placing the opening brace on a new line adds no new semantic information (we know it's a new block because of the if statement). Languages without braces typically do this:

for i = 1:100
if i % 15 == 0
println("FizzBuzz")
elseif i % 3 == 0
println("Fizz")
elseif i % 5 == 0
println("Buzz")
else
println(i)
end
end
>>
>>52973378
Allman style indentation won't help shit with that. Adding newlines to separate chunks of code does help.
>>
>>52973379
placing braces on new lines makes the block more visible
>>
>>52973450
No, there is indentation for that.
>>
>>52973483
Indentation is usually utterly shit, particularly when the line before the new scope is long
>>
C# library dev here.

Got a set of extension methods in two seperate namespaces. The extension class names are identical, and so are the method names within them.

However I can't seem to use them, how on earth do I access extension methods within namespaces?
>>
>>52973412
When you have no choice but to have nested blocks, allman style certainly helps.

if (condA){
if (condB){

}

if (condC){
if (condD){

}

if (condE){

}
}
}

VS
if (condA)
{
if (condB)
{

}

if (condC)
{
if (condD)
{

}

if (condE)
{

}
}
}

The latter is clearly superior
>>
>>52973093
Yeah. The syntax can be pretty annoying, though.

struct CharsAdapter<I> where I: Iterator<Item=u8> { iter: I }

impl<I> CharsAdapter<I> where I: Iterator<Item=u8> {
fn new(iter: I) -> CharsAdapter<I> {
CharsAdapter { iter: iter }
}
}

impl<I> Iterator for CharsAdapter<I> where I: Iterator<Item=u8> {
type Item = char;

fn next(&mut self) -> Option<char> { ... }
}


This is the code I ended up with just to convert a stream of u8 to char.
>>
>>52973450
What about this method? It makes the if statement really stand out.
int main(int argc, char* argv[])
{
/*
* some
* block
* of
* code
*/

/*
***************************
* THIS IS AN IF STATEMENT *
***************************
*/
if (1)
{
/*
* some
* block
* of
* code
*/
}

/*
* some
* block
* of
* code
*/

return EXIT_SUCCESS
}
>>
>>52973497
is there a way to do an anonymous alias for a C# namespace

like
using namespace std; //C++
>>
>>52973493
The length of the line is irrelevant to indentation.
>>
>>52973503
How is it superior? It adds no new semantic information and does nothing to help readability.
>>
>>52973510
clearly i {mistook you for someone incapable of honest debate

truly you} are respectable and worth discussing topics with
>>
>>52973503
Except it's not superior in any way, other than in your sperglord tastes.

I find the top much more readable because there's no pointless newlines.
>>
>>52969831
I read it last year. Most of the stuff it says is already well known, but it wasn't when the book was written.

Also it says a lot of things that are quite dated (punch cards, having to book a share of time for the computer, "high level" languages that are laughably low level by today's standards etc) but it's still quite a nice book.

I also read No Silver Bullet, by the same author, and I liked it more http://worrydream.com/refs/Brooks-NoSilverBullet.pdf shorter, but to the point
>>
>>52973519
Yeah,
using someAlias = System.Something;
but I don't know to reference it when using the extension method.

It's a bit annoying.
>>
#include <nigger>
using jewshekels std;

int gaschambers ()
{
cout << "OP IS A JEWNIGGER FAGGOT: ?

}
>>
>>52973534
>and does nothing to help readability.
It does, it clearly and elegantly denotes blocks of code and condB isn't hugging condA (and condD and condC) which was quite ugly.
>>
>>52973573
We have indentation to mark blocks of code, not braces.
>>
>>52973521
it affects the formatting

>>52973558
by anonymous alias I mean not really an alias
e.g.
using namespace std;
std::cout -> cout // what we want

using s = std;
std::cout -> s::cout // not what we want
>>
>>52973573
>it clearly and elegantly denotes blocks of code
The if statement already denotes the block of code, the additional line is unnecessary.

>ugly
Subjective. It's fine to prefer it, but stop trying to act like it's objectively better.
>>
>>52972956
Dropbox uses quite a bit of Rust internally
>>
>>52973610
>it affects the formatting
How?
>>
>>52973601
Indentation is a shitty method of marking blocks of code - it forces you to format your code a certain way

Braces are better because they're more flexible
With braces we can argue about { vs
{

with indentation we can't
>>
>>52973622
Because indenting changes how the code works, so I can't reliably format my code with indents
>>
>>52973645
What?
>>
>>52973611
>Subjective. It's fine to prefer it, but stop trying to act like it's objectively better.
I don't think you understand.
My taste are not subjective, they are objective.
To deny my tastes is illogical.
>>
>>52973625
>Braces are better because they're more flexible
Clearly not if they make you feel this buttblasted


>>52973645
>Because indenting changes how the code works
Only in python, where this argument is irrelevant.
>>
>>52973610
No, no anonymous aliases, I guess I'll have to drop the idea of extension methods for this I assume, which is a bit shit but what can you do.
>>
>>52973664
>>52973668

You were saying indentation marks blocks of code
I assumed you were supporting languages that organise blocks of code with indentation

So you don't really want indentation to mark blocks of code then
>>
>>52973686
is this helpful
http://stackoverflow.com/questions/3337453/why-do-extension-methods-not-work-with-namespace-aliasing
>>
i would be more inclined to switch to gitlab or bitbucket if they made their websites as easy to use as github's
>>
Retard here.

if (a == 1 && b == 1)

if (a && b == 1)

Can use either one right?
>>
>>52973814
in most languages no
in Java the first one won't work either
>>
>>52973814
really depends on the language - in some languages the second option wouldn't even compile
>>
>>52973173
kill yourself
>>
>>52973705
No, decided to just bring the methods together, clean them up and adding them to the default namespace, that way I don't have to alias it at all.
>>
>>52973836
http://ideone.com/GGNMdc

>>52973814
python allows
if a == b == 1: 
...
>>
>>52973814
in languages that allow implicit int to bool conversion,

if (a && b == 1)

is equivalent to

if (a != 0 && b == 1)
>>
>>52973814
You mean to factorize
(a && b)
as a double comparison/junction thingy? No you can't the second option will test a for a non-zero value and then
(b == 1)
>>
>>52973908
oh i get it
because they're the first ints created they have the reference of 1

after all, java only does value equality, which means it compares the references
>>
>>52973942
that is IT nathaniel go to your room NOW
>>
>>52973942
int is not a reference type in java.
>>
>>52973963
but java only has references and everything is a class
>>
>>52973784
Bitbucket's site is pretty awful in terms of UX compared to the other two. Gitlab is perfectly fine IMO, but the site is slow as fuck. The biggest thing holding me back, though, is the fact that 90% of people still use Github, meaning that's where 90% of the code is and 90% of people will be able to discover your project, versus the tiny slice of the community that might be able to see it on Gitlab/Bitbucket. If you're mainly using it for the sake of working together with your team on some code, Gitlab is perfectly fine. At the same time, it raises the barrier of entry to new contributors who might've found it and opened a few PRs/issues had it been posted on Github instead.
>>
>>52974021
java has primitives
>>
>>52974055
are primitives idiomatic
>>
>>52967786

So this code is supposed to save a value within the range of (Xmax - Xzero) as a percent, and then convert it to an unsigned 8 bit int (debug)

It doesn't work for some reason

debug = round(((Xval - Xzero) / (Xmax - Xzero))*2.55);


Im running this on an atmega328p compiled with AVR GCC. could the problem have something to do with data types and decimals?
>>
>>52974065
it depends on the use case, like some consider it more idiomatic to use enums instead of raw ints (but it think it's fine to use static final ints)
>>
>>52974086
What are the types of Xval, Xmax and Xzero? and you should probably multiply by 255.0 instead of 2.55
>>
>>52974141

they are unsigned 16 bit ints
>>
>>52974141

Also that didn't work either
>>
>>52974188
what are the possible values of (Xval - Xzero) and (Xmax - Xzero)?
>>
>>52974163
>>52974188
try this

anything less than 1 gets truncated to 0 if they're ints

debug = round(((float) (Xval - Xzero) / (Xmax - Xzero))*255.0f);
>>
File: 1424404082403.jpg (64 KB, 620x620) Image search: [Google]
1424404082403.jpg
64 KB, 620x620
>>52974227

it worked ty senpai
>>
>>52974055
>cannot even have list of int

top laughing m8
>>
>>52974413
http://fastutil.di.unimi.it/docs/
http://trove4j.sourceforge.net/javadocs/
http://dst.lbl.gov/ACSSoftware/colt/api/index.html

k tard

a generic list? no, use Integer objects. but a list of ints? yes.
>>
>>52974492
direct links

http://fastutil.di.unimi.it/docs/it/unimi/dsi/fastutil/ints/IntList.html
http://trove4j.sourceforge.net/javadocs/gnu/trove/list/TIntList.html
http://dst.lbl.gov/ACSSoftware/colt/api/cern/colt/list/IntArrayList.html
>>
>>52974492

These things are not part of the Java standard library.

>a generic list? no

Exactly.
>>
>>52974746
who the fuck even uses generics and you can still use an Integer list with auto(un)boxing

there is no problem here, sperg
>>
>>52974746
>implying a vector of ints isn't a generic list
a vector of ints could store poin-

oh wait
>>
>>52974856
>who the fuck even uses generics
anybody with a fucking brain
>>
>>52974856
There is, sperg. Integer takes up much more space than an int.
>>
>>52974882
>>52974884
lol k tards you're the ones having to deal with your asspain of java not having a primitive list built into the standard library, it doesn't bother me one bit, so the joke's on you faglords
>>
I have a challenge for you, /dpt/.

I'm going to post some C code later on in this post. This C code will print a single number to stdout. I want you, without compiling it to find out, to tell me what number will be printed to stdout.

I can't offer any rewards, but it's a very clever challenge and I'm interested to see how fast you lads can solve it.

Here's the code. It successfully compiles using gcc and normal warning/error flags.

int magic_function(int x) {
int *px = &x;
++*px++;
*px++ += *px++ + ++*px;
return px++;
}

int main(int argc, char *argv) {
printf("Remember, no cheating!\nThe mystery number: %i\n", magic_function(13));
return 0;
}
>>
File: 35747.gif (211 KB, 500x327) Image search: [Google]
35747.gif
211 KB, 500x327
I'd like to make a gmail account generator. Would Erlang be a good choice of language to implement this in?
>>
>>52974916
Lol k tard enjoy wasting 4kb on each Integer allocation.
>>
>>52974916
I don't program in Java
>>
who even uses lists at all just use arrays you fucking sub-110 IQ pseudonormie ass CRUD faggots
>>
>>52974941
typical clueless Cshart, it's a "waste" of around 4 bytes, not 4 kb

>>52974943
yet you're this butthurt about it
>>
>>52974945
"List" doesn't mean linked list
A list could be implemented as a vector
>>
>>52974961
OOGA BOOGA JAVA POOPA
>>
What's up with iOS development? I have to have an iPad/phone/mac in order to be able to develop apps for them?
>>
>>52974972
yes, and? an ArrayList is implemented with an array and you can easily make your own implementation if you want a primitive list without using a third-party library
>>
>>52974917
i dont know
>>
>>52975006
... that wouldn't be primitive, but I never said anything about that

an ArrayList is a vector
>>
>>52975003
you can use hackintosh but you should always have at the very least one physical target device to test on no matter the platform you faggot
>>
>>52974917
I don't think this would compile on many compilers, because of the postfix ++ on a rightval.
>>
>>52975033
you fucking retard are you fucking shitting me, how about some reading comprehension, you can make your own primitive list easy as fuck, it is no problem. including it in the standard library would just add clutter and bloat
>>
>>52975039
I emulate android just fine on PC.
>>
>>52975060
yeah and i bet you're using soundpool or some garbage like that good luck with that on real devices lmfao
Thread replies: 255
Thread images: 26

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.