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

/dpt/ - Daily Programming Thread

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

Thread replies: 331
Thread images: 25

Absolutely no gf edition ;_;

Previous thread: >>57674108

What are you working on, /g/?
>>
File: oop p2.png (57KB, 682x473px) Image search: [Google]
oop p2.png
57KB, 682x473px
>>
stdbool.h did nothing wrong
>>
>>57679595
first for python is ok if you're just a hobbyist making automation scripts
>>
>>57679595
Nudes?
>>
>>57679595
Started the cryptopals challenge. Thinking of posting my code on Github as I complete the exercises, but too much of a beta to do it.
>>
>>57679595
>>57679512
No it becomes
>
"Good idea anon. !!"

When the processor is done. Which is not what I meant (double exclamation points are dumb). So you see the communication error.

His parameter guards against that. It's how you make slightly more safe macro's.

It also solves your operator precedence issues explicitly for you. As you clearly define if you meant for a full expression to be negated or just the first term or whatever.

>>57679544
Well maybe read my post again and realize that I've already answered this reply completely.
>>57679554
Int is 4 bytes (usually). you mean char.
And even so char is 8 bits, you only need one.
>C++'s bool is big
Yes, but back then you need to conserve space so it's much wiser to let people choose a full byte for their bool type knowingly than have the deceptive type of 'bool'. If they care about that memory usage difference they are aware they can shift/mod/divide out the individual bits for usage, making a 8x more compact bool where more than 1 boolean value is used.

Which is quite frequently.

Nowdays it's important for other reasons but nevermind that for now. Focus on the now for you.

>>57679539
Quick answer is that you define that variables have to be 'resolved' using the scope resolution operator '::' by putting them in a namespace. The uses for this are many. You can have a way of grouping methods, static/global variables and other things. Which does simplify things a lot. It also allows for certain fancy automatic method selection. Like if you have two different swaps, one from the standard and one from your own code, using namespace std before the call can allow the compiler to pick yours when it exists and otherwise use the standard one without you modifying that code specifically.

But such close to invisible features aren't exactly something I endorse.
'using' is generally just to save typing.
>>57679622
Isn't this enough anon? She's clearly very pretty right there. Unrealistically so.
>>
>>57679708
macros don't get expanded in strings
>>
>>57679748
Well yeah. Ok. I don't use string literals much I had no idea. Though I should know.

Doesn't particularly matter because the problem holds true in other areas.
>>
File: 1479378507657.jpg (101KB, 800x527px) Image search: [Google]
1479378507657.jpg
101KB, 800x527px
I'm going to write a piece of software that aggregates images from across multiple cloud storage services and basically treats them as one directory, and lets you organize them by tags..
I have no idea what I want to write this in, so far I've only done C\C++. I want to be able to use it on locally stored files as well, and my supervisor thinks it would be a good idea if it ran as a web service.
what do you think /dpt/, how would you tackle this?
this is going to be my bechellor thesis btw
>>
>>57679375

It's less readable because it's only one character.

if(x==false)
{
//I know that x equals false because it's painfully obvious from the if statement
}
if(! x)
{
//oops. In my rush, I didn't see the negation. I now think this executes whenever x is true
}

I mean, this example is trivial. But imagine a if statement with multiple conditions. Misread one "!" and you'll be troubleshooting the wrong thing.
>>
>>57679764
like where?
>>
>>57679748
This. After the lexical scanning is done, if any <identifier> matches a macro, then the macro replacement is done. A string literal is not an <identifier>.
>>
>>57679785
>trying to defend == false
>>
>>57679710
>pretty looking grown up girls who buys Kingdom hearts 2 dakimakura
What's up with this?
>>
>>57679785
>It's less readable because it's only one character.

how does that make it less readable? Its simplicity is what makes it so readable.
>>
>>57679803
He's a Java programmer.
>>
>>57679808
That explains it
>>
>>57679785
! is more readable *because* it's just a single character - less clutter to read, especially in something like: (!a && !b) || c
>>
>>57679781
should I do it in .NET?
>>
>>57679868
Yes
>>
imagine being a python scriptkiddie
>>
>>57679785
Why not:
(x==false)==true
You want to be explicit after all!
>>
>>57679899
This isn't a YLYL thread
>>
Which is more efficient?

Calling this once, creating a new Java Array and cloning the values, and then reading each value.
JNIEXPORT jfloatArray JNICALL Java_finnstr_libgdx_liquidfun_ParticleSystem_jniGetParticlePositionBufferX(JNIEnv* env, jobject object, jlong addr) {
b2ParticleSystem* system = (b2ParticleSystem*)addr;
int32 count = system->GetParticleCount();

jfloatArray array;
array = env->NewFloatArray((jsize) count);

jfloat fill[count];
for(int i = 0; i < count; i++) {
fill[i] = system->GetPositionBuffer()[i].x;
}

env->SetFloatArrayRegion(array, 0, (jsize) count, fill);
return array;
}


Or calling this 50 times
JNIEXPORT jfloatArray JNICALL Java_finnstr_libgdx_liquidfun_ParticleSystem_jniGetParticlePositionBufferX(JNIEnv* env, jobject object, jlong addr, jint particleNumberX) {
b2ParticleSystem* system = (b2ParticleSystem*)addr;

// I don't know c++ syntax
jfloat positionX = system->GetPositionBuffer()[particleNumberX].x;

return positionX;
}
>>
>>57679803
Bitch I just explained it.

How about you make an argument as to why "!" should be used. You know, other than making you look smarter than you actually are.

I mean, it definitely compiles to the exact same assembly
bool check<int>(int):
push rbp
mov rbp, rsp
mov DWORD PTR [rbp-4], edi
cmp DWORD PTR [rbp-4], 0
jne .L4
mov eax, 1
jmp .L5
.L4:
mov eax, 1
.L5:
pop rbp
ret
bool check2<int>(int):
push rbp
mov rbp, rsp
mov DWORD PTR [rbp-4], edi
cmp DWORD PTR [rbp-4], 0
jne .L7
mov eax, 1
jmp .L8
.L7:
mov eax, 1
.L8:
pop rbp
ret

//code I used to compile with
template <typename T>
bool check(T a)
{
if(a == false )
return 1;
else
return 2;
}
template <typename T>
bool check2(T a)
{
if(!a)
return 1;
else
return 2;
}


>>57679866
That wasn't the original example. The original example was
if(!x)

I'm not saying negation doesn't have its uses. But negation like that is prone to errors for future programmers maintaining your code
>>
>>57679922
in haskell this is just

not x
e.g.

if not x then
>>
>>57679915
Measure it.
>>
>>57679786
Most don't use capital letters for variable names more than once, so in the case of NOT it's usually fine. But you can imagine if you later in the code define something containing NOT where you might not consider it like: ANOTHER_DEFINE
The preprocessor will go through the code, insert ! instead of NOT so it's A!HER_DEFINE
which is annoying.

At which point you'd have to change either of the defines, or undef then redefine NOT.
Which is not ideal for a utility macro.
With NOT(X) you avoid far more cases of this annoyance.
>>
>>57679922
> It definitely compiles to the exact same assembly
Irrelevant

>future programmers LIKE YOU maintaining your code
>>
>>57679781
File actions need to be loosely coupled from the service that's hosting them (incl. local files). At that point you're really just using the API for each service you plan to integrate. If you use .NET, there are probably nuget packages for using the API of all major hosts.
>>
>>57679943
>The preprocessor will go through the code, insert ! instead of NOT so it's A!HER_DEFINE
>which is annoying.
No anon, that's not how preprocessors work. Stop embarrassing yourself. Preprocessing isn't your find/replace like in a text editor.

See this for more information. >>57679788
>>
>>57679922
>How about you make an argument as to why "!" should be used.
It's simpler. It's more terse (lower verbosity). It's more standard practice, so most programmers will expect to see it.

These are good things for readability. Making something long and verbose doesn't mean something is readable. That's why Java was such a disaster.
>>
>>57679922
>But negation like that is prone to errors for future programmers maintaining your code
[citation needed]

== introduces the potential of confusing with =, seems like a wash in terms of accidental typing to me.
>>
File: 1439071334680.jpg (65KB, 450x576px) Image search: [Google]
1439071334680.jpg
65KB, 450x576px
I just set up a RTMP stream that i stream movies to with OBS.

Now i want to create a simple webpage that displays a player that shows that stream and host it from my computer.

I tried some simple code i found but it says server not found.

<embed width="1280" height="720" src="http://www.focusonthefamily.com/family/JWPlayer/mediaplayer.swf" flashvars="allowfullscreen=true&allowscriptaccess=always&autostart=true&shownavigation=true&enablejs=true&volume=50&file=livestream&streamer=rtmp://MY SERVER/live/test" />


Doest anyone have any experience in doing something like this? I have never coded anything like this before.
>>
>>57679938
>Making something long and verbose doesn't mean something is readable
Still less prone to errors

>>57679987
>== introduces the potential of confusing with =
By who?
>>
>>57679987
No programmer has ever mixed up = and ==. Fact.
>>
>>57679785
STOP
>>
>>57680003
>By who?
The one writing the boolean test.
If your argument is that they might forget ! they can just as easily forget the extra equal sign.
>>
>>57680006
Not sure if you're being serious or not.

I used to do this all the time when I was a noob and used ActionScript. Fucked me over because it wouldn't cause any exception at runtime if you did
if (muhVar = "sheeeeeeeeiiiiit") {


Though since then I've used sane langugaes that don't allow that shit to compile.
>>
>>57679866
Yes you are in fact correct anon. you can't be selective with your use of ==false and !
Ever, it's simply not allowed.
If you're a person who writes ==false in one situation you must write (a==false && b==false) || c

God forbid you do what suits you best.
>>
>>57680044
My argument is that future programmers who are maintaining code can easily rush through a piece of code (trying to understand how it works), and not notice the negation.
>>
>>57680045
>Though since then I've used sane langugaes that don't allow that shit to compile.
like Haskell
>>
>>57679962
What the fuck is this. I swear I've had issues with this before. I remember being very annoyed at it.
What am I mistaking this with?
>>
>>57679958
>>57679885
I'll probably go with .NET then, my supervisor is going to be upset though, he runs Linux and he said he could make use of such tool
>>
>>57679595
>What are you working on, /g/?

I'm trying to remake a number word converter (i.e. you put in an interger (e.g. 6584) and it gives the words (e.g. six thousand five hundred eighty four) from Java to Python. This is though given the only Python program I made was a shitty temperature conversion program.
>>
>>57680006
then why was yoda conditions invented? checkmate rebels
>>
>>57679899
Stop being ridiculous.
>>
>>57680084
Good luck anon, a program like that is actually pretty tricky because there are so many rules in the english language
>>
>>57680084
is that project euler 17
>>
>>57680069
or anything statically typed
>>
File: IMG_2416.jpg (2MB, 3000x2000px) Image search: [Google]
IMG_2416.jpg
2MB, 3000x2000px
>he's not printing out his datasheets
Why? Are you some kind of retarded or just a fat weeb?
>>
>>57680080
.NET runs on linux
>>
>>57680189
>removes the ability to search
Why
Was there a point to this?
Is this just a cheap replacement for a n+1'th monitor?
>>
>>57679595
>What are you working on, /g/?
Premature optimizations.
// Formats a human-readable representation of file size
func readableFileSize(s int) template.HTML {
if s < (1 << 10) {
n := strconv.Itoa(s)
l := len(n)
buf := make([]byte, l, l+2)
copy(buf, n)
return template.HTML(append(buf, " B"...))
}

if s < (1 << 20) {
n := strconv.Itoa(s / (1 << 10))
l := len(n)
buf := make([]byte, l, l+3)
copy(buf, n)
return template.HTML(append(buf, " KB"...))
}

n := strconv.FormatFloat(float64(s)/(1<<20), 'f', 1, 32)
l := len(n)
buf := make([]byte, l, l+3)
copy(buf, n)
return template.HTML(append(buf, " MB"...))
}
>>
>>57679936
>>57679915
>How do I do this?
Get precise timing values, somehow. I don't know how you do that in java.

Run the function a large sample of time and average the times.
Then run the function 5-25 times and try to ruin the cache inbetween (load a bunch of junk into the CPU cache by reading and doing useless operations, don't forget to save the results to the compiler doesn't eliminate the dead code). This is to simulate a worst case.
Then you swap the function for the other option and do the same.
Compare. Read the functions to see if you can make either of them better (you could go mad doing this so keep yourself sane and limit your time).
Pick the one that comes out on top and/or is easier to work with.

Also rememeber to profile all your code first. You don't know what's taking the longest amount of time. and where you can get the largest gains.
There's no point in making a part of the program that takes 0.001% of execution time a million times faster. it's already next to free.
>>
>>57680189
>not having a 4k e-ink display
>>
>>57680145
>Good luck anon, a program like that is actually pretty tricky because there are so many rules in the english language

It's not that hard, since the integers are formed by pretty regular rules. I was able to do it in Java in an afternoon.

A real challenger would getting number words into an interger.

>>57680162
>is that project euler 17

No, it's much simpler. Although I might try that one. I could perhaps cheat and just count the numbers my previous program generated.
>>
>>57680198
You can make nice notes on some pages :-)
Also mark them with a post-it, if they are important for you're current project
>>
>>57680214
awfully repetitive. can you factor out the first two ifs into a macro at least?
>>
>>57680194
oh fug :-D, it does?
nice
>>
>>57680189
that keyboard is encrusted with buggers
>>
>>57680068
! sticks out just fine, it's an operator, not allowed in other symbol names, it comes first in the boolean expression making it read better (if not x).
Not buying your argument at all.
>>
>>57680273
Acctually need to get a new one. Those little nipples on J and K are nearly gone and I misstype because of that quite often. Sucks, mang :'(
>>
>>57679595
reading the haskell function i made to rotate a matrix by 90 degrees and i genuinely don't understand how it works. i have no idea how i got it to be so concise

haskell really is arkane
>>
>>57679915
not sure what you're trying to do but

https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html#GetPrimitiveArrayCritical_ReleasePrimitiveArrayCritical

or use a native float buffer
>>
>>57680221
Thank you so much! I'm print screening this post
I'll write the code I want to test, then I'll do this!

Thank you
>>
>>57679595
>>57679710

I Want Morgan.
>>
File: github.png (21KB, 1990x158px) Image search: [Google]
github.png
21KB, 1990x158px
>tfw 30% of your project is just Makefiles
>>
>>57680315
J and F, lel*
>>
File: file.png (108KB, 953x218px) Image search: [Google]
file.png
108KB, 953x218px
>>57680256
I just do comments in my PDF or in my notebook program.

But honestly I should probably cull/sort some from the notebook.
It's starting to get messy.
>>
File: noppoo.jpg (470KB, 1124x750px) Image search: [Google]
noppoo.jpg
470KB, 1124x750px
>>57680315
i have pic related it's based af
>>
Why do so less people outside of academia use LaTeX? It just werks.
>>
>>57680362
so you have 7 lines of C++ and 3 lines of make
>>
>>57680259
Fair point.
// Formats a human-readable representation of file size
func readableFileSize(s int) template.HTML {
format := func(n, end string) template.HTML {
l := len(n)
buf := make([]byte, l, l+len(end))
copy(buf, n)
return template.HTML(append(buf, end...))
}

switch {
case s < (1 << 10):
return format(strconv.Itoa(s), " B")
case s < (1 << 20):
return format(strconv.Itoa(s/(1<<10)), " KB")
default:
n := strconv.FormatFloat(float64(s)/(1<<20), 'f', 1, 32)
return format(n, " MB")
}
}
>>
>>57680352
Well if you're interested in this I'd recommend a few talks who are also worth considering. These are people who probably make things go fast more than 99% of go-fast programmers. So they're good sources.
https://www.youtube.com/watch?v=nXaxk27zwlk
https://www.youtube.com/watch?v=rX0ItVEVjHc
https://www.youtube.com/watch?v=GPpD4BBtA1Y
In order of approachability. They're fast of course, they're talks. But they're all worth watching. The end of the third one is good because it goes through the process of optimizing an arbitrary thing in detail. Which shows you how you think about these things.

But remember, if you aim to make everything go fast you will never finish. Second talk mentions this, you have to put your energy where it matters.
>>57680406
Because people don't care that much about formatting usually and it takes some learning.
That's my understanding anyway.
>>
interface Bank {
public double getBalance(User user) throws BankNoAccountException;
public void addBalance(User user, double amount) throws BankNoAccountException;
public void removeBalance(User user, double amount) throws BankNoAccountException, BankNotEnoughException;
public void transfer(User src, User dst, double amount) throws BankSrcNoAccountException, BankDstNoAccountException, BankNotEnoughException;
}


vs

interface Bank {
public Double getBalance(User user); // returns null on error
public boolean addBalance(User user, double amount); // false on error
public boolean removeBalance(User user, double amount); // false on error
public boolean transfer(User from, User to, double amount); // false on error
}


Which is better?

Also how do i stop obsessing about good interface designs and actually write code?
>>
>>57680498
What should I search if I want to figure out what the distribution of whatever is counted in those percentages (lines) might exist.

Like for instance if this was 100 line it checks out, 70 lines C++, 29 lines makefile 1 line C.
Every multiple of that works. But then there's the rounding. it says .0, so there can be other distributions assuming different forms of rounding (truncation, floor, ceil, typical rounding).

I want to know what that is called.
>>
>>57680526
Don't use Java
>>
File: R8BYiiZ.png (139KB, 908x696px) Image search: [Google]
R8BYiiZ.png
139KB, 908x696px
>>57680002
When opening this code in a web browser i just get the code displayed in plain text. The guide says it should display a site.

The code is saved in a file.html.
>>
>>57680526
>Which is better?
The former.

>Also how do i stop obsessing about good interface designs and actually write code?
Don't do Java.
>>
File: screenshot.png (104KB, 602x602px) Image search: [Google]
screenshot.png
104KB, 602x602px
>>57680498
No anon
>>
>>57680526
Probably the former in java. Exceptions are often bad but it's not a language made for return codes. Like most languages with exceptions they give you little other options.
>>
>>57680526
the first one but you should probably redesign it so you only have valid users in the first place (BankNotEnoughException is ok though)
>>
>>57680556
I'm not webdev but looks like PHP not html, install and configure PHP on your server then save the file as .php
>>
>>57680548
>>57680559
>>57680589
>Don't use Java
No other choice in this particular case unless i want to spend the next 2 years rewriting existing code in another language.
Besides the same thing happens in C++. Even more so in C++ actually because you need to worry about satisfying standard C++ concepts when for example writing your own data structures. Unless you're suggesting a functional language in which case good luck writing a huge multithreaded application that connects to multiple databases with clever one-liners.

>>57680631
I think i'll go with exceptions yeah. Maybe also a BankUser interface with a loadUser() method in the Bank interface.
>>
>>57680556
Do this in your html file
#index.html
<script type='text/javascript>
// Paste that code here
</script>
>>
>>57680686
Correction
<script type='text/javascript'>
// Paste that code here
</script>


Also, I don't see how that'll display that. Your HTML file needs some display elements like <div> also I believe, although I'm no web developer.
>>
>>57680556
>>/wdg/
>>
>>57680526
getBalance :: (?bank :: Bank) => User -> Maybe Double
addBalance :: (?bank :: Bank) => User -> Double -> Maybe Bank
removeBalance :: (?bank :: Bank) => User -> Double -> Maybe Bank
transfer :: (?bank :: Bank) => User -> User -> Double -> Maybe Bank
>>
>>57680671
>Even more so in C++ actually because you need to worry about satisfying standard C++ concepts when for example writing your own data structures.
Well that or simply ignore the standard and use your own shit.
And if I were to be a bit disruptive to your programming style then I'd question why Bank is an interface and not a class. Why you're doing OOP (because it's bad) and more.

But that's just distracting, so keep going. This looks like homework, obviously. Doesn't really matter.
>>
>>57680671
Golang.
>>
>>57680736
>(because it's bad
Why? I'm not the guy who you're replying to but I'm interested. Also, what paradigm do you instead suggest?
>>
>>57680736
>why Bank is an interface and not a class
Because there are multiple banks each with its own unique way of storing money.
I have several systems that don't care which bank the money comes from, as long as it comes from somewhere.
And nah, it's not homework, it's a personal project.
>>
Optimizing some OpenGL code. Removing useless state changes, moving more stuff to VAOs (-> fewer function calls), better shader uniform handling, etc.
>>
Why do so many people cast the result of malloc?
>>
>>57679622
None, sadly. And she barely posts any cleavage pictures, so have fun.
>>
>>57680884
Type safety
>>
There's a .NET program that I want to use that is no longer maintained and has a critical bug in it. I'm trying to fix it by IL weaving with Mono.Cecil, but I've reached an impasse.

The exception is
>Cannot bind to the target method because its signature or security transparency is not compatible with that of the delegate type.

Basically happens when something goes wrong with Delegate.CreateDelegate().

The relevant class, decompiled and fixed up: http://pastebin.com/shqDPWsw

It's a bit of clusterfuck, basically what it does is look for particular types using the Microsoft.CodeAnalysis API. Anyway, I tried using it in my own project and it ran without a problem.

How the fuck can I track down the issue?
>>
>>57680905
No.
Just no.
>>
>>57680761
Imperative with OOP, where appropriate.
>>
>>57680884
In C++ you have to
>>
>>57680940
>C++
>malloc
Pick one.
>>
>>57680923
That's the reason anon. I don't know what else to tell you.
>>
>>57680958
I was just suggesting a reason
>>
So for double its bad design to check equality with ==
What if you want to check if double is zero?
>>
>>57680966
http://stackoverflow.com/a/605858/6518018
>>
File: penguin.jpg (41KB, 600x424px) Image search: [Google]
penguin.jpg
41KB, 600x424px
>>57680940
In C++ you're supposed to use new not malloc.
>>
>>57681006
>supposed to
I do what I want to do.
>>
>>57681006
I know. So what?
>>
who wins?
sizeof(thing) or sizeof thing
>>
>>57681074
sizeof thing
>>
>>57681074
first
>>
File: penguin2.jpg (409KB, 990x742px) Image search: [Google]
penguin2.jpg
409KB, 990x742px
>>57681027
>>57681034
Do NOT talk back to me.
>>
>>57681136
If not for reasons of cargo culting from C++, why do people cast malloc return value, then?
>>
>>57680761
>Also, what paradigm do you instead suggest?
Most other?
It's a big topic anon I can't really concisely type it out here it'd be a waste of time, especially not for an individual. Even if I had it all structured neatly in my head it wouldn't be wroth it. I'm also not a good authority on this.
So I point to others who aim to explain it well.
https://www.youtube.com/watch?v=jlcmxvQfzKQ
(here's his lecture on API design he mentions early on: https://www.youtube.com/watch?v=ZQ5_u8Lgvyk)
This is an experienced programmer who has worked for RAD game tools, a company that really has a lot of code in most big games. They made the bink video codec for games for instance, google it and you recognize it if you've played games pretty much. So to some extent he's a big guy. He works on performance oriented code. It's one of the primary concerns in such things.
His view of OOP is fairly enligthning if you've done OOP for a long time. He also used to do OOP before and he turned around. He talks a lot because people ask a lot, he has over 300*30min of Q&A now.
The reason it's so wide spread in the industry is something you can get from
https://www.youtube.com/watch?v=QM1iUe6IofM
for instance. I don't know who this guy is but he keeps a solid argument. The promises OOP has simply aren't delivered on in the end.
This guy >>57680939 probably enjoys certain features like dynamic dispatch and the ability to declare a set of data and add a few fields. Keeping his mental model of the code more tightly packed (I'm just guessing, I don't know where and how he likes OOP but that's common). But those benefits aren't all that much compared to the issues with OOP (many of which mentioned in the OOP is bad video).

Also it's important to note that OOP is Object ORIENTED programming. If he just used objects in say C++/java whatever for dynamic dispatch that's not really OOP. But if you were without OOP concepts entirely you could replace that easily (and more optimally if you cared).
>>
>>57681074
If this is a data type, sizeof(thing).

Otherwise sizeof thing.

This is the only correct answer.
>>
>>57681192
*if thing is a data type
>>
>>57681074
Parenthesis because makes it obvious for people who don't know it's not necessary.
And I'm used to it.
>>
>>57681074
i always put the brackets in
thing_t *thing = malloc(sizeof(*thing));
>>
>>57681214
>>57681248
>>57681112
>>57681090
THIS IS NOT A MATTER OF PREFERENCE IT IS LITERALLY SETTLED BY STANDARDS YOU BISCUITS REEEEEEEEEEEEEEE

>6.5.3.4.2
>The sizeof operator yields the size (in bytes) of its operand, which may be an expression or the parenthesized name of a type.
>>
If I know nothing, what's the fastest way to get an employable skillset?
>>
>>57681269
You mean that sizeof(0.5/'v') doesn't work?
Interesting.
>>57681279
Look at what employers want and learn that.
>>
>>57681269
>>57681292
are you retarded?

          primary-expression:
identifier
constant
string-literal
( expression )
generic-selection
>>
>>57681269
>which may be an expression
and expressions can be parenthesized

for the sake of clarity, I always use parentheses
>>
How many of you are actually professional software developers or software engineers? From glancing at these threads I get the impression most of you aren't.
>>
>>57681313
>which may be an expression or the parenthesized name of a type.
The exception that proves the rule here would imply that I can't parenthesize expressions. If you're saying that it's not a matter of preference.

But as I've used it all my life and as exemplified in >>57681292 you can parenthesis expressions. Which makes it a matter of preference because both work equivalently.
>>
>>57681334
i'm a 35+ year old asperg in a bedroom in his pensioners mothers house, been programming for 30 years
>>
>>57681292
>Look at what employers want and learn that.
No
>>
>>57681269
sizeof(<exp>) + 5 is more readable than (sizeof <exp>) + 5
>>
>>57681354
Wanna fuck?
>>
>>57681334
I'm a NEET but I frequently assist my mother in production code. She deals with control systems for a type of filter in powerplants which is interesting stuff. She's a combination of HW and SW engineer. Grew up on punch cards and designing logic with transistors or whatchmacallit (just kidding, I'm more SW oriented, it's PLC mostly).

So while I'm not really employed or a proven professional directly. I haven't written code that goes into pro-software without external approval yet. I have written code that exists in the wild.

I also help her with writing documentation (which they put on her because she's a woman and very detail oriented), reading through technical documents and more.
2X years old.
>>
>>57679595
WHO IS THIS? SAUCE. NOW.
>>
>>57681535
Use an image search anon.
>>
>>57681369
Ok?
What then?
>>
>>57681544
already did. no luck
>>
>>57681627
They're deleted now. So clearly mods don't approve of identifying her.
Either way the info in this thread allows you to find her online ID.
>>
does binaries compiled with gcc -> win32 cross-compiler use native binaries windows?
>>
>>57681655
>mods delete unoffensive pics
>they still don't delete the obvious shill threads or the black friday trash
thanks hiroshima
>>
>>57681535
holy shit how have you lived your entire life without being able to read?
>>
>>57681667
This doesn't parse.
>does binaries compiled with gcc
>for win32
>use native binaries windows?
Or is this about if cross compiled GCC compile for win32 native by default?
>>
>>57681292
>Look at what employers want and learn that.
employers dont know what they want tho
its like the first and second rule of "enterprise" programming
>>
>>57681535
>>57681687
sorry, didn't know they were deleted
it's Morgan Want
what the fuck are mods doing
>>
>>57681695
yeah fuck i meant if code cross-compiled for windows using gcc runs using native windows dll's or if they need custom versions due to call convention issues and what not
>>
>java can't do strings longer than 2^16 chars
>>
>>57681752
It wouldn't be much of a cross compiler if it didn't.
>>
File: IMG_20161118_130831.jpg (960KB, 4160x3120px) Image search: [Google]
IMG_20161118_130831.jpg
960KB, 4160x3120px
Clojure or Haskell?
>>
File: golf.jpg (36KB, 268x409px) Image search: [Google]
golf.jpg
36KB, 268x409px
>>57679595
>What are you working on, /g/?
Toy kernel, just managed to ping ATA drives to see whether or not there are any connected.
>>
>>57681805
depends on what you want to do with it
haskell isn't useful for anything but toy projects and very specific math problems tho
>>
>>57681805
Haskell is weaponized lambda calculus. Fuck knows what the other one is.
>>
>>57680989
It's fine to check for equality if exact value matching is what you want, so comparing against zero is perfectly fine in those cases.
>>
>>57681805
Why not both?

Clojure is excellent and as flexible as any Lisp. Haskell is great for maths.
>>
File: braveclojure.png (104KB, 900x900px) Image search: [Google]
braveclojure.png
104KB, 900x900px
>>57681805
clojure, definitively.
http://braveclojure.com/
>>
>>57681850
I need something to get off Java.
>>
static bool switch_to_array(long old_min, long old_max, long new_key, long entries)
{
long max_key = MAX(old_max, new_key);
long min_key = MIN(old_min, new_key);

if((entries * MIN_TREE_DENSITY) > (max_key-min_key))
{
return true;
}
return false;
}

That is what a professional programmer would write!
>>
>>57681869
>>57681886
Clj is great, bit runtime exceptions bleed me dry.
>>
>>57681894
C# baby.

Or better yet, F#.

Or if you want to be a bit more memely, OCaml.
>>
>>57681905
kek, why not
return (entries * MIN_TREE_DENSITY) > (max_key-min_key);
>>
>>57681869
Haskell has no relationship with math. It's a general programming language.
Please, refer to Agda.
>>57681951
why those parens even! The person actually teaches C and Unix programming at university. And that was an excerpt from his state-of-art equational theorem prover.
I don't understand....
>>
How do you a program to read arguments in c++?
>>
>>57682001
>Haskell has no relationship with math. It's a general programming language.

"""The Haskell Committee wanted expressions to look as much like mathematics as possible"""

>functional programming
>no relationship to maths
top kek
>>
>>57682051
int main (int argc, char *argv[])
{
return 0;
}

argv is a pointer to an array of c-strings which is your arguments. argc is the count of arguments
>>
>>57679617
Isn't bool just a typedef'd 8 bit unsigned integer instead of an actual bit type?
>>
>>57682095
no
>>
>>57682086
Just that? It looks simple.
>>
>>57682102
So it's a bit type? How is that implemented in standard C? Seeing as it is implemented in a header.
>>
>>57682103
That's how C does it. That's the C++ standard main function.

You can do platform specific versions like winmain for instance.

But it's that simple. Try it. I think the first arg is the path to your executable or your working directory, which might surprise.
But that's really it.
>>
>>57682086
Argv is an array of C strings, not a pointer to such. You are including an additional level of indirection.
>>
>>57682116
#define bool _Bool
or
typedef _Bool bool;
>>
>>57682051
Arguments to what?
>>57682059
Any programming language has a mathematical foundation: the abstract machine which interprets the language can be thought as a mathematical object.
Similarity of haskell notation to mathematical notation (well, only (->) type constructor is from math, the main thing, the function application, is different, however) doesn't make haskell useful in mathematics. Haskell is as useful for mathematical work as any other general purpose programming language.
>>
>>57682142
Yeah you're right i mispoke.
It's clear in the code though.
>>
File: 65876285652.png (437KB, 625x688px) Image search: [Google]
65876285652.png
437KB, 625x688px
I got an mobile app question:

Is it possible to communicate between phones without using client/server architecture?

So if Phone A and Phone B were outside wifi/bluetooth range, could they still transmit data between each other via the internet? Is there anyway to use push notification or text messages to obtain IP addresses?

Other than creating a web crawling to search through IPs to obtain the other and narrowing it down by state/city I'm at a loss.
>>
>>57682153
are you retarded? the whole point of PFP languages is to reason about your code like you would with mathematical functions. never reply to me again.
>>
>>57682163
technically yes, but it's not easy. You need a reaaaally good reason not to use a server.
>>
>>57682151
You are misunderstanding me. What is bool's storage type?
>>
>>57682210
What's a "storage type"?
>>
>>57682210
it seems sizeof(bool) is 1
gcc (Debian 6.2.1-5) 6.2.1 20161124
x86_64-linux-gnu
>>
>>57682163
The Internet (TCP/IP and HTTP) is built around server/client. There are abstractions, but everything is server/client.
>>
>>57682210
the standard says
>An object declared as type _Bool is large enough to store the values 0 and 1.
this is why saying

>>57682095
>Isn't bool just a typedef'd 8 bit unsigned integer

is wrong because f(x) == x is not true for every x where f is
bool f(unsigned char x) { return x;}


for example

unsigned char x = 133;
(bool)x; // evaluate to 1
(bool)x == x; // evaluate to false
>>
File: download_20161125_123138.png (43KB, 982x242px) Image search: [Google]
download_20161125_123138.png
43KB, 982x242px
/dpt/, I'm in a dilemma. I can only set up a basic array and don't know how to do this. It has to be written in Java and is due in roughly 3 hours. Help me out.
>>
File: spain-fs8.png (582B, 402x402px) Image search: [Google]
spain-fs8.png
582B, 402x402px
post a screen shot of your code / programming environment
>>
>>57681805
Haskell
>>
>>57682163
Client/server vs peer to peer is just if the two hosts send eachother data as if they were both server and client or not.

For instance you could have a videogame, pong, were every player sends its position to the other players. Making them all servers and all clients, peer to peer.

Other 'peer to peer' systems exist where there's a client and a server but they're both hosts where the user will interface as if they were both clients.
>>
>>57682197
Wanting to avoid investing capital in a server. Also the challenge sounds great. I've got a few ideas:

1) Send IP via text and instant delete to not clog the user. This unfortunately would require users to authorize access to text message so I would immediately lose a chunk of customers that would decline.

2) Create a web crawler that searches through IP addresses in a local range (city/state, most people stay without a range almost all the time)

3) Some unknown functionality I am ignorant of

Point three is where I am asking, for all I know there is some built in functionality of identifying a phone's IP location.
>>
>>57679595
Can you guys call me a faggot a bunch of times to motivate me to code? I just need some (you)s
>>
>>57682317
1 and 2 sound pretty fucking painful.

If you making it for shits and giggles just run a server locally.
>>
File: 9483204.png (29KB, 633x758px) Image search: [Google]
9483204.png
29KB, 633x758px
>>57682345
>mfw reading this
Holy shit, you're some fucking faggot.
>>
>>57682059
> (+) 2 2 == 2 + 2
>very mathematical indeed
> v `f` w == f $ v w
>holly Mooses!
>>
>>57682194
Yes and no. Functions in a programming language represent computations. Mathematical functions are tuples of their codomains and their graphs.
Either you have functions that aren't total in your programming language (which isn't like in mathematics) or you have each set/type inhabited by a divergent member like in haskell (which isn't like maths either).
You can't use haskell in maths just because its type system, which would normally describe properties of objects, isn't powerful enough: you can't encode rich mathematical theories in haskell.
Are you afraid of me?
>>
>>57682271
Alright.

>>57682236
The type that dictates the load/store instruction sizes. It's usually a byte, so each bool takes up a byte of memory. This is because C doesn't support the ability to automatically generate bit arrays. sizeof (bool) is 1, i.e. 1 byte.
>>
>>57682379
>I have never heard of lambda calculus
>>
>>57682286
>>
File: 2016-11-25_11-41-35.png (132KB, 1920x1080px) Image search: [Google]
2016-11-25_11-41-35.png
132KB, 1920x1080px
>>57682286
>>
>>57682163
Yes you could design it similar to p2p networks and let them create their own topology, with e.g. each node knowing the 2 following and the 2 previous nodes.
The big problem is bootstraping such a system if there is no dedicated server at all.
>>
>>57682408
>lambda calculus lol
>not into reppresentation theory with mutable objects
>>
>>57682454
The lambda calculus is probably the best invention of the 20th century
>>
>>57682498
There's autism, then there's you.
>>
>>57682498
And it's useless in math too.
>>
trying to learn C and math at the same time (got kicked out in 8th grade & never returned)

#include <stdio.h>

typedef struct {

int x;
int y;

} cell;

int coef(cell *c1, cell *c2)
{
int dy = c2->y - c1->y;
int dx = c2->x - c1->x;
int result = dy / dx;
return result;
}

int main(int argc, char **argv)
{
cell c1;
c1.x = 1337;
c1.y = 5;

cell c2;
c2.x = 297;
c2.y = -18;

int k = coef(&c1, &c2);
printf("k=%d\n", k);
}


feedback pls
>>
>>57682317
What it sounds like you really want to do (for ease of use) is either use a DHT Protocol. Which I don't know how successful they are but torrents work OK via them. I'm not even sure how they do what they do. But it's worth looking up

Or you can have a centralized server which coordinates tcp hole punching punching, like Skype does. Hole punching is apparently difficult. There's issues with routers acting differently etc. The cost for the server isn't much since the transfers it has to do is not particularly much, it could be a raspberry pi in your basement probably.

Either way if you're doing P2P between two hosts on completely unpredictable network with all kinds of firewall configurations you need to do holepunching.
>IP location.
Not a good way to think about IP's. The internet rounting protocols take care of that. All you need to do is find ways of communicating that the phone on the inside is requesting something from the outside so the firewall lets it through. If you don't have the correct destination IP you're in trouble. But it's not 'location based'.
>Other than creating a web crawling to search through IPs to obtain the other and narrowing it down by state/city I'm at a loss.
This is what confuses me about your idea of 'location'.
>>
>>57682574
Nothing to complain about. Mainly because it's so simple. Good luck with your pursuits.
>>
>>57682498
>mfw physicist
>group theory for everything
>lambda calculus is also useless in real maths
>>
>>57682574
> unused parameter argc
> unused parameter argv
> main function doesn't return anything
> typedef struct
>>
>>57682521 >>57682535 >>57682599
>they say, in a programming thread
>>
>>57682574
It doesn't make much sense to use integers for the slope of a line.
>>57682599
Exactly. I've seen very bright math phds who were doing their etale cohomologies and had no idea about lambda-calculus.
>>
>>57682638
Who cares, who cares, fix it, don't understand why people think this is a bad thing.
>>
>>57682639
>I never heard about computational physics
>>
>>57682662
>Who cares, who cares, fix it, don't understand why people think this is a bad thing.

that's why you will never be good in anything.
>>
>>57682638
There's autism, there's this guy,
>>57682498
then there's you.
>>
>>57682665
Nobody fucking cares about your meme division of meme physics
>>
>>57682715
>There's autism, there's this guy,
what?
>>
>>57682679
Explain why it's a bad thing without posting that Linus post "Encapsulation is bad! I'm smarter than everyone! Wah wah wah".
>>
>>57682747
you cared enough to answer him
>>
>>57682750
Read my response to the second quote.
>>
>>57682638
those are fine
>>
>>57682415
Where to learn racket from? I don't really like realm of racket because of the whole world state thing.
>>
>>57682909
why do you want to learn racket? pick haskell, it's better
>>
>>57682965
I think you're false-flagging
>>
>>57682965
there is nothing worse than a haskell developer-beginner who doesn't know math well...
>>
>>57682755
>Encapsulation is bad!
People don't honestly say that do they?
>>
>>57682965
>haskell
>>
File: 1453397158889.jpg (84KB, 701x572px) Image search: [Google]
1453397158889.jpg
84KB, 701x572px
>>57680721
Those functions return a Bank, so I'm assuming those are some kind of stateless, immutable variables
I'm not familiar with haskell/ML, but isn't this actually trashing a newly allocated variable every function call? It sounds highly inefficient and GC-heavy, unless there are some mechanisms I'm not aware of
>>
>>57682285
(a, b) =>
a.concat(b).sort()
>>
I'm giving up on Haskell lads. The language is great, but it's not meant for me. My projects don't involve complex math, so I'm better using an imperative programming language. I don't get the feeling Haskell makes things easier for me. For instance, I feel like recursion is the best solution to iterate over an array.
That said, I'm in for a new language. I like C++14, but the ecosystem is heavily segmented. Some use smart pointers, some do not. It's a big clusterfuck. D doesn't have any killer features IMO. I like Rust (apart from the community), except for the string handling. I've heard good things about Nim, Elixer and Crystal, but I haven't had the time to check them out.
What language should I focus on now? Ideally something that has map|filter|reduce functionality and a sane syntax.
>>
>>57683054
>this actually trashing a newly allocated variable every function call? It sounds highly inefficient and GC-heavy
The compiler can do such trivial optimizations.
>>
I'm taking my first steps into PHP.

I am making a simple blog hosted on a wamp server using a MySQL database for holding the information about the blogs and associated blog posts.
I can access the blog at localhost/blog/index.php

I have limited the content field to 50 characters and then have to click a "More" link at the end to view the whole blog post. Clicking the link takes me to localhost/blog/blogpost.php?ID=id_here

Here's the kicker: I want to know how to use this functionality in a single PHP file. How would I move the code in blogpost.php into index.php without breaking it and being able to retain functionality?
I'm new to this kind of stuff and I hope I can get some pointers.

Pastebin of the full code:
index.php: http://pastebin.com/DjvzQ7Ar
blogpost.php: http://pastebin.com/A8VhgHaQ

Any input is greatly appreciated!
>>
>>57683054
It could be optimised, but the good thing about immutability is you can happily re-use other immutables - e.g. your "tree + element" can use pointers to the old tree, with only a few nodes changed

>>57683077
use mapM or for to iterate
>>
>>57683077
Ruby
>>
File: 1463743448539.png (114KB, 300x300px) Image search: [Google]
1463743448539.png
114KB, 300x300px
How do you come up with programming ideas? I have no idea what I could write.
>>
>>57683094
>>>/wdg/
>>
>>57683094
hey
>>
>>57683054
>>57683107
Oh, and instead of returning a Bank, it could be something like Acc -> Acc -> Dbl -> State Bank TransferResult
>>
>>57682909
https://learnxinyminutes.com/docs/racket/
https://docs.racket-lang.org/
http://trycode.io/
r/Racket
https://www.edx.org/xseries/systematic-program-design-0
>>
>>57683094
Save the CSS in a seperate file and add a link tag.
>>
>>57683119
Wait for inspiration. Sucks complete ass. Can try to make it better by looking for things that don't exist yet, problems yet to be solves, shit people complain about, etc.
>>
>>57683107
Looping is one of many issues I have with Haskell.
>>57683111
I don't like interpreted and dynamically typed languages.
>>
>>57683023
>there's nothing worse than me
thanks. oh well, at least i'm white
>>
>>57683186
>Can try to make it better by looking for things that don't exist yet, problems yet to be solves, shit people complain about, etc.
That's exactly my problem. Everything useful that I could need already exists. It's pretty annoying
>>
>>57683197
mapM / traverse / for
are probably what you want
>>
>>57683077
use haskell, it has map filter and fold
>>
>>57683244
Are you that false flagging guy?
When the fuck will you fucking stop?
>>
>>57682639
If you don't care about math while programming you're not even worth being called a pajeet.
>>
>>57683077
Ada. Not joking.
>>
>>57680187
except for Java, C, C# etc. + any "dynamically" typed language
>>
>>57683244
checking dependencies...

Packages (2) cabal-install-1.24.0.0-3 ghc-8.0.1-1

Total Removed Size: 1164.06 MiB

:: Do you want to remove these packages? [Y/n] y
:: Processing package changes...
(1/2) removing cabal-install [########################################################################################] 100%
(2/2) removing ghc

It's too late, I'm moving on.
>>
let ( ** ) a b =
let rec loop a accu = function
| 0 -> accu
| b ->
let accu = if b mod 2 = 1 then a * accu else accu in
loop (a * a) accu (b / 2) in
loop a 1 b
;;
>>
>>57683330
you should've tried learning it before you gave up
>>
>>57683330
no, reinstall that shit now
>>
I don't properly know javascript, es6, or react, but I'm trying my ass off to make an android app using react-native. I'm making progress, I at least got to a point where I can fetch shit from my API and render it. Stuck on figuring out how to navigation properly.

My background is web app development in Ruby. This is a different way of thinking. I've been doing the same shit for way too long.
>>
>>57683349
I did. I completely read Learn You a Haskell for Great Good!, parts of Real World Haskell and wrote some fizzbuzz tier applications. It didn't click like Rust and C++ did.
>>57683358
resolving dependencies...
looking for conflicting packages...

Packages (1) ghc-8.0.1-1

Total Installed Size: 1146.92 MiB

:: Proceed with installation? [Y/n]

Should I?
>>
>>57683403
Compile OCaml instead.
>>
>>57683403
>1146.92MiB
no shit, just install gcc
>>
>>57683403
I think you wanted something more like mapM/for/traverse, perhaps with the state monad, instead
>>
>>57683438
>gcc
No, Clang.
>>
>>57683494
better install haskell, is a pure functional language
>>
Why does the c book (K & R) use
main()
{
}

and any other person uses
int main()
{
return 0;
}

???
What's going on? Which one's correct?
>>
>>57683307
not java
>>
>>57683532
why not both
>>
>>57683458
You got me. I'' reinstall Haskell and give it a second try.
>>
>>57683307
Java and C# both will throw a compilation error. C doesn't because it's weakly typed.
>>
>>57683539
K & R is a brain cancer.
>>
>>57683539
traditionally, a function requires the declaration of a return type, and a return statement. But c lets you skip them sometimes.
>>
>>57683330
>1164.06 MiB
B L O A T
B
L
O
A
T
>>
>>57683571
you can always just leave it installed
>>
>>57679938
#define not !
>>
jQuery question,

to summarise my problem, I'm asking about adding content to the DOM without having to recall handlers.

<div id="moo">
<a href="muh">muh</a>
<a href="meh">meh</a>
</div>


## handling ##
$("#moo a").click(function(event)) {
event.preventDefault();
}


Later, adding some item to moo
$("#moo").append(" <a href="mzh">mzh</a>");



how can I avoid to make a new call to ## handling ## and have that 3rd ahref handling ?
>>
>>57683330
>1164.06 MiB
dafuq
>>
>>57683629
>>57677221
>>
>>57683341
isn't ** built into F# already? Or is that OCaml?
>>
What is a good OAuth2 tutorial? I can't understand jack shit of this
>>
>>57683651
F#? Please be serious.
>>
>>57683149
Done, thanks for the tip!

>>57683125
Hello

>>57683120
Thanks for the redirect, sry for wrong thread!
>>
File: 1478608314279.jpg (52KB, 500x500px) Image search: [Google]
1478608314279.jpg
52KB, 500x500px
how do you choose names for your shit?
(as in projects, not variable names etc)
>mfw i named my anti anti-cheat module onee-san because she watches over me
>>
>>57681334
lead developer here at a SaaS company, never posted here though except for this. I'm with you, everyone here is shit
>>
>>57683539
The first is a C89 main-function definition: return type is taken to be int by default and no parameters in the function parameter list of the definition means it doesn't take any.
The second is the C++ style function definition.
Function declorators with an empty parameter list are an obsolescent feature in the modern C. As a part of a function definition, they are taken to mean a parameter list containing void keyword.
The portable way is
int main(void)
{
// ...
}
>>
>>57682210
>>57682095
bool's real type is _Bool whose size is implementation-defined
>>
>>57683608
I'm almost certain I'll never touch Haskell again.
>>57683599
>>57683640
That stunned me too. It's not like Haskell ships with a ton of libraries out of the box.
>>
>>57683678
Whatever is on my mind at the time. Named an imageboard engine meguca.
>>
>>57683694
GHC is a big guy
>>
>>57683678
I named my project You because it's a huge fucking faggot.
>>
>>57683720
Thanks You
>>
>>57683711
for you
>>
>>57683646
So is mobile app development /wdg/ or /dpt/?
>>
>>57683069
Yeah, do it in O((m+n)log(m+n)) when you can do it in O(m+n). Functional programmers are fucking dense.
>>
>>57683584
Can you elaborate on that?
>>
>>57683755
It's simpler. Of course you can do it in-place, but his homework does not need that kind of optimizations.
>>
>>57683755
If it's lazy then you don't know that
>>
>>57683684
So that is better than the two I posted? Does it matter when the program is compiled? My guess is no but I'm just a begginer.
>>
>>57683760
Every neurons storing information about this book increase their synaptic weight overtime thus slowly killing your intelligence.
>>
>>57683755
Lazy evaluation and stream fusions would compile that to a simple loop
>>
I created a long list of patterns that can be used to generate Hearthstone cards:
m    template    NAXX        0.2    Deathrattle: <effect> and <effect>.
m template NAXX 0.2 Deathrattle: <effect>.
m template TGT 0.5 Inspire: <effect multiplier=0.65>.
m template TGT 0.5 0.5 Inspire: Gain <stackable_effect multiplier=0.65>.
m template TGT 0.5 0.5 Inspire: Gain <ability_aura multiplier=0.65>.
m template 0.25 At the beginning of your turn, <effect>.
m template 0.25 At the start of your turn, <effect>.
m template 0.25 At the start of each turn, <effect>.
m template 0.5 At the end of your turn, gain <ability>.


Each entry, apart from text it generates, has parameters that, via addition and multiplication, will determine the mana cost of a final card.

So, as it is, the thing can be used to generate new cards and evaluate their cost. I have that working pretty well and results are somewhat impressive.

Now I'm testing gradient descent optimizer I wrote to alter those parameters, so that when I'm generating real Hearthstone cards, I'd get their real cost. This is a really enlightening experience.
>>
>>57683539
They're both valid. One is implicit, so it's easier to not be distracted by, while the other is explicit, so it's a bit more common.
I thought the K&R book used 'void' though?

return 0; just means "return without an error".

Daily reminder C is a really shitty language and it doesn't even have booleans.
>taking up 16bits for a value that can be held in a single bit.
>>
How to prevent API request throttling correctly?

So far I used whatever sleep function the language had. Seems to be a rather blunt approach though. I spread some calls through cronjobs.
>>
>>57683782
I didn't say anything about doing it in-place. Anyway his question states that merge the two arrays into a new array.
I'm just saying that the two arrays are sorted so concatenating them and then sorting them again is overkill.

>his homework does not need that kind of optimizations.
Maybe his question is from an Algorithms class and they are testing if he can merge the two sorted arrays in linear time.

>>57683794
>>57683833
Hmm, didn't know about that.
>>
>>57683732
javascript leans toward /wdg/ even if you use it for non-web purposes
>>
>>57683855
Daily reminder your 64 bits CPU can only process 64 bits of data.
>>
>>57679803
>>57679808
>>57679812
He's obviously trolling, but you're both retarded. His implication was that you can glance over a single character, while a full word is obvious.
>>
>>57683903
64 bits of data is enough for anyone

t. Bill Gates
>>
>>57683855
>taking up 16bits for a value that can be held in a single bit.

And how do you propose we align those single bits to word boundaries? Surely you can't be thinking of unaligned access.
>>
>>57680006
Wrong.
I've never mixed them up, but I've worked with other programmers, and programmers who use C and C-like languages are 95% retarded.
>>
>>57683931
I was badly trying to say storing boolean doesn't make sense
>>
>>57683820
It is The portable way by which the current standard of the language dictates main function to be defined without parameters.
They are compiled to the same code but some compilers will issue a warning to the first one. The evolution of the language will proceed similarly with respect to the second way.
>>
File: 201607221946411006167005.png (5KB, 238x212px) Image search: [Google]
201607221946411006167005.png
5KB, 238x212px
His language doesn't support fixed point and declaring your own floating point types.
>>
>>57683956
how come?
>>
>>57683961
you can do anything in a turing complete language

the thing about standard floats is that they're hardware accelerated
>>
>>57683908
Do you think that we should remove all single character operators?
&x : addressof (x)
*x : dereference(x)
+ : plus
>>
>>57680069
He said _sane_ languages, so Ocaml. ;)
>>
>>57683961
My langugae is F# buddy
>>
>>57683974
so are typed floats is masterrace F#
>>
>>57682345
get to work fucking ass faggot
>>
>>57682345
You will have to learn new languages/versions/libs/ etc. for your entire life and will never truly master your trade faggot.
>>
>>57682345
*cracks whip*
>>
>>57683993
?
>>
>>57683969
Well it does but most of the time it's not efficient since you're wasting space. Bit fields in C should be used instead.
>>
>>57684051
https://fsharpforfunandprofit.com/posts/units-of-measure/

basically you can tell the compiler what unit type your float is meant to represent, meter per second for example. And the compiler will make sure you don't accidently pass the float to a function that expects float representing kilometers for example.

It's pretty neat.

The typing gets removed at runtime, so there's no overhead.
>>
NEW THREAD >>57684107
NEW THREAD >>57684107
NEW THREAD >>57684107
>>
>>57684082
most software these days isn't run in such memory constrained environments such that you can't waste 7 bits every here and there.
>>
OpenBSD coding style is broken. Includes in C should have local includes on top, then libraries, then OS (sys/...), and finally stdlib.

OpenBSD gets it backwards. This means any time you try to include a file, it might not have included or forward declared all the required types.

e.g.
https://github.com/openbsd/src/blob/master/bin/pax/pax.h#L109

off_t isn't included in this header so if you try to include pax.h without first including something with off_t, then your compile will fail.
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include "pax.h"
#include "extern.h"


Please, C programmers. Follow the real rules.
>>
>>57683975
I never said I agree with him, but in my personal opinion as a langdev, I usually try to avoid tokens that might be unclear.

>&x : addressof(x)
Obviously, and maybe not make "addressof" the bitwise AND operator either.
>*x : dereference(x)
Obviously, but the fact that we're using the same character for multiplication and dereferencing pointers is a problem in and of itself.

>+ : plus
Only after we remove the order of operations, which obfuscates code regularly.
Take "3+5 * 6+2", for example.

C is just a pile of shit, honestly. No reason to fix it. Throw it in the trash and start over.
>>
>>57684143
I can't tell if this post is satire or not.
>>
>>57683094
I somehow figured it out myself, here's the final code if anyone's interested:

http://pastebin.com/r2jxxAWk
>>
>>57684209
It's not satire. It's idiocy.
>>
>>57684259
>>57684209
Calling people names isn't going to make your arguments any less shit.
>>
>>57684778
I'm not calling you names. I just see you calling yourself "langdev", I see you suggesting to remove order of operations, and I just can't figure if your post is satire or not.
>>
>>57683684
"C is a good language because its simple!!!"
le rob pike face
>>
>>57684092
You can do this in Haskell, desu, without language bloat
>>
>>57684856
how?
>>
>>57684807
>he can't program in Lisp because of his crippling dependence on ALGOL style languages
>>
>>57683835
This is cool, do you plan to share it when you're done? It would be fun to play with it
>>
>>57683139
A lil' bit late but thank you.
>>
new thread fuckers:

>>57684107
>>57684107
>>57684107
Thread posts: 331
Thread images: 25


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

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


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