/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

github.com/yegor256/eo
bdcampbell.net/javascript/book/javascript_the_good_parts.pdf
docs.idris-lang.org/en/latest/reference/syntax-guide.html?highlight=data#syntax-data-types
twitter.com/NSFWRedditGif

Real thread:

Thanks for anime picture!
Also, first for Ruby, the /comfiest/ language around!

>If you honestly think using a dedicated new natural number you invented out of thin air to mean "nothing"

No, thats just your interpretation of what you can do with it you brainlet. You could do the same maybe type in idris as well

reboastan from last bread:

just switched from guile 2.0.12 to guile 2.2.2
what am I in for lads

where are my scheme nibbas at

I'm working on creating a webscraper which will automatically fill out forms for me.
Does anyone have any good resources to do such a thing?

>picture with nothing related to programming on it
I'm sorry, but the other thread is the real one. Sage, hide and report this shit.

>You could do the same maybe type in idris as well
Yes and that's exactly why having the ability to just put define new locations along a number line in addition to this facility is not only disgusting but to make matters worse redundant.
By the way, this is only a problem for numbers. There's nothing wrong with being able to define new and never-before-seen values of the Type type, and in fact that's incredibly useful.

Fuck off, nobody is going to your shitty thread.

Writing a library in Python to parse and manipulate Avid ALE files I receive from feature film editorial.

It has been working pretty well, but I actually have a dumb question about this:

I parse the text files I receive from clients line-by-line. Current code snippet is this:

with open(fullpath, "rU") as ale_file:
for line_count, line_text in enumerate(ale_file):

However, I need to be able to accommodate any line endings (CRLF, LF, CR). As you can see, I've been opening the files with "rU" mode for Universal line ending support, which has worked SOMEWHAT, but not 100% (particularly with Mac classic CR endings).

In researching this and trying to make it better, I've found that "rU" mode is deprecated. The recommendation has been to open as binary ("r+b") instead, but when I do that, I have LESS support for varied line endings.

Any idea what the most up to date pythonic way is to be able to handle any line endings you throw at it properly?

>you shouldnt be able to do more things
>you should be restricted in a language and paradigm built for expression and type manipulation.
You haskultists are a fucking plague.

>If you honestly think using a dedicated new natural number you invented out of thin air to mean "nothing"

No, thats just your interpretation of what you can do with it you brainlet. You could do the same maybe type in idris as well

>>you shouldnt be able to do more things
>using the meme arrow to imply i am wrong about this fact
go play with your c++

see:

>the autist is copying the posts in here to the other bread
kek

I want to learn a functional programming language. Which one should I learn? I heard Haskell and Idris are good.

Autists*
The posts are too close in between.

Roses are red.
Violets are blue.
New numbers are cancer.
Here, have a (You).

>I heard Haskell and Idris are good.
kek

>other bread got nuked
kek

my brain is too small
the power of new types
i will never get

>404

C is a functional language but it's the shittiest functional language imaginable.
>imperative
>no type safety
>no ADTs
>no pattern based overloading
>not even any overloading at all
That being said, it's very standard, very simple, and very fast.
So you should probably learn it.

>nuked
What do you expect from a muslim thread?

Maybe I should preface it with purely functional programming language.

what did you think I was keking about user

We're not talking about new types, we're talking about new values in existing types that should not support the spontaneous addition of new values.
data X: Nat does not declare a type. It declares a Nat. One single Nat, whose type is a Nat, and which does not have a more specific type. (In this sense it's arguably an abuse of the "data" keyword.)

>learning a deprecated language that lets buffer overflows happen because it was invented before memory protection
lolno

>a natural number is not data

nibba you basically named the only ones
not even scheme is purely functional
because purely functional languages are s h i t

but learn scheme. a bit of functional language shit makes a language great

Would you consider Ruby a bit of a functional programming language?

It is, but that's not what the data keyword is for. The data keyword is for declaring new types. data X: Nat is not a new type, it's a new number. The fact that it works anyway is just a matter of shitty self consistent semantics.

never used it, I don't know

>shitty self consistent semantics
>consistency
>ever bad
the only bad thing is it reporting a warning on this use case instead of an error

Ruby is both heavily functional and heavily object oriented. However, *pure* functional programming is pretty much impossible with it.

Yes, you declared data x of type Nat.
But if you got past chapter 1, youd know you would rarely just leave it at that.
Next youre going to tell me that you shouldnt be allowed to declare a variable of type null.

Haskell and Idris are best in class purely functional languages. Both are very nice. Idris has dependent types, but it's slower and less mature than Haskell.

What is *pure* functional programming anyway? I learnt a little bit of scheme so I have basic understanding of functional programming.

So is *pure* object oriented.
github.com/yegor256/eo

>what am I in for lads

>spends the entirety of this debate defending the fact that Idris makes it possible to inject new possible values into types even when this makes no sense
>suddenly "lol it should be an error"
This is a step beyond moving the goalposts.
This is like twirling the chessboard.

>A C# program written a decade ago just got thrown into my lap
>Code written to interface with an old-as-fuck piece of equipment
>New piece of equipment needs to be implemented
>Different equipment manufacturer, thus zero compatibility with old code
>Need to figure out how to strip out the code for the old equipment and implement code to allow it to interface with the new equipment

>Never touched C# in my life (worked with C++)
>Very small timeframe in which I can complete the project (a couple weeks)
>Dude who wrote the old code is dead

I know it's hard to say exactly without knowing the intricacies of the project, but by your estimation, approximately how fucked am I here on a scale of 1 to 10, Sup Forums?

having everything be either a function or a side effect of a function
scheme fails to be that because (define (x) 3) for example assigns x to 3, rather than assigning 3 to whatever x -represents-
lambda, if, and a few other things also break functional programming rules, IO does it I think

a purely functional programming language never breaks convention

That wasnt me you melon.

I want to write an init system for linux (replacing systemd obviously) but I don't know where to start. I've read some articles about init systems in general but I can't find any tutotrials or books covering the subject of writing one.
Is other people's code the only way to learn?

is it that great or am I being memed on

>Yes, you declared data x of type Nat.
>But if you got past chapter 1, youd know you would rarely just leave it at that.
You seem to be suggesting it would make sense to go on to define X.
For example:
data X: Nat
X = 4

Not so. The use of the keyword "data" renders supplying a definition unnecessary.
That keyword makes the declaration its own definition.
X isn't just any Nat. X is X. Just a whole new Nat, which happens to be called X, distinct from any other Nat that existed before it.
You wouldn't just "rarely leave it at that." You straight up WOULDN'T FUCKING DO this.

go look at devuan's gitlab.

have you ever worked with Java? you may be better off than you realise

What if i want a Nat that can be anything it wants?
Who are you to say i cant you commie?

>What if i want a Nat that can be anything it wants?
Then you declare it like this.
X: Nat

Because if you instead used
data X: Nat

then X actually CAN'T be anything it wants. It can only be X.

So I'm starting my first job this monday, they build webapps using nodejs react and ruby. I'll have a training period of about 2 months where i'll be shown the basics. Any tips or recommendations? (i'm an advanced compsci student but we haven't worked much with js and web things in general so I'm kinda scared)

Devuan uses sysvinit, what's your point?

Are you retarded?

How do you guys not feel like shit about your abilities constantly?
I'll feel like I've finally learned something only to find out that there's far more efficient methods of doing it and the way I learned is actually horrible for about a dozen reasons.
It seems like I'm constantly wrong.

yes

>How do you guys not feel like shit about your abilities constantly?
>implying

>I'll feel like I've finally learned something only to find out that there's far more efficient methods of doing it and the way I learned is actually horrible for about a dozen reasons.
you're learning, that's great

>It seems like I'm constantly wrong.
that's life boy-o

to avoid this i never learned anything in the first place

you probably meant the replacing systemd part. It was a joke

x : Nat
data x: Nat
still return x : Nat
i love how much of a fit youre throwing because idris actually lets you have freedom.

Learn to think functionally. Modularized functions + Flux or Redux (unidirectional data flow) makes it crazy easy to find and fix bugs.

bdcampbell.net/javascript/book/javascript_the_good_parts.pdf

i beliv in u user

>have you ever worked with Java?

Nope. Most of my work has been in Python, and I've done a decent amount with C++ and dabbled with C.

Oops, this reply was for this.

>python
>programming
get out

/dpt/ how do I not be addicted to webcomics for teenage girls?
Also will technology ever advance to the point where there are programming languages like ~ATH and games like Sburb?
It would be pretty cool to be able to write software that affects reality and fate but I feel like our understanding of quantum mechanics is not quite there yet
What would that be like post-quantum computing or some shit

n-no
you were supposed to tell me something comforting
i dont wanna feel like this the rest of my life

also you should probably read the docs and not just assume everything is 1:1
docs.idris-lang.org/en/latest/reference/syntax-guide.html?highlight=data#syntax-data-types

Torvalds was joking when he wrote his terminal emulator, too.

There's a huge difference between freedom and bad fucking design.
C++ gives you the """""""freedom""""""" to declare implicit cast operators and dereference invalid pointers.
And look at THAT smoldering heap of garbage.

okay, then whenever you're shown to be wrong, insist that it is in fact you, who is right, denying all evidence saying otherwise
revel in your superiority as others grow through their admitted errors as you are chained by your foolishness

making mistakes and admitting we've made mistakes is what got humans where we are lad
lying to ourselves to avoid bad feels just leads to even more pain

>its a "bring up C++ to give my pedantic qualm "validity" argument
Im done.

Yeah well I'm writing this to learn about linux and init systems and keeping the code in a private repo. But it's rather challenging to start when there are no resources.

data X: Nat
data Motherfucking: Type -> Type
data
X:
Motherfucking
Nat

Does anybody know how Go 2 will be different to Go 1? Will Go 2 finally have generics?

>Will Go 2 finally have generics
Probably not and that's not even a significant problem in golang. It's something people bitch about in the same way they bitch about it not being OOP.
Golang won't be a usable language until they make their environment and package system less fucking retarded

I should add that my degree is not in CompSci, it's in Physics, so this is not exactly my wheelhouse.

The C# program solution has a dozen projects included in it, I don't even know how the fuck they interface. Are there any for-dummies things that could help a scrub like me out?

>Does anybody know how Go 2 will be different to Go 1?
It will be mandatory for all programs to create and run in a GUI or else they will not compile
The compiler will then populate this GUI with Google Ads

kek

>/dpt/ how do I not be addicted to webcomics for teenage girls?
same way you reclaim any other kind of lost masculinity
stop being a slob and exercise willpower
>Also will technology ever advance to the point where there are programming languages like ~ATH and games like Sburb?
no

I'm just fuckin with you dude. I've never even heard of Guile, but from my experience, upgrading to the latest version of anything typically results in a mine-field of bugs and broken packages (many of which are maintained by third-parties and will be abandoned in the coming weeks).

There was a memory leak in my tic tac toe outcome permutation counter. It uses seq properly now.
main :: IO ()
main = print $ games False $ listArray (1,9) $ Nothing Array Int (Maybe Bool) -> (Int,Int,Int)
games turn arr = fromMaybe play $ score arr
where play = foldl' add (0,0,0) moves
add (a,b,c) (x,y,z) = foldr seq (a+x,b+y,c+z) [a,b,c]
moves = map doMove $ filter (isNothing . (arr!)) $ [1..9]
doMove i = games (not turn) $ arr // [(i,Just turn)]

allIs :: Eq a => [Maybe a] -> Maybe a
allIs (x:xs) = x >>= fold
where fold y = foldlM eq y xs
eq b = (>>= \v -> listToMaybe [b | b==v])

score :: Array Int (Maybe Bool) -> Maybe (Int,Int,Int)
score arr
| isNothing result && not nomoves = Nothing
| otherwise = Just (eq $ Just False, eq $ Just True, eq Nothing)
where eq x = if x == result then 1 else 0
nomoves = all isJust $ elems arr
result = asum $ allIs . map (arr !) streaks

streaks :: [[Int]]
streaks = [1,5,9]:[3,5,7]:rows++cols
where rows = [[i..i+2] | i

>This is in the Go standard library.
Don't think I'll be writing anything in that for awhile

Does Sup Forums have a Discord?

Particularly a programming channel?

...

fuck off

You're going to get a bunch of raging autists replying to you user, but I wish we did.

RRREEEEEEEE

>a Discord?
WHAT THE FUCK
REEEEEEEEEEEEEEEEEEEEEEEEEE

what programming language have an best memes?

how does one write a non-autistic personal profile to go on their CV? i want job

A couple years ago I saw a panel that had some major players in the go community, but obviously most were there because Rob Pike was attending.

Someone brought up generics and Rob Pike actually gave some bullshit answer about using outside code generation tools with a dead serious face. Everyone laughed, but he just kind of looked around and I guess some people must have realized he wasn't joking.

Wish I could find the video.

Rust

C, it's a meme itself

I mean they designed with it a "C-style" philosophy in mind, so I could potentially understand his confusion, but a modern language avoiding it is just....it's dumb. it's really dumb.

Was that the one that had Rob, Andrei and the guy from Rust?

>>>>>>>>>>you dip
>>>>>>>>>>>>>>>>>IT AN MEME THE DIP

Maybe - it's been a long time so I just can't remember.

Honestly curious... What's wrong with Discord?

I know Slack has its problems (ie: it runs Electron), but what did Discord do wrong?

Names.