/dpt/ - Daily Coding Thread

What are you working on, Jow Forums?

Attached: 1556492865688.png (1834x1200, 581K)

Other urls found in this thread:

youtube.com/watch?v=XhjnG7tU6fo
github.com/rootcoma/cclife
github.com/rootcoma/cclife/blob/master/cclife.c#L27
cs.ukzn.ac.za/~hughm/os/notes/ncurses.html
youtube.com/user/njwildberger/playlists
asciitable.com/
twitter.com/NSFWRedditImage

>The Lisp/Haskell crowd lives in a dream world where they wear a monocle, drink fine wine and write elegant code. They always show the same toy examples. “If you are writing this convoluted made up example, Haskell is better than C.” Sure it is, grandpa. No, reading SICP or the elephant book did not improve my programming. Reading 50 shades of grey, or any of the vampire romance novels will teach you more about programming than learning Scheme or Haskell will.

I was wondering, do you guys do other stuff besides programming?

How fast do you code when you are at your best?

how do you measure that?

Been working on a shell written in Ruby. Trying to get kill implemented.

Just toss an estimate

>/dpt/ - Daily Coding Thread
>Coding
>no link to previous thread
>image expresses an opinion
>image is not anime
>first reply is language crusading
Worst /dpt/ I've seen in a long time. But then again, I left /dpt/ for several months and am only just coming back.
You'd better not tell me this is just what it's become now. I don't think I could handle that.
>inb4 it was always like this
No. It was always shit, but /dpt/ is like drugs, the only non-shit is staying away from them, but aside from that, there's good shit, and there's bad shit. This right here is the bad shit.

>self self self self self
>str.__len__() __main__
why such a terrible language is so popular?

Attached: g_-_-x-_-_-_x20160928141043_0.png (512x512, 12K)

Working on an admin too for a client's program. If this post gets quads I'll add and post a backdoor

completely worthless measurement
whats more important it how long it takes to figure out what you want to write

Technically counts as quads?

this is where it's at

It makes some of the conveniences of functional programming accessible to the unwashed masses of brainless poo-shitters without trying to force enough such abstractions down their throats as to exceed their tiny cognitive capacities.

when were you when you realized prototyping apps in classic GUI libs were faster then webshit ?

i was in living room eating C# butter when billgate ring

"y u use winforms u can use electron or prototype web app"

"no"

Attached: mfw_progress_from_afar.jpg (690x513, 29K)

>python
>functional
dude

like 11 or 12

>without trying to force enough such abstractions down their throats as to exceed their tiny cognitive capacities
Gosh it's almost like you're the kind of person I'm talking about

Illegitimate and shit thread.
Fuck off.
Someone make a proper one.

Who else listens to old vidya battle music while working on difficult themes? This unironically helps me.

youtube.com/watch?v=XhjnG7tU6fo

Attached: 1477798214685.jpg (1287x964, 368K)

Python is the anti-functional. It deliberately tries to prevent you from writing anything which even smells functional. Sepples and Java do functional better than Python.

>themes

Oops I'm 'tarded. Meant projects.

I have a snake game I'm trying to finish up. I just want it to open the main menu once I lose, so the user can play again.

When I run my program, I can play snake normally until I die; it works well and there are no problems there afaik. Once I die, I am back in the main menu, as expected. The problem is, once I hit my key to play again, the game screen flickers in, then disappears and brings me back to the main menu. I get stuck in the main menu, unable to back into the while loop I have. Why is this happening even though I called main()? Shouldn't my program just reset nicely?


This is my main:

int main(int argc, char** argv) {

Setup(); // variable stuff

MainMenu(); //open our main menu so we can start playing

while(gameOver == false){.

Input();
Draw();
Logic(); //All these are each frame
Sleep(80);

}


main(argc, argv); //when gameOver is true restart
}

Attached: 1445953256287.jpg (400x340, 47K)

what's the problem with self?

I’m learning to sew. I’m also an avid user of /fa/

I’m willing to bet OP did this specifically to piss off spergs like you, and it worked

>while(gameOver == false){.
>Input();
>Draw();
>Logic(); //All these are each frame
>Sleep(80);
>}

Attached: 5uc2s8ql.png (403x391, 256K)

>hurr even if functional code is safer than c it will always be slower
Wrong.
Reminder that pure functional programming is actually even lower-level than machine code. We just need a compiler that can build said even-lower-level code.

Which is to say, we need a Haskell compiler that can drive a USB interface to an assembly line for integrated circuits.

Pure functional code more closely mirrors the operation of electronic components than any other programming paradigm out there. A pure functional program is a perfect model for describing the structure of an arbitrary integrated circuit.

Since a processor is a specialized and highly complex kind of integrated circuit, an arbitrary integrated circuit is of course the next level of technology downward in the hierarchy from a processor, and therefore has the capacity to run faster, smoother, and more reliably than a processor, with far less bloat, but for a more limited set of purposes.

As such, functional code is FASTER THAN MACHINE CODE.
Checkmate poolets

I'm a musician of 10 years, writer of 4 years, and programmer of 1 year. Maybe that's like the inverse of the typical programmer.

Attached: 1532777619477.jpg (1306x982, 205K)

Currently working on a programming language for my final semester CompSci project for language dev. It's going to be pretty C/Java-derived, but whatever.

Speaking of which, anyone have any cool ideas they'd actually like to see in a language?

Do you ever set gameOver to be false again?

pls no bully, i just started

yeah, I do

Idk if this would make sense for your project but I really enjoy pattern matching

Also, instead of writing while(gameOver == false), you should write while(!gameOver).
Your functions should also start with lowercase characters.
My question is why exactly are you calling main recursively? You should make a new method to take care of starting the game and just call that instead. It's really not a good idea to call main at any point after the program has started.

Probably ridiculously hard to implement but multiple dispatch (aka generic functions) everywhere would look really cool. Also pattern matching, tail recursion, type classes.

I'm going to assume that after you're back in the main menu, you're not setting gameOver back to false. If it's still true and you try to jump back into the game, it will just take you back to the main menu again because it thinks the game is over.

>It deliberately tries to prevent you from writing anything which even smells functional.
It has first-class dynamic functions with closure properties.
It also has first-class types, which allow you to sustain a type algebra (though, admittedly, this solution, in which types and values are in the same category, is an inferior solution to just having a hierarchy of categories, that all follow the same syntactic rules but can't be intermixed, such that types are a step up in that hierarchy from values).
It also has immutable variants of data structures.
These are very basic functional features, true, and you might expect them from any modern high-level language. But even so, they are still the features I'm referring to.

>My question is why exactly are you calling main recursively
because you win by causing a stack overflow

>Want to learn programming
>Postponed it for a year again over uni math and courses
>Even did agile course even though I cant code
They say clear goal is the best thing for learning. Give me a clear objective to achieve so I can work towards something.

Attached: 0bb7050b.jpg (526x681, 113K)

This looks like C or C++. FYI, for future reference, in those languages, calling main() from anywhere in your program is undefined behavior. You should define main(), and expose it, but you should never call it. I don't know of a single standard implementation that does anything undesirable if you call main() later in your program, but in theory, it's not a case any of them actually need to be able to handle desirably.

Here's an idea. This is what I just did my compsci dissertation on, too.

Make a system to randomly generate a story. You can start small, IE words, sentences, then build up to paragraphs, chapters, etcetera.

Really? Because if so that is amazing functional languages are beautiful.

you just need a project

Doesn’t your math degree have some scientific or statistical computing class?

I'm not sure what you guys mean by 'pattern matching', but most languages 'pattern match' anyway don't they? My language uses a parser that recognises syntax patterns and converts them into an Abstract Syntax Tree, which is pretty common from what I'm aware.

Tail recursion is alright, but my language is interpreted and not compiled, so there's less benefit to doing it. Also, because of the AST, I'm pretty sure it already supports recursive tail functions (I'll have to test it tomorrow).

I did one this year but most work was with matlab so its not like I can actually program.

Not sure about computing, but in my uni the math and compsci students share Cryptography classes. Which most of the math students seem to struggle with horrendously, by the way. It's quite funny actually.

Oneechan, your JavaScript looks interesting.

Attached: a339aed98ee833b8171a5db989dc8863.jpg (564x846, 59K)

One of the most common babby's first programs used to teach programming is an interactive command-line program that asks one or more questions to standard output, retrieves answers from standard input, processes the answers to generate useful information, reports that useful information back to standard output, and terminates.

Very trivial example:
>stdout: What is your name?
>stdin: World
>stdout: Hello World

Another example:
>stdout: First number:
>stdin: 2
>stdout: Second number:
>stdin: 2
>stdout: 2 + 2 = 4

Fuck off pedo.

How do I focus /dpt/? I tried to turn off internet and just kode for 8 hours, but it doesn't work. Instead of shitposting I went smoking every 20 minutes. I cleaned up my room, listened to couple albums I really wanted to listen to, bushed my teeth 10 times, took a shower, shaved, and bought sparkling water in the nearby store. How do I get some willpower?

Alright, I think I just found the problem myself, turns out I never cleared the values of the snake's tail so it was just killing me instantly, it seems to be working now and I made changes as said, thank you

I do know that stuff, I have cursory knowledge of how classes, syntax etc in general works. What I lack is knowledge about algorithms and data structures. At least thats what I think I should learn next

I'm working on my untimely demise

you can help by being an unhelpful condescending asshole when I ask a pragmatic question

From , a typical logical next step is to learn how to implement a data structure, and write a shell to manipulate that data structure in memory.

Example: int stack shell
>stdin: push 1
>stdin: push 2
>stdin: top
>stdout: 2
>stdin: pop
>stdin: top
>stdout: 1
>stdin: push 1
>stdin: add
>stdin: top
>stdout: 2
>stdin: push 2
>stdin: add
>stdin: top
>stdout: 4
>stdin: push 4
>stdin: add
>stdin: top
>stdout: 8
>stdin: pop
>stdin: top
>stdout: Stack empty
>stdin: exit

Discipline. I'm like this too. Actually, fug this board. Getting back to work now.

Attached: 4386112-bibleqyuqtucy.jpg (1920x1920, 387K)

Don't worry about what you make just make something. Even if it is buggy slow and horrible because everyone starts somewhere and as long as you are willing to improve you can make it. You could also try some websites like hackerrank or something similar to practice solving problems if you can't think of anything offhand. At least you will still be programming even if it is just a single function.

Is it worth buying the TACP volumes?
>

this isn't Stack Overflow though?

>lol i don't hafta specify the type
god I hate reading python code

It’s more or less a syntactically sweet switch statement but, for example, can iterate over an entire list and check a condition on every element. Check out Ocaml pattern matching. I personally hate that language but I think the devs handled pattern matching alright.

It's literally me but for guitar practice.

Anyone know how to structure an SQL query/table to allow for multi-dimensional filters in a dashboard?
For example I want to calculate X formula, and be able to set filters to recalculate X formula where Y = 1 AND Z = 2
This probably makes no sense to anyone but I’m stumped

How hard can it be to make a simple webbrowser?

Very.

Fuck on pedo

ill show you later

define "simple".

no you're less helpful

>have to waste time on a computer filling out applications instead of programming

Attached: 1503455409734.jpg (820x700, 52K)

>tfw when the brainlet in the pic
wat do. but i am employed

What functional programming language doesnt eat 1GB of runtime memory?

I need help.

Whenever i draw a box of n*n dimensions in ncurses, it appears taller than it is wide because each "tile" is the size of a normal character rather than monospaced. However, in github.com/rootcoma/cclife they are able to draw "pixels" of equal height and width. How do they do this in ncurses and how can i do it? There's even a tetris game which also draws proper true squares instead of these oblong shitty rectangles.

Common Lisp

haskell
2gb

>immutable variants if datatypes
But somehow frozendict isn't good enough, so I have a bunch of .iters and dict calls everywhere.

funniest part about this pic and "smartlangs" in general is that just like arch linux, the majority of people who use it or adopt it do so only to feel smart despite it being impractical or more effort than its worth. What's even funnier is that these "smartlangs" are far too easy to learn.

But forget all that bro, let me define a monad!!!

Draw two space characters, it should be about as wide as it is tall then.

It's this COLS_PER_BIT value that defines how many of the BIT_CHAR to show per "pixel".

Extremely. The web is bloat.

Forgot link I was going to post.

github.com/rootcoma/cclife/blob/master/cclife.c#L27

Thanks.

What about if i want to half the height of a single col-line intersect? To get a display similar to dorf fort?

How do I fix my array to output 8 rows and 8 columns of alternating black and white buttons? In other words, I'm creating a checkerboard out of black and white JButtons.
This is for a test, due in two hours.

Attached: 1544915121019.png (756x702, 75K)

>recursive main in a non-tail call optimized language
>not doing while(!gameOver)
oof

Possible brainlet question here. I moved a couple of functions from main.c to another c source file and included it in a header. When I did this, the program got dramatically slower and takes more CPU. What's the reason for this?

that shouldnt be happening

>Trying to get kill implemented
Don't bother. Just use /bin/kill.

It's unlikely that it's THAT much slower, but enable link-time optimisation regardless.

I looked at some dorf fortress screenshots and they seem to have normal monospace characters, where they are taller than they are wide.

Maybe some of these special characters could help. Maybe you are looking for an ascii pipe or box or something?

Source: cs.ukzn.ac.za/~hughm/os/notes/ncurses.html

under "Line Graphics"
ACS_BLOCK solid square block
ACS_BOARD board of squares
ACS_BTEE bottom tee
ACS_BULLET bullet
ACS_CKBOARD checker board (stipple)
ACS_DARROW arrow pointing down
ACS_DEGREE degree symbol
ACS_DIAMOND diamond
ACS_GEQUAL greater-than-or-equal-to
ACS_HLINE horizontal line
ACS_LANTERN lantern symbol
ACS_LARROW arrow pointing left
ACS_LEQUAL less-than-or-equal-to
ACS_LLCORNER lower left-hand corner
ACS_LRCORNER lower right-hand corner
ACS_LTEE left tee
ACS_NEQUAL not-equal
ACS_PI greek pi
ACS_PLMINUS plus/minus
ACS_PLUS plus
ACS_RARROW arrow pointing right
ACS_RTEE right tee
ACS_S1 scan line 1
ACS_S3 scan line 3
ACS_S7 scan line 7
ACS_S9 scan line 9
ACS_STERLING pound-sterling symbol
ACS_TTEE top tee
ACS_UARROW arrow pointing up
ACS_ULCORNER upper left-hand corner
ACS_URCORNER upper right-hand corner
ACS_VLINE vertical line

anything?

>taocp
I did. Takes me about a year to do each volume. I just started Vol 4a. You don't buy and do these unless you're really interested in computer science, because there are dozens of unsolved problems per page in the books. The new ones he has coming out 'Math prelim redux' is filled with probability theory, like Martingales, all of which has direct applications to finance/machine learning.

I didn't start with taocp though, I read CS:App first and Algorithm Design by Kleinberg/Tardos which scratches the surface of these topics then Knuth will cover them in ridiculous detail. In Cs:App and 'hacker's delight' book you do a lot of bit shifting hacks, but nobody ever tells you the theory. Knuth will show you the theory in 4a and now you can apply it to anything from there. Vol 2 is still used by MIT and dj bernstein refers to it as the old testament of crypto analysis, sometimes still citing a chapter out of there for his recent talks.

Knuth assumes a certain math maturity level though, meaning you've already seen a bunch of proofs. In the same spirit of Knuth, where he uses a theoretical machine to teach you computer science, there's a series of math foundations lectures which teaches you math but with a theoretical confine to the rational numbers. youtube.com/user/njwildberger/playlists see the foundations A, B and C lectures. This is how I learned the math in taocp, watching wildberger doing basic proofs of things like projective geometry from 2D to 3D and lectures on matrices/his whole linear algebra lectures. After I was able to follow Knuth in the first chapter of math preliminaries where he tersely covers discrete math.

Finally the programming is up to you which language you want to use, I did the first book in MIX then switched to my everyday lang (because I also took a course in higher level language analysis, such as analyzing garbage collection/dispatching). MMIX is much easier, multiple registers make programs short.

pure keyword that enforces a function having no side effects.

Like gcc's __attribute__((pure)) but not gay

C compilers support TCO you fucking retard.

>in a non-tail call optimized language
If he compiles with GCC or Clang, he can guarantee tail call optimization.

*MIXAL/MMIXAL language

c++, say you are in a loop. is there a way to instantly skip the rest of the iteration and move on to the next one? or is that only possible in recursive style?

imagine:
loop
nested conditions IF YES DO X AND SKIP THE REST
conditions
end loop

continue

continue;

#include

int main() {
printf("NIGGAS IFFY UH, BLICKY GOT THE STIFFY UH"\n);
}

Attached: 1543138980935.png (748x689, 74K)

For ascii I use this site often.

asciitable.com/