/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread:

Other urls found in this thread:

youtu.be/yG1OZ69H_-o
youtu.be/RdE-d_EhzmA
twitter.com/SFWRedditGifs

I'm rewriting the linux kernel in haskell

Rewriting Haskell in simply typed lambda calculus.

writing my suicide note into the linux kernel source code comments

Rewriting my existence in the unvierse.

writing my suicide note into the Haskell-linux kernel source code comments

class UserInput(object):
def __init__(self):
self.value = ''

def read(self, prompt):
print(prompt)
while True:
value = input()
if self.validate(value):
return value

print('Invalid input value, try again.')

def validate(self, value):
return False

class UserName(UserInput):
def validate(self, value):
return len(value) > 1

class UserLastName(UserInput):
def validate(self, value):
return len(value) > 1

class UserAge(UserInput):
def validate(self, value):
try:
age = int(value)
return age > 18
except (Exception, ):
return False

def main():
name = UserName().read('Please enter the first name.')
last = UserLastName().read('Please enter the last name.')
age = UserAge().read('Please enter the age')

print(name, last, age, )

if __name__ == '__main__':
main()

Rewriting lisp in Rust.

>class for everything

why not "class main" too

with a single "run" method

>why not "class main" too
I would if it was supposed to store the name, last name and age values for further use.

>BIT TWIDDLIN'

OOP gone wrong

So any OOP?

No, any OOP is programming gone wrong. This is worse.

Rate my pattern matching tutorial.

...

what sort of future 4D keyboard do you have to get characters like that m8

Java is best language. I don't understand why someone would need anything else.

isMatch(yourTutorial, "shit") // returns true

>I don't understand why someone would need anything else.
I would imagine the most common reason is not being subhuman.

just because you have a hammer does not mean every problem is a nail.

especially when it's an old, plain, hammer thats been worn down to a nub by zillions of indians.

Most fancy characters are just something

The 'and' symbol is and, prime is '

how do you do the lady in the red dress?

What environment ?

10/10

Natural language input?

Mathematica notebook.

(defvar questions
'(("Enter first name" valid-first-p)
("Enter last name" valid-last-p)
("Enter age" valid-age-p)))

(defun valid-first-p (x) t)
(defun valid-last-p (x) t)
(defun valid-age-p (x) t)


(loop for i in questions
do (format t "~a: " (first i))
(setq x (read-line))

when (funcall (second i) x)
do (nconc i x))

just got ulisp installed on my Uno. breaking out a PS/2 right now to type to it :)

That's not OOP though. It may look like it but it's not.

What's OOP? I grant you that OP's code was just an abuse of Python's features. Now what's OOP?

What kind does '*' itself have in Haskell?

Due to lack of encapsulation or anything else?

OOP is a programming paradigm that focuses on modeling code after real world features. It promises maintainability and reusability, but if done sloppily (like ) it tends to lead to more problems in the long run.

>installed Gentoo, but still have an Ubuntu-tier beard
it's not fair

Why does everyone here hate Python?

I don't. I use it a lot, it's helpful.

A lot of people here aren't of the opinion that a language is just a means to an end though. I'm not sure I understand the complete dedication and adherence to one language.

Hipsters; it's too popular.

I don't think everyone here is that intelligent, by which I mean "above 60 IQ".

Python front-ends to C++ libraries.

The same reason people hate JS.
It got too popular and widespread, but not on merit.

Used by people who don't know what they are doing and rely on Google to solve their problems for them.

finally finished my shitposting bot in python

now to make a necrobumper

what do I read to understand how computers work?

Intel Dev Manuals

I am making an rpg game in Java and right now I am implementing a tilemap. I want to store information about each tile, right now the tile type id (int) and Entity objects

The first way I can do this is have an int[] array that stores the tile type id and another separate same size array that stores Entity objects. Also the array index corresponds to a position on the map. The amount of memory needed is about:
4 bytes * array size + 16 bytes * # of Entities + 4 bytes * (# of Entities
- array size)

The second way is have an array of Tile objects that stores the tile type and Entity object. But that means my array is filled with Tile objects and that will take as much memory as the first way plus another 16 bytes * array size for the Tile objects but this way seems easier to work with. Which method is the overall best?

How dead would /dpt/ be if there was a video-game programming general on Sup Forums.

Start with maxwells equations

Wrong board.

Basically I write code however I want, then call it OOP. That definition is the vaguest of all. It doesn't imply inheritance not single dispatch or even types afaict. This is the kind of definition that allow you to locate concrete objects or recognize them when you see them, like say "the washington monument is an obelisk built in front of the Capitol in Washington D. C., USA". For concepts it doesn't work --- and ironically OOP shills ignore the difference when they think about code --- and just leads you to believe whoever claims to know OOP knows the real OOP and you've found what you were looking for, even though said real OOP isn't. To me this makes the term redundant when discussing programming because everyone has a different methodology/paradigm they call OOP. So yeah, OOP is neither shit nor not shit, let's move on to discussing the value of dynamic dispatch, duck-typing, namespacing disciplines, implementation hiding and such.

>let's move on to discussing the value of duck-typing
Stopped reading right there.

There's very little video game programming talk as it is.

I didn't say it was good tho. So it's so bad it doesn't even deserve to be discussed according to you? M8 Imma blow your mind: everywhere there's RPC, there's duck typing in action. Good luck swallowing that fgt.

List some things that Hipsters do in Software Development/Web Development:

1.) Program in Ruby

from itertools import starmap

name_validator = lambda x : x if len(x) > 1 else False
questions = [ ('Please enter the first name.', name_validator)
, ('Please enter the last name.', name_validator)
, ('Please enter the age.'
, lambda x : x if x.isdigit() and int(x) > 18 else False)]
name, last, age = starmap(lambda x, y:(print(x), y(input()))[1], questions)

print(name, last, age)

Pretty sure this is what you meant.

>So it's so bad it doesn't even deserve to be discussed according to you?
It (and everyone who uses it) deserves to be laughed at. That's about it.
>M8 Imma blow your mind
I suggest you return to whichever internet cesspit you came from.
>everywhere there's RPC, there's duck typing in action
Your point being? It's fucking trash.

Considering we already have a video-game programming general on /vg/, I don't think we'd be that dead. /dpt/ mostly does not talk about game dev.

>MUH OOP

>MUH

Sir, excuse me, but I believe you have misunderstood my post. I was only pretending to be retard to make a point about the OP. Hopefully this can be avoided in the future.

You seem upset.

You should stop programming.

Holy shit. Weeks of trying to figure out what the Markov chain Monte Carlo algorithm was about where every internet blogger I came across was either too vague or left out a critical detail and I finally find the key in this book. Turns out it's extremely simple.

Blitzstein, "Introduction to Probability" if anyone is interested. Fantastic book. Also has a really good explanation of Bayesian inference.

short table[512];
static short table1[512] = {.......};
...;
memcpy(table, table1,512*sizeof(short));

Jesus Christ, Matlab.

Does she call her dad mom or dad?

That what optimizers are for.

That doesn't look like Matlab.

Implementing a shitty undocumented internal standard into the horrid abomination of a code base that the company that hired me develops and markets to airline companies.

It's what a matlab to c compiler did for me

'big data' visualization in JavaScript front to backend

Should I learn Fortran?

>decide to brush up on my math
>load up Khan Academy
>start from the beginning
>realize I forgot how to do long division

I'm sorry I'm an intellectual and you're not.

kys codemonkey

The static one is the literal, which must be instanciated each time the function is run so it can be mutated. What's wrong with that?

How to use C++ properly?

God I hate you user. You don't understand anything about OOP. You don't even understand he practical reality of what people call OOP. Yet you speak so surely about it. Horrible.

Nobody really understands OOP.

youtu.be/yG1OZ69H_-o

I was undefined once.

I got better.

I know this is a meme but that's what computers are for! Kids shouldn't have to memorize such banal algorithms now that everyone has a smart phone in their pockets. They should just be taught the IDEA behind division so they know when to apply it.

what do you think about making a scripting language with C-like syntax?

Small talk programmers understand OOP very well. And they understand what people claim to be OOP.
youtu.be/RdE-d_EhzmA
Here's a talk explaining the difference between actual OOP and the stuff pajeets peddle as object oriented programming.

sounds like PHP :(

Forgot to write that table1 was also constant and that table was also never modified after the copy.

you're gonna eat those words when the white board tells you to make a function divide(x,y,b) that divides x by z in base b with up to 3 decimal places

I hate programmers that are small talk.

is php even a scripting language though? i've never thought of it as one. just thought of it as a language for websites

Write it in Ada then write a wrapper in C

See this claim is why you need that talk.
It's not about the program being wrong or not. It's about your intent matching the code you've written.

...kinda

Yeah it makes no sense in the big picture. I still like the idea though.

>base b with up to 3 decimal places

Well it wouldn't be called a decimal place if it wasn't in base 10, now would it?

it is certainly formed to be geared towards web applications, it is also a scripted language.

i think it still would be called that. is there any other word for it?

The stupidity doesn't come across unless you see the whole function, I guess.

>what people call OOP.
Nigger there is no such thing because there is no conceptual definition. It's at best a bunch of poor man's Grandma Wisdom for programmers, and yet people pull a cult for it. Go figure.

Fucking idolaters, burn them alive in the name of gnu.

Hexadecimal places?

XXDOMVFSSOLUTIONPROCESSINGCONTEXT * ppItin = ( XXDOMVFSSOLUTIONPROCESSINGCONTEXT *) xxdomvfsThreadAlloc(hThred, sizeof(XXDOMVFSSOLUTIONPROCESSINGCONTEXT *));
pItin->data->moredata.somedata->evenmoredata();
xxdomvfThreadTerm(pItin);

the general term's a radix point

Oh, I didn't realize we had ourselves a mathematician in the room. Here, have a rare Pepe.

i just looked it up on google but ty for the pep

SAVE ME.
I can't continue, I don't fucking know how to use this shitty tool, itext and the rest that is out there is pure garbage and there is no documentation of how things work. Why are they doing this to me...