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

What are you working on, /g/?
>>
>>52518289
first for what show is that
>>
How is one supposed to dynamically allocate space for user input of arbitrary length?
Scanning through just to count the space to allocate in advance just seems wasteful.
>>
>>52518418
You allocate it block by block, i.e.

>alloc n bytes
>read n bytes
>need more input? Then expand buffer to fit 2n bytes
>read another n bytes
>...

Or just use a function that does it for you.
>>
>>52518356
himegoto
>>
Rewriting ocaml in ocaml
>>
File: 2084828421.webm (631 KB, 314x216) Image search: [Google]
2084828421.webm
631 KB, 314x216
Currently re-evaluating my programming career.
>>
>>52518289
Nothing right now, but Revision 2016 is only about 2 months away, so I should probably start working on a demo.
>>
Trying to wrap my mind around monads.

Jumped on the functional band-wagon mostly because I couldn't into objects, but now I feel like monads are even worse than objects.

Also, playing with vim unicode concealment. Not sure if I like it yet.
>>
Javascript question:

I have a forEach method, called on an array of strings. The callback function of this method makes a getJSON call - the url of which is modifed by whichever array element is currently selected by the forEach method. The callback function associated with this getJSON call contains another getJSON call.

A number of variables are used to store data associated with the JSON data returned by these username-specific calls. These variables are used to insert important data into an html string which is then appended to the html page.

However, if these variables are declared globally, the data appended to the page is incorrect. If I declare the variables at the start of the forEach method's callback function everything works fine. Why is that? Is it an issue related to scoping, or looping? I understand that local-level variables are erased once the function is complete, so is it preventing some kind of difficult-to-pinpoint error from happening by resetting the variable values on each array iteration?

Shit's confusing, dudes
>>
>>52518289
i'm using text to speech on my pdf textbooks while i read along and i feel like i'm plugged in to the matrix and having information uploaded directly into my brain
>>
>>52518731
Too many words for my autism, man.
>>
pseudo-code illustrating the layout in basic terms:

usernameArray.forEach(function(user){
$.getJSON(url + user, function(jsondata) {
// some code storing json data in variables.
$.getJSON(url + user, function(morejson) {
// more code storing json data in variables.
// code appending html to the page using
// the variable related data
end of second json call
end of first json call
end of foreach method
>>
>start job today
>get code I'm supposed to work on
>warned that the last guy was a shitty coder
>look at the code
>undocumented C for an embedded system
>tab width is 3
>barely documented assembly

What did I get myself into
>>
>>52518806
don't worry anon, you'll soon follow in the last guys footsteps
>>
Turns out I have to use VB for my job. Any tips for someone who's programmed in C++ and C#?
>>
>>52518620
why
>>
Good morning.
>>
>>52518881
Overhaul the entire system in either C++ or C#
Don't tell upper management though until it's finished, they'll be pleasantly surprised by your initiative
>>
>>52518881
don't
>>
>>52518731
i replied to this already here >>52518536

but yeah, it seems like because the getJSON calls are running asynchronously, they are accessing the global variables at the name time. So one callback is writing to one of the variables, then another callback writes to that same variable, then the first callback reads from the variable thinking the it has the same value as when it wrote to it last, but it doesn't because multiple callbacks are reading and writing to it and the same time.

When you declare the variables in the callbacks themselves then you have separate variables in memory for each callback, and you don't have those concurrency problems.

That's my guess at least. I'd need to see the code to know any better.
>>
>>52518928
I got fired from my last job from doing this. I think they guy I worked for was just insecure. Every time i made a suggestion about how we could improve the codebase it ended up exposing something basic about programming he didn't know. He never admitted that though, but got passive aggressive about 6 months. Fired me for effectively no reason.
>>
>>52518881
Assuming you are using .NET, Write in C# and run it though a C# -> VB converter. They are almost identical except syntax differences.
>>
>>52518928

I think my superiors are super insecure since they're all shit at their job.
This will probably happen. >>52518966


>>52518974
Neat. I'll do that. Thanks, m8.
>>
>>52518881
Leave your job. Unless you're making solid 6figs.
>>
>>52518937
good guess, but async isn't a problem, the second getJSON request is nested within the callback of the first - i.e. it won't be called until the first getJSON request receives the data it requested. additionally, the each getJSON request works with its own separate set of variables, so overwriting isn't an issue.

but yeah, the problem is too verbose to get help with on /g/. i might throw it up on codepen and see if I can get some forum-help.

thanks for all the help though dude
>>
Is an instrument tuning program a bad idea as far as a program that I can learn a bit about programming while making? I'd be using c++ btw
>>
>>52519002
I hope you have at least a rudimentary understanding of signal processing.
>>
>>52519000
>he second getJSON request is nested within the callback of the first - i.e. it won't be called until the first getJSON request receives the data it requested. additionally, the each getJSON request works with its own separate set of variables, so overwriting isn't an issue.
no, I mean you are running the JSON on every name in the array right? The array has say 100 names... you are running 100 json requests in parallel. That's the problem. I would think.

>thanks for all the help though dude
no prob bob
>>
>>52518990
>I think my superiors are super insecure since they're all shit at their job.
>>52518937 here. If you can get on good terms with someone in the company who just wants to see good work done, like say the CEO or some non programming manager, it might be a good idea to try show them something. I wanted to do this in my last job, but couldn't since it would be going behind the back of the guy I worked for directly, and that would have made me look like a dick. Was shitty because the company culture was really great otherwise, the CEO loved seeing people make cool new stuff. Just the guy i worked for was a cunt.
>>
>>52519025
>no, I mean you are running the JSON on every name in the array right? The array has say 100 names... you are running 100 json requests in parallel. That's the problem. I would think.

Right on dude, this would match some of the idiosyncracies I've seen with the errors - the html inserted is always associated with the final name in the array, and those particular variables are found within the first getJSON call - the one with the highest latency in terms of call to page write, so the data has plenty of time to be overwritten by newer calls before it's stuck into the page.
>>
I'm on windows and want to be able to compile 32bit programs. How do I force MinGW to compile 32bit stuff? Do I need to completely install a new version that is 32bit?
>>
File: modern operating systems 1.png (69 KB, 1233x644) Image search: [Google]
modern operating systems 1.png
69 KB, 1233x644
>>52518289
heh.
>>
>>52519104
Awesome. In general this is why shared mutable state is considered bad, because you can end up with bugs like this and it can be very unintuitive trying to figure out the cause, or even reproduce.
>>
File: 1353958087745.jpg (141 KB, 500x454) Image search: [Google]
1353958087745.jpg
141 KB, 500x454
Alright folks
Time to figure out who is based and who isn't

int* x;

or
int *x;


void method(){
//aaaa
}

or
void method()
{
//aaa
}
>>
>>52519169

The latter, the latter.

t. K&R
>>
>>52519169
Latter, former.
>>
>>52519189
Former with a space before the curly brace, to be exact.
>>
>>52519169
doesn't matter and doesn't matter

but

int *x;

and
void method(){
//aaa
}


because fuck you guys
>>
>>52519169
2 and 2
>>
>>52519169
latter and latter
>>
>>52519181
this tbqhwy
>>
>>52518289
I'm honoured my webm is now the OP image.
>>
File: thumbsup.jpg (10 KB, 238x211) Image search: [Google]
thumbsup.jpg
10 KB, 238x211
>>52519181
>>52519215
>>52519221
>>52519228
>>
>>52519169
i like the 2nd bracket style more tbph
>>
>>52518806
>>tab width is 3
wtf
>>
can anyone provide me good resources for system programming in c? apparently it was an unspoken prereq for a class i'm taking
>>
>>52519169
b, b.
>>
>>52519181
For once I agree with the filthy racemixer about something
>>
>>52519282
xD
>>
>>52519407
What's your point?
>>
>>52519282
There are quite a few groups of people who do that. I assume it's mid-east education at work.
>>
>>52519415
;D
>>
>>52519417
I don't get why you wouldn't just leave it at four
>>
>>52519417
There are also quite a few groups of people who need to be shot. What's your point?

>>52519456
This, 4 is the only acceptable answer. Linus' opinion can go fuck itself.
>>
>>52519456
Hence, mid-east education.
>>
>>52519339

What's wrong with racemixing, senpai? It feels good. Do it.

After that, please patronize my law firm, Shlomo, Goldberg, and Abramovitz.
>>
>currently working as receptionist. A job for babbies
>developing software for a specific solution by myself, in the hopes of selling it (saas) and if all goes well (sales and money Flow) the goal is to actually quit the job and work on myself.
Can an experienced anon share some advice. As cruel as it is.
>>
This isn't the correct image.
>>
>>52519169
The former for both. Any other choice belongs to the inbred.
>>
>>52519169

Former on both counts.
And a tab length of 4 spaces.
>>
>>52519570
>>52519572
plebeianmind
Except for 4 spaces, that's good
>>
>>52519594
Inbred detected!
>>
What percentage of /dpt/'s opinion actually matters?
>>
>>52519707
.8
>>
>>52519554
I would say be careful developing it on company computers or software because they may own rights to it.
>>
>>52519707
3.448%
>>
>>52519181
This.

The latter because
int *x, *y;


And the latter because functions are special blocks.
>>
>>52519169
First, second.
>>
Null terminated strings are great, and avoid the overhead of strings with explicit lengths. Prove me wrong.
>>
>>52519783
>they're a special block so they should look identical to normal blocks
OK pajeet.
>>
>>52519791
Both types of strings have their advantages and disadvantages.
>>
>>52519169
Sometimes I do int* x, sometimes *x. It doesn't make such a terrible difference. Except for the babbys who haven't learned C declarations, so they cry when they see anything that makes them think,
I wonder if
int * x;
will ever become a fashion.

I don't have those newfangled tall screens, though, so I can't afford the luxury of wasting lines on mere brackets. That's why I do void method(){
>>
>>52519791
>overhead
wow, you saved 8 whole bytes, but now you have to hang your program every time you want to read the length of a string.
Nice going.
>>
>>52519791
I believe you mean NULL-TERMINATED BYTE ARRAYS
>>
>>52519791
They can't include the null character and are thus, among other issues, vulnerable to poison null byte attacks. Moreover, length can be used to preserve safety by preventing buffer overruns. Obtaining the length on a runtime string is O(1), while it is O(n) with null-terminated strings. For other usage patterns, speed is the same, modulo safety.
>>
>>52519808
realistically, more like 2 bytes, if not just 1.
>>
>>52519808
You can just pass the length explicitly where it's necessary, and avoid it where it isn't.

>>52519808
Ever take slices of length-prefixed strings? C handles this flawlessly.
>>
>>52519795
>>they're a special block so they should look identical to normal blocks

That's only if you're using Allman/BSD style.

In K&R, non function blocks are written as follows:

if(...){
//thing here
}
>>
>>52519847
Hohohohohohohho
HAHAHAHHAhahahahahahaha!
Oh wait, you're serious?
HAAAAAAAAAAAAA!
>>
How does one get into programming? I'm interested in computers and I'm currently a nolife NEET so it seems like a logical step. My brother recommended getting into C-Sharp but I've no idea what language to pick. Should I just google a C++ tutorial and then kill myself?
>>
>>52519867
And
{
T temp = some_val;
do_temp_thing(temp);
}

????
>>
>>52519875
Eat cyanide pills, it helps.
>>
>>52519875
Learn C.
All other languages will seem easy in comparison.
It's also quite beginner friendly if you haven't been spoiled by overbearing scripting languages like python yet.
>>
>>52519875
Go hang out with programmers, read a book, watch university lectures on the internet, find a tutor, actually go to university.
There are literally so many different ways; a better question would be "how do you NOT get into programming?".
>>
>dicking around with sorting algorithms
>know basically which ones are faster than others
>bubble sort takes 24 seconds to sort my randomised array
>try quicksort
>it takes 130 ms
Jesus fuck is this supposed to happen?

also
>XOR swap is slower than swapping with a temp variable
>creating a swap function is slower than swapping without a function call, even though DMD should be inlining it
??????
>>
Will C shitters ever admit its time is gone and it should be buried?
>>
>>52519169
former, latter
>>
>>52519847
> Ever take slices of length-prefixed strings?
Ever take slices of null-terminated strings where the end of the slice isn't the end of the original string?

Efficient "tail-slicing" is the *only* significant advantage of null-terminated strings.

Saving a few bytes only matters when most of your strings are short. If they're all short, you only save 1 byte..

Whereas length-prefix gives you O(1) "strlen" (which can also be used as an optimisation when checking whether strings are equal) and the ability to store null bytes within the string.

The other sane option is a length+pointer pair, which has the advantages of length-prefix plus the ability to slice.
>>
>>52519996
Not until you can come up with a viable replacement for C.
All your compilers and operating systems are written in C.
>>
>>52520017
Rust
>>
IGNORE TRANNY THREADS

REPORT TRANNY POSTERS
>>
>>52520011
Honestly, it makes you wonder why this wasn't built into the standard.
You know how free() and realloc() know how much memory to deallocate?
The length information is written before(?) the pointer.
Nothing in the standard defines this, it's completely compiler specific.
>>
>>52520021
Good joke.
>>
>>52520017
No, ocaml's compiler is written in ocaml and mirageos is written in ocaml.
>>
>>52520017
>writing compilers in C
kek
>>
>>52520017
>compilers [...] are written in C
Nah, most languages try to be self-hosting.
Most interpreters are written in C though.
>>
>>52519992
> Jesus fuck is this supposed to happen?
That's the whole point of big-O notation.

If method A has worse complexity than method B, then for sufficiently large N, A will be X times slower than method B. For absolutely any X.

You say:
>bubble sort = 24 secondsrandomised array
>quicksort = 130 ms
I.e. 185x difference.

Bubble sort is O(n^2), quicksort is average O(n.log(n)). Given the same constant, you'd expect that to happen when n>2000 or so.

For n=10^6, you'd expect bubble sort to be around 50,000 times slower.
>>
>>52520017
>All your compilers and operating systems are written in C.
lol
ocamls compiler is written in ocaml
F#'s compiler is written in F#
C#'s compiler is written in C#
Java's compiler is written in Java
TypeScripts compiler is written in TypeScript
CoffeeScripts compiler is written in CoffeeScript

Not that I would expect a Ctard to know any of that.
>>
>>52519992
>>XOR swap is slower than swapping with a temp variable
XCHG is more efficient that load, load, eor, eor, eor, store, store. Kinda obvious.
>>creating a swap function is slower than swapping without a function call, even though DMD should be inlining it
idk, ask the compiler developers.
>>
>>52519878

What about it?
>>
>>52520114
Also, a ton of language's first compiler is written in ocaml, including rust's. F# and ocaml are best to write compilers. Then you want to be self-hosted as a proof of completeness and in order to be independent.
>>
>>52520017
> All your compilers and operating systems are written in C.
clang is written in C++, as are the latest versions of gcc.

C is still widely used for system libraries because you get a C-callable ABI "for free", and calling C from C++ is easier than the converse.
>>
When did the ocaml meme start?
>>
>>52520159
>F# and ocaml
Fuck off OCaml's coattails, runt.
>>
>>52520171
Like yesterday. This one guy has been shilling it non-stop.
>>
>>52520171
In 1996
>>
>>52520189
This.

It's just one guy posting about it literally every thread.
>>
>>52520188
but F# is just ocaml that's useful in the real world.
>>
>>52520189
>being this new
>>
>>52520203
>being pround to be old timer
>>
>>52520202
hahahahahahaha
>>
>>52520051
1. It's specific to the implementation of the C library rather than the compiler (e.g. MinGW uses gcc as the compiler but MSVCRT as the library).

2. Some implementations store the heap metadata in a header before the block, some store it separately. The latter has the advantage that writing to an array index of -N (for small N) doesn't trash the heap metadata.

3. The size of the allocated block isn't necessarily the size of the allocated string. The block size will typically be a multiple of 8, maybe more. In some implementations, it may be the next power of two above the required size. A length-counted string needs to hold the length exactly.
>>
>>52520202
OCaml is used plenty in the real world.
F# on the other hand, is OCaml tied to the M$ ecosystem, with no actual real-world use. It removes some of the biggest features in ocaml and adds literally nothing. But hey, buzzwords are cool I guess, the more you throw at people the better the language, right?
>>
If you put a million monkeys at a million keyboards, one of them will eventually write a Java program.

The rest of them will write Perl programs.
>>
>>52520255
OCaml is a buzzword

Literally no one uses this shitty language
>>
Dot files
>>
F# is C# Babby's first functional language.

It should be pretty clear from an objective comparison to OCaml that it's not nearly as good.
>>
>>52520266
Tell that to facebook and bloomberg.
>>
>>52520255
>OCaml is used plenty in the real world.
haha, come on now anon my man.

>F# on the other hand, is OCaml tied to the M$ ecosystem
That's what makes it great.

>with no actual real-world use
jet.com is 100% F# on the backend.

>It removes some of the biggest features in ocaml
like what? It has actual mature libraries available for common tasks like mobile and web dev. That's kinda neat.
>>
>>52520292
Unfortunately, there aren't many objective comparisons around.
>>
Alright fuckers, it's math challenge time. Everybody get out a piece of paper and a pencil... or a REPL.

https://www.youtube.com/watch?v=SOgn6J12NWE
>>
>>52520308
>haha, come on now anon my man.
https://ocaml.org/learn/companies.html

>That's what makes it great.
hahahahahahahaha

>jet.com is 100% F# on the backend.
Not even multinational.

>like what? It has actual mature libraries available for common tasks like mobile and web dev. That's kinda neat.
hahahahahahahaha

>>52520309
>I need someone else to do it for me
>>
>>52520313
>8 minutes
tl;dw

summarize it in 2000 characters or less
>>
>>52520308
>literallywho.com uses F#
>therefore it's used in the real world
>unlike ocaml, which is only used extensively by bloomberg, facebook, and hundreds of companies around the world
>>
>>52520313
from math import *

def fiveSquareRoot(num):
return sqrt(sqrt(sqrt(sqrt(sqrt(num)))))

def firstSix(aString):
decimalStr = aString.split(".")[1]
return decimalStr[:6]

def removeZero(num):
return str(num).translate(None, "0")

def sortCharacters(aString):
return ''.join(sorted(aString))

def standupHash(num):
return SortCharacters(FirstSix(RemoveZero(FiveSquareRoot(num))))

# For hilarity (and testing)
if standupHash(42) != "123789":
print "Wrong!"

for i in range(0, 10000000):
if standupHash(i) == "234477":
print i
>>
>>52520346
>laughing at extremely good features, not giving reason why they are not amazing
as to be expected from ocamlfags
>>
>>52520346
It takes a lot of time to work out how modules work in ocaml, just like it takes a lot of time to figure out what all the buzzwords in F# correspond to. You also can't tell whether one language has the other's features easily.
>>
>>52520313
I'd watch, but that means I'd have to pause The Melvins
>>
>>52520352
>literallywho.com
They raised $500million in funding. Aiming to be an amazon competitor. Trusted F# to make the entire backend with.

facebook used ocaml for one tiny project. I presume everyone else does the same.
>>
>>52519252
gochisousama
>>
>>52519992
>XOR swap is slower than swapping with a temp variable
About the only situation where XOR-swap is worthwhile is on *very* limited architectures (e.g. PIC10/12/16) where you only have a single "accumulator" register that can take part in loads or stores.

In that situation, a conventional swap requires two instructions per assignment for six instructions total
movf a,W
movwf temp
movf b,W
movwf a
movf temp,a
movwf b

versus five for XOR:
movf a,W
xorwf b,W
xorwf b,f
xorwf b,W
movwf a

If one of the values starts and/or ends in the W register, the difference is more pronounced.
>>
Machine vision/automatic target acquisition
>>
>>52520369
>being able to make le websites and le apps and use le amazing .Netâ„¢ Frameworkâ„¢ by Microsoftâ„¢ excuses the loss of:
>structural typing (substituted by nominal typing and subtyping, which totally wreck type inference)
>functors (don't worry guy, just use .Netâ„¢ and don't implement anything to suit your application!)
>a good garbage collector
>>
>>52520422
we gotta a wise anon here!

nice
>>
>>52520400
lol butthurt
>>
>>52520439
I like how the ocaml typesystem can emulate linear types to a pretty good extent. Can F#'s?
>>
Anyone hiring?

#include <stdio.h>
static const char* FizzBuzzResources[] = {"Fizz", "Buzz", "Baz", "Bar"};
static const int FizzBuzzMultiples[] = {3, 5, 7, 10};
static const int FizzBuzzTypeNum = (sizeof(FizzBuzzMultiples) / sizeof(FizzBuzzMultiples[0]));
int FizzBuzz(const int n)
{
int printedSomething;
for(int i = 1; i <= n; ++i)
{
printedSomething = 0;
for(int j = 0; j < FizzBuzzTypeNum; ++j)
{
if(i % FizzBuzzMultiples[j] == 0)
{
fputs(FizzBuzzResources[j], stdout);
printedSomething = 1;
}
}
if(printedSomething == 0)
printf("%d", i);
putchar('\n');
}
return printedSomething;
}
int main(void)
{
FizzBuzz(30);
return 0;
}
>>
>>52520439
structural typing and functors are more useful then the entire .NET framework? Ocaml is cool, but without an actually high quality ecosystem for real world jobs, it's just a toy. Maybe useful for text processing or whatever. F# is good for games, apps and web shit. And everything else.

Also had Type Providers, which are awesome. Ocaml kinda supports that I'm told, but hardly any are written.
>>
>>52520471
F# has monads, yeah.

The funniest part is that they made up some bullshit managerspeak name for them (computation expressions).
>>
>>52520479
#include <stdio.h>

int main(){
int c=1;
char *_[]={"%d\n","fizz\n","buzz\n","fizzbuzz\n"};
while(c<=100){printf(_[!(c%3)+2*(!(c%5))],c);c++;}
return 0;
}
>>
>>52520493
computational expressions are different afaik. they use monads, but they involve more stuff. Like they support recursive functions and while loops.

I only kinda know what I'm on about here.
>>
>>52520349

The question is asked in the first couple of minutes. The rest of it is him going off about how awesome hash functions are, and how he's not going to release the answer.

>>52520364

It is by luck that this should reveal a correct answer. Without doing the math first, the problem makes no obvious indications that the number should be an integer.
>>
>>52520483
>Type Providers
REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
>>
>>52520526
oh please go on anon. I can't wait to hear what has upset you so.
>>
>>52520493
How do you emulate linear types with monads? I was thinking of phantom types:
type closed = Closed
type open = Open
type t

val free : ('a, open) t -> ('a, closed) t
val deref : ('a, open) t -> 'a
val set : ('a, open) t -> 'a -> ('a, open) t

etc.
that way, the type system prevents double-frees and use-after-frees.
>>
>>52520533
i just got PTSD from type providers and you didn't use a trigger warning.
>go to latest /dpt/ thread
>first thing i see is "type providers"
>>
>>52520510
They're the same thing as using monadic-map, which supports an arbitrary function, recursive or not, which itself can contain any expression, be it a for loop or not.
>>
>tfw you implemented a search algorithm without having to look up the psuedocode
>it works on the first try with no segfaults

feels pretty good fampai
>>
>>52520579
And then you realize that it only works on the one-two inputs you tried that have a certain pattern to them such as the exact same amount of nodes.
>>
>>52520483
I refuse to believe you're not trolling at this point.

>>52520510
Yeah, Haskell has the same with MonadFix. Don't know about OCaml, though.

>>52520540
If you think of the IO monad in Haskell, it basically embodies the idea of this kind of computation, where the World is linear:
IO a <=> World -> (World, a)
>>
>>52520609
>I refuse to believe you're not trolling at this point.
natural reaction of the ocaml luddite
>>
Anybody have an opinion on PureScript? I'm not in webdev so I don't know if it is a good idea or not.
>>
>>52519000
uh...not much of a javascript guy but judging by the code...you don't run anything until the second nested function finishes, and then the first...

where you got your info is beyond me..

If this whole problem is really just mucking up during the fetch you could literally just cull the calls to a limited 3 and work out the problem from there. If your inner functions didn't get called until the outter ones were finished you wouldn't need to make them inner functions and could just iterate over the process..

methinks you were samefaggins.
>>
>>52520400
>literallywho.com
>site down
>F#eminine Code
>>
>>52520661
you moron, the site is jet.com.
>literallywho.com
is a joke the other anon made, thinking the site was some small time start up
>>
>>52519789
wassup mah nigguh
>>
>>52520676
lel
>>
>>52520709
>proud of having a shit internet connection
I'm so sorry anon
>>
File: he hates it.jpg (145 KB, 1280x960) Image search: [Google]
he hates it.jpg
145 KB, 1280x960
I HATE REFACTORING

NO ONE DESERVES TO SUFFER LIKE THIS

I BUILT MY OWN GRAVE
>>
>>52520839
language? I find refactoring fun in staticly typed languages.
>>
>>52520839
Refactoring is great. I get a warm fuzzy feeling when I take some shitty code and make it elegant.
>>
>>52520862
GML
>>
Stupid Question, but what kind of programming languages should a programmer know? I'm not talking super duper tier, but more of decent.

Like what's good for scripting, systems, etc.?

Only languages I know is Java from 3 years in high school computer science.

Learning Python and trying to get into C if I can muster the will to.

Any suggestions, anons?
>>
>>52520313
>tfw you can trivially solve this with a program but have no idea how to do it with a pencil and paper
>>
>>52518289
Please stop this programming trap meme.
Thanks.
>>
so why do we hate IDEs again?
>>
File: lexer.png (64 KB, 661x760) Image search: [Google]
lexer.png
64 KB, 661x760
>>52518289
prototyping a lexer for the interpreted math lang I decided to write 15 minutes ago

is it supposed to be this easy?

eg. output (deliberately formatted in a dumb way)
>def discrim(a,b,c) = b ^ 2- 4* a  *c
def
discrim
(
a
,
b
,
c
)
=
b
^
2
-
4
*
a
*
c
>>
>>52520915
It's better to learn algorithms and concepts than syntax.
>>
>>52521141
Too slow, bloated, shitty. A minimal text editor with optional syntax highlighting and some simple lexical autocomplete is all you need.
>>
>>52521141
Too much shit
>>
>>52520313
It's 4. It's pretty easy to work out on paper.
>>
>>52521188
Sounds reasonable. Well then, you know if there is a site that can talk about algorithms and concepts in good detail?

I already know http://www.sorting-algorithms.com/ for high school compsci.

Thanks for the reply, anon.
>>
Is codeeval screwing up for anyone else?
My solution claims its scored perfectly yet it's not on the ranking.
>>
>>52518289

Making my first qt application, I can't figure out how to show / hide widgets depending on what filter method is chosen in the top right drop down menu.

http://i.imgur.com/OAHcLz6.png
http://i.imgur.com/qUo0Tyg.png
>>
>>52518289

Writing a CSGO cheat and native memory interfacing in Kotlin: https://github.com/Jire/Abendigo
>>
Anyone know how to make an associative array of function pointers in D?

void function(string[])[string] COMMANDS;

void foo(string[] input)
{
...
}


then in main

COMMANDS["foo"] = foo;


doesn't seem to work, but that's basically what I want - and to be able to call it with COMMANDS["foo"](input)
I could do an enum for command IDs and then have it be just a boring old static array, but that isn't really as interesting
>>
>>52521750
>doesn't seem to work
I'm a retard and forgot this
COMMANDS["foo"] = foo;


provokes this error from the compiler

Error: function namespace.foo (string[] input) is not callable using argument types ()
>>
Beginner C programmer here. I've been trying to figure out what library or functions allows a sort of interactive terminal. Essencially I mean the kind of menu in cfdisk, where the changes in the terminal(?) doesnt simply scroll downwards and print a new line, and instead rewrites whats in the window. Could anyone point me in the right direction? Dont even know what to google and sifting through cfdisk source code hasnt helped.
>>
>>52520126
xchg is much more slower
>>
>>52521832
ncurses
>>
>>52521832

Termbox
>>
>>52521841
>>52521849
Thank you both! I think Termbox might be what I was thinking of, but it looks like either would work.
>>
>>52519169
2 and 2 for C
1 and 2 for C++/C#
1 and 1 for almost all other languages since their idiomatic style is usually like that
>>
>>52518482
This is the most retarded thing I think I have ever seen.
Should have known it was a trap too but whatever.
>>
File: Untitled.png (373 KB, 639x356) Image search: [Google]
Untitled.png
373 KB, 639x356
>>52518482
:^)
>>
>>52521200
Syntax highlighting should never be optional
>>
>>52520501
>"I'm sorry, but your code isn't easily legible so we must turn you down"
>>
>>52521908
Didn't you see the symbols in the background of the webm? Did you think they were mere decorations?
>>
File: solution.png (36 KB, 1600x900) Image search: [Google]
solution.png
36 KB, 1600x900
>>52520939

It's pretty trivial to work out on paper (or in paint). You just have to remember that the hypotenuse in a 45-45-90 triangle is equal to sqrt(2) times the length of either of the legs. That was... Freshman geometry class?
>>
>>52521961
What symbols?
>>
>>52521928
>every non-student council girl is a boy
>every non-tadokoro boy is a girl

this show is sleazy as fuck
but it's the good kind of sleazy
>>
Should I do the whole CS thing on edx.org? Or just stick with learning on language and moving into the next one.
>>
>>52521988
CS is not programming
>>
>>52521992
So is it basicly just the logic behind programming?
>>
File: 1452212716631.jpg (102 KB, 578x504) Image search: [Google]
1452212716631.jpg
102 KB, 578x504
>>52521986
I just, It's funny I guess but what the fuck is this?
I hate traps, why is this even funny?
Why was this made? Who asked for this?
Send Help
>>
>>52521976
Male symbols. The circle with an arrow sticking out of it. The symbol that appears when you press ALT 11. I wrote it in that post, but 4chan seems to have filtered it.
>>
>>52522000
it's the mathematical base behind computation
it's useful for devising complex ways to take advantage of the limitations of the computers
>>
>>52522001
plenty of shows feature traps these days and if your comedy anime doesn't have at least 1 crossdresser gag in it, it's shit

clearly, people enjoy watching anime about blatant sexual harassment
>>
>>52522021
So its trying to get non problem solving people to try to problem solve. I understand why you guys hate this people then
>>
File: 1451800065586.gif (112 KB, 255x231) Image search: [Google]
1451800065586.gif
112 KB, 255x231
>>52522034
I just can't deal, I'm not used to the type of thing I'm seeing.
>>
>>52521837

Fortunately, compilers are smart and when set to the highest optimization level, both C and Rust compilers seem to generate nearly identical results -- two loads, two stores.

> objdump -d -M intel cswap.o

cswap.o: file format pe-x86-64


Disassembly of section .text:

0000000000000000 <swap_ints>:
0: 8b 01 mov eax,DWORD PTR [rcx]
2: 44 8b 02 mov r8d,DWORD PTR [rdx]
5: 44 89 01 mov DWORD PTR [rcx],r8d
8: 89 02 mov DWORD PTR [rdx],eax
a: c3 ret
b: 90 nop
c: 90 nop
d: 90 nop
e: 90 nop
f: 90 nop

Rubyist@TARDIS C:\Users\Rubyist\Desktop
> objdump -d -M intel rswap.o

rswap.o: file format pe-x86-64


Disassembly of section .text:

0000000000000000 <swap_ints>:
0: 44 8b 01 mov r8d,DWORD PTR [rcx]
3: 8b 02 mov eax,DWORD PTR [rdx]
5: 89 01 mov DWORD PTR [rcx],eax
7: 44 89 02 mov DWORD PTR [rdx],r8d
a: c3 ret
>>
>>52521986
I wanted to watch it because I thought that it was based on 1 guy being forced to do what he does by the female school council. I didn't know that there were so many traps in it.
>>
>>52522054
it's not really surprising
the only characters that matter anyway are hime and the student council, which aren't traps.
>>
File: 1402619416322.gif (207 KB, 293x199) Image search: [Google]
1402619416322.gif
207 KB, 293x199
>>52522063
I just...
I don't want to understand.
I know too much, we've all lived too long.
>>
>>52522042
just let it happen
and once you're done in about 40 minutes, go read the manga, it's way longer and isn't limited to 4 minutes
>>
File: 1427348085130.gif (2 MB, 300x228) Image search: [Google]
1427348085130.gif
2 MB, 300x228
>>52522082
I don't think I want to.
I just cant.
>>
>>52522049
Are those nops there to align the functions to 8 bytes boundaries or something?
>>
>>52522063
Is it going to make me upset? I get easily upset on humiliation and unfairness towards weak male characters on anime.

>Each episode is about five minutes long
w-why
>>
>>52521970
fucking lmao just realized I was calculating the area before and that's why I got it wrong
>>
>>52521864
>>52521841

turns out it was ncurses, source code confirms.
>>
>>52521970
No, I know that. I had the formula right -- it's why my program worked. I fucked up because I got some clusterfuck like (sqrt(2) - 1)^2 and didn't feel like looking up exponent rules to simplify it afterward.
>>
>>52522198
3 - 2sqrt2
>>
>OpenCL 2.1 now uses C++
Good thing we can make our own front-ends for languages with SPIR-V.
>>
>>52518806
>tab width is 3
Is this an oxymoron? Tab width by definition is variable.
>>
>>52522230
[physicallysick.jpeg]
>>
>>52522038
No, I don't think that's inferred. I think it's more like the tools used in problem solving through mathematics.

I think you might be one of the people you hate.
>>
>>52521165
input lexing and dispatching of commands is done
eval can convert to basic reverse polish
(the only thing it can't do is differentiate functions from constants)
$ ./maths
>eval 1*(2+3)
This will evaluate an expression
1
2
3
+
*
>end


I'm enjoying this already
>>
>>52521165
wow, this is a really shitty language you are making this in
>>
>>52522105

Yep. Why else would you put a bunch of nops after a return statement?

>>52519282

Standard in Ada programming. Clearly, this was an Ada programmer who just decided to start programming C.
>>
>>52522338
You don't even know what language it is do you?
>>
>>52522349
Looks like D but could as well be Java or some other cancerous thing like Rust.
>>
I am Decamora.
>>
>>52522359
What's wrong with Rust?
>>
>>52522359
yeah it's D

what's shit about it?
>>
>>52519169
void method( ) {
// aaaa
int * x;
}
>>
>>52518881
>I have to use VB for my job

Suicide?
>>
My girlfriend said she will only swallow my cum if I do it first
>>
>>52522515
just swallow it
it tastes like snot
i'm sure you know what your own snot tastes like at this point
>>
>>52522515
Your own cum? This is fucking gross, slap her out of it and remind her that she is a woman and that she should know her place.
>>
>>52519992
Try bigger set sizes.
Lots of big O efficient algorithms perform like shit compared to "worse" ones because they are so cache unfriendly.
>>
WHY DO PEOPLE ALWAYS OVERLOOK THE FACT THAT YOUR KERNEL SCHEDULES PROCESSES ON MULTIPLE CORES? BUT NO IT"S ALL ABOUT MULTI THREADING, THAT"S THE ONLY THING THEY KNOW AND THEN THEY BUY A SINGLE CORE CPU LOL.
FUCKING NIGGERS.
>>
>>52522637
You can't even buy single core CPUs anymore
>>
>>52522654
DUAL CORE THEN.
IT"S STILL FUCKING STUPID INSTEAD OF BUYING ATLEAST QUAD CORE.
>>
>>52522656
Take your meds kid.
>>
>>52522663
I"M JUST MAD THAT PEOPLE IN THIS VERY FUCKING THREAD STILL DON"T KNOW HOW COMPUTERS EVEN FUCKING WORK DESPITE BEING "INTERESTED" IN PROGRAMMING.
WHAT IS THIS? TEMPLEOS YOU STUPID FUCKS? SCHEDULERS CAN SCHEDULE ON MULTIPLE CORES NOWADAYS FUCKTARDS.
>>
In C# is there a way to convert an int to a string without generating garbage? Or at least less than what ToString generates.

It's important because it's going to be called thousands of times.
>>
>>52522683
Who in this thread?
>>
>>52522683
>implying that programming has anything to do with computers
Please, stop
>>
>>52522304
$ ./maths
>eval 1*(2+3)^2
= 25
>end


eval can now evaluate basic RPN
I figured out how I'm going to write functions (roughly), which will mean that defining a constant like
>def pi = 3.141592


will be stored like a function called pi with 0 arguments that returns 3.141592
functions will be recursively resolved and then passed to the evaluation function

oh and conditionals are coming up nicely
$ ./maths
>eval 1=2
= 0
>eval 1=1
= 1
>end

I'm going to predefine a function for if(a,b,c) which will basically be expanded as if a is nonzero then b else c

would it be acceptable to call this a specialised interpreted language for the purposes of making it sound more impressive in a portfolio?
>>
>>52522683
hi terry
>>
>>52522702
THIS FUCKING THREAD >>52520070
>>
>>52522683
>>52522656
>>52522637
is this legit terry?
>>
>>
>>52522717
TERRY DOESN"T BELIEVE IN MULTI CORE SCHEDULING HE SCHEDULES EVERYTHING ON CPU0, THE PROGRAM HAS TO EXPLICITLY CONTROL THE EXTRA CORES ON THE SYSTEM FUCKING LOL WHAT A NIGGER.
TEMPLEOS IS STILL PRETTY COOL THOUGH.
>>
>>52522687
StringBuilder?
>>
>>52522541
No she wants me to swallow her cum
>>
>>52522813
Just do it.
>>
>>52518289
>webm
is all anime this autistic?
>>
>>52522530
ahahaha faggot
>>
>>52522705
Woah, way to grab hold of a Phyrric Victory there, eh champ?
>>
>>52522861
They're memesubs.
>>
>>52522871
Pyrrhic*
>>
>>52522813
Traps should learn to be submissive, slap her until she learns her lesson.
>>
>>52522871
>>52522901
What the fuck does this have to do with anything?
>>
>>52522900
i realize that, but even with the original audio and subs it should be pretty bizarre with all the gesticulating, childish dialog and such
Thread replies: 255
Thread images: 25

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.