[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: 329
Thread images: 28

What are you working on, /g/?

Old thread: >>60435165
>>
Type inference is a bit of a meme desu
>>
Static typing is a huge meme
>>
File: me_irl26.png (2MB, 676x3840px) Image search: [Google]
me_irl26.png
2MB, 676x3840px
>>60442822
I really want to doll up a /g/ anon and pair program with him.
>>
File: dlang_chan.jpg (139KB, 470x545px) Image search: [Google]
dlang_chan.jpg
139KB, 470x545px
Threadly reminder that dlang-chan is not dead; she's going to have her GC tumor removed (eventually); and she's super duper cute and easy to prototype in! Say something nice about her, /dpt/!
>>
>>60442881
Static typing isn't a meme
>>
>>60442905
Then why didn't you static type your post.

Should have been
shitpost Static typing isn't a meme
>>
>>60442919
Who says I didn't
>>
>>60442944
You need to declare the type of post you are making before you post m8
>>
>>60442957
>you need to declare the type
No I don't
>>
>>60442886
To give an example, say that we initialized an instance of /dpt/ one hour since it was made on /g/; at this point, we start tracking any updates made to the thread. For our example, such data is saved:
size_t initial_ip_addrs = 20; // The number IP addresses in /dpt/ at the time of initialization
size_t total_ip_addrs = 20; // The total number of IP addresses in /dpt/. At initialization, these two values should be the same
Post[initial_ip_addrs] uniquePosters = [/* 20 random posts that were made prior to initialization */];

Now, let's say we wait an hour. After the time is up, we check those two values again:
size_t initial_ip_addrs = 20; // The number IP addresses in /dpt/ at the time of initialization
size_t total_ip_addrs = 50; // The total number of IP addresses in /dpt/
Post[total_ip_addrs] uniquePosters = [/*...*/];

Notice how
total_ip_addrs
is now equal to 50; this means that since we initialized /dpt/ and started receiving updates from it, 30 new IP addresses post in it. So when
uniquePosters
is accessed, it's going to be filled with the previous 20 random posts that were made before we initialized /dpt, and the new 30 posts that were made from each of the new IP addresses.
>>
>>60443037
The thread only keeps track of how many posters post in a thread. Not how many post each made. The thread can have 20 unique post and 50 post.
>>
>>60443056
You still can track which post was the new unique poster's post though.
>>
>>60443064
Oh yes you can. But unique poster just means new IP. When I travel to work and phonepost, I have seen my IP change at least 3 times in the same thread.
>>
>>60442893
Whaddaya want to make?
>>
>>60443071
I know.
>>
>>60443071
This procedure is only as good as the data provided. The documentation defines what a unique poster and a unique post is in its context.
>>
>>60443072
Well, there was a colleague of mine who was looking at out-of-equilibrium Mott insulator-superfluid transitions via thermal quenching and I had an idea that maybe we could characterize the universality classes of these out-of-equilibrium transitions by calculating thermodynamic limits of expectation values of the superfluid order parameters and relate it to symmetry breaking with Goldstone's theorem and Noether's theorem. He also thought that it's an interesting idea but he's already busy with referrals for the paper he submitted so he can't really start working on it before I have to leave for my PhD.
My idea is to use QCPMC to calculate approximations he's developed to the superfluid order parameter at each iterations in the finite temperature DMRG until we reach a large enough lattice size to extrapolate the thermodynamic limit.
I was thinking that I'll be in charge of general management and the more cumbersome QCPMC part of the code while the cute /g/ anon could work on the finite temperature DMRG part. If this works then there might be something that'd be named after us.
>>
>>60443161
That sounds legit. I can at most give you encouraging words and bake cookies or something.
>>
>>60443601
>bake cookies
s-smegma cookies perhaps?
>>
A website using node.js :)
>>
File: circuitgirls.jpg (2MB, 3840x2160px) Image search: [Google]
circuitgirls.jpg
2MB, 3840x2160px
/dpt/-chan, daisuki~

Ask your much beloved programming literate anything (IAMA).

>>60442897
>she's going to have her GC tumor removed (eventually)
>(eventually)


>>60442822
Please, use an anime image next time.
>>
>>60443622
If that's what you fancy.
>>
I'm coming from a Java/C/C++ background and learning Python.

I read Learn Python the Hard Way to get a basic grip of it and have been working my way through programming challenges. Where do I go to learn how to make my code more "pythonic"? I'm still using 10 lines of C-esque code on things I see other people do in 3 lines.
>>
>>60443726
http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html
>>
I am trying to implement my elevator controller code from VHDL on a FPGA board, but it doesn't work. Any ideas why?

https://pastebin.com/RgwGATTX
>>
>>60443858
>Any ideas why?
my peenus weenus of course haha
>>
File: 1486600675933.png (2MB, 1165x1740px) Image search: [Google]
1486600675933.png
2MB, 1165x1740px
>>60443645
>Please, use an anime image next time.
I got you, akari-chan.
>>
>>60443858
What part isn't working for you?
>>
>>60443950
https://pastebin.com/hNsrsKw7

I updated the sensitivity lists, yet it doesn't work on the fpga.

The states don't work properly. It enters some kind of loop.
>>
>>60442872
>>60442881
>>60442905
>>60442919
>meme
>>>/v/
>>
>>60442919
What sort of retarded subhuman language writes type signatures that way and why would anyone human ever use it or mention it here?
>>
>>60443972
Not precisely sure what's wrong as I have done VHDL in years(Really liked VHDL). But i am pretty sure 'commands' and frequency never get called as freq never gets triggered.
>>
>>60444069
What do you mean?

I'm trying to simulate post-synthesis right now,
>>
>>60444098
What I mean is this:
commands : process(freq)
-- and
frequency : process(freq, k)

only trigger when freq and in frequency's case also k changes but those never change.
>>
File: 14568627524615.jpg (27KB, 519x519px) Image search: [Google]
14568627524615.jpg
27KB, 519x519px
>>60442822
Writing a program which will take down any compiler/interpreter which doesn't do static type-checking.
>>
Somone contribute to this
https://github.com/withmetta/g_tetris
>>
>>60444261
>C++
Not a chance in hell.
>>
>>60444172
https://pastebin.com/27SBcLpU

Now the simulation works in ACTIVE HDL but not in VIVADO's simulator
>>
File: 1493970426333.png (184KB, 396x396px) Image search: [Google]
1493970426333.png
184KB, 396x396px
>>60444261
Why would I be contributing to something written in sepples? And you're probably going to license it under the G*L as well.
>>
>>60444278
The post synthesis simulation * doesn't work in VIVADO
>>
>>60444261
Trash, fuck off.
>>
>>60444275
>>60444286
>>60444316
Sorry pajeet, here is the c# version
https://github.com/withmetta/g_tetris_csharp
>>
File: 1484862720362.jpg (30KB, 425x382px) Image search: [Google]
1484862720362.jpg
30KB, 425x382px
>>60444340
Why would I be contributing to something written in *#? And you're probably going to license it under the G*L as well.
>>
>>60444340
That's literally no better.
The only acceptable languages are C and x86-64 assembly.
>>
>>60444286
>>60444349
have you ever written any code or do you just spam anime and are generally autistic?
>>
>>60444367
>code
>>>/g/wdg/
Your kind isn't welcome here.
>>
>>60444364
>x86-64 assembly
x86-64 is fucking garbage though.
>>
File: circuitgirls2.jpg (88KB, 1500x938px) Image search: [Google]
circuitgirls2.jpg
88KB, 1500x938px
>>60444389
Why?
>>
>>60444367
Fuck off, Rajesh. You sperged out for literal months wrapping your poo-in-loo "buu huuu animoooooooooo" statements in code blocks for every thread.
>>
>>60444389
I know. However, it's what you're going to need to use if you're targeting desktop computers.
>>
I'm at work and supposed to fix this but don't get it. Someone help me with this?
if ((state  == (__FLAG|__FLAG_)) && (cur->user_id = 0))
val = -AVAL;
>>
>>60444394
Too bloated and was possibly created by CIA/GNU-nigger international police.

>>60444399
>I know
Then why is it the only acceptable assembly language?
>it's what you're going to need to use if you're targeting desktop computers
Sure, but that would hardly make it acceptable.
>>
>>60444406
(cur->user_id == 0))

fixed
>>
>>60444428
No, that was on purpose
>>
>>60444451
>>60444406
Then it's impossible for that statement to be true.
>>
C has nothing to criticise and you know it
>>
File: 1485652137.jpg (50KB, 433x469px) Image search: [Google]
1485652137.jpg
50KB, 433x469px
Why do people shill C when they never even written anything significant in it?
>>
File: sicppat.jpg (286KB, 1024x768px) Image search: [Google]
sicppat.jpg
286KB, 1024x768px
>>60444582
c has a lot to criticize. its type system, for example, is really crap.
>>
>>60444634
I wrote FizzBuzz in C
>>
>>60444261
it is your?
>>
>>60444634
I have written significant programs in C. Not "50K+ SLOC" significant, but certainly well beyond trivial.
>>
>>60444634
library written in C
>can call from literally any programming language if you write small wrapper
library written in something that is not C
>doesn't comply with any standardized ABI
>requires fuck huge userpace to work
>>
>>60444649
you've got unions and structs pal, that's all you need.

va_'s if you are autismal
>>
I got 87/100 in data structures are u proud of me /g/?
also today we do hashing and hash tables
what am i in for?
>>
>>60444699
unsafe arrays
>>
>>60444730
That has nothing to do with the type system. Also, it's extremely easy to make sure you don't incorrectly access an array.
If you can't even manage that, I don't think you have any business programming.
>>
I got 60/100 overall in my Java class. :(
>>
>>60444686
>>60444690
>>60444675

t. LARPer
>>
>>60444749
>not going to exam in hungover because of last night party
>not puking at the exam
>not acing it regadless
Pajeet...
>>
>>60444770
LARP MY ANUS
>>
>>60444785
Is that an acronym?
>>
>>60442872
:^| in a strongly typed compiler type inferencing is ez

var flabbyDicks = "1";
Console.WriteLine(flabbyDicks.GetType().Name);
>string
>>
What is the difference between

struct list {
void* next;
void* data;
}


and

struct list {
void* next;
char[] data;
}


in the case I'd like to program some sort of generics?
>>
>>60444796
'1' would be char
"1" would be string
1 would be int
1.0f would be float

etc
>>
File: comments.png (11KB, 1486x575px) Image search: [Google]
comments.png
11KB, 1486x575px
Why do people comment like this?
>>
>>60444817
right you are
>>
>>60444834
because they have no valuable contributions to make to the code so they just spend all day typing asterisks
>>
>>60444815
The first is just a pointer. You would need a second allocation to store the data.
The second "extends" the struct, so by over-allocating it, you can use the space for an array.
So it would be like
struct list *l = malloc(sizeof *l);
l->data = malloc(sizeof *l->data * 10);

vs
struct list *l = malloc(sizeof *l + sizeof l->data[0] * 10);

The second performs better than the first, but it comes with some extra limitations.
>>
>>60444834
Ocaml and Lisp don't have this problem.
>>
>>60444834
javadoc style
>>
What is the purpose of embedding Lua in C/C++?
>>
>>60444865
[] vs *
they are both the same you retard
>>
>>60444875
Yeah but void* and char* are not the same nigger.
>>
>>60444848
Text editors automatically add them.
>>
>>60444875
No they're not, you stupid fuck.
In argument lists, ONE of them is the same. Elsewhere, they are different.
>>
>>60444872
making your application scriptable?
>>
>>60444815
>generics
What is a "Generics"?
>>
>>60444937

The main reason to use C++ over C.
>>
>>60444879
Who cares, you'll cast them anyways. A good rule of thumb is to only use [] for stack arrs (if you use them) and * for heap.
>>
sup cia niggers, i wanna write a compiler like dad, i have written firmware in asm, whats the easiest way to map c style syntax to blocks of asm?
>>
>>60444956
But by using sepples over C you already lose more than you could ever gain.
>>
Hello, how are structs used in C programming?
I can see their use as abstractly being a parameterised list but are they used differently in actual C programming, for example containing pointers to functions?
I tried searching quora/stackexchange but all I got was indians giving dictionary definitions.
>>
>>60444987

Unlike arrays, they can store heterogenous data. You can keep an int and a char* in the same struct.
>>
>>60444987
Think of class in any language that supports OOP.
You use struct to store the data like you would store some data in object in OOP.
Then you make functions that operates on that data, in OOP they would methods in the class.
>>
>>60444987
sometimes you have a collection of related pointers and you want to pass around a single reference to that collection?
>>
>>60444985

You don't pay for what you don't use :)
>>
>>60444956
But what is a "Generics"?
>>
>>60444987
they offer the same as classes but without all the RAII goodness so they are trash
don't use structs
>>
>>60445009
who they fuck explains structs using oop jesus christ a struct is immutable
>>
>>60445009
>Think of class in any language that supports OOP.
No.
>>
>>60445030

>a struct is immutable
c# has given you brain damage huh
>>
>>60445022

Modern programming languages support constructs that look a little like this.
template <typename T>
struct list
{
list<T>* next;
T data;
};

list<int> my_list = list<int>();


I have defined a list of some other type. That type is effectively another parameter, given when I create the list. It's typesafe and it's fast.
>>
>>60445051
i was explaining why an oop struct is different from a class you cia nigger
>>
>tfw too dumb to understand recursion immediately in some ds methods
>tfw too lazy to write it all in paper step by step
>>
>>60445075

>an oop struct
???
>>
>>60445116
just imagine a stack of paper plates full of pasta, when your function recurses you add another plate of pasta to the activation stack, the invoke pokes a hole through the plate from the old one to the new plate, the return goes the other way
>>
>>60445147
Could you do a video tutorial with real paper plates of pasta, or at least a whiteboard drawing? I understood recursion before you explained it with that analogy.
>>
>>60445129
why not, classes are too fat for something simple like a datetime or string type
>>
File: Capture.png (115KB, 868x590px) Image search: [Google]
Capture.png
115KB, 868x590px
>>60445147
i understand the idea and some easy ones like factorials and shiet but on some more complex ones I dont or dont as fast as I think I should I need some time to like think about it and its annoying
>>
>>60445187

So yeah, you are talking about C#'s structs.

Those aren't immutable.
>>
>>60445067
Yes, I know about this. But how is it a "Generic"?
>>
>>60445204

>i understand the idea and some easy ones like factorials and shiet but on some more complex ones I dont or dont as fast as meme I think I should I need some time to like think about it and its annoying

I defniitely agree that it seems overblown
>>
>>60445116
Source?
>>
>>60445259

It is not a list of anything in particular. It is a list of whatever you choose. That is how it is generic.
>>
>>60445274
why did u add meme to that
>>
>>60445280
>That is how it is generic.
That doesn't make it "a" "Generic".
>>
>>60445259
jesus are you for real, the poor nigger even gave you example code and you cant figure it out
>>
>>60445286
>meme
>>>/v/
>>
>>60445301
>figure it out
Figure what out? No possible code anyone could show me would be "A" "Generic".
>>
>>60445294

List is a generic type.
>>
>>60445309
he added "meme" to the quote
>>
>>60445206
i mean you could probably change one if you wanted but you shouldn't, like if you need to modify a field on your struct you should be using a class
the typical struct behaviour is if you are modifying a field you just return a new instance rather than fucking your struct right up
>>
What's the deal languages like x10, zpl, fortress and chapel that are designed for HPC?
Can they be used as general purpose language or are they highly specialized?
>>
>>60445323
"Generic Type" isn't a valid word.
>>
>>60444815
>>60445322
he said generics, it could be a generic method, generic class, whatever
>>
>>60445363
>he said generics
What is a "Generics" though?
>generic method, generic class
Only in an absolute shit language. I'm not even remotely interested.
>>
>>60445374
>I'm not even remotely interested.
Why are you replying then?
>>
>>60445348

Of course it isn't, it's two words. An adjective modifying noun. How's your English course going pajeet?
>>
>>60445374
why the fuck are you getting so autistic over how hes using the word then

here lets change the subject to dynamic typing
>>
>>60445385
Because I want to know what a "Generics" or a "Generic" "Type" is. None of those seem like real words.
>>60445387
>How's your English course going pajeet?
No, how is your English course going? Didn't they teach you how to space your posts properly?

>>60445388
>why the fuck are you getting so autistic over how hes using the word then
Because it's gibberish.
>dynamic typing
What the hell is a "Dynamic" "Typing"?
>>
>>60445418
ho shit how did i not see this coming
variable types inferred by the values assigned to them
>but what is a type
class, struct, primitive etc
>>
>>60445471
>variable types inferred by the values assigned to them
So something can be both "Dynamic" "Tying" and "static typing" at the same time? Hm... Doesn't sound like a contradiction at all.
>but what is a type
>class
No. A "cl*ss" isn't a type.
>>
>>60444796
>type inference
>type reconstruction
>>
>>60445471
>>60445541
That's nice, but who said it?
>>
>>60445571
Holy shit you are fucking retarded just kill yourself you fucking nigger
Why do you come here you faggot
>>
File: 1458078464167.png (191KB, 303x327px) Image search: [Google]
1458078464167.png
191KB, 303x327px
>>60445580
How do you mean?
>>
>>60444340
I was going to contribute, but you haven't written anything yet.
>>
>>60445626
>wants to contribute to c#
why don't you kys instead?
>>
File: Alpha_AXP_21064_diephoto1.jpg (216KB, 454x550px) Image search: [Google]
Alpha_AXP_21064_diephoto1.jpg
216KB, 454x550px
|0000000|00000|00000|0|00|0|000000|00000|
|opcode | re1 | re2 |0|00|i| fun | re3 | integer register

|0000000|00000|00000000|1|000000|00000|
|opcode | re1 | litr |i| fun | re3 | integer literal

|0000000|00000|00000|0000000000|00000|
|opcode | re1 | re2 | function | re3 | flaot

|0000000|00000|00000|000000000000000|
|opcode | re1 | re2 | displacement | memory

|0000000|00000|000000000000000000000|
|opcode | re1 | displacement | branch

better?
>>
>>60445626
see >>60445636
>>
Do you guys start a program by writing the code out on a piece of paper? Or do you go straight to the IDE/Vim and hope you remember everything

for small projects
>>
>>60445755
vim, never paper och whiteboard.
>>
>>60445755

For extremely small projects, I just go for it and try to write good comments.

For large projects, I use diagrams and a running log/agenda that includes notes. Anything more than a couple thousand lines is hard to walk away from and get back to without some sort of notes
>>
>>60445755
i don't start by writing code, unless the program is trivial. piece of paper or txt file with what the program will do, split the task intoto subtasks, write the code for subtasks, write tests for subtasks, plug the subtasks together. >80% of the programs i write work on the first run.
>>
anime should be banned from /g/
>>
How To Stop Worrying And Start Gitting Gud
>>
oy vey looks like (((they))) were at it again
>>
>>60445755
I am left handed so I prefer to write all my code on a text editor.

if you need the initial warm up simply comment in the code blocks that you are going to write and think out the project before you start.

Don't go too detailed with your idea, simply get your overall idea out so that you are not pivoting your project based on small road bumps when you actually start coding
>>
>>60445755
I sketch proofs of correctness on a blackboard before writing my programs.
>>
>>60446038
>I am left handed so I prefer to write all my code on a text editor
?
>>
count your process in months not weeks.
If you can make something in a month you're good.
don't expect programming to be instant.
>>
>>60446053
left handed people have issues writing because the ink gets on our hands or we dump the rings on a binder when we write. This is why left handed people prefer to type on a computer.

Some people prefer to write on paper due to it feeling more natural to them, as they have done so since they where children.

If you're writing something down to remember you should not worry about writing or typing. If you simply sit there and interact with it long enough you will remember it after a while.

You cannot remember something if you don't want to. If you are having problems focusing on a certain topic, either force yourself to do it for at least an hour with no distractions or try again the next day. If you are stepping away from the task at hand every five minutes to look at 4chan or play games you are not learning anything.
>>
>>60442491
>However, it's significantly slower than my sieve
The issue with your traditional sieve is that it has an artificial limit. You can only make the table so large. A generator can keep going and going... You might be able to implement the pi() function and use that as a bound for your tables, but it depends upon what your are trying to do. It requires extra computation by nature, and consumes more memory by nature, which is why it's slower.

>the memory efficiency is outright abysmal. 5+GIB of RAM and growing sieving 2 billion (2e9) before I terminated it. My own sieve uses exactly 981MiB sieving the same, and memory requirements don't change as array is initialized only once. I'm sorry, but I'm not impressed by the implementation.
The implementation is excellent and it's not inefficient. It just requires more memory by nature of how it functions. The next_check dict holds the the next multiple of every prime found. That's an int32 -> int32 for each prime (under 2**31). There are 50 million primes under 1 billion, so... 50e6 * (4 + 4) = 0.4GB. There are more primes under 2 billion and there is plenty of overhead, 5GB isn't unreasonable (python is what's unreasonable).

>>60442670
>This won't handle large numbers
It's unreasonable to expect this to handle very large primes, as stated by other anon.
>It also doesn't catch even numbers
What? Yeah, the first prime out of primes() is 2, and it tests for divisibility.
>uselessly checks for primality
ur dumb dude
>>
Can I apply for IT-Security with this?

#include <iostream>

class ProHaxxor
{
public:

ProHaxxor(void)
{
static int number = 23;
hack = &number;
}

void foo(void)
{
std::cout << *hack;
}

private:

int* hack;
};

int main(void)
{
ProHaxxor hax;
hax.foo();
return 0;
}
>>
I've been trying to verify the convolution theorem for a single slit. However, this is what the convolution gives me:
http://imgur.com/a/2jL5d

This is my code:
def convolution(a, b):
con = []
for _x in range(0, 500):
con.append(0)
for x in range(0, 500):
con[_x] += a[x]*b[_x-x]

return con


Code for the plot:
    pl.plot(r, conslit)
pl.title("Convolution of the single slit with itself")
pl.axis([-250, 250, 0, 25])

pl.show()


Code for the slit:

    slit = []
for i in range(0, 500):
slit.append(0)
if i > 250 - b - math.ceil(w/2) and i <= 250 - b + math.ceil(w/2):
slit[i] = h
return slit


wat do?
>>
>>60446137

Just use a biro jesus christ that was only a problem when I was like 6 years old
>>
>>60446341
>a biro
A what?
>>
>>60446384
a fucking wizard
>>
What's the best way to get a job as a Python developer?
>>
>>60446487
https://www.pythonjobs.com/
https://stackoverflow.com/jobs?sort=i&q=python
https://remoteok.io/remote-python-jobs
https://www.python.org/jobs/
>>
>>60446487
homeless shelter
>>
>>60446487
>developer
Not programming.
>>>/g/wdg/
>>>/g/sqt/
>>
>>60445755
If it's something I haven't done before I jump in and test it out in some spaghetti code monstrosity prototype just so I know I can make it work, after that I write up a quick class diagram for how shit fits together.
Only really something you'd do for a medium/small project though.
>>
>>60446523
>https://stackoverflow.com/jobs
Stackoverflow has everything doesn't it.
>>
>Chapel library files cannot be used from Chapel code.
Is it even legal to make compiler that cannot compile code to shared library and dynamically load that shared library in runtime?
>>
Give me your dad's credit card information!
def gcd(*args):
if len(args) > 2:
return gcd(args[0], gcd(*args[1:]))
(a, b) = args
if a % b == 0:
return b
else:
return gcd(b, a % b)

def lcm(*args):
if len(args) > 2:
return lcm(args[0], lcm(*args[1:]))
(a, b) = args
return (a * b) // gcd(a, b)
>>
>>60446384

Just google it you dumbo
>>
>>60447020
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>>
>>60447020

That's autism on a whole new level, that's worse than even C and C doesn't let you have classes or anything so you can't just have nice functions like
list.insert(item)
you have to have
listfunctioninsert(random memory address that you hope points to a list, item)
>>
>>60447161
No, you can abuse function pointers pretty easily to make member functions.

list.insert(&list, item);

The only drawbacks is wasting memory storing function pointers for every object created, plus, the explicit passing of the object pointer is something that C++ and other languages hide from the user.
It has the double benefit of letting you see how stupid member functions actually are.
>>
>>60445755
I start by taking notes on what it should do and how I would test it.
Often you know the popular ways to achieve minor things, so working put a scenario of what you want to test and maybe what to compare it against.
When you have that, you have parts of the interface locked down.
Then you start to write the basic structure, basically get the whole thing up and running without actually doing anything.

Eg, you want to make a vision algorithm that detects your face.
You work out how you want to test it, what should you compare it to (like what face detection data sets is already out there you can use and how are their ground truth data interfaced etc)
Then you make the basic program, open images one by one and do some manipulation, eg make all images gray scale or something.
Then you add the stuff needed to compare it to the other algorithms.
When you have this, you implement your algorithm and replace the gray scale shenanigans with your intended algorithm.
During development you can test parts of it or have other people improve other stuff, but you always have a "working" prototype.

This method is very important when you have 5 different parts that all need to work before the entire thing works.
Getting the base up and running is so valuable.
Say you are part of a team who need to make a robot that wipes the nose of someone.
The vision algorithm was just the part that detects the face, the team needs this before the project is complete.
Make a mockup which always returns a coordinate close enough shouldn't take very long but when you have that, they can continue work as if this was the measured position.

Drawing UML is nice if you have the time, but it rarely works out that way as you discover a lot of things as you start to get specific.
>>
>>60447200

They could always just add classes and shit but make them optional so that if you want to be autistic you can be without being affected.
>>
>>60447226
congratulations you've just invented sepples
>>
>>60447275

and illustrated why it's a good thing
>>
>>60447316
C++ is terrible
>>
>>60447161
>classes
>>>/g/wdg/
Fuck off.
>>
>>60447316
Does C++ still confuse compound template type operators <<<T>>> as bitshift operators?
>>
>>60447334
surely this is an issue with a specific lexer and not a language specification you goon
>>
>>60442822
How are spaces represented in C? I'm trying to parse a string given by the user to print their initials.
>>
>>60447321

Because it has things you can ignore and can refuse to use? Sure thing autist
>>
>>60447366
I'm just saying that a language with non-deterministic syntax parsing cannot be good for anyone.
>>
>>60447382
>hey i took a shit on your car if you don't like it you can just ignore that part :^)
>>
>>60447275

C++ has gay syntax though, I want the comfy syntax of C but with the ability to actually be productive in it.
>>
>>60447409

Aka java but with memory access
>>
>>60447379
By a class.
>>
OOP newb here

struggling with Qt and its glorious connect function
>>
>>60447404

Shit analogy. Your old car is still right there and you can still drive it same as always, you also have a dozen others to choose from.
>>
gonna implement opencv2 videostream to the Qt UI too
>>
>>60447095
What the fuck is this language
>>
>>60447448
>OOP
Your kind isn't welcome here.
>>>/g/wdg/
>>
>>60447451
bullshit
>make shitty language
>millions of people take it up
>now there are less jobs in decent languages
>>
>>60447471

looks like python to me senpai
>>
>>60447427
Cheeky. The end of a string is '\0', so for example I could do
 while String[n] != '\0'

Is there something similar for space? Would I just type ' ', Or is there a specific char?
>>
>>60447501
>Would I just type ' '
Yes.
>>
>>60447485
>shitty language
>millions take up
It seems there were shittier languages, if Cpp got popular.
>>
>>60447501

the null terminator of a char* evaluates to boolean false.
>>
Ha the joke is on you i don't even know how to script
>>
>>60442822
nth for Haskell is shit
>>
>>60447517
>languages only take over worse languages
Who taught you this nonsense?
>>
>>60447517
This assumes that people are deterred by shit languages, which is clearly not the case.
>>
>>60447535
In English please, doc
>>
>https://crates.io/crates/libloading
>doesn't load without javascript
Rust is dead.
>>
>>60447579
Fuck off, retard. Lurk before posting.
>>
>>60447418
>java but with memory access
So C#?
>>
>>60447418
>>60447610
>>>/g/wdg/
>>
>>60444380
>>60446660
>>60447328
>>60447479
>>60447622
Stop shitposting.

Direct someone to /wdg/ when they are literally talking about doing webdev, rather than replying with this to any post that hurts your feelings.
>>
>>60447622

>If it's not functional autism it's not programming
>>
>>60447610

C# is the actual pajeet language, Java is for real developers
>>
>>60447716
That has absolutely nothing to do with the post you're responding to.
>>
>>60447706
If it's not functional autism it's not good programming
>>
>>60447734

Of course it does. You want me to use C# but who the fuck uses C#.

What even is C#? Nobody really knows, it's just some weird language that people shill as an alternative to clean and comfy java despite never using it themselves because nobody ever uses it.
>>
>>60447699
>when they are literally talking about doing
Java and C# are web"dev" garbage.
>webdev
>Oh so you think it's "development"? Why don't you fuck off back to your containment thread.

>>60447706
Functional autism doesn't imply not being POO.
POO doesn't imply not being functional autism.

>>60447716
see >>60447622
>>
>>60447750

>clean and comfy java
xD
>>
>>60447606
Sir why are you being so rude
>>
>>60447750
>clean and comfy java
>>>/r/india/
>>>/g/wdg/
>>
>>60447334
No and it's been fixed for a long time, at least with g++
>>
>Webdev isn't programming
Where did this meme start?
>>
>>60447810
with web"dev"
>>
>>60447810
>Webdev is programming
>meme
>>>/v/
>>>/g/wdg/
Fuck off. Your kind isn't welcome here.
>>
>>60447750
>You want me to use C#
I was literally only responding to the request for something like "java but with memory access". C# is similar to Java in many ways, and also allows you to do direct memory access, much like C or C++ with the unsafe keyword.

I'm not trying to convince you of anything; it was merely a suggestion to satisfy an attribute you seemingly desired.

For what its worth, Java was my first language, and "clean and comfy" is not what I'd use to describe it, particularly in comparison to C#. I find C#'s myriad of syntax sugars and toolset makes my life easy. It feels good to write. I'm not sure if the "nobody ever uses it" line was bait.
>>
Would it make sense to restrict programs so that they only have access to the particular file(s) that should be relevant at the moment? I suppose this would not apply to certain system programs. Anyway, imagine you have some sophisticated shell with a simple type system:

$ type cp # Show type info on `cp`; this `cp` program is simplified.
cp : File:R -> File:W -> Program
$ cp "foo" "bar" # The syntactic string literals are semantically interpreted as paths based on the type of `cp`.
$ type ls # This `ls` program is also simplified.
ls : Dir:R -> File:W -> Program
$ args ls # Show parameter info.
ls target=. output=/dev/stdout # `ls` takes two arguments; they have default values for convenience. Since the shell (rather than the program itself) is aware of the defaults, the program can still be restricted to the chosen files since the shell is aware of what files are chosen even when using defaults.


IMO this should let you run a lot of programs that you don’t know anything about without worrying about what they’re doing at all (provided you don’t add them to some “whitelist” or actually give them access to some file). Of course, every program might have some “data directory” or so where it can store e.g. its settings.
>>
>>60447837
>It feels good to write
"Epic".
Fuck off to >>>/g/wdg/
>>
>>60447843
Undecidable
>>
>>60447828
>being this jealous of my 6 figure/mo WebDev career
>being this jealous that I can work from anywhere on the planet and still make more than you
You're a manlet mentally
>>
>>60447843
what do you mean >should be relevant
>>
>>60447866
>my Web"""""Dev""""" career
The redditors seem to be out in force at the moment.
You need to go back.
>>>/g/wdg/
>>>/r/ebbit
>>
>>60447866
Don't respond to bait.
>>
>>60447866
>>60447893
>>>/g/wdg/
Your kind simply isn't welcome.
>>
>>60447565
(You)
>>
>>60447931
>dodging
>>
>>60442822
Lisp is the most powerful programming language.
>>
>>60447940
>.
Stopped reading right there.
>>
>>60447935
(You) taught me.
Got it?
>>
>>60447950
>there
>e
Stopped reading at this exact spot!
>>
>>60444035
you're a meme
>>
>>60447969
What?
>>
I'm getting upload failed whenever I try and spread C propaganda, anyone know why?
>>
>>60448000
Fuck off shill. Learn Lisp.
>>
>>60447992
>meme
see >>60444035
>>
>>60448021
shut up, you meme
>>
>>60448010
C is equal to Lisp.
>>
>>60448031
Every programming language is a Lisp in disguise.
>>
>>60448031

Lisp had its time and it failed.
>>
>>60448030
>meme
see >>60448021
>>
>>60446770
well, employers are now asking your stackoverflow account to check your karma and answers so it does make sense
>>
>>60448046
This is hilariously retarded.
>>60448048
Same with C. Both are complete shit.
>>
>>60448048
I only like Lisp because it's unpopular.
I can't imagine normies using my Lisp.
>>
>>60448101
Thanks for your opinion, anon!
>>
>>60448048
lisp is still strong.
>>
File: 124573678.gif (1MB, 450x190px) Image search: [Google]
124573678.gif
1MB, 450x190px
>>60448048
>(((Lisp))) had its chance
>>
>>60448106
>"normies"
I think you mean "normalfags".
>>
>>60447993
Not what, but who.
(You).
>>
File: 1481672953871.jpg (45KB, 312x395px) Image search: [Google]
1481672953871.jpg
45KB, 312x395px
>>60448125
If that's what you fancy.
>>
Why I can't post pictures in agdg?
>>
>>60447095
newfriend here
how do I write code in a white space like that?
plz no bully
>>
>>60448209

>>
Is Timsort (as it's implemented in Python if nothing else) in-place?
>>
>>60448207
Ask on >>>/vg/agdg/

>>60448209
>code
It's not "code".
>>
>>60447095
>his language doesn't have gcd and lcm by default
>>
>>60443645
Do you have a feminine butt?
>>
>>60448221
>>60448230
this doesn't help...
>>
>>60448209

Google it you pleeb
>>
>>60448101
t. someone who hasn't programmed in C nor Lisp
>>
>>60448230

Why is the tag called code then?
>>
>>60448209
nigger go read the faq and never speak again
>>
>>60448268
>t.
Kill yourself, crossboarder.
I have programmed in both, both are an insult to any intelligent programmer.
>>
>>60448230
>It's not "code"
No, it's code. The act of writing it is programming, which is what I assume has your panties in a knot.
>>
test

>>60448292
o-ok
>>
>>60448325

DING DING

SHAME SHAME SHAME
>>
>>60448312
t. too brainlet to understand Lisp and C
>>
what's a good C networking/socket book?
>>
>>60442822
some stupid owl carousel project for mah jub
>>
>>60448346
man socket
>>
>>60448345
We need to put people like you in camps.
>>
>>60448325
123 ffs
>>
>>60448400
Not my fault you're getting this buttblasted over programming languages you can't understand.
>>
>>60448415
Read the fucking sticky, and there's also a minimum character count for
code tags.
>>
>>60448442
>character count for code tags
But that's stupid.
>>
>>60448472
the limit is low enough that I can right nigger
that's fine with me
>>
>>60448487
>>>/pol/
>>
public class extraCreditPath extends Application {
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
// Create a pane
Pane pane = new Pane();

Rectangle rectangle = new Rectangle (0, 0, 25, 50);
rectangle.setFill(Color.ORANGE);

Circle circle = new Circle(125, 100, 50);
circle.setFill(Color.WHITE);
circle.setStroke(Color.BLACK);

// Add circle and rectangle to the pane
pane.getChildren().add(circle);
pane.getChildren().add(rectangle);

PathTransition pt = new PathTransition();
pt.setDuration(Duration.millis(4000));
pt.setPath(circle);
pt.setNode(rectangle);
pt.setOrientation(
PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT);
pt.setCycleCount(Timeline.INDEFINITE);
pt.setAutoReverse(true);
pt.play(); // Start animation

circle.setOnMousePressed(e -> pt.pause());
circle.setOnMouseReleased(e -> pt.play());

// Create a second smaller circle.
Circle circle2 = new Circle(80,90,7);
circle2.setFill(Color.CYAN);
circle2.setStroke(Color.DARKORANGE);

// add circle 2 to pane
pane.getChildren().add(circle2);

// create a second path transition.
PathTransition pt2 = new PathTransition();
pt2.setDuration(Duration.millis(4000));
//trouble with path here>>
pt2.setPath(rectangle);
pt2.setNode(circle2);
pt2.setOrientation(PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT);
pt2.setCycleCount(Timeline.INDEFINITE);
pt2.setAutoReverse(true);
pt2.play();

// Create a scene and place it in the stage
Scene scene = new Scene(pane, 250, 200);
primaryStage.setTitle("PathTransitionDemo"); // Set the stage title
primaryStage.setScene(scene); // Place the scene in the stage
primaryStage.show(); // Display the stage
}

public static void main(String[] args) {
launch(args);
}
}
>>
>>60448503
>>>/r/eddit
>>
>>60448510
Nope
>>
>>60446150
>A generator can keep going and going
No, apparently yours can't, as the memory consumption is too high. It's more of a limiting factor than initializing an initial array. Your incremental sieve has more of a limit than a traditional sieve.
>The implementation is excellent and it's not inefficient
The implementation is trash, and you're a outright wrong in claiming a hashtable is in any way "not inefficient".
>python is what's unreasonable
No, keeping values in a hashtable is what's unreasonable, and the worst case for space complexity.
>It's unreasonable to expect this to handle very large primes
And why is that? Because you rely on sieving for divisors? Why not simply implement a Miller-Rabin primality test?
You should consider rewriting the sieve using an unsigned char array, because as it stands it's nothing but a toy, even more so than my basic sieve. I mean, you're actually claiming increasing both time and space complexity is a valid trade-off for it being segmented.
>>
File: yuzu.jpg (77KB, 600x400px) Image search: [Google]
yuzu.jpg
77KB, 600x400px
>error posting images
>>
File: 0nj41RY.jpg (47KB, 650x255px) Image search: [Google]
0nj41RY.jpg
47KB, 650x255px
Is there a library for sepples for quick prototyping of stuff like you'd do with matlab(e.g. uis, dataviz/plots, 2d/3d rendering, symbolic math)?

I'm thinking of starting something like that after I fail all my finals.
>>
File: 1488183809920.png (383KB, 1250x1425px) Image search: [Google]
1488183809920.png
383KB, 1250x1425px
>>60443601
If you can't work above the desk then you stay below it. I can buy my own cookies.
>>
File: 1431280252037.png (103KB, 400x400px) Image search: [Google]
1431280252037.png
103KB, 400x400px
I just started learning my first language and I already want to learn another one
Can I learn two languages at once or will I get stunned?
>>
pajeet up

verb

1. Start writing a lot of Java code everyday
>>
>>60448671
Depends on the languages and about 100 other things.

Generally speaking, yes. You can learn two languages at once.
>>
>>60443930
>>60443645
Here's a question - how much of a waste of time is sickpee? Is it useful at all if you already have programming experience?
>>
>>60448682
>Java
C and Haskell*
>>
>>60448671
Learn Lisp.
>>
help
public class extraCreditPath extends Application {
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
// Create a pane
Pane pane = new Pane();

Rectangle rectangle = new Rectangle (0, 0, 25, 50);
rectangle.setFill(Color.ORANGE);

Circle circle = new Circle(125, 100, 50);
circle.setFill(Color.WHITE);
circle.setStroke(Color.BLACK);

// Add circle and rectangle to the pane
pane.getChildren().add(circle);
pane.getChildren().add(rectangle);

PathTransition pt = new PathTransition();
pt.setDuration(Duration.millis(4000));
pt.setPath(circle);
pt.setNode(rectangle);
pt.setOrientation(
PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT);
pt.setCycleCount(Timeline.INDEFINITE);
pt.setAutoReverse(true);
pt.play(); // Start animation

circle.setOnMousePressed(e -> pt.pause());
circle.setOnMouseReleased(e -> pt.play());

// Create a second smaller circle.
Circle circle2 = new Circle(80,90,7);
circle2.setFill(Color.CYAN);
circle2.setStroke(Color.DARKORANGE);

// add circle 2 to pane
pane.getChildren().add(circle2);

// create a second path transition.
PathTransition pt2 = new PathTransition();
pt2.setDuration(Duration.millis(4000));
//trouble with path here>>
pt2.setPath(rectangle);
pt2.setNode(circle2);
pt2.setOrientation(PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT);
pt2.setCycleCount(Timeline.INDEFINITE);
pt2.setAutoReverse(true);
pt2.play();

// Create a scene and place it in the stage
Scene scene = new Scene(pane, 250, 200);
primaryStage.setTitle("PathTransitionDemo"); // Set the stage title
primaryStage.setScene(scene); // Place the scene in the stage
primaryStage.show(); // Display the stage
}

public static void main(String[] args) {
launch(args);
}
}
>>
>>60448696
Like all books, skip the first 2-3 chapters.
>>
>>60448717
I need to make the smaller circle trace the rectangle, that is tracing the bigger rectangle.

here are the javafx libraries:

import javafx.animation.PathTransition;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;
import javafx.util.Duration;
>>
What language has abstract data types?
>>
>>60448719
you are crazy? the first chapters are a gold mine on abstraction.
>>
>>60448717
>extraCreditPath
Why do you need this extra credit?
>>
>>60448739
most of them.
>>
File: current grade.png (17KB, 288x429px) Image search: [Google]
current grade.png
17KB, 288x429px
>>60448753
I don't need it at all, I just want to know how to do it. is that good enough?
>>
>>60446306
>static field
>ever
ya done goofed
>>
File: 3[1].png (26KB, 112x112px) Image search: [Google]
3[1].png
26KB, 112x112px
how do i learn matlab or python for data analysis shit? i need to learn python for sure but as an EE it seems i need to learn the data analysis stack (numpy, scipy, mathplotlib) and idk where to start to use it
>>
>>60448693
I'm learning c but I want to pick up BASIC because I have a hard on for 8 bit computers
>>
>>60448901
Just Johnny 4 stock your prof lmao
>>
>>60447226
for oop, cant you just put functions inside structs? like functions that can only access inner fields?
>>
>>60448929
Of course.
>>
C > Scheme > Assembly > Haskell > C++ > Lua >>>>> Everything else
>>
>>60448671

The more languages, you know, the better programmer you are.

The best programmers know hundreds of languages. YOu learn different paradigms and theories. So learn all the languages you can. Thats how you learn the most.
>>
new thread, though
>>60449063
>>
>>60449051
>hundreds of languages
top fucking kek

Listen to this NEET. She's surely going to steer you down the path to greatness with these motivational alternative facts.
>>
>>60448620

I was getting that
>>
File: IMG_0222.png (4KB, 183x275px) Image search: [Google]
IMG_0222.png
4KB, 183x275px
So I wrote a function to get the length of a string, and I wrote a function that will skip every space in a string until it reaches the first non-space character, then it returns it.

Using these, i want to take a users full name as an input and return their initials. It should work regardless of how many spaces they enter.For example, "Rodger Smith" should return "RS". " John Gary Smith" should return "JGS".

Im unsure of how to proceed.
>>
File: IMG_0214.png (28KB, 640x476px) Image search: [Google]
IMG_0214.png
28KB, 640x476px
>>60449295
Language is C btw
>>
File: anal beads.png (4KB, 447x85px) Image search: [Google]
anal beads.png
4KB, 447x85px
>>60449295
>>60449314
This is why you say your language first.

You could do something like this in a higher-level language:
string GetInitials(string input) => 
string.Concat(input.Split(' ')
.Where(x => !string.IsNullOrWhiteSpace(x))
.Select(x => x.Trim().First())).ToUpper();
>>
>>60449295

Split the name by spaces into a bunch of substrings.

Then take the first character of each substring.
>>
>>60449295
barely tested
std::string initials (const char *str) {
size_t i (0);
std::string ret;
searching:
switch (str[i]) {
case 0:
return ret;
case ' ':
i++;
goto searching;
default:
ret += str[i++];
goto skipping;
}
skipping:
switch (str[i++]) {
case 0:
return ret;
case ' ':
goto searching;
default:
goto skipping;
}
}
>>
>>60449463

Actually no that's silly you can just do it all in one go as you loop through the string
>>
>>60449295
>search first character
>search for space then next character
>repeat until end of string
Even ignoring language features you'd be able to do it in a simple loop.
>>
>>60449295
Look into Strtok
>>
i know java now, but the tutorial on udemy just told me everything about java but not how to make projects, what are some cool project turtorials , pref some that build cool apps for windows which allow me to customize the gui, Everything i search for online is pajeet with sht code and sht gui and sht projects like making a calculator or some lame sht

Also what is the latest sht java like what librarys/frameworks/platforms, is JavaFx still being used whats the most popular?
>>
File: IMG_0253.png (193KB, 397x530px) Image search: [Google]
IMG_0253.png
193KB, 397x530px
>>60449617
>>60449546
>>60449500
>>60449463
>>60449379
Here you guys go.
#include <stdio.h>
#include <cs50.h>

int strglen(string s);
char firstChar(string S);
void initials(string name);

int main(void){
initials("Curtis Martin Curry");
return 0;
}

int strglen(string s){ //Returns length of a string
int n = 0;
while(s[n]!='\0')
{
n++;
}
return n;
}

char firstChar(string S){
// Parse string until first non space character is reached
char c = 'a';
int length = strglen(S);
for(int j=0;j<length;j++){
if (S[j] != ' '){
c = S[j];
return c;
}
}
return '\0';
}
void initials(string name){
//Print initials of a string
int i = 0;
printf("%c",firstChar(name));
while(name[i] != '\0'){
if(name[i] == ' ' && name[i+1] != ' '){
printf("%c",name[i+1]);
}
i++;
}
}


please be gentle this took me 10000 in Microsoft word.
>>
>>60449295
>>60449919
>IMG_0222
>IMG_0253
>>>/r/abbit/
>>
>>60449919
What's a string?
>>
>>60450738
An array of characters.
>>60450677
I can't post from my computer atm
>>
>>60448901
anyone please?

>>60448920
what a legend
>>
>>60448901
>web""" dev""" usage of ""stack""
Perhaps you should ask on >>>/g/wdg/
>>
>>60450989
autistic af desu
Thread posts: 329
Thread images: 28


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