[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: 32
File: 1452244976030.jpg (56 KB, 640x696) Image search: [Google]
1452244976030.jpg
56 KB, 640x696
go is ridiculously disgusting edition fuck you

Previous thread: >>54964614

What are you working on, /g/?
>>
A Firefox extension to track Jews
>>
java looks disgusting for math as well
>>
First for Scala a shit
>>
>>54972289
at least the syntax doesn't look like it was designed by a mongoloid

>>54972296
this
>>
File: Capture.png (38 KB, 677x727) Image search: [Google]
Capture.png
38 KB, 677x727
this is what im doin

what are u doin?
>>
>>54972302
you what
java syntax is a lot worse
>>
File: image.jpg (33 KB, 533x477) Image search: [Google]
image.jpg
33 KB, 533x477
>it's a bikeshedding episode
>>
>>54972313
kys
>>
>>54972302
Java syntax is disgusting.
>>
>>54972264
Give me a project slightly harder than fizzbuzz?
>>
>>54972264
>go is ridiculously disgusting edition fuck you
indeed, uninstalling as we speak, that was the most disgusting shit I've seen in my life recently
>>
>>54972346
Photoshop clone
>>
>>54972308
anyways its scraping the harry potter wikia in its entirety (finished), converting to an appropriate tabulated format, converting to .opf (xml-style format), then converting to .mobi (dictionary-style format for kindles)
should take another 3 or 4 days but in the end you should have a dictionary for when you're reading on-the go (so you could click any word that says worms and get the definition in the harry potter universe)
it'll be great

can be ported easily enough to other wikis too
cool, right?
>>
how is this:

>
var facts [10001]*big.Int
facts[0] = big.NewInt(1)
big_i := new(big.Int)


not infinitely worse than:

>
BigInteger[] facts = new BigInteger[10001];
facts[0] = new BigInteger(1);
BigInteger bigI;


KILL YOURSELVES
>>
File: operating_systems.png (43 KB, 740x189) Image search: [Google]
operating_systems.png
43 KB, 740x189
>>54972358
fug
Slightly less difficult?
>>
>>54972264
16th for Go is faster than C+libgmp
package main

import (
"fmt"
"math/big"
)

func main() {
var facts [10001]*big.Int
facts[0] = big.NewInt(1)
tmp := new(big.Int)
for i := int64(1); i <= 10000; i++ {
facts[i] = big.NewInt(i)
facts[i] = tmp.Mul(facts[i], facts[i-1])
}
fmt.Printf("%s", facts[10000].Text(10))
}


#include <stdio.h>
#include <gmp.h>

mpz_t facts[10001];
int main()
{
int i;
mpz_init_set_ui(facts[0], 1);
for (i = 1; i <= 10000; i++) {
mpz_init_set_ui(facts[i], 1);
mpz_mul_ui(facts[i], facts[i-1], i);
}

gmp_printf("%Zd\n", facts[10000]);
return 0;
}
>>
>>54972363
because in java, there is no type inference system pajeet
>>
>>54972384
fucks given:
>>
>>54972385
>i'm too lazy and stupid to specify and care about types
kill yourself
>>
>>54972384
>fmt.Printf("%s", facts[10000].Text(10))
once again, this is dumb...
fmt.Println(facts[10000].Text(10))
>>
>>54972264
New to programming here. Why would something like n % 3 = 0 mean something is divisible by three when 6 % 3 = 2, etc.
>>
>>54972401
oh now
what type could this be eh?
var facts [10001]*big.Int

big int since that is the value you are assigning it!

compare that to
BigInteger[] facts = new BigInteger[10001];

hmm... why do I need to write the type both times?
>>
>>54972425
the java syntax is by far more consistent and readable you complete moron
>>
>>54972422
see >>54972284

https://en.wikipedia.org/wiki/Modulus
>>
>>54972428
y u mad pajeet
too lazy to learn a new language?
>>
>>54972428
How is it more readable? I don't need to read (and write) the type twice
>>
>>54972422
if something is divisible by 3, it would produce a remainder of zero.

Did you skip all of 2nd grade math or something?
That's all % is. It gives the remainder.
>>
>>54972440
kill yourself lazy troll

>>54972441
kill yourself pathetic cunt
>>
>>54972422
6 % 3 is not equal to 2, its equal to 0?
>>
>>54972443
Oh! I see / would just be the division. Thanks anon.
>>
variable declaration:

Foo foo;


variable declaration with object creation and assignment:

Foo foo = new Foo();


consistent. readable.
>>
>>54972479
oh pajeet

in good languages you can't declare Null variables

so you are left with this
Foo foo = new Foo();


Writing the type twice for no reason whatsoever
>>
>>54972502
>in good languages you can't declare Null variables
holy fuck kill yourself smug prick

also what about this

Foo foo = new Bar();


FUCKING RETARD
>>
>>54972384
could you compare it with the Builtin factorial in gmp? mpz_fac_ui
>>
https://round.io/chat
>>
>>54972515
it would probably be O(n^2) instead of O(n) since they're generating each one
>>
>>54972479
foo_t *foo = (foo_t *) malloc(sizeof(foo_t));
>>
>>54972551
don't forget

foo_init(foo);
>>
>>54972513
pajeet please, there is no inheritance in good languages well
>>
>>54972576
>go doesn't have inheritence
AHAHAHAHAHA that's just pathetic, what a pathetic joke of a shitlang
>>
>>54972479
Go (golang)

variable declaration:

// this actually initializes foo to the "zero" (default) value:
// https://tour.golang.org/basics/8
// https://tour.golang.org/basics/12
var foo Foo


variable declaration with assignment
// Foo here is a function that returns an object of type Foo
var foo Foo = Foo()
or
// type inference: https://tour.golang.org/basics/14
foo := Foo()
>>
can I just write a c++ cli and then use a gui framework so should I make my program from the ground up in the framework. In this case considering qt
>>
>>54972551
>Casting malloc
What a fag.
>>
>>54972596
hello pajeet,
inheritance, like java with it no type inference, is outdated

interfaces are the proper way to do object oriented code, alan kay didn't think of java with his OO definition
>>
>>54972599
disgusting as shit, with the new operator it's more readable because you know that you're constructing a new object, and 'Foo' at the start of the line conveys a shit ton more information than 'var'
>>
>>54972195
To the linux anon from prev thread.

Is that a time command?
What params should i use to obtain similar data being printed? (not just real, user and sys time)
>>
>>54972644
time prog
>>
>>54972636
lol good luck with that smug hipster fag just look at which lang is #1 and which lang is irrelevant and stillborn
>>
>>54972378
red black BST
>>
>>54972596
>implying
golang has OOP-like features, without being OOP. google golang inheritance"" :)
https://github.com/luciotato/golang-notes/blob/master/OOP.md
>>
>>54972744
>OOP-like features
>without being OOP
>https://github.com/luciotato/golang-notes/blob/master/OOP.md
>OOP
the smug in this post
>>
how cool is this https://github.com/noctuid/tdrop/blob/master/tdrop
>>
>>54972907
>anime in the screenshots
into the trash it goes
>>
first f# post
>>
>>54972384
well shit, after doing it in quick successions (5 calls each)
gmp was 20ms for me
go was 10ms

I wonder if someone could try it with R or julia or whatever math shit there is
>>
>>54972515
>mpz_fac_ui
sorry, I hadn't seen this post.
mpz_fac_ui is much faster (at least 5x) than both versions, C+mpz_mul_ui and the Go code I posted.

mpz_fac_ui would be equivalent to facts.MulRange(1, 10000) in Go, which takes ~ 2x the time mpz_fac_ui takes (including printing):
package main

import (
"fmt"
"math/big"
)

func main() {
facts := big.NewInt(1)
fmt.Println(facts.MulRange(1, 10000).Text(10))
}
>>
>>54973090
>MulRange
but I bet ^ could be optimized/simplified easily:
https://tip.golang.org/src/math/big/int.go#L164
>>
Can't wait to end this semester
I have a personal project of programming a simple neural network and also learn functional programming. Any recs for the second one? Which language should I use?
>>
>>54973090
>mpz_fac_ui would be equivalent to facts.MulRange(1, 10000) in Go, which takes ~ 2x the time mpz_fac_ui takes (including printing):
nevermind, for some reason, MulRange is much slower... like ~1/20x of mpz_fac_ui
>>
>>54973195
>~1/20x
err, 20x
>>
why the fuck is
temp = new
new = temp+new
different from
temp,new = new,temp+new
???? is python just retarded? is there a name for why it does this?
>>
question : does anyone have that list of 200 od programming challenges ?
>>
File: Racket.png (7 KB, 88x85) Image search: [Google]
Racket.png
7 KB, 88x85
I got Ivy to zoom in/out on an image with the scrollbars adjusted for the mouse position. Took me a while to figure out how to pull that off based on how init-auto-scrollbars works, but I am pleased it's working now.
>>
>>54973277
CocaCola<pepsi
>>
File: le.png (14 KB, 752x106) Image search: [Google]
le.png
14 KB, 752x106
>le webapps are le future amirite guise xDxDxD
>>
File: 1430897184549.gif (1 MB, 200x200) Image search: [Google]
1430897184549.gif
1 MB, 200x200
>tfw someone from your class asks a question on stack overflow about the assignment your stuck on.

Nigga was pretty hardcore too, even included his name, picture and what university he goes to on his profile.
>>
>>54973530
link that shit nigga
>>
>>54973536
Why nigga?
>>
>>54973591
stuck on the problem as well
>>
>>54972551

>casting a void* before an assignment
>thinking there is anything wrong with the rest of the line
>>
>>54973595
how do you know what the problem is
>>
>>54973607
because I go to the same university
>>
>>54973614
Are you by any chance who >>54973530 was talking about?
>>
>>54973621
No, but I am
>>
>>54973649
What a small world lads, we all go to the same university!
>>
>>54973708
are you sure you aren't me?
>>
>>54973731
Well I posted this within 30 seconds so 4chan says you arent me.
>>
>>54972428
I don't know about Go in particular, but type inference is a done deal. Seriously, it's a "solved" problem. HM type inference (and derived systems) is very simple, reliable and robust.

Then again Java folk managed to fuck it up, predictably, by only half-ass-ing it.
>>
>>54972360
I don't even read hp but that sounds cool
>>
>>54973804
KILL YOURSELF

TypeName foo = bar();


is obviously more readable than

var foo = bar();
>>
>>54973947
also

// if bar returns something other than a TypeName it's a type error
TypeName foo = bar();


// no error here no matter which type bar returns, might get hard-to-detect errors later on in the code
var foo = bar();
>>
>>54972363
>>54972363
>>54972363
>>
>>54973947
pajeet
>>
>>54974071
pathetic gjewgle python-tier normie shitcunt
>>
>>54974086
>gjewgle
What?

captcha is 2016
>>
>>54974086
java is for normies and pajeets
>>
>>54974123
Why are normies so retarded?
Why do they like Java?
>>
>>54974123
>>54974134
"java is bad" is literally a normie meme you're fucking pathetic normies
>>
>>54974134
that's what they were taught in university/high school
they don't know anything else

these are the same people who go to youtube for tutorials, can't even read online documentation
>>
see:
>>54972363
>>54973947
>>54974007
anyone who isn't a stupid normie can clearly tell that type inference and go syntax is disgusting, fucking idiots

>>54974153
you're the ones that got taught it and you were too stupid to understand it so you're butthurt as shit over java and fox and the graping this hard
>>
see also: >>54972479
>>
>>54974167
pajeet my son
>>
>>54974184
that's some weak ass trolling get a life stupid shitkid
>>
>>54974167
you poor poor man
>>
>>54974195
pajeet go back to your kind at xda forums
>>
File: hmm, yes.jpg (34 KB, 396x303) Image search: [Google]
hmm, yes.jpg
34 KB, 396x303
>>54974209
>>54974215
you sure convinced me with those hot opinions
>>
>>54974227
pajeet, telling someone to get out isn't an opinion
surely your call center boss trained you better
>>
>>54974236
haha very funny now fuck off to /b/ kid
>>
>>54974227
Nice image macro, you gonna upload that to your facebook?
>>
File: swastika_bw.jpg (21 KB, 200x201) Image search: [Google]
swastika_bw.jpg
21 KB, 200x201
Is functional programming the White Man's paradigm?
>>
>>54974238
see >>54974246
>>
>>54974246
fuck off to reddit normie newfag
>>
>>54974251
pajeets certainly will have a hard time
>>
>>54974251
it's for literal trannies

real men use C++ and java
>>
>>54974263
you're fucking delusional fucking idiot there's nothing hard or good about FP shitlangs
>>
>>54974266
The tranny image from that anime that gets posted here is a C, C++ programmer
>>
>>54974253
You've got to be less obvious about being so new, you can't just spam random phrases you've heard other people use like the dirty talk sluts do in pornos
>>
File: 1452635429762.jpg (67 KB, 416x508) Image search: [Google]
1452635429762.jpg
67 KB, 416x508
>>54974266
>C++ and Java
You can be serious.
>>
>>54974280
no he's not, it's C not C++, and it's not the official subs it's "parody" subs

>>54974286
kill yourself

>>54974291
kill yourself
>>
Don't worry, I'll save everyone the time of replying to >>54974295

>kill yourself
>kys
>newfag
>reddit
>normie
>/b/
>tranny
>cuck
>sperg
>shitter
>delusional
>>
shitlangs such as python, go, haskell are for sub-105 IQ literal FAGGOTS
>>
>>54974279
like to see you do functionality and clarity like discriminated unions in Java
type BankAccountState =
| ZeroBalanceState
| ActiveState
| OverdrawnState
| ClosedState
>>
>>54974315
in haskell this is just
(.) foldleft (:) forall *. $ (. id) = 3
>>
>>54974315
kill yourself fag
>>
>>54974320
>just
>a bunch of keywords that look incomprehensible to non-Haskell programmers
>>
>>54974320
kill yourself fag
>>
>>54974315
enum BankAccountState {
ZeroBalanceState,
ActiveState,
OverdrawnState,
ClosedState
}


retard
>>
>>54974343
LMAO

enum is just syntax sugar for int, I can input any int I want and it will compile fine.

which isn't the case for discriminated unions
>>
>>54974361
not in java you FUCKING CLUELESS SMUG ASS RETARD
>>
>>54974343
type BankAccountState = Closed | Open of float<dollars>
>>
>>54974375
>float<dollars>
FPfags confirmed for stupid normies
>>
>>54974375
right it even has Units of measure and you can define your own
>>
>>54974383
Units of measure are pretty nice. F# can automatically infer stuff like measure types - if you had

let fuelRate = 5.0<seconds/dollars>
and multiplied it by a float<dollars> you'd get a float<seconds>
>>
>>54974408
that's pathetic
>>
>>54974419
conversions within types (e.g. mi vs km) ended a NASA mission
>>
>>54974428
kill yourself retard
>>
>>54974435
>>54974312
>>
you think NASA or memelon musk is gonna use F# lmfao off yourselves
>>
File: 12yo simulator.png (15 KB, 801x270) Image search: [Google]
12yo simulator.png
15 KB, 801x270
>>54974445
Literally the first fucking one too.

>>54974435
You will never not be a newfag.

>>54974451
What's that faggot got to do with anything?
You still haven't given a concise example of >>54974375
>>
>>54974462
kill yourself idiot
>>
>>54974462
>You still haven't given a concise example of >>54974375
it's idiotic and disgusting, no one with a functioning brain would want to replicate it
>>
File: 13yo simulator.png (19 KB, 926x280) Image search: [Google]
13yo simulator.png
19 KB, 926x280
>>54974479 >>54974500
Still no answer.
>>
>>54974507
>hurr if you don't do this arbitrary task it means i'm not retarded and that my meme lang isn't shit
delusional idiot
>>
File: 7phuJaq6.jpg (42 KB, 512x512) Image search: [Google]
7phuJaq6.jpg
42 KB, 512x512
>>54974507
>D
good lad
>>
>>54974520
>arbitrary task
It's simple, define a type for a bank account that either be closed or open with any amount of money (denoted by a float)

type BankAccountState = Closed | Open of float
is pretty self explanatory
>>
>>54974534
good goy

>>54974542
the code is disgusting dumbass
>>
>>54974572
You still haven't completed it, I notice. I wonder when you will
>>
File: 1364300555351.jpg (51 KB, 439x452) Image search: [Google]
1364300555351.jpg
51 KB, 439x452
What is the best rating system, something in a format of Elo?
No time decay.
>>
>>54974589
i'll just let you hold on to your beliefs
>>
>>54974595
Hahaha is it even possible in Java? Can you even do union types?
>>
>>54974602
stay delusional you sad moron
>>
>>54974612
It's not, is it?
Fucking lol
>>
>>54974624
keep replying :^)
>>
File: github.png (288 KB, 1639x1080) Image search: [Google]
github.png
288 KB, 1639x1080
>>54974627
Yeah, you were only pretending to be retarded to get (You)s

Don't worry, we all believe you. Maybe when you've hit puberty we'll get together to buy you a fedora and a tripcode.
>>
>>54974650
>muh union types
you're the one who needs a fedora and a tripcode
>>
File: 1958201258.png (123 KB, 1112x600) Image search: [Google]
1958201258.png
123 KB, 1112x600
>>54974669
C++ has union types
Is C++ retarded?
>>
>>54974702
java doesn't need them and shouldn't have them because java is a distilled and purified language with minimal feature creep
>>
>>54974650
not again installgen2
>>
>>54974760
>union types
>feature creepy
Holy fucking shit, is this what they teach you in Uni's these days?
>>
>>54974760
A union is as primitive as a struct you idiot
>>
>>54974790
they're literally unnecessary, pajeet
>>
>>54974858
java doesn't have structs either and it was a conscious decision not to have them. the way you make an airplane better is not to tack on a bunch of shit, it's to remove weight here and there. the main difference of python 3 vs python 2 is that they removed a bunch of features.
>>
>>54972280
Are you done yet?
>>
>>54974882
What a coincidence, Python is also shit
>>
>>54974892
if you think you have a need for unions and structs just use C++ and get on with your life
>>
>>54974903
Or literally every language other than Java
>>
>>54974908
nice facebook meme nathan
>>
>>54974908
>he is THIS butthurt that he had a hard time in programming101 with java
lmfao @ your life
>>
>>54974916
Did you ever know what you were saying?
You realise that all the other users of this site don't just pick words and phrases randomly, right?
They actually form sentences, sentences that make sense.
>>
Is C's rand() considered harmful and non-uniform inducing like C++'s rand() was before the standard included a range of better random algorithms?
>>
>>54974927
lol k tard keep believing you're intelligent for autistically adhering to formal grammar rules on a belgian shoemaker chatroom
>>
>>54974940
yes just copy and paste one of these and you have a gorillion times better rand()

http://xoroshiro.di.unimi.it/
>>
>>54974966
Just copy this and the website will be the only person who can hack your system
>>
>>54974955
what?
>>
>>54974969
if you need something cryptologically secure you shouldn't use any of the stdlib randoms anyway
>>
>>54974955
Speaking of formal grammer, did you hear anything about BNF notation in "programming101"?

Apparently it's not plausible to express with Java types because they don't have sum types
>>
File: 1462733485004.png (7 KB, 461x91) Image search: [Google]
1462733485004.png
7 KB, 461x91
Nice GC and memory usage, retards.
This is just me repeatedly opening and closing a windows form in C#.
>70mb
How do you find this acceptable for a simple forms application? And the GC is completely useless too, didn't free fucking anything, even though all the forms resources go out of scope when it's closed, it still hangs around even after a GC pass.
>>
>>54975011
Maybe it's too smart and decided not to free stuff you'd be opening a second later
>>
>>54975011
doesn't seem too weird, open up firefox or someshit it's like 500 MB or something for a single blank page
>>
>>54975027
Except even after I leave it sitting for a few minutes, it doesn't make any more GC passes until I start opening forms again, and no memory ever gets freed.
>>
>>54975051
Well, that's what you get for using literally any language other than C or C++
>>
>>54975037
Yeah, but Firefox does a shit ton in the background.
I'm not doing much at all in the background.
>>
>>54975065
I know, it's not like I had a choice, we have to use C# and Java (kill me) in the course I'm taking.
I use C and C++ at home.
>>
>>54975051
it's supposed to avoid doing GC passes until it's absolutely necessary
>>
>>54975077
At least neither Java nor C# have unions in, which as we've been taught earlier by the Java cleric, are literally the devil, are retarded and are completely unnecessary in a language
>>
>>54975078
Yeah and when it does, it frees nothing.
See pic in >>54975011, those yellow marks are GC passes.
>>
>>54975120
a GC pass clears the heap but you still have the memory allocated for the heap
>>
>>54975140
No I don't, all resources used by the form are inside that instance, when I close it they shouldn't be allocated anymore, and the GC should be collecting them.
I don't keep references to the form instance after the function the button calls returns.
>>
>>54975187
yes you do, the program works the same as when you have a custom allocator in C/C++, you have a chunk of memory allocated and just because you free some objects doesn't mean you deallocate the chunk of memory
>>
>>54975286
You're talking about something completely different.
Get out and stop changing the subject.
>>
Can anyone here answer >>>/sci/8130752 ?
>>
>>54975011
Just use the unsafe keyword and manage your own memory.

Use a memory profiler. I guarantee you're sitting on uncollected event handlers.

Also, just because you close a form, doesn't mean it is disposed. The object can still be in scope.
>>
>>54975382
It's declarative programming, sounds like a rule based system
>>
>>54972346
Solves sudokus. Simple case of value evaluation. Basically fizzbuzz.
>>
>>54975388
How to properly cleanup the form?
>>
>>54975435
I have no idea what your code base looks like.

I cannot help you with your issue without the entire repository.

Even still, this anon:
>>54975286
>>54975140
is right.

C# (and Windows in general) will allow the application to maintain allocation of memory, even if that memory isn't being used.

As for scoping issues, a basic example:
var form = new CustomWinForm();
form.Show();
form.Close();
GC.Collect();
GC.WaitForPendingFinalizers();


The GC does nothing here, because the object is still in scope, even though it is 'closed'.

This goes for any other event handlers or objects you may have given global scope within a class.
>>
>>54975507
My form goes out of scope when the event handler returns though.
>>
>>54975561
It's nice that you think that, but without your code I cannot show you where you are making a mistake.

There are plenty of questions on SO dealing with your exact issue: making a basic form, opening and closing it, and seeing the memory just keep going up.

It's almost always an issue with instantiating a new form object and never actually leaving the scope, or having the event handlers still within scope.
>>
>>54974361
Sure thing faggot.
https://ideone.com/LURsFo
>>
>>54975589
        private void btn_stats_Click(object sender, EventArgs e)
{
new StatisticsForm().Show();
}

I'm not sure what you mean by global event handlers, is that some C# thing? as far as I know when any object local to that one function go out of scope they are to be garbage collected.
>>
>>54975627
>enum class
not Java
also can't do this:
>>54974375
>>
>>54975011
could be that GC is waiting until you near its limit to begin freeing
>>
File: 1388883645667.png (581 KB, 640x480) Image search: [Google]
1388883645667.png
581 KB, 640x480
>>54975011
>doesn't know how the GC actually works
>talks shit

You should go back to ricing your distro faggot.
>>
>>54975677
Did you even look at the pic? the GC fired 3 times with no effect.
>>
Not sure if this should belong in SQT or DPT...
Anyone here knows how to write and implement a network protocol? (like ICMP or HTTP).
>>
>>54975688
Enlighten me faggot.
Oh that's right, you don't know anything.
>>
>>54975699
Show me ALL your code related to that form.
>>
>>54975673
>also can't do this:
>what are enum bases

Also
>currency
>floats
I really hope it's not doing what I think it does.
>>
>>54975693
are you not listening to me? GC firing has nothing to do if it decides to free or not. A GC does not imply itll clean up evwrything immediately, most GC algorithms are free to delay until needes as to not hammer you with freeing constantly.
>>
>>54975704
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace assignment
{
public partial class StatisticsForm : Form
{
public StatisticsForm()
{
InitializeComponent();
}

private void StatisticsForm_Load(object sender, EventArgs e)
{

}

private void msi_file_exit_Click(object sender, EventArgs e)
{
Application.Exit();
}

private void msi_about_company_Click(object sender, EventArgs e)
{
new AboutCompany().Show();
}

private void msi_about_app_Click(object sender, EventArgs e)
{
new AboutApplication().Show();
}

private void btn_back_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
>>
>>54975710
Units of measure are unique to F# but the basis of the idea is just to create a type

type BankAccountState = Closed | Open of float
Where BankAccountState is either Closed, or is Open with any float, i.e. Open 0.0 or Open 0.4, etc for all the 2^32 possibilities
>>
>>54975669
You're going to have to share you entire project if I can even begin to troubleshoot this.
>>
>>54975695
yes?
>>
File: 1379964206876.jpg (81 KB, 900x702) Image search: [Google]
1379964206876.jpg
81 KB, 900x702
>>54975728
Close() doesn't do what you think it does.

>lc_lc_lc_Uc method name, I don't even want to explain why it doesn't collect the object that is STILL in memory.
>>
>>54975752
Where do you even start learning it? I've read the SMTP protocol here http://www.faqs.org/rfcs/rfc821.html but am too dump to understand how to start.
>>
>>54975695
yeah
>>
>>54974650
lmaoing my ass off
>>
>>54975762
well first of all you should probably read up on TCP and build on top of it like HTTP does rather than making a protocol that works directly to IP. Then its just a matter of defining a spec as far as requests that will be expected and their answers dependent upon the application.
>>
>>54974650
>women
>implying you're not a biologically male flaming faggot
>implying women are the only ones who would be affected and are too weak to have "spoken up"
>>
File: snaggg.png (50 KB, 1152x1167) Image search: [Google]
snaggg.png
50 KB, 1152x1167
>>
>>54975901
>literally only use of snek language is to shitpost
>>
I'm working on the very last steps of a multithreaded C server and signal handling is kicking my ass.
>>
I'm trying to randomly select from two outcomes when you kill a monster. I can only make the first one appear. I know I'm missing something obvious.

code in python


choice = random.randint(0, 1)
if choice <= 1:
message('The ' + monster.name + ' is dead! You gain ' + str(monster.fighter.xp) + ' experience points.', libtcod.orange)
monster.char = '%'
monster.color = libtcod.dark_red
monster.blocks = False
monster.fighter = None
monster.ai = None
monster.name = 'remains of ' + monster.name
monster.send_to_back()

elif choice > 1:
message('The ' + monster.name +' has surrendered!')
monster.char = '*'
monster.color = libtcod.dark_red
monster.blocks = False
monster.fighter = None
monster.ai = None
monster.name = 'A surrendering ' + monster.name
monster.send_to_back()
>>
>>54972280
Interested in this.
>>
>>54976157
No shit. You can get a 0 or a 1 as result, and the first option happens every time you have anything equal to or lesser than 1.
>>
>>54976157
Never mind I'm an idiot
>>
Python babby greenhorn here.
Going through exercises on Code Wars. Starting to feel a tad strained.

Recommend me some easy projects I can start workin' on.
>>
Anyone have the fan LED color guide? The one where someone's brother died by mixing em.
>>
File: guide to LED-LED Fans.png (233 KB, 700x900) Image search: [Google]
guide to LED-LED Fans.png
233 KB, 700x900
>>54976191
>>
>>54976191
>>>/g/sqt
>>
>>54976155
I'm gonna go ahead and ask.

Let's say I have a bunch of threads all trying to handle connections from a list while inside a while(condition) loop.

Condition is a static volatile sig_atomic_t.

Now on receiving a certain SIGCSTM I use sigaction to run a one line method which flips condition to 0, and thus the threads should all exit the while loop after finishing up their current connection and rejoin main, then killing the server quietly.

Though when I throw the signal, nothing happens. The server just hangs as if waiting for more connections.

I'm handling the signal by doing
struct sigaction s;
memset(&s, 0, sizeof(s));

s.sa_handler = shutDown;
sigaction(SIGCSTM, &s, NULL);


while the method is

void shutDown(){
overlord = 0;
}

Anything glaringly wrong here?
>>
>>54976300
Yeah don't run thread per connection, that's insanely retarded.
>>
>>54976331
I don't run a new thread for each connection, the server starts with a thread pool of size specified by the user, and each thread in the pool looks inside a shared list which a specific dispatcher thread fills with accepted sockets.
If they find a socket ready to be read on that list they take it out of the list and work with it until the client on that socket disconnects, then go back to looking at the list.
It's in the program's specifications, I can't really work around them.
>>
let foo = Foo::new();


all other languages btfo
>>
>>54976433
HON HON HON
>>
>>54976389
Hmm, maybe try adding:
    s.sa_flags = 0;
sigemptyset(&s.sa_mask);


Also could it be that the call to accept is simply blocking waiting for a new connection and thus the thread does not see that it should terminate?
>>
>>54976225
he got it much faster here than he would have in /sqt/
>>
>>54976565
He didn't even get the image he was requesting, moron.

There's a longer one specifically with the mixture.
>>
>>54976433
'Foo' is more interesting to know at the start of the line than 'let'
>>
>>54976457
I think I found my problem. My dispatcher stops on the accept function, and my workers stop on the conditional variable the dispatcher uses to warn them a new element has been put into the socket list.
So I'm gonna try implementing a select call before my accept on the dispatcher and see where that goes.
>>
>>54976599
t. someone who doesn't understand what let bindings do or can do
>>
>>54976646
kys
>>
File: 1464730808092.gif (842 KB, 500x500) Image search: [Google]
1464730808092.gif
842 KB, 500x500
>>54976651
>proving you're retarded
for what purpose?
>>
>>54975305
>Even still, this anon:
>>>54975286 (You)
>>>54975140 (You)
>is right.
get rekt arrogant faget
>>
>>54976626
That was it, fixed with a select.
>>
>>54976723
>animuu~
>>
>need block device with FAT32 partition for USB gadget
>want to "export" CIFS share as that device
>planning on writing a FUSE file system that creates the block device from scratch and places all the files in the CIFS share into it, redirecting reads to the CIFS share when reads are performed on the specific file in the virtual FAT32 file system
Is there an easier way to do this? Like a way to turn a directory tree into a block device or something?
>>
File: animal.jpg (50 KB, 989x561) Image search: [Google]
animal.jpg
50 KB, 989x561
>Experience with multithreading, databases on Android

What's so hard about that? Literally takes 5 minutes to read how to open a sqlite connection and send commands or write new Thread(new Runnable(){}).Run(); and wait()/notify()
>>
>>54972280
>>54974887
>>54976170

>look its two niggers who dont know this already exists and was blocked
>>
What should I read to learn more about multithreading in C#? I want to improve the performance of my puzzle solver by having the solutions checked on multiple threads simultaneously and then have a background thread read valid solutions found off a stack and write them to the console window. The msdn example is pretty confusing.
>>
can someone explain data-driven programming vs message passing programming to me?
>>
>>54977481
>What should I read to learn more about multithreading in C#?
Firefox source code. You should implement each thread as a separate process.
>>
>>54977481
This video is pretty good and gives concise examples using LINQ:
https://channel9.msdn.com/blogs/bruceky/how-to-parallelize-your-application-part-3-using-tasks

It goes over the difference between just throwing a thread at each iteration, and utilizing a thread pool of workers that complete tasks as they can.
>>
>>54977481
>>54977903
Oh, and that's part 3 where they actually go over the code. The first two parts are good if you want to understand the entire concept and when to use it.
>>
https://ideone.com/i788wX

Am I smawt, /g/ ?
>>
>>54977912
>>54977903
Thanks anon.
>>
>>54972384
This is plain wrong. The bottleneck is printing the number out. If you eliminate that, C is faster than Go.
>>
>>54977812
kys
>>
>>54978213
not that it matters, but how come C is slower than memelangs at doing console I/O?
>>
Idea: message board that allows you to "attach" a file to a post. Instead of uploading the file to the server, the server just mediates a WebRTC file transfer. The "attached" file is removed when the uploader's session ends (since no one is able to receive the file if the uploader isn't online).
>>
>>54978328
Yeah, let me just upload a popular image and have millions of computers nuke my connection.
>>
>>54978280

No clue. Here are the numbers to back up my claim btw:

./facts-c  0.03s user 0.05s system 98% cpu 0.088 total 
./facts-go 0.11s user 0.06s system 108% cpu 0.157 total


I changed it to 13000! to make the numbers a bit bigger. I'd post the gist with all the code + makefiles but fucking spam filter
>>
>>54978358
The website could handle queuing, but still, good point.

I'm not sure if it is straightforward with the APIs that exist, but you could load balance downloads among all active sessions that have downloaded the file. Else, you could do full on bittorrent-over-WebRTC.
>>
>>54978395
Could set up some kind of p2p, so that people who have downloaded the image also start uploading (wow, I just invented torrents!)

Your idea also already exists, but I can't find the link right now. It's just a small demo that lets you share files p2p with webrtc
>>
>>54978269
is kys ironic or not? i post it ironically
Thread replies: 255
Thread images: 32

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.