/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1536774167980.png (566x650, 318K)

Other urls found in this thread:

gist.github.com/jo/8619441
twitter.com/NSFWRedditImage

I don't think anyone saw my post in the other friend but

Just implemented a client server that sends files in packet sizes of 524 (header is 12 bytes) over the network using recvfrom and sendto. Emulated packet loss using tc. Handled packet loss and used fast retransmit and recovery to resend lost packets

what the fuck is tewi doing

Lisp is the most powerful programming language.

Gonna continue reading c++ primer and updating my solutions to the exercises
last update was a year ago, fuck me

Attached: 1476182487672.jpg (1111x823, 174K)

Lisp is great, used it all throughout my artificial intelligence course

Still reading The Racket Guide. The language looks suspiciously comfy. What's the catch?

This was done in C++ btw

learning abstract/anonymous functions

> What are you working on?
Youre mom lol

>working on OP's mom
Wow, real original. Who isn't?

there is no catch, it's really that good

AAAAAH I WANNA WRITE A PROGRAM

Attached: 1553586021696.png (800x600, 455K)

I'm not sure I like this image

I'm trying to get a list of primes up to the input number and the first one works but is slow
In the second one i figured that the first number in possiblePrimes should be a prime after i've removed divisible numbers below it
Is the problem with it with how for works in python?
def primeList(n):
primes=[2]
for x in range(3,n+1):
isPrime=True
for y in primes:
if x%y==0:
isPrime=False
if isPrime:
primes.append(x)
return(primes)

def primeList2(n):
possiblePrimes=list(range(2,int(n)))
print(possiblePrimes)
primes=list()
while(any(possiblePrimes)):
p=possiblePrimes[0]
possiblePrimes.remove(p)
print('p='+str(p))
for x in possiblePrimes:
print('x'=srt(x))
if x%p==0:
possiblePrimes.remove(x)
primes.append(p)
return(primes)

I had the same feeling with Haskell until I got bitten by IntInteger, StringData.Text and lazy I/O.

do not

How do I know what library is related to some header in C?

This would be more pythonic

import primes

print(primes.primes(1000000))

or

import requests

res = requests.get("primes.utm.edu/lists/small/100000.txt")

print(res.text())

I want to write a program invovling mathematical expression evaluation, so I'm building a basic interpreter to take strings of algebraic expressions and do things to them. I'm new to this though, so does anyone have some good introductory material to parsers and specifically abstract syntax trees? If possible I'd prefer something that deals with that specifically, rather than a whole course on building an actual compiler. I won't be touching assembly so those go out of my scope somewhat.

>using base

use modern c++ or I swear to go I'm going to introduce you to so much pain you'll be begging to be deleted to which I'll say no because we don't use delete in modern c++, you little bitch

Attached: s.jpg (480x360, 11K)

>lazy
$! is your friend, user

You gotta first stake your claim. There's no way you can parse all mathematical expressions. Because as the math gets more advanced, it invents new ways to write it down. Until you end up in quantum mechanics and literally use squiggles going left or right.

Are there any good books on how the Virutal DOM and DOM renderers work?

implying you can hit me without your glasses

>Lisp is the most powerful programming language
granted is as old as shit, and never used any more, is shit based on the pure fact of how it implements ligma operations

I just google it

wow i gotta look into this requests library, thanks

agreed, there probably isnt a single complete or partial ligma algorithm that performs well in list

what you're trying to do is how w3m browser works. why reinvent the wheel?

>we don't use delete in modern c++
MyClass(MyClass&&) = delete;

>requests
requests.exceptions.SSLError: HTTPSConnectionPool(host='primes.utm.edu', port=443):
Max retries exceeded with url: /lists/small/100000.txt
(Caused by SSLError(SSLError("bad handshake:
Error([('SSL routines', 'ssl3_get_server_certificate',
'certificate verify failed')],)",),))

*lisp

For simple algebraic expressions, use the postfix to infix algorithm, it's fairly simple

this is a non rhetorical and genuine question.
Are you guys trying to sound as obfuscated and complex as possible to look smart?
Somehow i can read a couple of these threads and take no useful information for my job as a software developer out of it.
The little that sounds like its vaguely related i can barely understand.

i am genuinely confused how a bunch of programmers talking about programming can be of so little use to me.

SHIIIIT

import requests

res = requests.get("primes.utm.edu/lists/small/100000.txt", verify=False)

print(res.text())

>TypeError: 'str' object is not callable

SHIIIIIIIIIIIIIIIIT

Give an example or two.

Judging by your ability to type I'd say your problem is low IQ and lack of knowledge.

It's because 85% of the people that post here have not gone through any type of rigorous education in computer science or math. They are people trying to build

*deep breath*

import requests

res = requests.get("primes.utm.edu/lists/small/100000.txt", verify=False)

print(res.text)

nice, here's the one-liner
print (__import__('requests').get(\
"primes.utm.edu/lists/small/100000.txt",verify=False).text)

>Are you guys trying to sound as obfuscated and complex as possible to look smart?
I'm hardly ever having trouble understanding what's being said here.

>here's the one-liner
>it's 2 lines
what did user mean by this

I don't like when the (code) section gets a scrollbar so i had to break the line.

in real languages whitespace doesn't matter and everything up to the first semicolon counts as one line

only took me 1 year haha, I'll be done in a decade no problem!

Attached: SumatraPDF_2019-06-08_20-27-38.jpg (136x27, 2K)

Need to get the movitation to study for finals

>It's because 85% of the people that post here have not gone through any type of rigorous education in computer science or math.
Having a degree in CS doesn't automatically make you a competent programmer.

what book

Your mom used some real language last night when I was teaching her some python.

he didn't say that though

Anyone saw. Anyone just don't care. Tell us about SICP.

i'm gonna watch the SICP lectures on youtube Jow Forums wish me luck

Planning to build a notes web app that has client side encryption but I don't know if there are javascript libraries for encryption on the client side, or if I have to build one on my own. Any suggestions/thoughts Jow Forums?

Learning exercise.

Is there a standard about whether one could express inequality conditions using \ge (>) or \le (

Attached: answer.jpg (407x325, 68K)

That's what he implied though.

no

wut?

There wouldn't be any cryptocurrency web wallets if there weren't.

So I googled and give you this
gist.github.com/jo/8619441

Attached: dange.jpg (564x732, 31K)

Yes, he did.

x = "good" if count > 3 else "bad"

vs.

x = "good" if 3 < count else "bad"

S-expressions or reversed polish notation would be easy mode.
The common way is to split it to scanner (sometimes also called lexer or tokenizer) and parser.

Scanner routine matches prefix of input to possible symbols and skips ignorable symbols (e.g. whitespaces). The common issue is to properly detect multi-character symbols where its prefix is also valid symbol, e.g. += could be + and =. Usually some simple decision tree with peak() lookahead is enough. Then create some token struct with input string, detected token type and position, move current position in input and return the token.

Bigger problem for parsing expressions is obviously precedence. Also that some symbols could be both prefix and infix operators.
Pratt parsing is pretty simple algorithm, usually overlooked because it's only for expressions and solving that part of parsing differently from whole language is weird.
Another could be nested grammar rules, where rule for lower precedence is specified as one higher precedence expression maybe followed by the operator and same higher precedence expression. for example:
AddExpr

people *normally* do the former and have variables/expressions on the left and literals on the right
do what you want though

No standards, but I think putting the constant last is more english-like.

literally doesn't matter
in poorly designed langs where == is equality and = is assignment, some people make a habit of writing constants first but it looks pretty awkward

if (x == 3) // intended code
if (3 == x) // equivalent
if (x = 3) // bug that might break something at runtime
if (3 = x) // syntax error caught at compile time


and anyway well-designed langs use something like := or

Thank you user

Okay, yes in the example I sort of forced a prefered reading, but if both are varibales it's not clear and I wonder if anybody even proposed a default convention

if win > loses

if loses < wins

I didnt say that

i guess > is usually preferred. depends on the situation, e.g. if IRL you'd say/think less than, it might be preferable

How do you deal with having so many choices in programming?
like my autism just paralyzes me and I can't choose which language to use or what framework and I don't end up accomplishing anything
and everyone has their opinion on what will be big in the future (e.g. javascript devs vs javascript sucks people)

I should had been clearer, I'm not trying to write a simple calculator but more things like an algebraic simplifier. If I have 3x+5x it should simplify to 8x, but also realise that it can't simplify 3x^2+5x any further.

I've already got a basic lexer built yea. I don't think I specifically need polish notation if I just construct a tree of functions (operations) where the arguments are further operations, so it simply goes up from the bottom of the tree and returns the simplest algebraic form each time. My main challenge though is figuring out how to take a stream of tokens and figure out how to construct that tree properly and in the correct order according to precedence (however I think here actually what regular shunting-yard calculators do with mapping operators to int values to represent precedence may help here a lot anyway)

Whatever's most familiar or popular (which translates to good docs).

choose whichever one gets you paid
choose whichever one teaches you something new

I don't think anybody "likes" javascript, it's just a necessity. Although javascript apologist of course state things are getting better (fair enough).
If you only want to do your own desktop projects, just learn... Kotlin? Learn some heavilty typed thing, in any case.

Well, when you have a specific idea of what you wanna build/learn you don't have quite as wide a choice as you think. What's big in the future is also irrelevant. Take the SICP approach - it teaches you in Scheme, by far the 'hot' language at the time and even less so now, but uses that as a medium to teach you the fundemental concepts of programming such that you can simply pick up whatever the 'big thing' turns out to be with a weekend of learning syntax.

Nah, i use Rust instead :^)

Ah I see what you're saying, I haven't implemented anything like that before. What's your main approach rn?

>Anyone saw
I have a feeling you don't speak English

>rn
Fucking type properly you fucking nigger. This isn't SMS.

Anyone cope

Any anons work a job with 20 - 30hr weeks unrelated to software and just program on the side? Is it feasible? I currently have a fulltime job programming but it is in a city I don't want to live in anymore. Trying to find a new job but it is really hard...part of me wants to just give up but I don't want to abandon programming because it is fun. I do want to be able to have a life and go outside though.

It didn't diminish the meaning of my message so why don't you shut the fuck up you brainlet

Attached: 1559004414894.png (420x420, 9K)

Bisqwit did this iirc, so move to Finland.

Do you have bills to pay? Unless you're doing true code monkey stuff, you're probably making good money. Idk if another non programming job will pay you as much

Well as I described in the reply, I think I need to build an abstract syntax tree consisting of every operation being carried out on the expression, in the order of first in last out, so the tree is reversed backwards from the most fundamental terms. Taking 2x+3x, we would start with 2 times x, which returns 2x, then start at the other branch of 3 time x returning 3x, both of which then return into the addition function which sees 2x and 3x can be combined into 5x, thus returning 5x at the top of the evaluation. The way I intend to do this rule checking for combination and simplification is through objects, so 2 times x will return a '2x object', with the traits coefficient, variable and exponent, or something like that. Then the addition function will just need to check that both the variables and the exponents match up to confirm their coefficients can be added to create one term. This might have some overhead, especially as I'm using Python, but I can still use numpy/scipy for the heavy lifting of the calculations, and the objects can be removed from memory when they're no longer needed.

It did. It had the meaning "Look at me I'm fucking retarded I can't even spell correctly hur durruudurujthguufh"

that's no fun

Been playing on and off with my osdev pet project for the last two weeks;
There are many visible improvements, such as bbcode support in the standard library and related niceties, but also important under-the-hood additions.
Specifically, the "expirecc" (expire with current continuation) system call:

From its inception, my OS has been using cooperative multitasking, as opposed to the preemptive model employed in most OSes.
I like it because it offers interesting problems/solutions to play with, and it's overall in line with the philosophy of the project. There is, however, one important drawback.
If a task is taking too much time, i.e. during some heavy number-crunching, the whole system could be slowed down or even frozen for a while!
Traditional cooperative multitasking would require to litter the greedy code with lots of yield() calls, which is IMHO a very unelegant and human-time-consuming solution.
I've devised a primitive which allow a task to set an "expiration time" for itself, after which the kernel will yield the task automatically.
When the execution returns to the expired task, it will enter a "resume handler", instead of the normal program flow.
From within the resume handler, the task is allowed to set the expiration time again (kinda like when, in javascript, you call window.setTimeout() again from within its callback).
Also, the task running the resume handler could fire the "continuation" system call to resume the execution from the interruption.

Attached: moonrabbitos_domus.webm (1024x797, 1.5M)

This thread often gets derailed because of retards like you that autistically spazz out when they see something they don't like

The thread got derailed by you when you started posting complete fucking retarded nonsense.

I could pay off all my debt today if I wanted. But I also am willing to wait a bit and save money. Due to living in a tiny town my rent is extremely low so I can easily save money. So basically when I did this I would just have basic essentials rent, food, electricity, and of course computer expenses which are generally low. I would want to move somewhere a bit bigger though. I don't think I want too much things but I don't want to feel like I can't pay the bills.

>This thread often gets derailed because of retards like you that autistically spazz out
squealed the retard, autistically spazzing out, rn

blacked

>bullying in /dpt/
that's illegal

very nice user

>bbcode support in the standard library

Attached: 1501135514673.jpg (346x346, 38K)