/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: sip.jpg (768x768, 83K)

Other urls found in this thread:

buildyourownlisp.com/
leanpub.com/alexandhappy/read
en.wikipedia.org/wiki/Programming_paradigm
twitter.com/NSFWRedditImage

anime is gay

What the FUCK did you just say about Python?!

Attached: 1534477258112.jpg (1919x991, 98K)

Since everyone and their mother is implementing toy languages now, any good resources on writing parsers?

>C++20 will have standardized stack trace reflection
pretty neat t b h

buildyourownlisp.com/
but don't write your own parser, use lex and yacc.

Nice, I followed the same guide. I use helm-gtags currently. There recently seems to be a lot of development around LSP servers which supposedly can do tagging, syntax checking, and other stuff all in one package.

I used irony-mode a long time ago, but ran into a lot of bugs with syntax checking and the server crashing every 15 minutes. It was pretty decent, but ccls (up to date fork of the cquery LSP server) seems to be a lot faster

memelang creation guide v1.0:
1) Lexer & Parser generators for grammar
2) LLVM for codegen
3) ??
4) memelang

Guys is learning C a good way to start learning computer science? Also I kinda know the basics of C++ and I tried programming with winapi or win32 or whatever that is im not sure and is that stuff like using pre coded stuff to make programs or is it something else? And if its precoded how do they code it, like where do I learn it. Basically i wanna know how to do everything from scratch but right now im kinda confused.

(You)

Attached: 1549319332059.gif (100x100, 39K)

coding does not equal computer science

Well I don't want to just go and make a syntatic sugar on top of existing things, I'd actually like to learn about those concepts, I'm just winging it right now, wrote a neat lexer and working on my parser to generate the AST, doing alright but I'm struggling a bit with how should I handle things like prefix vs infix parsing and expressions vs statements. I figured some reading material could help me understand these concepts better rather than me just going full pajeet and writing random shit that seemingly works only to realize later that it will fall apart once I want to move onto another feature.

you forgot the memesolution, monadic parser combinators

What's the best practice for choosing a line discipline ID?

Are there more detailed guides on using Parsec? I feel like I have a vague grip on monadic programming but all I can find are calculator examples that don't have explicit keyword checks.

here's one i just found
leanpub.com/alexandhappy/read

no u

ok my interest is only programming then

I liked the discussion in last thread about mathematical truths in opposition to post-modernist rejections of absolutes.

en.wikipedia.org/wiki/Programming_paradigm
research all the titles to the right and then research all different implementations of the same paradigm.

>in opposition to post-modern rejections of absolutes
implying it's post modern
implying it's a rejection of absolutes

If there was an optional borrow checker for C, would you use it?

also why not make a thread
if there was an optional borrow checker for rust maybe people would use it

I'm working on trying not to kill myself

It'd be a barely functional band-aid, so there'd be no reason to use it.

This is just a guide on using Alex/Happy as a lexer/parser generator?

and you are failing really bad

Oh parsec, sorry
Well as I said before, would it be possible to have another tokenising/lexing step into words beforehand?

>failing
If he's posting here it means he succeeded so far.

good luck

Working on re-learning Python atm. Once I am done with that gonna move on to Java. Also going through Linux Journey too.

Why are you wishing her good luck if she really did succeed?

I guess me and other two anons have a sufficient understanding of each other's position and sufficient discussion, isn't really needed.
tl;dr the anime avatar guy wants honesty, which I really cannot provide with my worldview.

Im writing a program to read a csv like file with different sections and rewrite it.

Would it be good design if I wrote each section as its own class to do specific rewrite actions and store important fields in a struct within each class.

Example

[Code]
SectionOne()
{
List secList

Writefields(int i, data,data,data)
For(int i)
StructSecOne(data,data,data)
SecList.add(structSecOne)
}
ClearFields()
}
Struct structsecone()
{}

[Code/]

That's basically what my question is.
like say I'm trying to read
include lib.Thing;
start class main (String input) {

}

And my grammar defines that first line explicitly, followed by the grammar rule that defines the start class.
How would I go about matching *those exact keywords* that were not non-terminal grammar rules? e.g. Matching the grammar rule
start := "include" "lib.Thing" ";" main
main := "start" "class" "main" "(" "String" ID ")" "{" STMT "}"
I can build the non-terminal trees perfectly fine, but I cannot for the life of me figure out how I should be matching these specific, hard coded, exact word strings?

I recomend taking basic grammars and trying to use the parsec primitives by hand. Then you can use more magic once you understand how it works.

I can't decide what functional language to pick

I want a language with these features:

* good type system but you don't have know or do anything with monads because I'm too dumb
* optimized for recursion
* good concurrency model i.e. no GIL
* has at least an active community, but more libraries the better
* no OOP to the level of Scala where it could be written like Java

any recommendations?

Using parsec? Why not just have something like (string "include")
string is from Text.Parsec.Char
Matching a string is basically just matching a sequence of characters

I improved the Jazzy compiler and wrote a program to dynamically allocate and fill a buffer with factorials and print it
facts n = a 1 i 1 l 0 tmp 0:
= l @m * + tmp n 8
??

You can use Haskell without understanding monads. It has all of the rest of those just fine.

>tfw solve all the easy problems
>now gotta do all the hard shit

Attached: 349.jpg (637x921, 34K)

Why hasn't CS theory improved on parsers? I've looked at both GCC and Clang and it's a goddamn nightmare

>her

dumb frogposter

>string is from Text.Parsec.Char
_yes_ thank you, fuck. That is exactly what I was looking for. Everything I was googling around for to do matching on exact strings was overly obtuse.

Go is strongly typed, has first-class function types, was specifically designed for concurrency, relatively active community, and has at best a vague level of OOP.

Parsers are generally considered a "finished" problem. Most of the research focus now is on compile-time optimizations using polyhedral models or automatic parallel optimization or vectorizations without having to use pragma specifications, side-stepping the parser entirely.

heres a toy program to parse (a very restricted) subset of xml-like docs

Attached: xml.png (823x824, 102K)

holy shit why didnt anyone tell me ML has pretty much exploded since 2010

Have you literally been living under a rock?

Very helpful, thank you.

Attached: avr.gif (100x100, 397K)

no, but i never appreciated just how much new stuff there is out there

k neighbors, dense neural networks, regressions, expert systems, decision trees, search etc. seem like such old decrepit news now

let me lick your balls for that sexy post

those all existed already for decades, you're even older than you know

go is ugly

Compared to most other languages Go is probably the tidiest and most readable around.

np. good luck, user.

parser combinators don't get enough love in /dpt/

i'm talking about convolution and batch optimizations or whatever, TPU's

i know the other shit is old, that's what i said

Monads aren't difficult, they're just usually poorly explained and mystified because they're a very general concept that doesn't have any immediate meaning, so people try to invent one and fail. It's like a moderately difficult language feature (say, a double pointer) that you just have to use to understand.

Attached: power of monado.png (1883x1424, 249K)

Forgot to add.

>optimized for recursion
>good concurrency model i.e. no GIL
>has at least an active community, but more libraries the better
I have no personal experience with it, but it seems like you might want to look at Clojure.

Pls respond i wanna learn about design patterns

nice

I'm the smartest programmer on Earth.
AMA.

Attached: 1530086254197.jpg (680x680, 69K)

Why did you waste your time mastering programming?

Attached: 1550644025144.jpg (512x512, 19K)

what's a monad?

Want to work for me?
I can pay you in spuds

Can someone red pill me on why you'd use a double pointer to malloc a 2D array in C? This is the context of what I'm seeing it in.

struct foo {
char x;
int y;
}

struct foo **bar = (struct foo **)malloc(sizeof(struct Instructions) * 10);

//malloc space for character array for each state, 255 characters

for(int i = 0; i < 10; i++){
bar[i] = (struct foo *)malloc(sizeof(struct foo) * 255);
}

They they later use fscanf to populate the array from a file.

Attached: jokster.jpg (1280x720, 40K)

Intellectual curiosity.

The defining feature of monads is the ability to convert simpler type values and calculations into higher type calculations caused by simpler type constructors, and to link multiple such transfers to a single type.

I use C, however.

Could be for a jagged array

2d arrays can better fit data, or they can be easier to index depending on the application
You may also want to do it for the purpose of optimizing memory access

probably for the convenient arr[x][y] syntax but it's inefficient as fuck

>The defining feature of monads is the ability to convert simpler type values and calculations into higher type calculations caused by simpler type constructors, and to link multiple such transfers to a single type.
>I use C, however.
The smartest programmer is a retard. I can't say I'm surprised.

Attached: 1550697308463.jpg (423x347, 16K)

hello, fellow blockchain entrepreneur

Developing an additional feature for an accounting software we use.

Using Python/Flask to handle it.

Small project but webdev ain't actually that bad after all.

Doing Win32 shit with UI Automation.
Why is the decoumentation for Win32 crap so garbage?

Fuck stacks and fuck stack "languages"

>I'm the smartest programmer on Earth.
>The defining feature of monads is the ability to convert simpler type values and calculations into higher type calculations caused by simpler type constructors, and to link multiple such transfers to a single type.
Jow Forums in a nutshell

>Fuck stacks and fuck stack "languages"
Wow rude. Also your language probably uses stacks for scopes.

Attached: 1550699529077.jpg (750x560, 170K)

My language has no concept of scope or context

Attached: 58e.jpg (1024x576, 44K)

Without knowing what the sections mean or what the data represents, we can’t say. Are you processing the data first? If so, you may want classes that represent the data in a meaningful way, regardless of what section of the file it is stored in.
Are you simply reformatting the file? If so, breaking your reads and writes down by section may make sense.

FALSE is love. FALSE is life.

Where did Forth touch you? Show me.

Use alt+c to code

typedef struct { ... } library_type_t;

Attached: 1550942468614.png (418x346, 242K)

It wouldn't stop gabbing my registers ...

how would I specify a python script to run through an entire directory and read each file in that directory?

Attached: 1520032141391.gif (487x560, 898K)

typedef was a mistake

import solution

def solve():
\tsolution.run()

if __name__ == '__main__':
\tsolve()

Animals are great! Animals are great! Animals are great!

But you're refering to implementations, not really just pure CS theory.

>_type_t
this triggers my autism

Separate namespace for structs was a mistake

look up documentation for these: os.listdir, os.walk, os.path.join

os.listdir

Google "shell script for each file in directory"
Copy code feom stackoverfmow
Add python p1.pyh, or whatever python extensions are, in the loop

what the fuck is freshcode.club and why are they sending people to my shitty project?

Attached: file.png (534x210, 10K)

Yeah, pretty shit. It's 10 times worse if they ever do it to a pointer too.

It works fine for simple shit like int32_t. Although libraries typedeffing their own integer types when the standard typedefs already exist is really fucking annoying too.

>freshcode.club
>Open source software release tracking

Sure, typedefs outside of stdint.h are a mistake

Another situation I would consider acceptable are function pointers, especially non-trivial ones.

does it just scrub shit off github?