[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: 320
Thread images: 30

File: 1484950409106.jpg (785KB, 1520x1080px) Image search: [Google]
1484950409106.jpg
785KB, 1520x1080px
What are you working on, /g/?

Old thread: >>58838969
>>
first for TRAPS!
>>
>>58842169
template raw asynchronous programming system?
>>
File: Bw-r_1RIAAAaf3O.png (2MB, 2048x2048px) Image search: [Google]
Bw-r_1RIAAAaf3O.png
2MB, 2048x2048px
>>58842148

this would be a better thread if SOME PEOPLE didn't try to program with

BIG

MEATY

JAVA
>>
>>58842191
No one does though.
>>
File: why would you compile that.png (248KB, 819x466px) Image search: [Google]
why would you compile that.png
248KB, 819x466px
>>
>>58842185
you know it!
>>
game cheats (CS:GO)
>>
>>58841757
Your computer is not a Turing machine, bra.

https://en.wikipedia.org/wiki/Turing_machine
>A Turing machine is an abstract machine[1] that manipulates symbols on a strip of tape according to a table of rules.
Note 'abstract'.
>The machine operates on an infinite[4] memory tape divided into discrete cells.
Note 'infinite'.
>>
>>58842191
well, you don't need to have Thread with java, you just need to
implements Runnable
>>
>>58842148
thank you for using an anime image
>>
Demo part for c64... I got a techtech scroller running and need a second part... some text zoom with sprites maybe.
>>
>>58840576
Could you actually give any examples on just how much of a performance gain did you get by switching to C++? What sort of program is it, and what parts had the biggest differences in speed?
>>
>>58842324
200%
>>
>>58842324
20% to 50% I'm not even joking desu
Compilers are shit
>>
>>58842324
It gives you +10 performance.
>>
File: 1484525100634.jpg (18KB, 291x343px) Image search: [Google]
1484525100634.jpg
18KB, 291x343px
>year 2017 of our lord Jesus Christ
>logic programming is useless outside of specific domains
>computers don't solve problems on themselves
>fifth generation computing project was a mistake
>>
>>58842357
Logic programming is coming. Check out the Berkeley Orders of Magnitude stuff.
>>
>>58842347
That's too vague.

What is your program doing? Is it a game? Processing strings? Audio/Video?

What exact parts actually benefited the most from the switch?
>>
How to get a gf?
>>
>>58842357
Prolog came and went.
>>
>>58842347
when going from c++ to c you should get almost no improvement, but when going from c++/c to assembly you could get a small improvement, but I don't think thats worth the extra effort
>>
>>58842426
Prolog is incredibly ugly. I'm not surprised it tanked.
>>
>>58842425
sudo apt-get gf

or
sudo yum-install gf

should do the trick
>>
>>58842231
From the fifth paragraph of the very article you posted:
>A programming language that is Turing complete is theoretically capable of expressing all tasks accomplishable by computers; nearly all programming languages are Turing complete if the limitations of finite memory are ignored.
>>
File: crack.jpg (37KB, 350x499px) Image search: [Google]
crack.jpg
37KB, 350x499px
Worth it?
>>
>>58842445
>you could get a small improvement
you can get considerable improvement depending on specific task and platform
>>
>>58842476
I didn't say anything about languages, derp.

Furthermore, with respect to your unrelated post:
>if the limitations of finite memory are ignored
>>
>>58842478
You'd probably be better off with Skiena.
>>
Is Clojure worth learning/experimenting with?
>>
File: microexpressions-disgust.jpg (28KB, 524x336px) Image search: [Google]
microexpressions-disgust.jpg
28KB, 524x336px
>>58842445
>he doesn't know
>>
>>58842575
>JVM
It's garbage.
>>
File: Clrs3.jpg (50KB, 420x475px) Image search: [Google]
Clrs3.jpg
50KB, 420x475px
>>58842478
This is better. Learn to code, not to try to cheat interviews.
>>
>>58842575
Better to use CL, Racket, or Scheme if you want to learn a Lisp.
>>
>>58842581
What would you recommend as an alternative for a modern lisp that focuses on immutability?
>>
>>58842602
Scheme or Racket.
>>
>>58842594
I'm currently doing SICP and I was wondering if it's relatively easy to switch to CL later if I feel like it?
>>
File: pepet.png (525B, 64x64px) Image search: [Google]
pepet.png
525B, 64x64px
>>58842584
which algorithm is the most essential besides the obvious ones you can figure out for yourself
>>
>>58842634
All of them.
>>
>>58842634
hash map is the only relevant data structure
>>
>>58842478
>Worth it?
No. Interviewers aren't looking for a perfect answer, they're looking for how you tackle problems you've not seen before, how you think, and whether trivial unexpected shit stops you in your tracks. You get exactly fuck all help with any of those from cramming a book.
>>
int * p = new int[somenumber]


i have this array. i want to create a couple threads and then tell each thread to work on a range of elements of that array. for example, one thread is supposed to work on the first half of the array and the other thread is supposed to work on the second half of the array. i'm gonna give each thread the pointer to that array like so

void somefunc(){
threadclass thread_01(p, size_t start, size_t half);
threadclass thread_02(p, size_t half+1, size_t end);

thread_01.work();
thread_02.work();
}
//----------------------------------------------
class threadclass{
int* p;
size_t from;
size_t to;

threaclass(int* ptr, size_t f, size_t t){
p = ptr;
from = f;
to =t;
}

public void work(){
for(size_t i = from; i < to; ++i){
p[i] = i;
}
}

}


is this gonna work or will i have to add some sort of mutex to the work function?
>>
>>58842677
go programmers pls go
>>
>>58842634
>which algorithm is the most essential besides the obvious ones you can figure out for yourself
This depends on the company.

At the company I work for we have a lot of data processing, analyzing, etc... So we need algorithms that are associated with that.
Also we need to create or own algorithms, since the field we work in hasn't many companies (that publish their results / best practices / ...)

Anyways, learning to program isn't the same as learning how to write (good) algorithms.
>>
>>58842711
Which field are you in, is it a corn field?
>>
>>58842677
So.. Lets imagine you have 8 values for 1 sensor, 512 sensors per (lets call it) 'device', 4 of these devices and then you have one dataset per 0.0001s. You also have 12+hours of recorded data.
Please tell me, how a hash map can handle ANY data structure, especially the one I mentioned, please.
>>
>>58842733
>Please tell me, how a hash map can handle ANY data structure
Easily.
>>
>>58842733
You just need to set the hashing function and load factor appropriately and it will work.
>>
>>58842717
Very funny. Cancer like you should leave this thread.
>>
Daily reminder to use hashmaps for everything.
>>
>>58842733
>8 values for 1 sensor
"Values"? Bits? Bytes? Words? Floats? Doubles? Something exotic?
>>
>>58842768
rob pike pls go
>>
>>58842781
Hamlets
>>
>>58842781
8 values would be three bits worth, genius.
>>
>>58842768
>Daily reminder to use hashmaps for everything.
Not everything. There's arrays too. Arrays are great for dense int->value maps.
>>
File: portrait.jpg (19KB, 500x335px) Image search: [Google]
portrait.jpg
19KB, 500x335px
>>58842782
No.

>>58842806
There is only hashmap.
>>
>>58842806
>dense int->value maps
A lookup table is the correct term for that.
>>
Daily reminder that mutable datatypes are deprecated.
>>
>>58842815
It's not the 1970s any longer. You're going to have to get over it.
>>
>>58842815
what if i want a fibonacci heap
>>
>>58842815
>There is only hashmap.
You appear to believe it. That's even funnier.
>>
File: 4818477029_d2502b9a6f_b.jpg (234KB, 1024x683px) Image search: [Google]
4818477029_d2502b9a6f_b.jpg
234KB, 1024x683px
>>58842828
Nevaaaaar.

>>58842840
There is only hashmap.
>>
>>58842823
Making everything immutable was a temporary hack while the details of effect systems were being worked out. Now it's really not all that useful.
>>
>>58842853
You think effect systems are anywhere near ready? They're not.
>>
Sorry if this isn't the place to ask but what's highly customizable GUI with decent documentation that I can use for rendering text and images (mainly SVG)? Any language is fine and I'm on Windows 8
>>
>>58842851
what if i want a sorted map

>>58842871
emacs
>>
>>58842851
>never being able to rub that smooth bald head
why live
>>
>>58842870
Okay, let me modify that statement a bit. Even if effect systems aren't ready YET, it still means mutation isn't deprecated.
>>
>>58842900
This is a BLUE board!
>>
>>58842853
>>58842870
Effect systems are meaningless because they aren't available in C. Using them entails learning a new language that cannot be used without learning new skills on top of already knowing how to program. Any language like that is dead in the water and will be totally forgotten in a year.
>>
>>58842933
Okay well good luck using C without mutation.
>>
>>58842681
i'm just gonna try i guess, wish me luck
>>
>>58842944
There's no such thing as computation without mutation.
>>
File: 1466559848718-fs8.png (40KB, 469x428px) Image search: [Google]
1466559848718-fs8.png
40KB, 469x428px
>go to interview
>anon, what's the difference between linked-list and an array
>don't call us, we'll call you
>>
>>58842970
Well, not on von Neumann computers anyway.
>>
How can I make this python code even shorter?

from sys import argv
script, from_file, to_file = argv

indata = open(from_file).read(); open(to_file, 'w').write(indata)
print("Copied %s to %s" % (from_file, to_file))
>>
File: 1454259861244.jpg (28KB, 719x719px) Image search: [Google]
1454259861244.jpg
28KB, 719x719px
>>58842914
>implying
>>
>>58842626
You probably won't go through too much pain if you're already thinking in a Lispy style, but CL is a much larger language. Many functions in Scheme have slightly different names in CL. It's a Lisp-2 (Scheme by comparison is a Lisp-1, which means variables and functions share the same namespace). There are many other things, but you can discover those yourself. I'd say dive into CL after you read your book, as it's fairly battle-tested.
>>
>>58842982
There is no such thing anywhere in reality. Computation is a process of change. A process of change cannot happen without change.
>>
Is Norwegian useful for programming?
>>
>>58842988
>make this python code even shorter
Why do you have an indata variable?
Why do you use multi-letter variable names?
>>
>>58843006
All Norwegians learn English in school.
>>
>>58842988
perl
>>
>>58843006
It's only useful in Scandyland.
>>
>>58843006
Does anyone have a Norwegian compiler that produces even half-decent x86 code?
>>
>>58843018
Can it be made shorter than this?
from sys import argv
script, a, b = argv

open(a).read(); open(b, 'w').write(b)
print("Copied %s to %s" % (a, b))
>>
>>58843073
Doesn't really matter, it's going to be bloated as fuck anyway.
>>
>>58843073
script, a, b = __import__('sys').argv and \
open(a).read() and \
open(b, 'w').write(b) and \
print("Copied %s to %s" % (a, b))
>>
>>58843169
It's part of an exercise. I had to make this into as few lines as possible.
>>
>>58842478
Contrary to what others have said here, the book is not just a list of interview questions intended for rote memorization. The questions are supposed to be representative to give you practice answering such interview/whiteboard questions, but also gives generalized advice about how to tackle such problems. If working through it helps you get a better job or even just makes you more confident interviewing, I would think that's $20-30 well spent.

>>58842976
Maybe you should consider looking at that book too, sir.
>>
>>58843233
>python 2
>>
>>58843073
>Can it be made shorter than this?
You've changed the meaning.
>>
oi /dpt/
i'm making a scraper in C# that keeps track of 2 craigslist-likes sites, and texts me if I a thinkpad pops up under 100$

that's kinda sexy right?
>>
>>58843305
>C#
Nope.
>>
>>58843233
from os.path import exists
script, from_file, to_file = __import__('sys').argv

print "Copying from %s to %s" % (from_file, to_file)

indata = open(from_file).read()

print "The input file is %d bytes long" % len(indata)

print "Does the output file exist? %r" % exists(to_file)
print "Ready, hit RETURN to continue, CTRL-c to abort."

raw_input()

open(to_file,"w").write(indata)

print "Allright, all done."
>>
>>58843133
print((lambda _,f,t:(open(t,'w').write(open(f).read()),"Copied %s to %s"%(f,t))[1])(*__import__("sys").argv))
>>
>>58843378
beautiful
>>
>>58843321
>inb4 python

literally give me a language better for this. C# has sexy OOP to keep track of shit in non-hacky ways.
>>
give me an anime image to relieve myself.
i need to relax after a hard programming session.
>>
>>58843378
>>> from sys import argv
>>> a,b,c = argv
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: need more than 1 value to unpack

>>
>>58843430
golfed and bad for debugging****
>>
>>58843455
>OOP
>sexy
>non-hacky
>>
>>58843478
what's your point, brainlet
>>
>>58843502
shut up, brainlet
>>
>>58843455
Scheme
>>
>>58843473
>>> from sys import argv
>>> a,b,c = argv
>>> a
'-c'
>>> b
'a'
>>> c
'b'

works for me
>>
Is there any reason to do:

if (foobar) {
return foo;
} else {
return bar;
}


instead of

if (foobar) {
return foo;
}
return bar;


?
>>
File: languages3.png (17KB, 522x384px) Image search: [Google]
languages3.png
17KB, 522x384px
Reminder
>>
>>58843585
return foobar ? foo : bar;
>>
>>58843585
no reason really

i like the latter
some compilers are dumb and will complain if they think the base case is unreachable in a non-void function.
>>
>>58843543
>Scheme
>FUNCTIONAL LANUGAGE

Implying I'll learn this useless meme for a scraper. you're retarded
>>
>>58843571
it doesn't work on my pc (python 2, python 3)

dafuq
>>
>>58843606
Becomes less readable (and won't fit in 80 columns) when all three are function calls.
>>
>>58843627
It's multi-paradigm, bra.

Never knew why people thinks LISPs are functional.
>>
>>58843455
Racket
>>
>>58842478
What >>58843239 said.

This book is pretty great and working through it will absolutely help you both improve and describe your thought process when being interviewed.

This book can prepare just about anyone to perform well on interviews, as long as you have a foundation in programming.

Also the questions the book uses are very indicative of real interview questions.
>>
>>58843632
like i give a fuck, you fucking nerd
>>
File: 593.gif (835KB, 480x270px) Image search: [Google]
593.gif
835KB, 480x270px
>>58842148
learning closures
https://gobyexample.com/closures
>>
>>58843631
well since argv holds the command line arguments you will not get anything in it when using the repl
I got arguments in using
python -i -c "" a b
>>
>>58843585
will compile to the same thing anyway
>>
>>58843655
>functional programming in java
>functional programming in javascript
>closures in go
>X in language Y which is totally unsuited to it
Why?
>>
File: 1460362735531.jpg (118KB, 499x389px) Image search: [Google]
1460362735531.jpg
118KB, 499x389px
/dpt/ I'm sending various types and lengths of data through a socket in a loop, I'm curious as to how I should store the size of that data. Should I keep 2 arrays, 1 with the data and the other with the size of that data
const char *x[amount]
size_t xSize[amount]

or should I keep a single array of structs that contain a void * to .data and a size_t .size?
struct x {
void *data;
size_t size;
};
struct x xa[10];

Then in socket send() cast it from void to a char.

Which (if either) is preferable? I'm not familiar with this kind of stuff yet.
>>
>>58843679
Flexibility
>>
File: muh.webm (1MB, 405x319px) Image search: [Google]
muh.webm
1MB, 405x319px
The first programming I've done outside of work for fun in over 4 months...
;_;
>>
>>58843681
you could do
struct x {
void *data;
size_t size;
} xa[10];
>>
>>58843606
how come i cant return inside a ternary
>>
>>58843679
A lot of projects and APIs only support languages like Java/Python.

Being able to write some functional expressions is valuable and efficient, and has its place alongside oop.

I swear to god /g/ has the functional fixedness of a toddler.

When actually developing things and working with people you can't compile a cross-platform application whose source has 12 different fucking languages.

Real world projects have so many dependencies and frameworks that only support large languages. Get over it.
>>
>>58843728
what you mean

ofc you can
>>
Should I learn C if I'm not planning on doing any system programming or performance critical programming?
>>
>>58843732
And what does that have to do with learning a concept? Want to learn functional programming? Java/Javascript is just going to get in the way and make it take much longer.

You can learn the concept and then apply it in a different language later.
>>
>>58843728
Which language are you using?
>>
>>58843585
>Top one
Dumb but good programming practice. But I suggest that you try ternary if your language supports it.
>Bottom one
Not only dumb but also stupid. Trait of a shitty programmer that only wants his shit to "Just work" and regrets in the long run.
>>
>>58843728
I think only expressions can go inside a ternary
>>
>>58843728
If you're talking about C or something similar, a ternary statement takes expressions as its arguments, but a 'return' is a statement.
>>
>>58843704
I'll go with that then, I wasn't sure which would be preferable for this kind of task. Thanks, Anon.
>>
>>58843732
>the functional fixedness of a toddler.
You mean like a fixed point?
>>
>>58842191
I kek'd
>>
>>58843757
I would encourage you if it's your first language, if you're fairly experienced with programming I doubt you haven't learnt C.
>>
>>58843777
C
>>
>>58843779
Why is it dumb/stupid
>>
File: 1452722428881.png (156KB, 270x270px) Image search: [Google]
1452722428881.png
156KB, 270x270px
>>58842478
>buys book
>memorizes every word
>kill interview questions
>hell yeah
>interviewer asks whether I like C or Java better
>confused.jpg
>this wasn't in book
>panic rising
>try to play it cool
>say you like your coffee black
>"hmm, alright. well it was good to meet you anon. you will be contacted in 3-4 weeks if we decide to take you"
>5 weeks later
>dammit
>>
>>58843820
>functional fixedness
see:
https://en.wikipedia.org/wiki/Functional_fixedness
>>
>>58843898
the correct answer is java
>>
how do I unsubscribe said button from this delegate?

button1.Click += delegate(object sender1, EventArgs a)


i understand i need to make a reference to the delegate and unsubscribe from that reference but

button1.Click = delegate(object sender1, EventArgs a);


doesnt work
>>
why does C feel so comfy.
also, can you do functional C easily?
>>
>>58843455
Don't listen to those retards, C# is literally the best language for almost everything apart from the MOST performance critical shit, if you're on windows.
>>
>>58843934
java is not the correct answer
it's frequently a passing one though
>>
>>58843757
Yes, c promotes actually understanding what you're doing

Maybe it won't change your life, but better understanding of what the machine is doing when you ask it to do something will help prevent you from being an enterprise tier programmer.
>>
>>58843938
for the second code i meant


MyDelegate = delegate(object sender1, EventArgs a);



my bad
>>
>>58843948
literally this
>>
>>58843944
Why would you want to.
C is so comfy because its closer to how computers work without any silly memefeatures like functional.
>>
>>58843938
Operator -=
>>58843944
Because C is small and simple, aka cute. I don't use it anymore tho :^))
>also, can you do functional C easily
I just did callbacks once, though didn't knew anything of FP.
>>
>>58843948
this:
c# is an incredibly optimized language on windows, any large-scale development should be done in this language.
>>
Trying to think how to assemble skills programmatically in my bullet hell engine.

Maybe someone has a better idea? I think this sucks.

Skill sk = new Skill(source, target);

SkillCommand.SpawnCircle c1 = new SkillCommand.SpawnCircle();
c1.radius = 500;
c1.holdDuration = 1500;
SkillCommand.HomeIn c2 = new SkillCommand.HomeIn();

sk.addCommands(c1, c2);
>>
>>58843934
>the correct answer is java

>I write enterpriseâ„¢ level code

If you want to write shit for a shit company. If you want to write good code for a better company you had better say c.
>>
double sqrt(double n) {
double result = 0;
__asm__(
"fldl %1;"
"fsqrt;"
"fst %0;"
: "=g" (result)
: "g" (n)
);
return result;
}

Doesn't work in g++. Says invalid instruction suffix for fld, operand type mismatch for fst. That is, if I remove the space before the second g to make it this far.

Double n is already declared at the top... Not sure what's going on.
>>
>>58843921
I can't be bothered to Google that image of the joke going over the stick man's head.
>>
>>58843950
Most corporations don't have time to deal with the literal dipshits who insist on doing everything in vim, think abstractions are dumb, and spend hours of their day fanaticizing over meticulous little details like memory-optimizing a fucking string as an array of characters, or using static arrays because dynamic lists are too inefficient
>>
File: Missed the Point 02.jpg (12KB, 424x335px) Image search: [Google]
Missed the Point 02.jpg
12KB, 424x335px
>>58843921
>>58844008
I got you senpai
>>
>>58844008

>>58843820 Isn't a joke, there's nothing clever about it, it's just someone saying dumb shit.
>>
File: 1459238258189.png (413KB, 800x1000px) Image search: [Google]
1459238258189.png
413KB, 800x1000px
>>58844020
>he wants to be a code monkey writing bloated garbage that nobody wants for an oppressive megacorp

Lmaoing at your life
>>
File: 1485717019861.jpg (50KB, 640x480px) Image search: [Google]
1485717019861.jpg
50KB, 640x480px
>>58844020
>meticulous little details like memory-optimizing a fucking string as an array of characters, or using static arrays because dynamic lists are too inefficient
>>
>>58844020
In the end it doesn't matter what editor or ide you use.
I use gvim in spare time the rest in qtcreator.
>>
>>58844048
>Anonymous 02/07/17(Tue)17:27:17 No.58844044â–¶
>>>58844008
>>>58843820 Isn't a joke, there's nothing clever about it, it's just someone saying dumb shit.
>he wants to be a lonely, average-intellect, unemployed 20 year old who sits in his childhood bedroom with anime figurines showing off how elite he is for writing rudimentary low-level code in vim, and does this every day till he dies, without ever producing anything worth half a shit
>>
If you write Java, and use the word "clazz", ever, I hate you.
>>
>>58844065
it totally does.

In an enterprsie environment there are complex debuggers, gigabytes of dependencies, code reviews, a check-in system, etc.

You cannot possibly keep up if youre using vim in your cute little terminal, still entering console commands to compile every time
>>
>>58844034
Yeeeeahbuddy.
>>
>>58844002
try this function see if it works
int square(int i) {
asm("mov %rdi, %rax\n\t"
"imul %rax, %rax\n\t");
}
>>
why should i buy a url if i can just use tinyurl
>>
>>58844105
yeah ok anon

maybe you'll get a code job someday
>>
>>58844150
Why should i get a girlfriend if i can just masturbate?
>>
>>58844105
that's only codemonkeys
actual architects use vim
>>
>>58844105
>check in system
>code reviews
>debuggers

What in god's name is stopping you from just running those separately

Most every place I've heard uses git, mercurial, or svn including microsoft for 300gb of windows source code. All of those are separate tools that some ide's have little buttons you can click on to run commands for them automatically.

The same goes for debuggers. It isn't as if the company is going to force you to use a specific debugger. They might promote one, but they can hardly stop you from using something else if you want.

The code review is hardly worth mentioning. If somebody is going to jump down your throat for using a different editor on a machine only you should really be using, you need to find a different job.
>>
>>58844099
I prefer klazz.
>>
>>58842148
I did something similar to a lock-free condition variable. There has to be some locks left or it doesn't work but the lock handoff is lock-free.

https://sstewartgallus.com/git?p=linted.git;a=blob;f=src/ada-core/src/linted-wait_lists.adb
>>
>>58844195
thats your website?

hold old are ya?
>>
>>58842681
maybe now someone knows the answer? i have to build a lot of things before i can do this so it's gonna be a while before i get the answer myself.
>>
>>58844044
> there's nothing clever about it, it's just someone saying dumb shit.
Welcome to /dpt/ :)
>>
>>58844150
why should I go big if i can just be insignificant
>>
>>58844220
Yes it should work although you might run into cache performance problems because there's no padding between the areas of work and the threads have to fight over the same cache area.

The rule in C is that any separately addressable area of memory can be updated independently.
>>
What are good books for learning C#, SQL, and Ruby?
>>
>>58844506
I doubt you're going to find a book which teaches all of those.
>>
>>58844518
What makes you think I want one book for them all?
>>
File: 1311603778372.jpg (91KB, 323x323px) Image search: [Google]
1311603778372.jpg
91KB, 323x323px
>>58844518
>>
>>58844518
>books
>>58844506
Visual C# step by step, Beginning with Microsoft SQL 2012, Programming Ruby (pragmatic) and the one from O'reilly.
>>
>>58842733
>ANY data structure, especially the one I mentioned
>doesn't mention a data structure
m8...
>>
>>58844672
dude...
>>
>>58842711
>webshit
gtfo
>>
>>58843976
>Because C is small and simple, aka cute.

I started with Python and now I'm learning C. I'm getting this feeling already - like always starting with main(). Simple shit. I like minimalism so C is feeling comfy so far.
>>
>>58844695
>NEET
gtfo
>>
>>58843002
REKT
>>
>>58844276
what would be a better way? should i have the threads create their own int arrays, return a pointer to those and then just work with a couple of smaller arrays instead of one big one?
>>
>>58844730
It's fine. You just might want to add a bit of padding.
>>
>>58843948
>everything
great
>apart
anon...
>>
>>58844775
i don't really understand this padding issue, i'm not very experienced with c++

are you saying that my array should be bigger than required and instead of iterating from, for example, 0 to half, i iterate from 0 to half-50 and from half+50 to the end?
>>
Will Rust ever add OOP? I just wanna be safe before I start learning right now.
>>
>>58844840
It depends on how you define OOP.
But I'm pretty sure it's not going to add Java-level bullshit at any point.
>>
File: combined.png (185KB, 1361x663px) Image search: [Google]
combined.png
185KB, 1361x663px
>inb4 Java
I know.

Anyways, I'm being asked to calculate the perimeter and area of a triangle using a Point type and it's gotten pretty fucking confusing.

I have the point type working in another class but now I just don't know how to set the equation up (can't use math in Point and can't convert double to GeometricType) and how to get it called and printed.
>>
>>58844856
OOP is defined simply as OOP.
Is it at least 100% optional?
>>
File: 1402886051076.jpg (126KB, 856x704px) Image search: [Google]
1402886051076.jpg
126KB, 856x704px
>>58844859
>RectangeFromSimpleGeometricObject
>TriangleFromSimpleGeometricObject
You can't make this shit up.
>>
>>58844712
Until you need to do anything complex with it, then you won't like it so much.
>>
How do I create threads that have small stacks?
>>
can I get that C vs Java picture that shows a dragon kite and the differences between the two languages?

literally asking for a friend
>>
>>58844840
The only thing OOP can "contribute" to Rust at this point is inheritance, so I would say no. Rust has privacy (at the module level) and traits for static AND dynamic dispatch (i.e. better than interfaces), what else is there?
>>
>>58844881
As in, the segregation and encapsulation of state into units, that communicate with each other via messages?
No, it doesn't do that shit.
>>
>>58844882
I lose points with anything else.
>>
>>58844898
If you define "contribute" as "make shittier" then yeah. I just want to know it won't add any OOP bullshit in the future.
>>58844904
Yeah, thanks.
>>
>>58844887
Threads usually have smaller stacks to begin with.
However, there is shit like pthread_attr_setstacksize.
>>
>>58844916
Rust is a very procedural/functional language, you don't have to worry about that changing.
>>
File: 1363164395711.jpg (28KB, 500x600px) Image search: [Google]
1363164395711.jpg
28KB, 500x600px
>>58844891
>>
free will is an illusion
>>
>>58844859
What a clusterfuck, I'm just going to say you're doing everything wrong unless you're trying to emulate pajeet code
>>
File: 4k.jpg (584KB, 3840x2160px) Image search: [Google]
4k.jpg
584KB, 3840x2160px
>>58843073
>a is 8 GB file
>>
>>58844933
yeah I have a pajeet professor
>>
>>58844859
usually you use the Math class why are you using point wtf? lol
>>
>>58843991

Component entity system with some sort of variation of the observer pattern for interactions is a pretty standard way of doing this.
>>
>>58844859
what
why would it be wrong to just do this

PointClass{
public float x = 0f;
public float y = 0f;
}


and then have a triangle be a class holding 3 points and some function which do math on those points?
>>
>>58844970
>>58844977
I got in an argument with my professor today because I was trying to use a math class.
>>
>tfw dont know everyhting there is to know
>>
>>58844971
That sounds awful. What the fuck happened to structs and functions?
>>
>>58844998
OOP
>>
>>58844983
What did the professor say? Why does he want you to do it like that?
>>
>>58844998

Modularization, scripting systems, and using one code base for multiple game projects kinda made the extra overhead / complexity necessary to meet flexibility / budget requirements. Just using structs and functions tends to make you mass produce the same functions or code sections en masse.
>>
>>58845064
And using dynamic shit and callbacks leads to code that cannot be reasoned about nor run efficiently.

That may be an industry standard where you need a dozen sleep deprived slaves to work on anything at a given time but I don't think it's appropriate advice to give a normal hobbyist or amateur.
>>
>>58844983
side = p1 - p2;
sidelength = sqrt(side.x * side*x + side.y * side.y)

do this for every side

https://en.wikipedia.org/wiki/Methods_of_computing_square_roots
>>
>>58845041
>he

It's a female from SE Asia. I think she's trying to get us into abstract classes but I don't really see what she's going for. I must use the point classes because making a triangle with side instead of vertices is unacceptable.
>>
File: 02-08-03-36-43.png (23KB, 782x518px) Image search: [Google]
02-08-03-36-43.png
23KB, 782x518px
>>58844859
This is exactly the same as your code, just in C#. (It's still an absolutely garbage way to solve this "problem")

I feel sorry for you, that this is what you're being taught.
>>
>>58844884
don't worry, I'm not learning C so I can use it in production. Only to get a better understanding of how things work. After C I'll do C++
>>
File: distance.png (15KB, 888x100px) Image search: [Google]
distance.png
15KB, 888x100px
>>58845093
I already have this.

>>58845115
God, that looks so much cleaner.
>>
>>58845115
You can't use the math class remember

>>58845113
It doesn't make any sense that is not how you learn abstract classes properly
>>
>>58844921
Yes but how does pthread set the stack size at the kernel level?
How does the stack size of the main thread get set? There's no pthread involved...
>>
>>58845148
I try to teach myself everything and I have a pretty ok understanding of OOP and Java from books and Udemy. It's just this fucking professor who is making me lose my mind.
>>
>>58844859
I thought the Java memes were just memes until reading this

>>58845174
normally any good professor would allow you to use math class but they would still structure solving the problem in the same way of having a triangle class with constructors of side or point and a perimeter method and having to create an object of it in the main class
>>
This thread is shit now. Someone should make a new one.
>>
>>58844838
Thread 1 uses data from 0 to 30. Thread 2 will use data from 30 + n to 60 + n with n bytes left free for padding.

>>58844887
The memory is lazily mapped in. Don't use it and it won't take up space.
>>
>>58845091

The first part of your reply depends on the manner of implementation and programmer maintaining / using the code base it's highly subjective.

All techniques have their own set of pros, cons, and gotchas it's a matter of discernment on the progammer's end if the technique and it's implementation is maintainable . You personally may find that sort of method to be hard to follow and inefficient. However, that doesn't necessarily mean it is a true statement for everyone.

As for the second portion of your post why not contribute your own view point and appropriate advice for a hobbyist or amateur?
>>
>>58845232
I already did. Structs and functions. It doesn't get any more straightforward or efficient than that. If you want to reuse fields and related code, you split them off into their own structs (components) and functions (systems).
>>
>>58845226
>The memory is lazily mapped in.

So it depends on the memory being in high addresses commonly associated with stacks (as opposed to heaps/.bss section)? I just start using it and rely on the kernel to implicitly mmap it?

Does this mean it's possible to allocate a stack without making any system calls explicitly? (Portability doesn't matter I only care about linux)
>>
is Java a meme?
>>
>>58845263
Do
char my_stack[8 * 4096]

and it will be allocated in the .bss section lazily. However, note that it will lack guard pages.
>>
>>58845294
That's static allocation. I've done that once to provide a backup stack for a signal handler.

Is it possible to allocate a stack for a thread at runtime without any systemcalls?

It seems GCC, Go and Rust either have or had implementations of split stacks, where threads were spawned with small stacks and then allocated new blocks all the time as they needed it. How did they do it? Did they just mmap it in?
>>
>>58845261

I guess my problem here is in the cases I have seen just structs and functions used it ended up as either reinventing the wheel to make a similar system or make a exact duplicate of the system I recommended or it quickly became a mess of repeating the same code constantly with disorganized random bits of hacks to glue things together.

In the long run the ansi c code bases I've seen solving these types of problems actually ended up being harder to maintain and reason about later in their life cycle. As I've stated though this is a very subjective topic of discussion so mileage or usefulness may very.
>>
>>58845383
>C
Well, yeah, go figure. I'm talking about doing it in a language with actual features like generics.
>>
>>58844927
Do you have more like this, anon? I had a giggle
>>
>>58842497
>I didn't say anything about languages, derp
The original post said that CPU instruction sets are turing complete, which is generally false, since registers capable of holding dereferencable pointers are bounded in size.
This similarly makes C without a standard library turing incomplete, since pointer types must have a fixed size, and all stack variables must be able to be taken reference to.
>>
>>58842148
>lain.jpg
Thanks for using it.
>>
>>58845450
Quite right, but he was back trying to insist that computers were Turing machines.

I just had to shit on that.
>>
Lets make Java great again
>>
>>58844105
I write code in VIM. I configured it to automatically check for syntax errors. Then I configured it to automatically perform style checking based on my company's standards. After that I setup a debugger that I run outside of VIM.
>>
why does couting a char array output the following

"the actual string and also â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• ..."

to the limit of the char array?

Is there a way to remove these extra chars?
I've tried initializing the array to 0,
tried converting it to a std::string

What do you guys think?
>>
>>58845508
Because you forgot the null terminator.
You're literally reading into uninitialized memory.
>>
>>58845115
That font would be nice if the glyphs were a little wider.
>>
>>58845508
c++ btw
>>
Can anyone help me with regex? Needs to be only uppercase, lowercase, numbers, dashes. Needs exactly 2 dashes, and they cannot be at the beginning, end, or consecutive. Any help would be appreciated.

only have this so far : [A-Za-z\\d]+[-{2}]
>>
>>58845473
But computers are turing machines, as far as anyone doing anything useful is concerned. It's similar to how in physics you commonly take something that is much larger/smaller than another, and you treat it as being infinite/zero, as this simplifies the mathematics and leads to a result that is extremely close to the "actual" value (had you taken negligible measurements into account).
For instance, you would never actually put every 2^40 states of a 32 bit machine into a deterministic automata.
>>
what makes you REEEEE the most about programming?

I will start when you can't figure out how to solve a specific problem
>>
> MTG is Turing complete
>>
>>58845538
Your computer is not a Turing machine, bra.

https://en.wikipedia.org/wiki/Turing_machine
>A Turing machine is an abstract machine[1] that manipulates symbols on a strip of tape according to a table of rules.
Note 'abstract'.
>The machine operates on an infinite[4] memory tape divided into discrete cells.
Note 'infinite'.
>>
>>58845569
what is MTG?
>>
>>58845577
magic the gathering
>>
>>58845575
You didnt even read my post
I have a feeling you dont know what youre talking about
>>
>>58845517
so append after my string a '\0' char? just reading up on it now.
>>
>>58845397

:p it's game dev C has been a dominate language in the field for a large portion of it's existence. I

Actually until more recent times in many game projects the use of C++ was basically limited to nearly ansi C for a lot of platforms from the heavy hardware restrictions .
>>
>>58845521
^([a-zA-Z\d]+\-){2}[a-zA-Z\d]+$
>>
>>58845596
Yes.
>>
>>58845596
yes always null terminate strings in languages without counted strings (vectors)
>>
>>58845605
Alright.
>>
Anyone else watching Handmade Hero? It's pretty interesting
>>
>>58845588
>Tfw I have an EDH deck but no one I know plays magic or wants to play
>>
>>58845593
Your post equates to 'memory is essentially infinite'. It's not, they're not, etc. Your computer is not a Turing machine, bra.
>>
>>58845621
>>58845613
thanks /dpt/
>>
>>58845621
Not everyone's counted strings are filthy vectors
>>
What's a good calculation time on creating/searching a binary search tree? My program is creating a binary tree of about 100 elements and then searching it for a few numbers in about 30 milliseconds, is that decent time or can I accomplish it faster?
>>
>>58845610
Thanks a lot mate
>>
why isn't there a program which you can use to design websites the same way you can use qt to design apps?
>>
>>58845743
There's like a dozen of them.

>apps
choke yourself
>>
>>58845743
Wordpress it will also make you lots of money I make $1200 to $1700 a week using Wordpress for the local businesses in my area
>>
>>58845685

Optimal time for a search off the top of my head is something like O(n^3) or O(n^2). Real time with creation depends a lot on what is done in the creation step and what hardware / environment it's actually being run on.
>>
>>58845752
like what
when i learned webdev for fun, i had to write everything by hand. especially the design.
>>
>>58845350
>and Rust
Are you under the impression that there is anything interesting or useful in the details of how Rust is implemented? Because that's wrong and you're an SJW and you need to leave.
>>
>>58845776
https://en.wikipedia.org/wiki/List_of_HTML_editors#WYSIWYG_editors
>>
>>58845799

Interest in the Rust language doesn't exactly imply SJW status. You can have interest in the language or its features without buying into the heavily pushed indoctrination in sjw bullshit.
>>
>>58845839
Only if you live under a rock and the SJWs were the ones who first told you about programming. All of Rust's safety features are in C++ if you just turn on ASAN.
>>
>>58845799
Of course I am. I just mentioned a feature that was present in its implementation and is also present in Go and GCC.

By the way, both Go and Rust have abandoned split stacks; they now copy the stack into a bigger buffer instead.
>>
>>58845775
>binary search tree
>Optimal time for a search off the top of my head is something like O(n^3) or O(n^2).
Uh, isn't it like O(log n)?

I don't know much about data structures and algorithms, but how can any (non-daft) search take longer than O(n)?
>>
>>58845861
>ASAN
Autistic Self Advocacy Network?
>>
>>58845861
Dude nobody cares about any SJW. Get back on topic
>>
>>58845880
Because you have to rebalance the tree when searching in it.
>>
>>58845896
But searching doesn't change it, so why would it necessitate rebalancing?

And even then, why would one conflate the time complexities of searching and rebalancing?

I was under the impression that the 'whole point' of BSTs was O(log n) search time.
>>
>>58845887
This is a programming thread. SJWs are on topic here because they are anti-merit. The only reason any of us learned to program is it makes men into gods.
>>
>>58845861
>testing instead of proving
>On average, the instrumentation increases processing time by about 73% and memory usage by 340%.
>>
>>58845916
Trees are always the wrong data structure. They degenerate into linked lists upwards of 31% of the time. Use a flat array. End of discussion.
>>
>>58845917
no most people learned programming because they either tried it out and liked it, liked computers, liked video games, or liked solving problems

take your /pol/ stuff and go please
>>
>>58845861
ASAN is a runtime debugging tool like the sort that have existed for decades; it doesn't detect errors at compile time and it introduces slowdown and depends on your program logic running down the erroneous path during testing. It's a completely separate class from Rust's compiler checks.

Also, moaning about SJWs in every post makes you sound like a moron.
>>
>>58845939
Fair enough, but that doesn't really answer any of the questions raised.

Does anyone here know enough about this topic to weigh in?
I thought BSTs were O(log n) balanced and O(n) when degenerate.
>>
the thing I like most about /dpt/ no one cares about anything else but programming everything else is ignored
>>
>>58845880

I could very well be mixing up search time with sort time.
>>
>>58845916
It is. Dunno what that other guy is smoking.
>>
>>58845961
I suspect so, because search times over O(n) is just daft, for any data structure.

>>58845972
Yeah, it sounds like he was thinking about sorting.

Unfortunately I'm more interested in PLT than data structures and algorithms, so I can't really afford to be assertive with this sort of thing.
>>
Anyone have any good resources for picking up WPF relatively quickly? I'm using it for work, and I am just barely making sense out of it right now.
>>
>>58842225
Luke, go to sleep.
>>
Why do people still mention single core-cpus?

Even phones have multicore cpus, in what scenario would i ever need to care about single core-cpus when i'm not making legacy software?
>>
Any thoughts on this shitty code?

It is for Exercism's hamming challenge. Basically you are given two strings and need compare each index and increase value of the set for each different pair.

(ie "AAGT" and "AGGT", would have a value of 1)

Here's my solution, last time someone blew my mind with a WAY simpler method.

  def self.compute(sidea,sideb)
raise ArgumentError if sideb.length != sidea.length
hamming_distance = 0
sda = sidea.split('')
sdb = sideb.split('')
sda.each_index do |x|
hamming_distance += 1 if sda.values_at(x) != sdb.values_at(x)
end
return hamming_distance
end
>>
>>58846027
because multi-threading processing is a meme and most tasks do not benefit from being multithreaded.
>>
File: a.png (1MB, 4000x4000px) Image search: [Google]
a.png
1MB, 4000x4000px
>>58842148
kruskal's method is fun
>>
>>58846027
ARM. The new chipset supports multicore though.
>>
Are lisps still relevant?
>>
>>58846117
Some girls find them cute
>>
>>58846117
Programming languages in popular use tend towards LISP over time.
>>
>>58846117
Anything dynamically typed is by definition not relevant.
>>
>>58846117
What's your definition of relevant?
>>
>>58846117
>the entire program is represented as a tree
Get real
>>
NEW THREAD!

>>58846135
>>
>>58846142
>what are ASTs
>>
>>58846117
Train timetables use CL, banks use Clojure, and a number of small businesses/startups use Racket.
>>
>>58846086
>how to fuck a woman.png
>>
>>58846032

hamming distance = population(int1 xor int2)

and population is something that has a fast bitwise algorithm
>>
File: PPp61h2.png (256KB, 666x370px) Image search: [Google]
PPp61h2.png
256KB, 666x370px
>>58842216
>>
>>58846142
Do you program in forth, or in basic?
>>
>>58846683
I'm a bit lost on that, it doesn't seem to do anything.

If I run it in irb, I get an undefined method.

Is that from another Programming Language my code is implemented in Ruby, perhaps I should have noted that.
Thread posts: 320
Thread images: 30


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