/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1492919334654.jpg (1280x720, 130K)

Other urls found in this thread:

warosu.org/g/?task=search2&search_username=Ruby
pastebin.com/aAcLseU0
gist.github.com/nonducor/ddc97e787810d52d067206a592a35ea7
dropbox.com/s/0i1k46qqewyg0fn/Chapter 3 Case Project.pdf?dl=1
pyimagesearch.com/2017/07/10/using-tesseract-ocr-python/
twitter.com/AnonBabble

First for scheme

Attached: 1547407493348.jpg (1152x720, 83K)

removing all the 'const' keywords from my code because I'm an idiot

JavaScript rocks!

Attached: js_rocks.png (1433x779, 473K)

is that you salomonelli

The lower level you code, the higher IQ. This is a fact

Feels good to use a language that makes everything constant by default unless specified.

where's ruby? he come by here much still?

this is too hard

Died last september in his sleep.
warosu.org/g/?task=search2&search_username=Ruby

Attached: 1548339851698.jpg (280x280, 22K)

oops, wrong image.

Attached: 1548349795714.jpg (225x225, 11K)

That is scary what killed him?

Anyone?

I believe Terry is actually alive in Canada so I'm guessing this is a hoax as well. Terry A. Davis that is. Homeless I'm sure but I'm guessing he's running from the parents and they declared him dead over nothing. I still haven't seen a cogent stream of evidence to support his death. False obituaries come up all the time and it's not like they need his permission to upload a text that says goodbye from his family.

How do I make an Android app talk to a server using a binary protocol? (It needs to be encrypted)

TLS

...

It sounds like non-advice, but you have to break a problem down to its smallest parts. LIke Pong
>draw two rectangles at either side
>draw a square/circle ball in the middle
>add keyboard input to change the y position of player1
>change the ball's x to move towards you on start or a keypress
etc etc
Then you refine and polish for more desired behavior.
There's no shortage of tiny arcade games to clone. Try galaga or tetris next. Or maybe try making your own version of pong with a gimmick

I unironically have been recently using mostly Python and Assembly for projects. It’s all about the right tool for the job.

You may not like it, but this is what peak performance looks like.

pastebin.com/aAcLseU0
I would've posted it here directly, but was getting that "connection error" bullshit.

Attached: output.png (858x798, 7K)

I like that font , which font / text editor user?

It's just Vim. The font is terminus and the colour scheme is "jellybeans".

>register keyword
Did it actually help? Have you contrasted?

It made literally no difference here at any optimisation level above -O0.
The only real difference that register makes in this era of optimising compilers is that it stops you from accidentally taking a pointer to the value.

Lisp is the most powerful programming language.

>want to learn programming on my own both because it's interesting and so I can eventually get a decent job and not remain a NEET or a retail wageslave forever
>got SICP three weeks ago
>rarely ever feel motivated to read it
>whenever I open it up I either read a few pages and then stop or feel too tired to read it at all and close it
>spend all my other time browsing 4channel and playing video games
Life is pain

Attached: 1548576293397.gif (616x338, 419K)

What motivates me is shitposting code on /dpt/.

The most powerful programming language is Lisp. If you don't know Lisp (or its variant, Scheme), you don't know what it means for a programming language to be powerful and elegant.

Attached: 1512420430575.jpg (1024x682, 126K)

Go make something. The important part is to accomplish small things, make progress in any way.
Even something as simple as "I got a window to say hello world today" or "I got a programming language/environment/compiler/editor installed today" is good enough if it's your first time.

I responded in a bit late in the previous thread
Basically what said.

>want to learn programming
>so I can eventually get a decent job
>rarely ever feel motivated
>feel too tired
>on my own
something's wrong. maybe everything.

Why tf you use SICP if you're a beginner.

anyone do any work with tesseract/pytesseract? I'm trying to rip text from this specific image but I'm not getting the actual fps values from the bars in the chart. I even tried cropping out everything but the bars but it's not picking it up.

Attached: 4K.png (1328x1807, 92K)

Just finished my cli reverse polish notation calculator, now to make a tokenizer and a serializer to read the config files for the tokenizer.

Attached: thingy_with_the_tongue_out.png (595x720, 607K)

and the code and output

Attached: file.png (1086x858, 63K)

Is it wrong of me to want to do things to that girl?

like buy her a lollipop? no

my own "lolipop" maybe in her mouth

What are you making? An interpreter?

Do you generally store pointers in hash tables so you don't have to store the value, just the key?

user, you have lollipops? Can I have one too?

Attached: 1547228204569.gif (360x560, 460K)

She looks retarded

If the value is large, storing the value elsewhere is usually good. Bad hash tables, like the one in the STL, force this indirection on you.

What's the point of using python __dict__ over manually going through all the elements in a class?
OOP is so confusing to me

yes you sound very confused

you shouldn't be learning OOP with python.

Can you repeat the question?

My rpn calculator an only takes valid tokens as input, the idea of the tokenizer is to take in a UTF string and convert it to valid tokens my program can understand
ie changes this
23 50 ÷
to this
25 50 /

Don’t listen to the anti-Python posters. They want to corrupt your mind and coding style with sepples. They want to tear you down to their level.

Monads are like polymorphism? Yes/No

>ie changes this
>23 50 ÷
>to this
>25 50 /

Attached: 0766C8F1-23D3-4B1D-9E1A-8BA35CDA8873.jpg (250x220, 6K)

no

Fuck off, frog scum.
You're not allowed to post here.

dumb frogposter

your waifu belongs in the trash

Attached: rember.jpg (800x473, 39K)

That’s the only wtf face in my folder.

I'm trying to figure out gist.github.com/nonducor/ddc97e787810d52d067206a592a35ea7

there's a method that produces a formatted string
def toLedgerFormat(self, indent=0):
"""Format the commodity in a way good to be interpreted by ledger.
If provided, `indent` will be the indentation (in spaces) of the entry.
"""
outPattern = ('{spaces}commodity {id}\n'
'{spaces} note {name} ({space}:{id})\n')
return outPattern.format(spaces=' '*indent, **self.__dict__)

When I try to do something similar, I go by concatenating a string.
That may be because I don't use python beside basic scripts, but something feels off. Like it's too simple so there must be a clusterfuck hell hiding behind this __dict__

Neat. I did something similar (a Forth interpreter) with the shunting-yard algorithm. Are you handling overlong encodings, bad bytes, etc. in the UTF-8 stream or do you assume a correct encoding?

>python reflection

Hmm that gives me a bit too think about, as I just started it and I thought UTF was fairly consistent

i assume the other variables - id, name, and space, are lookuped up in the dict

*looked up

who decided that declaring and assigning should share the same syntax?

Attached: why.png (500x258, 14K)

Can an user look at my homework before I turn it in? My first homework I got a bad grade so I tried harder on this one because I don't want a bad grade.

dropbox.com/s/0i1k46qqewyg0fn/Chapter 3 Case Project.pdf?dl=1

Fuck off tripfag

class Commodity:
def __init__(self, e):
"""From a XML e representing a commodity, generates a representation of
the commodity
"""

self.space = orElse(e.find('cmdty:space', nss)).text
self.id = orElse(e.find('cmdty:id', nss)).text
self.name = orElse(e.find('cmdty:name', nss)).text

def toLedgerFormat(self, indent=0):
"""Format the commodity in a way good to be interpreted by ledger.
If provided, `indent` will be the indentation (in spaces) of the entry.
"""
outPattern = ('{spaces}commodity {id}\n'
'{spaces} note {name} ({space}:{id})\n')
return outPattern.format(spaces=' '*indent, **self.__dict__)
this is the whole class.
Somehow, __dict__ automatically gets filled with all the class members?

the last line indentation is fucked up though

I fixed the unreadable typeface in the tables in the end btw, it didn't export correctly for some reason

Your "RAIL" example is inconsistent with the explanation. Where the fuck did you get 'Q' from?
I skimmed the rest. 3-2 is completely wrong. You did not answer any of the prompt. Do it over.
They did not ask you to autistically regurgitate the algorithm. Keep it short.
They asked you to perform an analysis on the algorithm and tell them what you think of it.
You made no mention of information loss in PlayFair.
Where is your analysis on the perceived randomness of the output?
According to information theory, the output of a cipher should be similar to completely uniformly distributed data.
Even answering how easy or hard to use an algorithm would have been easy because all you needed to do was list some pitfalls where it might be easy to make a mistake encoding or decoding the cipher.

thanks

I played around with it a while back, but I never dug in too deep. Without doing too much fiddling, I found that it tends to work best with medium-ish resolution, serifed fonts. Also works best if you feed it an image that's just text, but that isn't always an option of course.

>C
A pain in the ass tiny ugly language. Freshman hacker larpers shill it despite knowing next to nothing about it.
>C++
A bigger pain in the ass and uglier but not tiny.
>Java
Replaces all of C++’s problems with being a ram hog.
>Python
Genuinely good. Reliable but slow. Freshman hacker larpers also hate it so that’s a good sign.
>Rust
Somehow uglier than C but more reliable.
>Assembly
A good language. Freshman don’t understand it and it can do anything. Also the fastest because it’s closest to the metal and all fast languages compile into it. Useful for shaming larpers and genuinely challenging and fun.

Why bother with python when i can do scripting in lisp?

Reminder that if you don't understand comonads then you're not a programmer yet.

I tried scaling the image to double resolution but that obviously doesn't do anything about the pixelation of the text. I might try to apply some antialiasing later though.
My idea was to fully automate ripping benchmark scores from a few different websites to but some kind of mega benchmark but it's a bit tricky since everyone feels the need to embed their data into images for some god forsaken reason

Why would you think something like that?

Attached: 34b71ea1-769b-4858-9849-4c8950c2c196..jpg (640x619, 196K)

Reminder that if you can't program without 50 layers of abstraction then you're not a programmer

If you refuse to use the appropriate tool for the job you’re a shit programmer.

Still unable to understand even basic abstractions, I see. And so ashamed of it that you didn't even dare reply directly.

Are abstractions really appropriate if you don't understand them? Try to understand that poor user's predicament.

>also the fastest
Java can be faster because the JVM will optimize at runtime :^)

You could transcribe that one page by hand, if it was a one-time job. But since already started try to copy and paste the example code here exactly. pyimagesearch.com/2017/07/10/using-tesseract-ocr-python/ Maybe they did something slightly different? Good luck!

It's funny that so many "programmers" don't even understand the most basic abstractions that languages like Haskell and Idris make possible.

Except it can't since Java is horrible on caches and has lots of indirection.

Imagine coming home every evening and shilling for Idris while ruining /dpt/ with your autistic shitposting

Most C codebases contain assembly. What's you're point?

>Most C codebases contain assembly
No they don't. You only see them in video encoders/decoders (for highly optimised SIMD), operating systems, and a tiny bit inside of standard libraries.

upset half of /dpt/ with this one neat trick

>Freshman don’t understand it
every freshman at my school had to take a computer fundamentals course in their first semester that was ~7 weeks of transistors and logic gates plus ~7 weeks of assembly programming

RISC ISAs are nice, CISC is shit.

Too bad x86 won. (And yet RISC is so much better that most modern chips use it internally, what a waste of silicon translating to it)

>people ruining /dpt/
this makes me mad, /dpt/ is supposed to be comfy

Attached: 1548129005862.jpg (640x480, 45K)

If you want /dpt/ to stop being "ruined" then obviously you should learn Idris.

Fuck off jani

This is a Lisp board stop shilling your shitty language

Any recommendations on what I should follow up on for computer architecture after finishing NAND2Tetris? My goal for this year is to build an NES emulator.

>~7 weeks
HOLY SHIT STOP THE PRESSES!!!

Are you the one who made that thread the other day about 'how to make a game?' Just problem solve fool. Break your issue down into it's smallest bite-sized components and implement them and things will come together.

>If not enough memory is available in the free store for an object of type T, the new request indicates failure by throwing an exception of type std::bad_alloc
What the fuck is wrong with C++?

Attached: 1421386169089.jpg (195x195, 23K)

yeah it should download more RAM