/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Previous thread:

Attached: yG7tbJH.jpg (1561x2048, 203K)

Other urls found in this thread:

github.com/ksimka/go-is-not-good
en.wikipedia.org/wiki/Cuisenaire_rods).
nim-lang.org/
blog.cleancoder.com/uncle-bob/2016/07/27/TheChurn.html
githut.info/
madnight.github.io/githut/#/pull_requests/2018/2
twitter.com/NSFWRedditVideo

underscore library. i'll see if i can find an alternative.

not sure why i didn't think of that.

Making a Jow Forums browser in Go

Attached: 1525700666802.png (985x481, 36K)

I'm working in C# and I need help making sense of something. I have a Binary Tree class that looks like

public class BinarySearchTree : IEnumerable {
public int Value{ get; set; }
public BinarySearchTree Left { get; set; }
public BinarySearchTree Right { get; set; }

...
}

that has 3 properties, an int value and a left and right node of type BinarySearchTree, with incoming values less than or equal to the current node going to the left, and all greater values going to the right. Inside that class there's a method called GetEnumerator() that looks like

public IEnumerator GetEnumerator()
{
if (Left != null)
{
foreach (var value in Left)
yield return value;
}

yield return Value;

if (Right != null)
{
foreach (var value in Right)
yield return value;
}
}

that is supposed to return an enumerable of all of the values in the tree in ascending order. My question is how the foreach here works, or specifically, how it can iterate through every value on the left or the right side of the tree in the correct order. Does it have something to do with the IEnumerable interface? sorry if I got some terminology wrong

elinks already exists

Jow Forums looks like shit in any generic terminal web browser for obvious reasons.

Why do you use Go? The consensus is it's a badly designed language not worth wasting your time on.

Attached: go_doesnt_need_generics.png (920x379, 42K)

foreach calls the getenumerator method on its value and uses that ienumerator to get each value inside the collection

>giving a shit about what the """"consensus"""" is on Jow Forums
you are pathetic

Attached: 1506193868493.png (297x435, 197K)

ahh, that makes a lot of sense now, thanks

Not on Jow Forums: github.com/ksimka/go-is-not-good .

Attached: pike_on_go.png (675x513, 74K)

Yes I've seen that out of context quote already.
>github.com/ksimka/go-is-not-good
>no OOP is a bad thing
fucking lmao
keep shitting up Jow Forums pajeet

>out of context
how much clearer can he really be before just outright calling you a brainlet?

It just clicked with me why you would want to pass functions to other functions.
Sometimes I want non-generic functions with semi-generic functionality. If I just have a function accepts a function, I can do all the common things then call the foreign function in the section I need, and continue with common stuff, without breaking it into 2 separate copies of essentially the same function. But also retain some amount of type safety.

There're a lot of good points in that list, you can't just dismiss them by laughing at the weakest one.

Attached: e55.png (680x680, 150K)

>argumentum ad populum
kekus maximus

Why is easier bad? Why is simple worse?
If simpletons can use it effectively, what's the harm in someone with ingenuity using it? What makes more difficult languages better?

>Why do you think it is intrinsically good to believe in things?
Because it takes effort and feels good when you manage to do it.
Effort + payoff = inherent good.
>Belief in something is only good insofar as you can be confident it is true (reflects reality in a meaningful way).
I disagree. See above
>It doesn't much matter what the smart people of the past did because they were blending in to preserve their social standing. They might have all secretly thought it was bullshit and known better than to die on that hill.
"Have ALL secretly thought?" I very much doubt that.

Im a retarded phone poster but this looks like it should be recursive. How would C# know to traverse through each object by left or right? This would probably just return the value.

?

lol

yield does magic to make it work.

lol oops
meant for

>Type Foo is not equality-comparabale and hashable
>C++: 1 Gb/s of template errors
>Rust: Foo does not implement Eq and Hash, nigga
Will concepts fix this?

Attached: 1528376158246.png (2693x3385, 441K)

>you're not capable of understanding this brilliant book
>here's an animorphs instead
He is calling you stupid.
He is saying Google can't be fucked teaching cs brainlets properly so they'd rather just churn out mildly incompetent people in a language that's hard to fuck up in.
Why is this so hard to understand.
Go is literally a language to churn out shitty programmers so Google can save a few shekels by running down the average salary.

>It just clicked with me why you would want to pass functions to other functions.
Callbacks

>argumentum ad populum
You should try COBOL then, disregard all the bad press it gets, just try it yourself, it must be really good.
>Why is easier bad? Why is simple worse?
Easy and simply is good, but Go is neither. Being primitive makes it harder to use properly, error handling is a good example - it's not easy or simple since you have to put a lot of effort to make it right, it's primitive.

Yes, that's the point of concepts.

duplicate the pointer in big Joe time I estimated reference to god infinity is NaN thanks monad everything is

>with semi-generic functionality
Actually, if your language does offer any way to violate type safety, you can use higher order functions to fully emulate generics, not just "semi-". Granted, the trade-off is that you violate type safety.

That's why C doesn't need generics, for example: because the language isn't about type safety and never has been

Is it normal for city/government jobs to ask for your social security number? I'd like to get the job since I know a guy working there who would get me the position, but I'm kind of worried about identity theft. No other online application has ever asked for my SSN

I always wondered if there was a way to do the opposite of what I did in C, which is just have an ifdef in the middle of functions.

The idea at the time was always to reduce complexity and calls so when moving to other languages it never occurred to me to just pass a function in to replicate that.

compile-time vs runtime thing I guess. I never thought of the latter for that task.

Quick question here. I have a thing coming up that requires scripts for a bunch of sysadmin stuff and there's like a contest for speed involved in this. What the fastest way to run shell and batch scripts (both linux and windows servers)? I was thinking about the built in shell/batch ways to run things in parallel. I even thought about perhaps leaving the scripts in small sections and then running them through in C with pthreads (more parallel). What's the fastest way to do this ?

bow down to your master plebs. I'm back

>no generics means a language is bad
Sasuga

Guys, why is DB connection so slow? I have batches of 2500 rows/accesses every 10-30 seconds and it starts fast then after 50K records it takes at least ~2min to persist data.

forgot pic

Attached: jelly.jpg (1024x576, 62K)

Do pretty much all employers do take home projects in addition to four hours of whiteboarding now? This is a bit ridiculous.

Attached: 1534216750662.png (512x438, 401K)

There's literally no excuse for a statically typed language created post-2005 for not having generics.

Not him but coroutines aren't magic, literally all yield has to do (in a minimal implementation) is:
>push the program counter into the stack frame
>create a co-stack if this is a bottom level yield, or otherwise just use the last used co-stack
>pop the frame from the stack and push it to the co-stack instead of just trashing it

And then later, on resume:
>pop a frame from the appropriate co-stack and push it to the stack
>jump to the program counter copy stored in that frame

Rob Pike on syntax highlighting:

Gofmt was written to reduce the number of pointless discussions about code formatting. It succeeded admirably. I'm sad to say it had no effect whatsoever on the number of pointless discussions about syntax highlighting, or as I prefer to call it, spitzensparken blinkelichtzen.

Syntax highlighting is juvenile. When I was a child, I was taught arithmetic using colored rods (en.wikipedia.org/wiki/Cuisenaire_rods). I grew up and today I use monochromatic numerals.

I do agree with pike that bikeshedding is a fucking plague. And if i ever made a language, wrong formatting would be a compiler error.

>What the fastest way to run shell and batch scripts (both linux and windows servers)
$ ./script.sh
That'll be 20$ + tip

I haven't looked much into Go, the things I've seen looks a bit uninsteresting with strange oldish syntax.

If you're a language guy, check out Nim lang:
nim-lang.org/

Python like syntax, optional but fast GC, compiles to C, C++ or JS. You can easily write "fast code" because of mature c compilers. Still inmature language itself though, no version 1.0 yet.

E.g. to start out take a look at the mapIt, filterIt, reduceIt function and how they are implemented as templates.

I meant I have hundreds of them. I was wondering what the fastest way would be to parallelize the non dependent ones.

How do I show dominance in my first day of CS class? I'm a god tier programmer and have been doing it since I was a little shit head. I want to show my classmates and teacher that I'm not to be taken lightly and I know my shit. I really don't want to be bundled up with the other brainlets who are going to get stuck at designing a linked list. I can tell from the class roster names that there are gonna be girls and black men failing miserably, and I gotta say I'm looking forward to seeing them all fail as they realize I've been light years ahead of them. What's more is that I hope one of the girls cry at how stupid she is for not comprehending the study of computation and the trivial logic it encompasses, it truly reveals her lack of basic reasoning if she can't pass such easy standards. She will withdraw from the class and blame the "male dominated culture of CS" and the black man will probably go back to rapping or some shit fuck whitey etc.

>You should try COBOL then, disregard all the bad press it gets, just try it yourself, it must be really good.
You jest but it is truly the only way to gauge merit or value.
Your statment is about as valid as the schoolchildren phrase
>a million flies can't be wrong

>Easy and simply is good, but Go is neither.
You're contradicting your previous stance that Go is bad because it's simple, but saying now that it's actually not simple. Which is it? Does that trait actually matter? Focus more on the design like you've done here

>harder to use properly, error handling
>you have to put a lot of effort to make it right
This is a benefit of the language, not a detriment. Go makes it very easy to ignore errors as you would in other languages, but by default expects you to handle them. As you would and should in other languages. At least there is a finite lexical list of areas where you can handle errors, that are reported to you, which you can make guarantees about, if you handle them.
The alternative is unstructured anarchy where you either have to implement them yourself, use the reverse pattern of ignoring it by default and only triggering on certain exceptions, or write a lot of pure functions.

I will never see the argument against go's errors as anything other than an amateurish whine about, as you said "effort". As if writing arguably better (safe) software, can be effortless. To me, this whole attitude implies people have never handled errors in their native languages.

blog.cleancoder.com/uncle-bob/2016/07/27/TheChurn.html

Friendly reminder that if you use meme languages that you are part of the problem

It's probably faster to use shell builtins to run C programs in parallel than vice versa.
Use a fast shell, I heard dash is pretty fast comparatively.
also have the shell do as little as possible, try to hand work off to commands, as these will most of the time be compiled programs

It's not just Jow Forums
Go is regarded by anyone that isn't a fresh uni grad sucking google's dick in hopes of getting hired as a bad, useless language for anything more importtant than a simple crud shit web service

>Clean coder
LOL

you could try formulating your data flow as a makefile and have make handle the parallelism.

There is no need to put the isntruction pointer on the stack, you already have the return address derp.
You also need to preserve nonvolatile registers.
Also what kind of faggot calls it "Program counter"? Instruction pointer
And using recursion would be more performant.

#!/bin/bash
script1.sh &
script2.sh &
script3.sh &
...
wait

dependant_script1.sh
dependant_script2.sh
...

Or AFAIR it is called wait

>How do I show dominance in my first day of CS class?
bring in your copies of SICP and R&K then beat the professor to death with them
the APs will get the message and will hand you your courtesy masters degree and body pillow on your way out

Even /wdg/ would outsmart Uncle Bob.

My error handler is sig seg

>baseless raving claims
wew lad
What language do you propose instead?

how bad thing is executable stack?
I read that in some case if you use gcc extensions to implement lambda it makes the stack executable.
Then again there was just post in month or 2 ago that every program compiled with ghc(de facto haskell compiler) has executable stack.
So I get it reduces attack vectors, not having executable stack, but do you really care as C programmer if all faggots using their higher level languages don't give shit about security as long as they can provide fucking monads or what ever the kids are sniffing today?

Oh okay. So basically use C and run pthreads with the os commands run via system(). Avoid shell scripting in general. Does file redirection and using commands like service and running package managers still work fine?

Nice arguments, zoomer babies

>executable stack
If you have a buffer overflow you could override the return address to dynamically generated code that was put on the stack (HELLO TERRY), assuming the buffer was put on the stack
It is not bad at all if your users are not niggers

> it is truly the only way to gauge merit or value.
Yet it's extremely unpractical and it's better to listen to people who know better than you.
> Which is it?
So let us be clear here: Go is a simple language as in the size of the virtual standard, but it's a hard language to use, especially for anything not simple. It's like a hammer - a simple tool, but it's hard to build something complex with a hammer alone.
>The alternative is unstructured anarchy
The alternative is monadic error handling modern language like Haskell or Rust use. But even classic exceptions is better at reliable and ergonomically handling errors than Go's lackluster approach is.
> As if writing arguably better (safe) software, can be effortless.
Go read about error handling in Rust - it's much safer yet less verbose.

Attached: goland_error_handling.png (548x411, 18K)

>major complaint is hard to use
>suggest Haskell or Rust
hilarious

>So basically use C and run pthreads with the os commands run via system()
that's literally the opposite of what I said. Use the shell to do things it's good for, calling other programs, be they services or package managers or whatever. Just think about what you want the script to do, most of the time there is a program that does it, and the script just needs to supply a few arguments and maybe run the input through something else first. You wouldn't have your shell read input line by line to check for a word when you could just call grep

*sips Onions*

even better
>it's impractical to try languages to see if they're good or not
>you should use language x and y btw

Wait, is Goylent (replace G with S) replaced as Onions?
Onions Onions Onions

>There is no need to put the isntruction pointer on the stack, you already have the return address derp.
the fuck are you talking about? they'd be completely different. the return address would point into the caller, the instruction pointer at the time would point into the coroutine.

Alright. Got it. Sorry I misunderstood earlier.

These are different "hard". Go is hard to use as in it's hard to build a house with only a hammer, and Haskell and Rust are hard to use as in you need to read an instruction before you start using power tools.

But what about parallelization? What's the best way to go about that? Compiled language or still shell?

I've never encountered a linker error before, but people say it's a nightmare. What makes it so difficult?

>But what about parallelization?

command1 &
command2 &

Will run in the background in Parallel, use wait to wait for all background tasks to complete
It was alreayd posted

Okay

Onions

Rust and Haskell are both memes that no houses have been built with.
githut.info/

Everyone knows you mean onions when it gets censored to onions anyways, no need to even try to avoid it

Depending on the libraries you use, linking order may sometimes matter. There's no logic as to why, at least not without looking at the source code, and even if you do, the errors give you very little to go on as to where exactly to look, since linkers work with object files, not sources. Basically figuring out the right order to link your dependencies in is often a matter of trial and error.

>2014
At least use the recent data madnight.github.io/githut/#/pull_requests/2018/2

Why would you use a language if you hate it?

>not anime op
trash

Attached: 1532552347927-vr.jpg (9999x9999, 1.73M)

>t. unemployed

employment ;_;

Are there any good books for compiler implementation?

Thankfully I have a job using the best language ever invented.

Also, you can hate a language you've tried but no longer use. And you don't need to use a language to read some code and see that it's retarded.

You have my pity.

>gnuc supports lambda through local functions
>clang supports lambda through objective-c blocks
you can't support C lambdas in both gcc and clang. Which extension will be dominant in the future?

out of curiosity, why are shell scripts faster than system()

>Used book dealer is willing to pay 6c for my Teach Yourself HTML & CSS in 24 Hours book
Might take it tbqh

how difficult would it be to program a matchmaking system, like for a dating site?

Not sure, but one thing's for sure, lambda implementation is going to decide which compiler rules and which one falls

go ask a match.com or an ok cupid dev.
a decent one is definitely not a one man job.

>But even classic exceptions is better at reliable and ergonomically handling errors than Go's lackluster approach is.
only with [spoiler]checked exceptions[/spoiler]

like these things matter

>using nonstandard nonportable hacks when C++ lambdas just werk

>using C++ when C just werks

Updating C++ on my computer broke Visual Studio, C++ is a piece of shit

Do you guys listen to any programming podcasts?

Clearly it doesn't, if you're seriously advocating the use of compiler specific hacks.

All a language needs to be is Turing complete, any "features" beyond that such as lambda expressions are unnecessary, and the lack thereof cannot mean a language doesn't work

I too love programming in brainfuck.

Welcome to the Programmer Podcast. Todays episode: Error handling
Guy1: Yeah error handling is such an important thing, but no language really gets it truely right
Guy2: Yeah
Guy3: Actually I disagree. There is nothing wrong with exceptions, and all the smart people use it, like myself.
Guy2: Monads are nice though
Guy3: Monads are for niggers with no gonads. Real programmers use exceptions
Guy1: I guess error codes are also okay, just use a switch case with them
And that's it for todays programmign podcast, thank you for tuning in. Make sure to like favourite comment share and subscribe.

Is it possible for you to make your point without analogies? It's condescending and not indicative of a real world case either. We're talking about languages and applications of them, not houses and hammers.