/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1538258658211.png (656x945, 414K)

Other urls found in this thread:

people.eecs.berkeley.edu/~bh/sicp.html
groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/
twitter.com/SFWRedditGifs

lisp filtered me

fuck recursion, fuck parenthesis

ocaml

Attached: ocaml.jpg (225x225, 8K)

>no native thread support
>no unsigned types
>boxed types
>shitty FFI
>no macros, have to use external tool
>;;
Ocaml is shit
consider SML, SML# or actually good programming language

Is it me or has C# skyrocked in popularity? Is it because of all this .net-core shit? Is it worth learning?

Attached: 86568567845754.png (782x752, 886K)

ocaml

Attached: ocaml2.jpg (446x500, 76K)

Literally neither of those things are hard brainlet

why does JB look like my uncle who's married to his aunt lmao

i want a repository of algorithms in pseudocode

where might i find this?

my cumbrain doesn't have the GPU to visualize the recursive function unfolding itself and then springing back

struct Foo{
int *one = nullptr;

~Foo(){
if(one) std::cout

What language should I start to learn now I am comfortable with C#. I'm thinking Haskell.

emojiscript / cunnyscript

Maybe its stupid question... But can i use context free grammars in yacc/flex/bison? I want to generate parser for palindromes defined by: 0, 1, and if w is palidrome then 0w0 and 1w1 are palindromes. So CFG for this is something like
1. T-> 1, 0
2. P-> 1T1, 0T0

Question is how to write it in flex/yacc/bison and then compile? I only used regexp inside flex

Yes C# is nice. It is basically like Java if it wasn't shit.

Ok thanks, I will look into it :)

It's not about visualizing, it's about being woke enough to feel it within you

Trying to get all files from directory into an array. This seems to work but it breaks when a file has a space in its name.
files=$(ls -v "$path")

for file in $files; do
echo "kek $file"
done

I need files sorted with ls -v, so I can't use for file in "$path"/*.

M8's, I'm getting back into programming again and I want to brush up on C++ with the new 2017 standard. Anyone got any suggestions of books or web resources to look at.

why waste your life grappling with c++?

>and the only Foos that the destructor is called for are temporaries that should be default constructed
std::vector needs to copy things when it reallocates and grows.

If parsers were limited to regular languages they would be absolutely useless, so yes, they can handle CFGs and that's literally what they are built to do.
Just look up any tutorial on yacc and it should tell you how to do so.

It think the Foos with one set to &bar are destroyed in push_back(). The vector allocates a bigger chunk of memory, copies everything and destroys the old Foos.
Put a breakpoint on cout

lookup bash IFS

find tmp -maxdepth 1 -type f | sort -V | while read -r file; do
# ...
done

My neck is so stiff from writing JavaScript all day. Can you please give me a nice massage so I can continue wiritng JavaScript?

Attached: 655b64a60ba4c4e7e70c045dd5d88cb0.jpg (540x810, 52K)

switch to typescript and stop reinventing the wheel

thanks anonymous it worked

>stop reinventing the wheel
>typescript
the irony is rich

what

lets invent dynamic languages because static languages are too cumbersome to use
wait a minute, dynamic languages are bad for writing large stable programs in, what are we going to do?
Let's invent a static language that compiles down to a dynamic one

What are some of the hardest common programming challenges you have to deal with?

If it's common then it's not hard

Haskell

>static languages are too cumbersome to use
What? How?

>not oCaml
shiggy diggy do

This

Threading/concurrency, connection pooling, cache invalidation, hardware interactions.
These cause 90% of our bugs.

you are aware of why dynamically typed languages were made yes?

I assume because people just didn't like static languges but frankly static type checking is so much better than dynamic.

Try actually thinking about your answer

What do you mean? Peopel didn't like making type definitions they would rather just do it on the spot. That sounds convenient but it is really just asking for runtime errors.

DUDE IT'S JUST A 7-RANK MONOIDAL CATEGORY FOLD ON THE VERPUNCTUOUS TYPE-BLOPPITYBLOOP RINGPIECE

NOT THAT HARD, ANY BEGINNER COULD DO IT

I mean you gave a brainlet "I like X more than Y" response without objectively considering the benefits of each approach

seething

I know there is a way in bash to check whether a string starts with some other string:
if [[ "$mystring" == "$someotherstring*" ]]; then
echo "$mystring starts with $someotherstring"
fi

but is there a way without usage of double brackets, with only single brackets? The reason is that I'm used to using single brackets. Also why the code above doesn't work with single brackets?

What benefits does dynamic type checking have? Cleaner syntax? You can have that with static type checking.

I forgot to eat again today. I don't think this programming thing is good for my health.

Attached: [Arukoru] The Wind Rises (Kaze Tachinu) [01:39:17.034].jpg (1920x1080, 1.3M)

useful and original post

If a university you pay for actually teaches people functional programming and not real programming you should be able to sue them for negligence

Give me a topic idea for my C++ project.
Something that won't take me aeons because I don't have much free time but I need to do it.
The requirements are at least 8 classes (at least 4 linked in a hierarchy), uses virtual methods, abstract classes, static attributes and operators or templates.

Attached: V.jpg (1280x720, 94K)

If you're using bash there's no reason to use [ over [[, being "used to it" is not a valid reason. In [ there's not really a way, although I guess you could use a substring parameter expansion.

i developed scoliosis from being sat programming every day and now my existence is distilled misery. i advise against programming, take up a healthier profession like welding, saturation diving, or being a soldier

SICP was a rigorous course in real programming but in an "unusual" language. very instructive even to a procedural neanderthal moron such as myself

>sepples project begins with minimum-complexity requirements
heh

I assume you're trying to start a dynamic vs static typing argument here so I'm telling you I'm not asserting one is better than the other, but the benefits of dynamic typing are obvious.:the programmer doesn't have to worry about types. That is, until your program becomes large and complex enough that you do have to worry about types

>SICP was a rigorous course in real programming
haha good one

TypeScript is a gradually typed language, which is bleeding edge technology and is supposed to give you the benefits of both dynamic -and- static typing. The idea that you should be able to start out with a dynamically typed program and gradually transition to a statically typed program definitely isn't just reinventing the wheel.
Ad even if it was just a static language that compiled to a dynamic one, it's not like the TS developers decided to do this out of fun or because they were stupid. JS is dominating in regards to the web, so gradual typing was really the only choice if you wanted something more statically typed.

Static typing rejects some programs that are correct and may also limit what you can do, so if you're doing rapid prototyping dynamic typing can be beneficial. E.g. if your typing system doesn't support something like generics, HKTs and so on, there are functions that you just straight up can't implement. You can also just get away more with 'hacky' solutions.
I'm personally not that fond of dynamic typing, but there's obviously a reason it exists that isn't just "people are too stupid for types". Otherwise everyone would just use statically typed languages with type inference.

t. code monkey
might as well just go to a coding bootcamp

>The idea that you should be able to start out with a dynamically typed program and gradually transition to a statically typed program
Why don't you just write the statically typed program from the start and avoid the shit performance that comes with a dynamic lang?

>i developed scoliosis from being sat programming every day and now my existence is distilled misery. i advise against programming, take up a healthier profession like welding, saturation diving, or being a soldier

Stand up desks are nice

>Static typing rejects some programs that are correct and may also limit what you can do, so if you're doing rapid prototyping dynamic typing can be beneficial. E.g. if your typing system doesn't support something like generics, HKTs and so on, there are functions that you just straight up can't implement. You can also just get away more with 'hacky' solutions.
This is fucking peak CS student who read more books than written lines of code
At least the coding bootcamp would equip you for a job, all universities do is equip you for Jow Forums shitposting apparently

>i developed scoliosis from being sat programming every day
Should have invested in a proper office chair instead of using some cheap chink garbage.

Attached: embody_graphite_frame_charoal_fabric.jpg (720x576, 40K)

haha yeah some faggot writing helloworlds in sepples knows better

I'm not trying to start an argument but I don't think worrying about types is such a big deal. F# has static type checking but the syntax is really clean you barely have to worry about specifying types. That's what I meant when I said I don't really see much point to dynamic type systems.

>there's obviously a reason it exists
Okay but I think for most use cases it really isn't necessary. Also it really isn't necessary for the web I think it just took off because JS became the web language. I can see how it is faster to write but faster to write isn't always a good thing.

i had a steelcase chair at the time

When your code is relatively simple it's easier to write code in a dynamic language. That's the point

Procedural with functional elements: the paradigm of today, and of tomorrow.

They probably do unfortunately

Yes but if you look at F# it is static but pretty much just as easy to write in granted it is a functional language so that changes things a bit.

john carmack recently (probably more than 4 years ago at this point) worked through SICP and said it was a most instructive experience for him. does some faggot shitposting on Jow Forums know better than john d. carmack? the "d" stands for big dick, by the way.

He's right, leave him alone. Before SICP, programming courses were about how to operate a computer with a specific programming language. SICP was the first course to be truly about the practice of programming, the effects and costs of abstraction.

people.eecs.berkeley.edu/~bh/sicp.html

Attached: sicppatt.jpg (800x534, 66K)

>John Carmack!

Attached: 1533387818794.gif (413x243, 51K)

fuck off pedoweeb

>Herb Sutter!

Attached: india2.jpg (865x823, 350K)

>Yes but if you look at F# it is static but pretty much just as easy to write
Yeah you're being a fucking idiot and confusing "I like something" with "It must be objectively better than the alternatives" again. It's easier to omit types than put them in. That's just a fact, it's easier to not have to say something that have to say it, until the complexity requirements of a program reach a certain point and the drawbacks of implicity start to outweigh the benefits of it being easier to write

go away

If your task isn’t compute bound then dynamic languages will be good enough. The big advantage ms of a dynamic language are realized with objects and duck typing. You can simplify your design to “does my object support this message?”. This avoids the pitfall of static OO languages like Java which require complicated subclassing to satisfy the static checks.
Its quite fun and freeform to glue objects together like this free of boilerplate.

so what you're saying is, one of the best programmers never read SICP until he became washed up and irrelevant? Sounds like a valuable book

SICP isn't a course. It's a book. If you think there's no non-language specific books on programming then you need to take visit to the library. There's hundreds

Fucking retard, AskJeeves "type inference" and then come back here.

>That's just a fact, it's easier to not have to say something that have to say it
Yes and you can do that with type inference. You are the one getting emotional. I am not saying dynamic isn't a little easier I am just saying it isn't easier enough to really be that great goddamn.

It's like you've never heard of structural typing.

>The big advantage ms of a dynamic language are realized with objects and duck typing
that's right, and duck typing isn't compatible with static typing, so again, why not just use an actual static language like the rest of the world

>SICP isn't a course.
groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/

>SICP isn't a course
Lecture 1A | MIT 6.001 Structure and Interpretation of Computer Programs, 1986

It’s like you are too afraid to write code without the safety rails of static type checks.
Programming well in a dynamic or untyped language is difficult and liberating.

Why would you badmouth sicp? Who the fuck does that? It's like calling your grandma a cunt.

Would you consider writing a parser for some format like XML/JSON to be a relatively easy or a hard task?

easy for JSON, hard for XML

sicp was first released in 1985, it completely revolutionized the teaching of programming.

>I am not saying dynamic isn't a little easier I am just saying it isn't easier enough to really be that great goddamn.
What the fuck does that weaselly little sentence even mean?
Type inference is not dynamic typing. You can't do duck typing with type inference. Different paradigms have different advantages. You're looking it through this emotional lense of you trying to justify your own preferences by saying it's better than the alternatives. The hallmark of a stupid programmer

>Programming well in a dynamic or untyped language is difficult and liberating.
>caring about this bullshit instead of writing a good program that you know works based solely on the fact it compiles (in an ideal world in reality most languages has some dynamic type checking)

>You can't do duck typing with type inference

>it completely revolutionized the teaching of programming.
no it didn't
who is feeding you this information

There's nothing to be gained from making things "difficult" for no other advantage.

just graduated with applied/computational maths. going through K&R+AlgosTextbook and some Project Euler problems using Sagemath. I feel as if I go through K&R with an accompanying algorithms textbook I can begin grasping fundamentals. Trying to avoid becoming a webdev shitter.

Attached: 1557014869689.jpg (2048x1148, 39K)

Where do you think you are?

I never mentioned duck typing that is separate from static type checking. Static type checking just means during compilation it will determine if it is a valid program or not. You also throw around a lot of insults to me that is a hallmark of a jaded programmer.

So you are saying we should all use Java because dynamic typing is too scary?
Ignoring that most of the code in the world is written in dynamic languages, large parts of your OS are glued together with then, the internet is glued together with dynamic code in both the browser and infrastructure, assembly and machine code are themselves untyped.
Static typing is a convenience, not a necessity

Similar but not the same

>Static typing is a convenience
Exactly! So why not use it?

The advantage is not writing endless type declaration information for code you know works.

Actually they are the same.