/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

python.net/~goodger/projects/pycon/2007/idiomatic/handout.html
pastebin.com/RgwGATTX
pastebin.com/hNsrsKw7
github.com/withmetta/g_tetris
pastebin.com/27SBcLpU
github.com/withmetta/g_tetris_csharp
twitter.com/SFWRedditGifs

Type inference is a bit of a meme desu

Static typing is a huge meme

I really want to doll up a Sup Forums user and pair program with him.

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/!

Static typing isn't a meme

Then why didn't you static type your post.

Should have been
shitpost Static typing isn't a meme

Who says I didn't

You need to declare the type of post you are making before you post m8

>you need to declare the type
No I don't

To give an example, say that we initialized an instance of /dpt/ one hour since it was made on Sup Forums; 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.

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.

You still can track which post was the new unique poster's post though.

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.

Whaddaya want to make?

I know.

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.

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 Sup Forums user could work on the finite temperature DMRG part. If this works then there might be something that'd be named after us.

bump

That sounds legit. I can at most give you encouraging words and bake cookies or something.

>bake cookies
s-smegma cookies perhaps?

A website using node.js :)

/dpt/-chan, daisuki~

Ask your much beloved programming literate anything (IAMA).

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


Please, use an anime image next time.

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.

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?

pastebin.com/RgwGATTX

>Any ideas why?
my peenus weenus of course haha

>Please, use an anime image next time.
I got you, akari-chan.

What part isn't working for you?

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.

>meme

What sort of retarded subhuman language writes type signatures that way and why would anyone human ever use it or mention it here?

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.

What do you mean?

I'm trying to simulate post-synthesis right now,

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.

Writing a program which will take down any compiler/interpreter which doesn't do static type-checking.

Somone contribute to this
github.com/withmetta/g_tetris

>C++
Not a chance in hell.

pastebin.com/27SBcLpU

Now the simulation works in ACTIVE HDL but not in VIVADO's simulator

Why would I be contributing to something written in sepples? And you're probably going to license it under the G*L as well.

The post synthesis simulation * doesn't work in VIVADO

Trash, fuck off.

Sorry pajeet, here is the c# version
github.com/withmetta/g_tetris_csharp

Why would I be contributing to something written in *#? And you're probably going to license it under the G*L as well.

That's literally no better.
The only acceptable languages are C and x86-64 assembly.

have you ever written any code or do you just spam anime and are generally autistic?

>code
Your kind isn't welcome here.

>x86-64 assembly
x86-64 is fucking garbage though.

Why?

Fuck off, Rajesh. You sperged out for literal months wrapping your poo-in-loo "buu huuu animoooooooooo" statements in code blocks for every thread.

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;

Too bloated and was possibly created by CIA/GNU-nigger international police.

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

(cur->user_id == 0))

fixed

No, that was on purpose

Then it's impossible for that statement to be true.

C has nothing to criticise and you know it

Why do people shill C when they never even written anything significant in it?

c has a lot to criticize. its type system, for example, is really crap.

I wrote FizzBuzz in C

it is your?

I have written significant programs in C. Not "50K+ SLOC" significant, but certainly well beyond trivial.

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

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 Sup Forums?
also today we do hashing and hash tables
what am i in for?

unsafe arrays

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. :(

t. LARPer

>not going to exam in hungover because of last night party
>not puking at the exam
>not acing it regadless
Pajeet...

LARP MY ANUS

Is that an acronym?

:^| 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?

'1' would be char
"1" would be string
1 would be int
1.0f would be float

etc

Why do people comment like this?

right you are

because they have no valuable contributions to make to the code so they just spend all day typing asterisks

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.

Ocaml and Lisp don't have this problem.

javadoc style

What is the purpose of embedding Lua in C/C++?

[] vs *
they are both the same you retard

Yeah but void* and char* are not the same nigger.

Text editors automatically add them.

No they're not, you stupid fuck.
In argument lists, ONE of them is the same. Elsewhere, they are different.

making your application scriptable?

>generics
What is a "Generics"?

The main reason to use C++ over C.

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?

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.

Unlike arrays, they can store heterogenous data. You can keep an int and a char* in the same struct.

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.

sometimes you have a collection of related pointers and you want to pass around a single reference to that collection?

You don't pay for what you don't use :)

But what is a "Generics"?

they offer the same as classes but without all the RAII goodness so they are trash
don't use structs