/dpt/ - Daily Programming Thread

/dpt/ - Daily Programming Thread

old thread: What are you working on, Sup Forums?

Maki Edition btw!

Other urls found in this thread:

tomasp.net/coeffects/
youtube.com/watch?v=QM1iUe6IofM
youtube.com/watch?v=IRTfhkiAqPw
youtube.com/watch?v=V6VP-2aIcSc
twitter.com/SFWRedditImages

Thanks for using an anime image

First for

now that I have your attention, how portable is ncurses when going to compile on cygwin?

Implementing the simply typed lambda calculus

If I'm phrasing myself so poorly should I really be in charge of a language? I don't think so.

Also I suspect people may be confused because I didn't reply to the right post. The initial problem is that any performance oriented language isn't high level enough to reorganise your data for cache line efficiency. If they can do that they solve a lot of issues. Some js newbie is using a linked list? Put every element in a vector and allocate chunks.

It doesn't have to be perfect. It just half to be good enough for me to not have to be frustrated about it.

And the only language I see moving in that direction is JAI. and it's years from being there. Its frustrating.

if lisp was the 70s of langauges and Haskell was the 2000s of languages

What will be the 2020s of languages? Idris?

If Haskell is reaching satori, what would idris be called

Brainfuck

They're both memes that will be dead in a few years.

Relatively portable, but you don't even need Cygwin. There's a native win32 version you can use with MinGW.

First fo scala is best java

What's something simple that I can make in Go? I'm trying to learn a little more.

>Reading two values from memory: 846 and 745
>846 is VERY CLEARLY hanging out at address 5543EBC8 and 745 is at address 5543EBCC
>Print the values of both addresses
>846, 846
I don't understand this computer shit Sup Forums. Technology was a mistake.

>I have no idea how I would do 80% of the easy ones
What should I do? I know OOP practices and am not a total beginner, but most of these seem way too complex for me.

Random wallpaper downloader, 20 minutes tops

Post your code

Start one and see. Just do something.

>I know OOP practices
It would be best if you forget all of that.
OOP is fundamentally flawed and should never be used.

I love Maki!

Most of easy are easy but for some you need extra knowledge, For e.g how to calculate PI.

There is no trick to it, even if you dont know how, go and try to solve, when you are stuck google

...

I'm not even baiting. OOP is actually garbage.
Enjoy your shared state and difficult to reason about programs.

It's not bait, it's true

No its not, OOP is a tool you use it for some problems not all. And once you learn it its not hard to reason about programs.

What do you suggest functional programming like haskell where you must wrap everything into monads?

you better not be going through all this just for colors

>OOP is a tool you use it for some problems not all
Some tool are just shit. You need to be able to think critically about things and throw out things that don't work.
>And once you learn it its not hard to reason about programs
By "reason about programs", I mean reasoning about the state of the system at any given point, not how your shitty mishmash of classes fits together.

I don't see why you're aiming to hurt people..

>What do you suggest functional programming like haskell where you must wrap everything into monads?
Not a bad start but a type and effect system is better

>some programs
Show me an open source project where OOP is used appropriately.

Okay lets assume i want to make muh game. I find OOP particularly suitable for modeling objects and game state? How do you propose doing this without objects? Old C style?

I dont know but that doesnt mean OOP isnt good for some tasks

Basically any open source library intended to be used with Java/C#?

> yfw you won't able to learn and do programming after 70+

FUCK, I want to stay alive, even in loneliness, to able to continue learning new tech and p. languages!

Why aren't cyborgs or augmentations a thing yet?

I'm not familiar explain?

Is F* any good?

That sounds awful. Terrible standard placed for OOP code then.
So you're basically arguing that it has to be good for something and that's why it's a 'useful tool'. That's like arguing bongo sort is a useful.

Object oriented programming is really useful for crud-apps. Business applications, stock management, employee management, that kinda nonsense. Since most software that get's written is crud business apps, oop is the most popular paradigm.

The difference is rather than explicitly using monadic types, say [x : IO Int], your terms have effects, e.g. [x : IO & Int]

I wouldn't use it for professional development

Yeah, like any other tool it sucks for some things, its ok for other, and great at rest... And you should learn it as its industry standard.

Beside that im generally curious how to model a game without OOP and massive code duplication

whoops
x : Int & IO
indicating that x is an Int with an IO effect

so you wouldn't need to worry about using bind or do notation or such, the compiler would infer it, and you could easily combine effects

x : Int & (IO, State)

>curious how to model a game without OOP
Entity component system

So state monad basically? Or something impure?

So state monad?

Isnt ECS part of OOP? You just use composition instead of inheritance or am i missing something?

I'm so lonely. My coworkers think I'm a workaholic, it's just that I have nothing else to do

And decent game avoids OOP as much as possible. Your kind of thinking is why there's such a major difference between games in performance despite the visuals being close to identical.

I dont know thats why I'm asking!

Effects and monads are very similar, a type and effect system just encapsulates an effect with each term rather than requiring it to be part of the type itself

>and he starts claiming territory.
No. OOP is not what you think it is. Go read Wikipedia.

Yet you say you're in a position to judge what I should learn and/or not learn. Maybe have a few spoonfuls of modesty.

That's not how you spell Clojure.

I want to give this cat some catnip and a bowl of milk.

Blame biology majors for not coming out with a cure for aging yet.

I never said anything about learning im only arguing against general statements like: oop is inherently bad, which like all generalizations are necessarily false

Do you have any reading recommendations on subject?

>all generalizations are necessarily false

OOP doesn't fit problems because it's not oriented around problems or how computers function. Its a completely arbitrary construct made to be marketable.

Maybe that will help you understand why it's bad if you don't feel like exploring the topic for 10 minutes.

There's a good article/website on co-effects, which are kind of like the opposite of effects (they're analagous to comonads), they place constraints on the context rather than the result

tomasp.net/coeffects/

Idris "has a flat effect system", but really it just has an effect monad that combines other effects

I never said OOP is good yea i know it has shortcomings i just fail to see it as such evil.
And ofc its arbitrary construct so what that doesnt necessarily equal bad.
Are you saying it doesnt fit any kind of problem?

Thanks, can i apply this in other languages?

It doesn't fit any kind of problem the best and it doesn't fit problems decently well in the first place. Plain dumb procedural programming without planning can very often get you further unless you're dealing with a problem that you've done using OOP before.

It's incredibly underperforming. But yes of course it can be used to solve things. So its not 'the worst' simply by virtue of things being possible. But it's terrible for the software community at large.

I don't know any* languages with builtin effects or co-effects

damn, ill still read it since its interesting

OH and of course completely trivial OOP tasks you're taught in school are designed around OOP. So its not surprising a newer programmer will have these opinions.

Okay lets say we agree

So i want to move away from OOP what do i do? And dont give me some method only available in some nieche language i cant apply to anything useful.

Procedural programming, while favouring pure functions.

Daily reminder to use comments and to write fucking documentation.
>inb4 self-documenting code
No nigga, nobody should have to infer anything about your code and your "intuitive" naming schemes are anything but. Write some documentation or get the fuck out.

Now lets see on concrete example

Lets say in OOP game i have object player with bunch of attributes and methods, i also have different kinds of player all sharing same superclass thus eliminating code duplication. Its relativly succint solution, how do i do the same in procedural style without objects?

Functional programming, while favouring procedures

Im forced to use c++ since this is a game and i need performance, have you seen func prog in c++?

Just write higher order procedures yourself

Does that sound like simple or elegant solution to you? Especially in c++? Yeah in haskell thats way to go but haskell is basically useless in industry

You're asking us to explain something to you in a language you don't even know.

Just use a fucking struct.
You seem so fucking engrained in pOOP, that you don't even know how to write simple procedural code.

This.
Seriously this kid has gotten so destroyed it's ridiculous.

You've fallen for the shitposting meme

Yep im retarded... And i thought someome might give me practible solution... But no, all i got was implement your own higher order functins and duplicate bunch of code or fake oop with structures...

>don't understand higher order functions
>think all structured programming is OOP
You don't know how to program

I thought maki left g?

Yes because i talked so much about higher order funcs you managed to get i dont understand them

I dont like OOP either, I just cant seem to find good alternative to it when using "popular" languages.
Show me example of how OOP solution to a problem can be transformed to structured program without lots of code duplication? I agree with you in principle but not in practice

Why would there be duplication?

No one leaves this place. When I'm 50, I'll still be shitposting here.

>give me an alternative to OOP but make it OOP do that I still like it
Literally rajeeshit

non sequitur much?

On example of inherited classes how would you create structured program?

there's only room for one Idris poster in this town
also Eff has effects but in a kinda different way than Idris (that i prefer)

"depends on the language" is the answer to virtually every structured programming question

do we have polymorphic variants? do we have existential types?

We have C++ or java or c# since thats what most employed people use if you are not doing web.

To add to this, solutions to replacing OOP must be practicable, abstract solutions you cant apply in real life are useless

Procedural programming is completely practicable, and is in fact a much more "natural" way to program.

thanks lad

No, I'm doing it for seperating content in a terminal window for chat program

Yes i agree its more "natural", do you know any github repo or any code base i could check which does some problem we usually use OOP with procedural style? (And please no C)

I actually want to do stuff differently god damnit

Wouldnt it be easier just to mash together some light weight gui?

check'd
also, it's a hell of a lot easier if you give an example of a problem that you associate with OOP. i think the other user's point is that there isn't a specific thing you associate with OOP because it's not the best for anything

Okay crud applications, GUI's, or basic 2D games are mostly done with OOP

>I know about OOP practices
there's only one important thing, and that's encapsulation to reduce possible invariances related to necessary state at runtime.
anything else you learned that's *specific* to OOP, and not to other paradigms as well, is likely useless.

>encapsulation

>he doesn't watch Brian Will
shiggy my man
Start here
youtube.com/watch?v=QM1iUe6IofM
then
youtube.com/watch?v=IRTfhkiAqPw
finish with
youtube.com/watch?v=V6VP-2aIcSc

and then you will no longer be a Pajeet.

Thanks, I'll give it a try

Please use an anime girl that is related to programming next time such as lain, rei or hime, not stupid meme girls.

Writing your own ncurses is a waste of time.
However I would look into termbox, it's not cross platform with ancient terminals that you aren't supporting anyways, but it's a lot easier to use than the vast and cryptic ncurses api

The thing about monads is that they aren't "built in", you can build your own state monad using GADTs and basic polymorphism.
"do notation" is all sugar but makes things easier.
data State :: * -> * -> * where
StReturn :: a -> State s a
StGet :: State s s
StModify :: (s -> s) -> State s ()
StBind :: State s a -> (a -> State s b) -> State s b

runState :: s -> State s a -> (a,s)
runState s (StReturn s) = (x,s)
runState s (StGet) = (s,s)
runState s (StModify f) = ((),f s)
runState s (StBind m f) = runState s' (f x)
where
(x,s') = runState m

So basically he is arguing against pure OOP, okay i can get behind that. Write functions for everything and use encapsulation only on strongly coupled methods...