[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: 318
Thread images: 21

File: drop table.jpg (26KB, 338x292px) Image search: [Google]
drop table.jpg
26KB, 338x292px
What are you working on, /g/?
Previous thread: >>61984897
>>
Idris is the language of the future
>>
>>61992323
How the fuck are all the Django tutorials broken. Fuck this framework.
>>
>>61992350
>inb4 removed ableist language
>>
>>61992350
https://www.youtube.com/watch?v=uqsZa36Io2M
>>
$ cat branchless.c
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
int max1(int x, int y) {
return (x > y) ? x : y;
}
int max2(int x, int y) {
return (-(x>y) & (x^y)) ^ y;
}
int main() {
srand(time(NULL));
for (int i = 0; i < 1000000; i++) {
printf("%d", max1(rand(), rand()));
printf("%d", max2(rand(), rand()));
}
}
$ gcc branchless.c -std=c11 -O2
$ objdump -d a.out
[...]
0000000000400660 <max1>:
400660: 39 fe cmp %edi,%esi
400662: 89 f8 mov %edi,%eax
400664: 0f 4d c6 cmovge %esi,%eax
400667: c3 retq
400668: 0f 1f 84 00 00 00 00 nopl 0x0(%rax,%rax,1)
40066f: 00

0000000000400670 <max2>:
400670: 31 c0 xor %eax,%eax
400672: 39 f7 cmp %esi,%edi
400674: 0f 9f c0 setg %al
400677: 31 f7 xor %esi,%edi
400679: f7 d8 neg %eax
40067b: 21 c7 and %eax,%edi
40067d: 89 f8 mov %edi,%eax
40067f: 31 f0 xor %esi,%eax
400681: c3 retq
400682: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
400689: 00 00 00
40068c: 0f 1f 40 00 nopl 0x0(%rax)
[...]

>muh optimizing compiler will fix everything
>>
>>61992366
Any text versions of this?
>>
>>61992411
Not that I'm aware of anon
>>
>>61992373
What about this?
>>
Scheme is the only good lisp dialect desu senpai. Cuckmon lisp doesn't have proper functional programming support because of the lisp2 meme after all, on top of being bloated as fuck.
>>
>>61992430
1) They should both compile to the same thing
2) max2 (a bit hack) is faster than max1 (the "more clear" version which "professional" "programmers" will always recommend you)
>>
>>61992453
max1 produces shorter code, however
>>
>>61992453
How fast? You benchmarked your example with rand calls?
>>
>>61992472
shorter code != faster code
>>
>>61992453
tested this and max1 is slightly faster
>>
>>61992481
wasn't saying it was (but on some weird cache-constrained architecture it might be)
>>
>>61992481
On RISC architectures, it is. On the CISC RISC hybrid abomination of Intel though...
>>
>>61992498
Eitherway people use neither: they macro max1 instead (#define max(x, y) (x > y? x: y))
>>
>>61992512
>not parenthesizing correctly
>>
>>61992498
How did you test it? With O2 enabled? Even with branches, depending on the input you can get good results because branch prediction.
>>
>>61992472
Yes, but cmov is slow.
>>61992479
The point of this was the assembly was different. Benchmarking with rand calls isn't optimal, what's the keyword for "don't constant propagate this variable" for GCC?
>>61992498
Platform-dependent and missing the point.
>>
>>61992512
>y?
>x:
(x > y) ? x : y
>>
>>61992373
heh,
_Z4max1ii:
cmp ecx, edx
mov eax, edx
cmovge eax, ecx
ret

_Z4max2ii:
xor eax, eax
cmp ecx, edx
setg al
xor ecx, edx
neg eax
and eax, ecx
xor eax, edx
ret

_Z4max3ii:
cmp ecx, edx
mov eax, edx
cmovge eax, ecx
ret


max 3 is C++.
int max3(int a, int b) {
return std::max(a,b);
}
>>
>>61992520
Wrong.
>>61992553
Sorry, I'm not homosexual.
>>
File: 1440246538429.png (304KB, 722x768px) Image search: [Google]
1440246538429.png
304KB, 722x768px
Is it possible to write code with ethanol in your system? If so, how?
>>
>>61992574
ballmer peak
>>
>>61992323
somebody PLEASE make a 4chan extension for Thunderbird

I want my shitposts in the same place as my email and rss
>>
Can your language do this?

val book =
("author" ->> "Benjamin Pierce") ::
("title" ->> "Types and Programming Languages") ::
("id" ->> 262162091) ::
("price" ->> 44.11) ::
HNil

scala> book("author") // Note result type ...
res0: String = Benjamin Pierce

scala> book("title") // Note result type ...
res1: String = Types and Programming Languages

scala> book("id") // Note result type ...
res2: Int = 262162091

scala> book("price") // Note result type ...
res3: Double = 44.11

scala> book.keys // Keys are materialized from singleton types encoded in value type
res4: String("author") :: String("title") :: String("id") :: String("price") :: HNil =
author :: title :: id :: price :: HNil

scala> book.values
res5: String :: String :: Int :: Double :: HNil =
Benjamin Pierce :: Types and Programming Languages :: 262162091 :: 44.11 :: HNil

scala> val newPrice = book("price")+2.0
newPrice: Double = 46.11

scala> val updated = book +("price" ->> newPrice) // Update an existing field
updated: ... complex type elided ... =
Benjamin Pierce :: Types and Programming Languages :: 262162091 :: 46.11 :: HNil

scala> updated("price")
res6: Double = 46.11

scala> val extended = updated + ("inPrint" ->> true) // Add a new field
extended: ... complex type elided ... =
Benjamin Pierce :: Types and Programming Languages :: 262162091 :: 46.11 :: true :: HNil

scala> val noId = extended - "id" // Removed a field
noId: ... complex type elided ... =
Benjamin Pierce :: Types and Programming Languages :: 46.11 :: true :: HNil

scala> noId("id") // Attempting to access a missing field is a compile time error
<console>:25: error: could not find implicit value for parameter selector ...
noId("id")
>>
>>61992601
Impossible thanks to moot and hiroshima's betrayals.
>>
>memory leak that only occurs if debug information is completely stripped
why
>>
>>61992631
i see, but why is it impossible?
isn't the json api stable?
>>
>>61992639
>c/c++ in a nutshell
>>
>>61992647
It's because of the captcha meme. Note that it would actually be possible to make an emacs mode for it, however.
>>
>>61992350
Basically, gib me Django tutorials
>>
>>61992658
You could fetch recaptcha, use pass, separately handle it, etc
>>
>>61992658
That makes sense.

Someone made a 4chan viewer for emacs (no posting though): https://github.com/desvox/q4
>>
What is the best programming language to write while on LSD? Lisp?
>>
>>61992373
>>61992562
and benchmarked on my potato. (granted this was compiled with a c++ compiler..)

/*
Run on (6 X 2800 MHz CPU s)
08/19/17 22:35:23
Benchmark Time CPU Iterations
-------------------------------------------------
BM_max1 166 ns 167 ns 4480000
BM_max2 163 ns 164 ns 4480000
BM_max3 165 ns 165 ns 4072727
BM_max4 163 ns 164 ns 4480000
BM_max5 162 ns 161 ns 4072727
*/
#include <benchmark/benchmark.h>
#include <random>
#include <algorithm>

int max1(int x, int y) { return x > y ? x : y; }
int max2(int x, int y) { return -(x > y) & (x ^ y) ^ y; }
int max3(int x, int y) { return std::max(x, y); }
template<typename T> constexpr T const& max4(T const& a, T const& b) { return a > b ? a : b; }

static std::random_device rd;
static std::mt19937 gen(rd());

static void BM_max1(benchmark::State& state) {
std::uniform_real_distribution<double> dist(1, 1e10);
while (state.KeepRunning()) {
auto m = max1(dist(gen), dist(gen));
}
}
BENCHMARK(BM_max1);

static void BM_max2(benchmark::State& state) {
std::uniform_real_distribution<double> dist(1, 1e10);
while (state.KeepRunning()) {
auto m = max2(dist(gen), dist(gen));
}
}
BENCHMARK(BM_max2);

static void BM_max3(benchmark::State& state) {
std::uniform_real_distribution<double> dist(1, 1e10);
while (state.KeepRunning()) {
auto m = max3(dist(gen), dist(gen));
}
}
BENCHMARK(BM_max3);

static void BM_max4(benchmark::State& state) {
std::uniform_real_distribution<double> dist(1, 1e10);
while (state.KeepRunning()) {
auto m = max4(dist(gen), dist(gen));
}
}

BENCHMARK(BM_max4);

static void BM_max5(benchmark::State& state) {
std::uniform_real_distribution<double> dist(1, 1e10);
while (state.KeepRunning()) {
auto m = std::max(dist(gen), dist(gen));
}
}

BENCHMARK(BM_max5);
BENCHMARK_MAIN();
>>
>>61992583
This trivializes alcoholism. I haven't been able to write code in months, and now that I'm an alcoholic, I still can't program. I hate programming.
>>
File: smug neural girl.png (42KB, 128x128px) Image search: [Google]
smug neural girl.png
42KB, 128x128px
>>61992693
Bit hacks win again.
>>
>>61992668
Captcha needs to be refreshed regularly and needs to be request explicitly. There is no way to handle it separately per se. If you use a pass, you're a redditnigger and don't belong here.
>>
>>61992373
clang appears to be a bit better (with -O3 instead of -O2):

00000000004005e0 <max1>:
4005e0: 39 f7 cmp %esi,%edi
4005e2: 0f 4d f7 cmovge %edi,%esi
4005e5: 89 f0 mov %esi,%eax
4005e7: c3 retq

00000000004005f0 <max2>:
4005f0: 89 f1 mov %esi,%ecx
4005f2: 31 f9 xor %edi,%ecx
4005f4: 31 c0 xor %eax,%eax
4005f6: 39 f7 cmp %esi,%edi
4005f8: 0f 4f c1 cmovg %ecx,%eax
4005fb: 31 f0 xor %esi,%eax
4005fd: c3 retq
>>
>>61992718
bit hack and std::max is basically the same amount of nanoseconds per. (except std::max is also generic and works on any types that provide a greater-than operator (like std::greater<>). and you can use it at compile time, unlike bithack.)

but yes, for C the bithack is slightly faster. like 4 billionths of a second faster.
>>
>>61992741
Not him, but are thunderbird extensions not allowed to make arbitrary http calls or something? If not, I don't see any reason why a captcha wrapper wouldn't work
>>
File: 1471397567615.jpg (19KB, 343x354px) Image search: [Google]
1471397567615.jpg
19KB, 343x354px
/dpt/ how should I handle reading config settings inside of functions, should I keep the config structure in the global scope and have functions read that global, should every function that needs to read the config have a parameter that accepts a pointer to a config struct, should I have a function that returns a copy of the config struct that's stored in maybe a static variable, should I have functions that return bools for each option (`showDotfiles()`), or something else?

I'm not sure what the best practice is for this kind of thing, I am leaning either towards a global variable, or a static variable inside a function which returns a copy of the config.
>>
>>61992747
I thought the thing we wanted to avoid was cmov*? clang has put it in both of them
>>
>>61992630
yeah python can do dat
>>
>>61992759
>should every function that needs to read the config have a parameter that accepts a pointer to a config struct
IMO this is a good way to do it.

void reads_config(const struct Config *c) {
...
}
void writes_config(struct Config *c) {
...
}
>>
>>61992768
hahaah i'm retarded, nevermind
>>
>>61992750
Yes, std::max probably compiles to bithack but x>y?x:y meme doesn't.
>>61992741
They can last for a while. Just embed an image in each post, that works fine.
>>
>>61992758
As far as I'm aware they can't dynamically update the content of a pending message nor create arbitrary render surfaces.
>>
>>61992814
i see, that's fucking gay
>>
I'm a little dense but I've been using python to try and automate a boring, shitty, manual part of my job.

Basically I can get a report (only in csv) that gives me the receipts and disbursements from a remote site direct from the bank's janky clunky system and a report from the janky accouting system the remote sites run. Since absolute monkeys handle the remote sites the numbers between the bank and the accounting software never match.

The report from the bank give me on each row an account id, date, debit, credit, and a string for the type.

The report from the accounting software gives roughly the same but at a more granular level.

So far I've written a simple program in python at iterates through the csv from the bank and groups items by type and gives me totals. I have a separate program that does the same for the accounting softwate and writes both to the same spreadsheet and sends it off to the monkey to look at each.

It works right now if I pull a single site's report for each or split it manually by site. Since I have to pull each report manually from each system running it for every property one at a time takes a while.

I'm trying to figure out the best way to only pull a single report from each side and have it split out by site automatically.

Do I need to define classes for site to hold the values or some kind of dict/list structure?
>>
>>61992677
>I am no longer developing this package. It's a fully functional browser but lacks a few features I initially planned because I decided not to waste any more time browsing chans then neccesary :^)
wow
>>
>>61992771
It can't give you a compile error for the last one or statically type all the retrieved values
>>
>literally arguing over individual clock cycles worth of performance
>>
>>61992787
I like the idea of it but I don't like actually having to pass it, I feel like it's going to increase the arity of my functions in a weird way, like any function that calls another function which needs the config, will then also need to accept the config as a parameter.
Parent(int){
Child(*config)
}

needs to become
Parent(int, *config){
Child(*config)
}

Is my complaint indicative of bad design? If I switch to this pattern do you think it will force some good refactoring or is it mostly just a preference kind of thing?

I know this is kind of a simple problem but I'm really hung up on it, it feels important but nothing I consider feels like an obvious correct answer.
>>
File: dumb.png (123KB, 1920x1080px) Image search: [Google]
dumb.png
123KB, 1920x1080px
>>61992811
it may do it for ints, but it probably doesn't. those bithacks won't work for max(3.2, 4.7).

also, why is icc dumb?
>>
File: kok.png (169KB, 1366x768px) Image search: [Google]
kok.png
169KB, 1366x768px
Finished the virtual memory and interrupt system for my microkernel. Moving onto device drivers and will have a boot screen done soon.
>>
>>61992835
from collections import defaultdict

report = defaultdict(defaultdict(list)
# now you just run through each report doing shit like
report[FROM][TYPE].append(result)


?
>>
>>61992858
book = {
"author":"Benjamin Pierce",
"title":"Types and Programming Languages",
"id":262162091,
"price":44.11
}
print (type(book["author"]))
print (type(book["title"]))
print (type(book["id"]))
print (type(book["price"]))
print (book.keys())


out
<class 'str'>
<class 'str'>
<class 'int'>
<class 'float'>
dict_keys(['author', 'title', 'id', 'price'])
>>
>>61992891
That might just do it, thanks I'll give it a shot and report back on my success/failure.
>>
>>61992916
FYI: you can write that as
map(type, book.values())
print(*map(type, book.values()), sep='\n')
>>
>>61992861
No, it's about the "optimizing compilers are always fastest" meme, it just goes to show how wrong they are when they're wrong about even the trivial examples, what about when you're not using an extremely common and well-known pattern?
>>
>>61992875
If you write anything of any consequence in C, you're going to wind up with a few really blown out function declarations. Cost of doing business.

Global config structures are bad unless you're very, very sure nobody will ever want to embed more than one of your thing in a given process. Someone did that with lex once upon a time and it took 25 years to unfuck.
>>
>>61992982
I appreciate the input.
>>
>>61992965
nice didn't know
>>
>>61992880
What about if you write one that masks the floats, then compares sign bit, exponent, and mantissa in that order?
>>
>>61992880
>icc

Disgusting.
>>
>>61992972
That's only for C, and everyone knows C is trash.
>>
>>61993110
It goes for C++ too, except the compiler manages to compile a standard library expression (surprise!) into something remotely close to efficient. It's still shit at anything remotely uncommon and you're best of using bit hacks.
>>
Are dependent types a good meme or a bad meme?

How do they compare to refinement types?
>>
>>61992972
I reran it with all optimizes turned off. just a "release" build with no debugging symbols, frame pointers or any of that useful stuff.
Benchmark Time CPU Iterations
-------------------------------------------------
BM_max1 284 ns 285 ns 2357895 // ternary
BM_max2 287 ns 290 ns 2488889 // <-- bit hack
BM_max3 286 ns 285 ns 2635294 // std::max
BM_max4 288 ns 285 ns 2357895 // template
BM_max5 290 ns 292 ns 2357895 // std::max directly

btw, its not consistently faster because we're talking about 4 ns (on my 7+ year old processor..), which could be attributed to all kinds of outside forces.

also MSVCs assembly output sure does produces the ugliest labels (no optimizations turned on)
?max1@@YAHHH@Z PROC                    ; max1 (ternary)
$LN5:
mov DWORD PTR [rsp+16], edx
mov DWORD PTR [rsp+8], ecx
sub rsp, 24
mov eax, DWORD PTR y$[rsp]
cmp DWORD PTR x$[rsp], eax
jle SHORT $LN3@max1
mov eax, DWORD PTR x$[rsp]
mov DWORD PTR tv65[rsp], eax
jmp SHORT $LN4@max1
$LN3@max1:
mov eax, DWORD PTR y$[rsp]
mov DWORD PTR tv65[rsp], eax
$LN4@max1:
mov eax, DWORD PTR tv65[rsp]
add rsp, 24
ret 0
?max1@@YAHHH@Z ENDP

?max2@@YAHHH@Z PROC ; max2 (bitwise)
$LN5:
mov DWORD PTR [rsp+16], edx
mov DWORD PTR [rsp+8], ecx
sub rsp, 24
mov eax, DWORD PTR y$[rsp]
cmp DWORD PTR x$[rsp], eax
jle SHORT $LN3@max2
mov DWORD PTR tv65[rsp], 1
jmp SHORT $LN4@max2
$LN3@max2:
mov DWORD PTR tv65[rsp], 0
$LN4@max2:
mov eax, DWORD PTR tv65[rsp]
neg eax
mov ecx, DWORD PTR y$[rsp]
mov edx, DWORD PTR x$[rsp]
xor edx, ecx
mov ecx, edx
and eax, ecx
xor eax, DWORD PTR y$[rsp]
add rsp, 24
ret 0
?max2@@YAHHH@Z ENDP

I had to remove a fuckton of comments that had the line number, file number and all kinds of ?statements that is probably used by the compiler for doing diagnostics/visual studio stuff.
>>
>>61992323
>What are you working on, /g/?
I'm working on a combined assembler-disassembler library for x86.
>>
>>61993143
[citation needed]
>>
>>61992702
Clearly you're not mixing enough uppers with your downers. You might also want to try lsd microdosing and writing lisp.
>>
Working through a Data Structures (in C) book

Is this a good way to delete/free all the nodes in a tree?

void clearTree(Tree t)
{
if(t == NULL) return;
else
{
clearTree(t->Left);
clearTree(t->Right);

free(t);
}
}

>>
>>61993237
Sure, if you want stack overflows.
>>
>>61993237
Yes. Recursion is very suited for trees.

>>61993254
The max depth scales logarithmically. It's likely that he would need a tree that doesn't fit in memory before it stack overflows.
>>
>>61993237
the else is not needed
if it returns, how would it get to the other statements?
other than that, looks solid
don't listen to >>61993254
he's gay. 99.9% of the time you won't have a large enough tree for this to cause any issue
and if it did. you could just increase the amount of branches at each level to make things more efficient stack wise
>>
>>61993254
Would it stack overflow due to the (possibly) large number of recursive calls?
How else could it be done?
>>
>>61993270
>The max depth scales logarithmically
Correction: it scales logarithmically if it's height balanced.
>>
>>61993277
Set a flag matching the node after you traverse it left, operate only on fully marked or leaf nodes. Work backward from the leaves.
>>
>>61993277
>How else could it be done?
make a stack structure of Tree objects
stack them up by level. when you're done, pop and free

that said, if you're doing things right though. freeing a tree won't cause a stack overflow

just keep your trees balanced
>>
>>61993273
10/10
>>
File: 1501366724548.png (95KB, 218x220px) Image search: [Google]
1501366724548.png
95KB, 218x220px
>>61993314
>10/10
thanks senpai
>>
>his language is susceptible to stack overflows
LOL
>>
>>61993273
>the absolute state of /dpt/
>>
>>61993279
>ever using unbalanced trees
>>
File: 1501564096576.png (6KB, 419x249px) Image search: [Google]
1501564096576.png
6KB, 419x249px
>>61993344
>>
File: Happily riding a horsey.gif (605KB, 400x400px) Image search: [Google]
Happily riding a horsey.gif
605KB, 400x400px
>>61993273
>>61993270
>>61993293
>>61993300
Thanks famalam(bda)
>>
>>61993345
Yes, always balance your trees, but I was just covering my bases because it's possible.
>>
>>61993344
There is literally nothing wrong with recursion.
>>
>>61993385
unbalanced trees should really be a type error tbqhwy
>>
>>61993387
There is when you have an undelimited depth and you refuse to be tail-recursive.
>>
>>61993460
>There is when you have an undelimited depth and you refuse to be tail-recursive.
why do they do this in MODERN ENTERPRISE PROGRAMMING languages?
>>
File: 1502000894426.png (396KB, 567x567px) Image search: [Google]
1502000894426.png
396KB, 567x567px
>>61993333
>those digits
>that wisdom
noice
>>
>>61993460
If you have unlimited depth then you can't do it with iterations either.
There is literally nothing wrong with unlimited depth.
t. Haskell.
>>
Languages without infinite stacks means that you have to manage the recursion manually using an explicit stack, which is always going to be more complex and less elegant than the simple recursive solution.

Infinite stack doesn't just mean tail calls; many Lisps that have proper continuations consequently allow for the stack to grow arbitrarily, in the same way that other languages can arbitrarily allocate from the heap (until you run out of memory, of course)
>>
>>61993568
you know whats a shame about infinite stacks? practical hardware doesn't have them :^)
>>
>>61992350
django is broken
use flask
>>
>>61993591
I understand languages like C or C++ that have thin memory abstractions to have limited stacks, but not higher level languages like Python, Javascript or Java.
I suppose there's justless of a demand outside of functional lanaguages
>>
>>61993625
you can use trees in non-FP languages, you know.
>>
>>61993648
Yes but they are unnecessarily awkward when you have hard stack constraints
>>
i'm working on a c++14 framework for a mobile game engine using the android native dev kit
>>
>>61993680
but people do it all the time.. you just to be smart about it. and be especially aware that your tree is both balanced and acyclic. if its cyclic, though, its quite useful to have a stack to determine if you're cycling.
>>
>>61993695
>c++
>>
>>61993520
Kek.
But undelimited is not infinite. Polynomial computational time can still be viable whereas polynomial space usage might not be.
>>
>>61993715
By definition, it's not a tree if it's cyclic.
Only "data" trees can be balanced. In general, trees are not balanceable.
>>
Just finished making a postfix-expression-to-binary-tree program

Currently unsure of how to expand this for things that aren't 1-character long (currently, both operators and 'numbers' are stored as one digit)

I'm thinking of changing the structure from:
#define TreeElem char

struct TreeNode
{
TreeElem Element;
struct TreeNode* Left;
struct TreeNode* Right;
};


to

#define TreeElem char*
enum TreeTag{ OPERATOR, NUMBER};


struct TreeNode
{
enum TreeTag tag; /* Stores info about whether the current element is
an operator or not */
TreeElem Element;
struct TreeNode* Left;
struct TreeNode* Right;
};

to eventually be able to evaluate the operation... Is there a better way of doing this?
>>
>>61994555
You're running into the realm of lexical analysis and parsing.
What you're doing is basically the correct thing.
>#define TreeElem char*
Don't use #define for this sort of thing. typedef is designed to do that, and it doesn't run into any weird corner cases.
typedef char *TreeElem

However, I would argue that it's better to not do this at all.
>>
>>61994555
you could also use a union in your new node.
>>
File: Untitled.png (20KB, 656x531px) Image search: [Google]
Untitled.png
20KB, 656x531px
This is a very stupid question and I know it has to do with the access level but why can I not reference say, contextMenu from Message()?

Ive tried every way I can think of, not just static.
>>
>>61994664
I have tried changing static to every combination I can think of and nothing works. This is my first time doing a visual c# project without a template so forgive me.
>>
>>61994664
its made inside of main. make it a static variable.. or make a class and create that in main

public class Program {
static void Main(string[] args) {
var f = new Foobar();
// can do stuff with foobar here
Application.Run();
}

public class Foobar {
private ContextMenu menu { get; }
public Foobar() {
menu = new ContextMenu();
menu.MenuItems.Add("Message", Message);
}

public void Message(object sender, EventArgs e) {

}
}
}


or, pass a lambda to the contextmenu in your static main function. (it works, but you should probably learn why you can't access instance variables in a static method..)
// ..
menu.MenuItems.Add("Message", (s,e) => { });
>>
>>61994734

Thank you, but I think I'm still making a mistake. I cannot reference it. This is what I have now:

using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Threading;
using System.Drawing;

namespace Packlemore
{
public class Program
{

static void Main(string[] args)
{
var f = new Foobar();
Application.EnableVisualStyles();
Application.Run();
}

public class Foobar
{
public Foobar()
{
NotifyIcon notifyIcon = new NotifyIcon();
ContextMenu contextMenu = new ContextMenu();
contextMenu.MenuItems.Add("Exit", new EventHandler(ExitMenuClicked));
contextMenu.MenuItems.Add("Message", new EventHandler(Message));
MenuItem menuItem1 = new MenuItem();
notifyIcon.Icon = Packlemore.Properties.Resources.box;
notifyIcon.Text = "Packlemore";
notifyIcon.ContextMenu = contextMenu;
notifyIcon.Visible = true;
}

public void ExitMenuClicked(object sender, EventArgs e)
{
Application.Exit();
}

public static void Message(object sender, EventArgs e)
{

}
}
}
}
>>
>>61994843
Oh wait I see. You said create it in main so it can be referenced. I understand. Thank you!
>>
>>61994843
make the contextmenu a field of the 'foobar' class
also, don't make Message static. it won't be able to access instance variables/fields/members.
in my example, you could use "menu" from Message. although, you could probably make ContextMenu static.. but don't do that. static is useful when you don't have/need state. and you'll clearly have/want to have state in your program.

static means it doesn't need an instance of its class to be usable.
public class Foo {
public static bool Bar() { /* can only access other static things */ }
public bool Baz() { return answer == 42 }
public int answer { get; set; }
}

var foo = new Foo()
foo.answer = 42;
foo.Baz() == true; // yes
foo.Bar(); // will do nothing (it'll be some sort of error. I haven't done C# in a long time..)
// but
Foo.Bar(); // will call Bar. (notice Foo is the class name and foo is the instance of it)
>>
>>61994927

I see, and I did not mean to make message static I forgot to remove it. I got it working now. You answered my question after an hour of research.
>>
I'm stuck doing C# work using .Net 2.0 and it is driving me fucking insane. All of the documentation for this .Net 2.0 has been wiped out, searching for answers to questions I have fucks me over more every day.

How do I find .Net 2.0 autists to help me
>>
>>61995006
I usually work with .NET 2.0, if you specifically append .NET 2.0 to your searches you should get relevant results. There are a lot of people who still write .NET for legacy systems.
>>
>>61995006
>>61995030
that must really suck.
>>
>>61995030
Thanks for the tip, man. I am just now realizing that most of the code I find out there will shit the bed on .Net 2.0, it was a mild eureka moment I had to shitpost about.

This is going to suck, isn't it?
>>
hey guys should i learn web dev if im just doing a 4 year degree in cs? other option would be development with c++
>>
>>61995102
As you work with it more you'll get used to the differences and be able to adapt modern code more easily. There are quite a few features it really sucks to have to do without though.
>>
Is there like a DPT discord community or anything?
>inb4: >discord
>>
>>61995622
>discord
>>
>>61995630
(You)
>>
>>61995622
>>61995647
Fuck off to /v/, you proprietary cuck.
>>
    mov edx, len2
mov ecx, msg2
mov ebx, 1
mov eax, 4
int 0x80

i'm learning nasm assembly for the primary reason of learning reverse engineering.
here i'm printing msg2 to the console. but what exactly is happening on line 3? this is the first argument of sys_write if i'm not mistaken, which takes an int, so what other values could be put there?
this language is seriously confusing but really interesting at the same time, i'm trying to understand what happens on every line.
>>
>>61995679
ok bub. see ya later.
>>
>>61995737
>bub
how do dicks taste?
>>
>>61995747
project much?
>>
>>61995760
project what? my cum on your face?
>>
>>61995779
project this
 8 == D 
>>
>>61995630
>>61995647
>>61995679
what happened to tox? is it still a thing or did /dpt/ turn on it because it did something that touched their neck
>>
when you jump in games right, its exactly 1 second long

how does the software ensure this? what windows stopped my program because the os is doing something else? i am thinking having a timer and checking at x intervals to ensure that the animation is punctual and appropriate.
>>
I want to make a little program that should run in the background, waiting for incoming SNMP packet and then popping up a window (alert).

Are there any things one should be aware of? Ideally it should have near-zero resource usage when idling/listening. Can this sort of tool be done effectively in Pythong?
>>
>>61996021
>python
>near-zero resource
>>
>>61992759
https://stackoverflow.com/questions/14178889/what-is-the-purpose-of-the-reader-monad
>>
>>61992350
Pythonprogramming.net
There is also some videos on youtube
This is how I learned django
>>
>>61996021
>near-zero resource
Use C.
>>
If I use someone's library on github for my program, are they technically a contributor?
>>
>>61996092
>>61996028
I wanted to avoid using a language I'm not familiar with. But looks like I have no choice and will have to start learning some C/C++.

In order for the program to run in a background I suspect a use of threads. Generally, how difficult a topic are threads in C/C++?
>>
>>61996139
no but you have to follow the rules of their license
>>
>>61996143
>C/C++
Don't say that. They're completely different languages.
C is the one you want to go for.
>In order for the program to run in a background I suspect a use of threads
No. If just block on some resource and your resource usage will basically be zero.
If you want to daemonise your code, it can simply be done with fork, or you can get your init manager to do it for you.
>>
>>61996167
>and your resource usage
then your CPU usage*
>>
>>61996143
You don't need threads. You run the program as daemon. Check if there's input and handle input if there's input.
Do your faggy gay ass shit.
Go back to start.
>>
>>61996167
>Don't say that.
Ops.

>>61996167
>>61996179
Alright, thanks for the tips. I just wanted to know what to expect. I'll try to find some decent C tutorial/book.
>>
>>61996143

If you are only coding for Windows then you can use Windows API.

It has CreateThread function which lets you manipulate OS threads without using any third party library on lowest possible level.
>>
>>61995838
c == 3
>>
>>61995984
do you mean jumping specifically, or was that just an example? for things like linear interpolation or "what frame of this animation am i in?" or other pure functions the answer is simple, but jumping is generally done via integration (essentially simulating a simple physical particle), in which case the answer is a bit more complicated
>>
>>61996318

yea "what frame of this animation am i in"

i have an (x,y) axes for my character and when i jump i just increment the y-axis by 1 then by -1 afterwards, problem is depending on the computer speed the jumping animation is either too quick or too slow.
>>
Regarding initializer lists in C++:

Let's say you have the following class:
class Foo { 
public Foo(int n1, int n2);
int n1;
int n2;
};


When you try to initiate n1 and n2 with an initializer list, does the compiler automatically determine that you're trying to assign a value this->n1 and not the parameter n1? I.e. is the following legal?

Foo::Foo(int n1, int n2)
: n1(n1), n2(n2)
{}
>>
>>61996335
>depending on the computer speed the jumping animation is either too quick or too slow
ah, i see. you'll want your game loop to take time into account. check these out:

http://www.koonsolo.com/news/dewitters-gameloop/
https://gafferongames.com/post/fix_your_timestep/
http://lspiroengine.com/?p=378

a fixed timestep would probably suit your needs just fine, and it's easier to work with if you're relatively new to games
>>
>>61996521
That's legal. The scoping makes it work out perfectly.
>>
What language doesn't have shit generics?
>>
>>61996709

C#
>>
>>61996521
yes. the list items are of class scope because they must be class members, but arguments supplied to them will be the arguments supplied to the constructor, because function arguments are more local than class members, and equivalent names are disambiguated in order of scope locality
>>
>>61996759
wrong
>>
>>61996792

What's wrong with C# generics though? They are both compile and runtime compatible unlike Java and work perfectly.
>>
>>61996817
being better than Java is not an accomplishment.
>>
>>61996826

Name better ones.

>inb4 STL and C++ templates
>>
>>61996840
D templates.
>>
>>61996709
>>61996759
this. constraints and covariance/contravariance. still can't believe Java doesn't have constraints. without them generics would be so crippled that it's hard to see the point of having them at all
>>
>>61996861
>covariance/contravariance.
extends and super
>constraints
All C# lets you add is a value type vs reference type constraint. Everything else (must derive from a particular class or interface) is supported by Java.
>>
Will Accelerated C++ teach me the language well enough? I already know buncha C
>>
Is it worth learning C11 or start with good C99 and move to C11?
>>
>>61996994
GNU11 YOU FOOL
>>
>>61996994
C is a conservative language, very little changes from version to version. All that's worth mentioning in C11 is the _Generic macro and a stub for threading.
>>
Are there any nice tutorials about shipping native programs (C/C++) on Linux?

I have been trying to get some programs of mine to build in such a manner they could be ran on almost any graphical Linux desktop, but to no avail. The problem always stem from the shared libraries.

For example, I had program that uses ncurses. On the machine I compiled the program on (Arch), the ncurses version was 6. I attempted to run it on a Debian machine using ncurses 5 and it simply would not work. Ncurses doesn't come with a .a file on Arch at least so it cannot be linked statically without the source either. Finally with that specific program, I built it on Debian and packed into the shipping folder the ncurses 5 .so files found on the machine. That kind of worked, but the program crashes when I run another related program on the same desktop on the Arch machine. And I had to pack in some other .so files for it to work, too.

Is the only way to make ALL the libs I use a dependency of the program build process and include their sources in the git repo, then build them manually and include the .so files with the released application?
>>
>>61997001
>he doesn't know about anonymous struct/union or alignof
baka desu senpai
>>
>>61996994
It won't make a difference, the language is still very much the same apart from a couple of small features from C11. I would advice against C11 though because its not supported on all compilers yet.
>>
>>61997019
> anonymous struct/union
Huh, that finally became standard.
>>
>>61997019
Hardly features that some one just learning the language would care about.
>>
>>61997061
>can finally extend structs in easy way
baka desu senpai
>>
>>61997019
>>61997061
Anonymous structures/unions are useful as fuck once you know what to do with them.
I find it useful for treating a bunch of named struct values as an array, and be able to remove a lot of code duplication, while also keeping a "nice interface" for the struct.
>>
>>61997093
Wow, you get to drop the name of the union member. What a game changer, totally. I am sold, anyone about to begin learning C should obviously begin with C11.
>>
>>61997114
>you get to drop the name of the union member
I know, it's great. It's the little things which really makes a language nice to use.
>>
>>61997121
C's "convenience features" are almost invariably garbage.
>>
>>61997121
>I know, it's great. It's the little things which really makes a language nice to use.
More like, it's the little unnecessary words that you have to type that make the language feel retarded.
>>
You make a struct that holds filepath.
const char *file; // dup it when initializing
// or
char file[256]; // some systems don't support longer filenames
// or
char file[64]; // saving some space, it's likely enough
>>
>>61997134
C is supposed to be spartan, but there is nothing saying it can't have little features which make it nicer to use.
Anonymous unions are an incredibly minor/niche example, but are you opposed to things like mixed declarations and designated initialisers too?
>>
New Thread:
>>61997191
>>61997191
>>61997191
>>
>>61992323
>What are you working on, /g/?

I wrote a small php script that uses 4chan's api and checks thread OPs (subject and comment) on specific boards for some search keys. Basically I made checking board catalogs faster and composable (board(s) and search keys provided as arguments; formatted output to stdout). It's meant more as a "is anyone on [wsr] looking for help with [blank]"; I may set it up on a cron and feed it into notify-send.
>>
>>61997180
MAX_PATH
>>
>>61997180
Trying to deal with the max length of a path properly is actually surprisingly tricky.
256 is a "safe" bet, but to be truly correct, you probably want to use the top one.

>>61997210
>183 posts
>Completely wrong format
Delete that and kill yousrself.
>>
>>61997204
Both of those are fine, they don't break anything.
>>
>>61997233
Are you implying that anonymous structs/unions would have broken any real-world code?
>>
>>61997180
260 is generally good enough for Windows, but they opened up the APIs in Windows 10 to support extended paths (32,767 characters) which is something you'll need to plan for if you intend to support Windows.
>>
>>61997272
No, that's not really what I'm talking about.
>>
>>61997294
Then what are you talking about?
>>
>>61996840
to be fair C++ concepts would be great if they'd just get added to the fucking standard already

>>61996876
>All C# lets you add is a value type vs reference type constraint
don't forget new(). it lets you instance parameterized types, which you can't do in Java. also kinda crazy that you can't pass primitives as type parameters or instance arrays of parameterized types. as for the rest, after looking into it, i finally found bounded type parameters. was it a later addition or something? i've looked before and not seen it until now. i'm not afraid to admit when i'm wrong, but... it's kinda funny that i've mentioned that to a lot of Java programmers and you're the first that's ever corrected me, haha

>covariance/contravariance
>extends and super
those definitely aren't the same tho. if you're inclined to learn why:
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/covariance-contravariance/
Java does have covariant return types (much more specific), but i *think* that's it. in C# they apply in a wider range of contexts
>>
>>61997290
>260
Why is it such a retarded number?
>>
>>61997315
C++ concepts are sugar for what is already possible.
>>
>>61997329
1 + 2 + 256 + 1
[C] [:\] [Path] ['\0']
>>
>>61997336
i'm well aware. it's a *much* better syntax, though. and (though up to the implementation) it'd come pretty naturally hand-in-hand with much better error reporting
>>
>>61997338
Windows really is clusterfuck of bad desing.
>>
>>61992693
Is there a boost::max or something?

curious to see if it's faster.
>>
What's the best version of visual studio that's piratable.
I need a quick one for an exam on Tuesday.
>>
>>61997426
Just use the free as in free beer version
>>
>>61997426
https://gcc.gnu.org/releases.html
>>
>>61997426
community is free and it should have everything you need. unless you need enterprise TFS or some shit
>>
I'm writing an RSS downloader in Scala.
RSS downloaders are a good way for me to try out how practical a language is for me. It has disk I/O, network I/O, threading, data structure, threading and library support. So far I've written RSS downloaders in C++, Go, Python, Rust. Python was the most comfortable to write. I couldn't finish the Haskell one.
>>
>Can't pass structs to Haskell through the FFI
Haskell is a memelang.
>>
>>61997485
>implementing the same thing in many languages
>never advancing always staying at the same spot
Must be fulfilling life you are living, dumb scala user
>>
>>61997485
>I couldn't finish the Haskell one
why not?
>>
>>61997493
I think this package can do it, not certain though
https://hackage.haskell.org/package/inline-c

You can always use pointers
>>
>>61997493
Almost no language supports that, they all require you to pass structures as pointer.
The only language that I can think supports using C structs as values is Chapel.
If your language supports inlined C you could use it but FFI is usually seriously gimped.
>>
>>61997485
>RSS downloaders are a good way for me to try out how practical a language is for me
yeah as long as you only write RSS downloaders. have you considered that the practicality of a language could vary depending on the nature of the project
>>
>>61997495
It's not like I only write RSS downloaders. I use it to test my skill in the language and how well it does with practical problems. fizzbuzz is bad in that regard.
>>61997497
There's not 'just to X and it works' way in Haskell. Everything is really tedious.
>>61997517
Most of my toy projects are I/O related, so it's fine for me.
>>
>>61997529
I don't find Haskell tedious at all, what do you mean "just to X and it works"?
>>
What does /dpt/ think of OpenMP?

 int sum=0;
#pragma omp parallel for reduction(+:sum)
for(int n=0; n<1000; ++n) sum += table[n];
>>
What is wrong with my linked grid, /dpt/?

    void Generator::create_floor(unsigned int rows, unsigned int cols)
{
for(unsigned int i = 0; i < rows * cols; i++)
{
spaces.emplace_back(Space());
auto* pSpace = &spaces.back();

// set vertical neighbor
if(i / cols > 0)
{
auto* pNeighbor = &spaces[i - cols];
pNeighbor->pBottom = pSpace;
pSpace->pTop = pNeighbor;
}

// set horizontal neighbor
if(i % cols != 0)
{
auto* pNeighbor = &spaces[i - 1];
pNeighbor->pRight = pSpace;
pSpace->pLeft = pNeighbor;
}
}

auto* test = spaces[0].pBottom->pBottom->pBottom;
}
>>
>>61997538
i think he might be referring to the fact that requiring a glorified shell script to basically be a pure function is retarded overkill
i see the value of FP in the places it actually belongs, but it's impossible to argue it's better suited than an imperative language for a project that's literally "do this, then do this, then do this, then do this, then we're done"
>>
>>61997538
It's a typo. "Just do X and it works" is what I meant.
I got stuck at parsing XML and gave up. I don't think it's the fault of Haskell, but it takes a lot of time to figure out what all those operators do. I don't want to put much effort in that.
{-# LANGUAGE Arrows #-}

quoteParser :: (ArrowXml a) => a XmlTree Quote
quoteParser =
hasName "Contents" /> hasName "StockQuote" >>> proc x -> do
symbol <- getAttrValue "Symbol" -< x
date <- readTime defaultTimeLocale "%d-%m-%Y" ^<< getAttrValue "Date" -< x
time <- readTime defaultTimeLocale "%H:%M" ^<< getAttrValue "Time" -< x
price <- read ^<< getAttrValue "Price" -< x
returnA -< Quote symbol date time price

parseQuoteDocument :: String -> IO (Maybe Quote)
parseQuoteDocument xml =
liftM listToMaybe . runX . single $
readString [] xml >>> getChildren >>> quoteParser
>>
>>61997596
just use do notation
>>
File: what the fug.png (11KB, 211x246px) Image search: [Google]
what the fug.png
11KB, 211x246px
Why does do while need a semicolon in C?
>>
>>61997615
Because it has loop body between do and while
>>
void Class::destroy() 
{
delete this;
}
>>
File: time.jpg (38KB, 540x160px) Image search: [Google]
time.jpg
38KB, 540x160px
So I'm reading a book on C and I just finished a chapter about subporgrams and defined functions.
At the end of each chapter they present programming projects that usually required you to use techniques described in that chapter.
But I don't see a justification for using subprogams for the problem that they're giving, it would only make it more complex imo.
Should I still do the subprogram thing?
>>
>>61997610
>Arrows
that's some really advanced and niche shit
(>>>) is flip (.), generalised to categories
(^<<) composes an arrow with a pure function


there are saner ways, try using a non arrow based library
xml-conduit or xml for example
>>
>>61997596
You're right, most of my projects are CLI programs.
Python would be ideal for this, but I really hate that language. Most of the hate comes from dynamic typing though.
>>
Can we all agree that C# is the future of videogame programming?

>>>/v/387686658
>>
>>61997641
this should have been a reference and not a pointer
>>
>>61997615
Consistency, probably.
>>
>>61997670
No LaTeX is. To make beautiful games.
>>
>>61997670
>Linking to /v/
Off yerself, mate.
>>
>>61997615
for them macros
#define forever(body) do body while(1)
forever({
printf("xoxoxoxoxooxoxox\n");
});
>>
>>61997648
It's a learning exercise. Also, if for whatever reason you need to perform that calculation multiple times with different inputs then it makes sense (hence "function").
>>
>>61997554
It probably works for some stuff but its not a thread pool. Convenience always has a cost, and the cost of OpenMP is the cost of the creation of new threads (instead of keeping them alive but asleep).
>>
>>61997649
>xml-conduit
That brings me to another issue I have with Haskell libraries: most of them have no documentation. Not even a simple list of available functions.
>>
>>61997703
https://www.stackage.org/haddock/nightly-2017-08-19/xml-conduit-1.5.1/Text-XML-Cursor.html

?
>>
>>61997554
>As of 2017 only runs efficiently in shared-memory multiprocessor platforms (see however Intel's Cluster OpenMP and other distributed shared memory platforms).
https://en.wikipedia.org/wiki/OpenMP
SAD
>>
>>61997703
https://hackage.haskell.org/package/xml-conduit-1.6.0/docs/doc-index-All.html

It just sounds like you don't know what you're doing at all and blaming language/lib, sorry.
>>
>>61997721
Why didn't the autist put a link in the repo? https://github.com/snoyberg/xml
>>
>>61997728
Because hackage/stackage is the package repository while github is just source? You look into package repository for packages, not on GitHub. You have link to source from the package, not the other way around.

Who's the autist here m8?
>>
>>61997749
Any half decent repo has links to the documentation in the readme.
I guess Haskell is too 'special' for that.
>>
>>61997783
Or you're too 'special' to look for a release of a package in the place packages are released to. Honestly I'm surprised you didn't forget to breathe yet.
>>
>>61997703
Most of the big ones do, especially for functions and types.
The types themselves are partial documentation too
>>
>>61997788
Why is it so hard to write a proper readme with links to hackage, docs etc.?
>>
>>61997831
because you look on Hackage where you are then shown the docs, README and everything else

It's not hard to understand. If package was hosted in some non-canonical place (i.e. not Hackage/Stackage) then it would say so. Same if docs were hosted separately: some packages do this and then you do get a link.

You're just expected to go on Hackage and see the package. If you're trawling through GitHub then use a slightest bit of common sense and think "let me check Hackage for rendered docs".
>>
File: yui and her bitch.gif (139KB, 322x367px) Image search: [Google]
yui and her bitch.gif
139KB, 322x367px
#include <stdio.h>
/* Eratosthenes */
int main(void)
{
//Make a list of values 2,...,100
int list[99];
for (int i = 0; i < 99; ++i)
list[i] = i + 2;

int m = 0;

while (list[m] <= 10) {// Magic number - 10 = sqrt(100)
for (int j = 0; j < 99; ++j) {
if (list[j] % list[m] == 0 && list[j] != list[m])
list[j] = 0;
}
do {
++m;
} while (list[m] == 0);
}

for (int i = 0; i < 99; ++i)
if (list[i] != 0)
printf("%d, ", list[i]);

printf("\n");

}

What is this on the order of? If we're looking at 2,...,n there's n - 1 values since 1 gets skipped and we check those values at least sqrt(n) - 1 times.
So I think it's (n - 1)(sqrt(n) - 1) = O(n) but I've been known to be a retard in the past and wikipedia says it should be O(n log log n)
>>
>>61997869
I usually search on GitHub for a good library and go from there. mavencentral and jcenter just host the library. Haskell does it the other way. Whatever, both work.
Still, I don't find Haskell very practical. It's too much of a hassle to work with a pure FP language. My personal favorites are multi paradigm languages like Scala. Clojure is cool too, but it's dynamically typed.
>>
>>61997900
>(n - 1)(sqrt(n) - 1) = O(n)
Looks like it to me too. But that doesn't look like a proper sieve. A proper sieve works like this:

First find all primes under 10: 2, 3, 5, 7

Then we go through every prime, incrementing by the prime, and mark numbers as non-prime:

for (int p = 0; p < primes.count(); p++) {
for (int i = primes[p]; i < 100; i += primes[p]) {
numbers[i] = notPrime;
}
}


So the first iteration will go through:
2, 4, 6, 8, 10, 12, 14 ...
The second will go through:
3, 6, 9, 12, 15, 18, 21...
The third:
5, 10, 15, 20, 25, 30, 35...
Fourth:
7, 14, 21, 28, 35, 42, 49 ...

Now you can see why it's not O(n).
>>
>>61997663
>Python would be ideal for this, but I really hate that language. Most of the hate comes from dynamic typing though
i hear that. i'm not a fan of either. i like C# for "i don't wanna write that as a bash script and C++ would be overkill" territory. it's high-level, statically typed, garbage collected, with a solid and pretty broad standard library, pretty decent selection of third-party libararies, while still supporting value types, allowing unsafe code (pointer arithmetic, unsafe casts, etc) if you need it, has good C ABI interop (and even C++ with CLI/CLR), easy binding, etc. so it's simple when it ought to be, but robust when you need. great for things like tools, testing, automation, etc (especially alongside C/C++ projects, if that applies to you). maybe try it on for size with another RSS downloader, haha
>>
>>61997900
>magic number 10 = sqrt 100
Surely just about any compiler will manage this 100% of the time.
If you pull it out of the loop it absolutely should.
>>
>>61998182
That's just me being lazy not me trying to be smarter than the compiler.
>>
>>61998195
I don't see how that's lazy. And I certainly wouldn't encourage anyone to not try to be smarter than the compiler. They're very dumb a lot of the time. I just wanted to point out that they're probably smarter than this. If not that's a compiler bug rather than a implementation limitation.
In case you were needlessly cautious.
>>
>>61997663
>python would be ideal
You can try something like Go instead.
>>
>>61998085
C# is a great all-round language. I used to avoid it like the plague because of Mono, but .NET Core looks like it finally has proper Linux support. I still prefer the JVM though and that's because I've been a Java dev for 5+ years.
>>
File: 145237293798.png (65KB, 826x1030px) Image search: [Google]
145237293798.png
65KB, 826x1030px
What are the most cyberpunk languages?
>>
>>61998334
Common Lisp. Literally used by MIT hackers.
>>
>>61998334
J is kawaii
>>
>>61998227
I did try Go and it was a waste of time and effort.
It took me an afternoon to become productive in the language. My first project was the notorious RSS downloader and it went really well. The second project was a Dropbox clone.
I knew from the start that it didn't have generics, but I was ignorant and took the bait. It didn't take long for me to realize how important generics are in a static typed language. What a terrible mistake. I also noticed a lot of
if err != nil {}
noise in my code. I read up on it, but apparently it's idiomatic.
TL;DR Python > Go
>>
>>61998334
Fortran
>>
>>61996698
>>61996767
Thank you!
>>
Can we all agree that if you're a beginner and want to get into programming, the best language to learn is Java.
>>
>>61998447
I don't see why everyone complains about
 if err != nil;
. What kind of error handling model would you prefer, exceptions?
>>
>>61998486
ADTs
>>
>>61998486
Actually, exceptions are even better than Go's way of error handling.
I like how Rust handles errors with the Result and Option type.
>>
>>61998501
Too complicated for brainlets, Go's demographic.
>>
>>61998486
use monadic composition
>>
>>61998485
If you want to get a job, yes.
>>
>>61998261
>I used to avoid it like the plague because of Mono
haha yeah, that's fair

>.NET Core looks like it finally has proper Linux support
yeah, i'm happy about that. damn shame they didn't take this approach to begin with. things probably would have gone pretty differently. though actually, C# is getting pretty popular in the triple-A lately, largely for the reasons i mentioned before. i know people at some big-name game and software companies where they use it for all their tools, testing, automation, asset pipelines, and internal (and sometimes external) servers, even though their main public-facing product/service is in another language

>I still prefer the JVM though and that's because I've been a Java dev for 5+ years
fair enough. most projects would look extremely similar in C# and Java, anyway. i just advocate for C# because if you look up the differences between them, you'll notice it's basically just a list of things C# supports and Java doesn't, and in my personal experience, there's been one time or another where almost everything on that lists has saved the day (the old "sometimes you don't know what you're missing until you need it"). but to be fair, my experience with C# has been largely niche/nontrivial. i definitely can't say everyone would have the same experience
>>
>>61992373
I don't quite believe that max2 could be faster. Looking at the instructions, both have a cmp, followed by a conditional instruction (which means bubbles). cmov isn't that much slower than setg, and max2 has more to with those involved registers after the condition.

Personally instead of a hacked-together benchmark framework I'd rather see the output of perf.
>>
This is the class I have:
class Foo
{
Foo operator-(const Foo &rhs);
}


Why can't I perform the following?
Bar::setPosition(const Position &position)
{
Position delta = position - this->position;
}

this->position is a Position (no const, no nothing).

The compiler gives me the following error (on this->position):
error: passing ‘const MyNamespace::Foo’ as ‘this’ argument discards qualifiers


What am I not understanding?
>>
>>61998554
From my experience, C# is used quite a bit in companies that focus on Windows centric software. It wouldn't suprise me that game studios use it for everything that doesn't require to run soft-realtime like games. Doesn't Unity use C#? It's also used a lot for backends because of Azure.
>>
>>61998639
>Bar::setPosition(const Position &position)
It should be
Bar::setPosition(const Foo &position)
>>
>>61998639
Add const to the the prototype of Foo::operator-
Foo operator-(const Foo &rhs) const;

That means that it can be called on a const Foo.
>>
>>61998698
Oh yeah, of course! Thanks for pointing that out for me.
>>
WHAT THE FUCK AM I SUPPOSED TO PROGRAM
>>
>>61998745
RSS downloader in Idris.
>>
>>61998745
>people who think they are programmers struggling with inane problems like what they should program
>>
>>61998753
already done something similar, just not in idris
lang doesnt matter
>>61998786
ive made compiler(to asm, not with llvm ie cheating, but is buggy), ML framework, chess ai and a hundred minigames like sudoku, mazes, snake and so on
these are from the /g/ prog. challenges

i want something to do
>>
>>61998810
Join a project.
>>
https://dev.to/kataras/go-vsnet-core-in-terms-of-http-performance
don't use iris, though
>>
>>61998651
>From my experience, C# is used quite a bit in companies that focus on Windows centric software
well, that too. but it also applies at many companies i wouldn't necessarily call Windows-centric. sure, the internal dev machines may often run Windows, but their primary/defining product/service is often multiplatform. i even know a guy who works on a well-known multiplatform game where (as mentioned before) they use C# for all their tools/testing/automation/pipelines/etc. but more interestingly, while the game client is (unsurprisingly) written in C++, the game server application is actually written in C#. i'd not heard of that before. maybe secondary servers for user data/matchmaking/telemetry/etc, but not the actual game server itself for a game with a native client. kinda neat

>Doesn't Unity use C#
yeah. unity is garbage though (but not because of C#). i could go on for days about that
>>
why dont you friends make a /dpg/ discord so i can spam questions :^)
>>
>>61998745
I have the same problem, but tell us your interests so we can recommend you something.

On the top of my head, you could make a command line program that applies DSP algorithms to images (filters, convolution, etc). You could even embed a small interpreter in your program to apply an arbitrary number of algorithms to an image during each execution.
I think I'm going to do this in C or C++ actually.
>>
>>61996021
use golang

>>61995699
read the syscall manpage
>>
>>61998898
>the game server application is actually written in C#
I'm no game dev, but why is that suprising? AFAIK servers need to handle many clients at once, but don't have to thrive in single threaded performance. C# is an excellent choice for that.
>yeah. unity is garbage though (but not because of C#). i could go on for days about that
I thought game devs orgasm when you mention Unity. Our company switches focus from mobile development to Unity development. They make a small fortune on programs you click together. Insert AR module, buy assets and you're done.
>>
>>61995699
IIRC that's the the file descriptor you are writing to. 1 for stdout, 2 for stderr and so on
>>
>>61997691
>not knowing ; can signify an empty statement
begone pajeet
>>
>>61999028
hello rajesh
>>
>>61999076
120 / 1.5 = 80
>>
>>61999123
yes my bad
>>
Monads add noise too
>>
What are some good and free online courses for Algorithms and Data Structures?
>>
>>61999140
if you think code is noise
>>
>>61999140
t. programlet
>>
File: bait-but-also-true.png (17KB, 522x384px) Image search: [Google]
bait-but-also-true.png
17KB, 522x384px
Reminder
>>
>>61999291
JAVA
>>
File: result.jpg (40KB, 500x666px) Image search: [Google]
result.jpg
40KB, 500x666px
>>61998929
already done something like that - just in a simple way and it's just a script, not a full CLI tool
here's a picture of lily labeau 'embossed'
whatever that means - i dont quite remember

i also have a blur, a left sobel, a right sobel, sharpen, outline, top and bottom sobels funtcions

did it in python
>>
>>61999307
Also falls into the Neither category
>>
Imagine using a statically typechecked language without parametric polymorphism
>>
>>61999291
>Go
>not good performance
I feel bad for you
>>
>>61999363
https://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=go&lang2=gpp
>>
File: result.jpg (24KB, 500x666px) Image search: [Google]
result.jpg
24KB, 500x666px
>>61999314
and heres the blur
the script only works with black and white pics though
>>
so which is it /g/:

substring(string, startingIndex, numberChars)

or

substring(string, startingIndex, excludingIndex)

?
>>
>>61999482
substring(string, startingIndex, excludingIndex)
where te excludingIndex is optional
>>
>>61999146
https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/
i haven't used it myself but this looked alright
>>
>>61998992
>why is that suprising?
i hadn't personally heard of any game doing it that particular way before, but i don't know everything. i was mainly surprised because of how large-scale a game it is, and because i know that for the kind of game it is, the servers have a lot of work to do. in a networked game with a client-server model, depending on the nature of the game, the server generally needs to do a lot more CPU work per frame than a given client. not to mention you want to keep things fast because you're already having to pay a baseline time cost for network latency even in the best of cases, and delay from the server negatively affects every player, moreso than any given client could. so you could make the case that server performance is (at least in a sense) more important than client performance. it works in the case of this game because the servers are all run by the company, and they can afford to build and maintain a bunch of beefy-ass server machines. but if you were developing a game where you distributed the server application to let users run third-party servers, potentially on much more consumer-level hardware, a language with higher overhead may not necessarily be the best call given you wouldn't know if you actually had the headroom to spare
>>
>>61999511
i have used that course
i learnt a lot
>>
File: i shig at you jerry-kun.jpg (86KB, 600x649px) Image search: [Google]
i shig at you jerry-kun.jpg
86KB, 600x649px
>>61999482
string[startingIndex:excludingIndex]
>>
>>61999583
I think you're underestimating C#.
A properly configured and hot JVM is as fast as -O2 code if not faster.
>>
>>61999346
imagine parametric polymorphism without rank n polymorphism
>>
>>61998486
I like it.
It's a nice and clear syntax with the correct amount of context passing. Exceptions add unnecessary complications.
>>61998485
No. Why do you say that? It's an awful language which forces you to learn about tons of language specifics. Even C has you learn less language specifics than Java.
We need an esperanto of programming languages.
>>
>>61992350
you mean on the test server or on a deployed on? you have to set up apache right
>>
>>61999999
>>62000000
don't mind me, thread reaching bump limit anyway
>>
>>61999488
>excluding index optional
This. This is the best.
>>
New thread:

>>62000152
>>62000152
>>62000152
>>
>>61998992
>I thought game devs orgasm when you mention Unity
hahaha. publishers? sure. art school dropout amateur indie devs? sure. actual game devs? no way. people like it because you can use it to put out a pile of shit and make a quick buck. it's flooding the market with absolute garbage. if you have any kind of respect for the craft, it's just insulting. it runs like absolute shit for what it is, and from the other devs i've talked to about it (ones who knew what they were doing), getting it to perform more in the neighborhood of what it ought to is generally a matter of working *around* it rather than *with* it. that's the opposite of how an engine is supposed to work. and games are supposed to perform. lowering settings is supposed to actually improve performance somewhat proportionally. and hell, it seems like most indie unity devs live in a bubble and never once even tested their game on anything other than a high-end machine. if your game has the visual fidelity of fucking crash bandicoot it, then really it ought to be able to run on an old intel chipset, but i'm seeing games like that that can't maintain a framerate on a machine with an i7 and dedicated GPU. it's partially a sympathy thing; i grew up with pretty weak machines so i was always psyched when i was actually able to run a game, and i know there's plenty of people around the world now in the same boat, and considering i actually give a shit about my work, i want as many people as possible to be able to enjoy it if they want to. but even if you're the coldest capitalist in the world, you'd have to be stupid not to realize that those people are potential customers. all that aside, it's mostly just passion for my craft. optimization is part of the job. technical innovation is part of the job. paid plugins for fucking A* pathfinding (something for which there are tons of comprehensive articles explaining exactly how to do freely available online) is not equipping people to be good developers
>>
>>61999384
Make it a gimp plugin.
>>
So, it even possible to get a job programming with no CS degree? Sorry if this is a newfriend question, I'm just really curious whether the whole "I got a job with no CS degree just hard work and determination" posts you see on sites that aren't 4chan are just complete crocks of shit. It really feels like the only way to pass through HR filters is a BS degree in computer science.
Does anyone have any kind of experience with this sort of scenario?
>>
How to use code tags here?
>>
test
>>
 std::cout < test << std::endl 
Thread posts: 318
Thread images: 21


[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.