« first day (4360 days earlier)      last day (781 days later) » 
00:00 - 10:0010:00 - 00:00

00:00
@Bubbler I originally designed it as a De-Operator, which takes an Operator and makes it a function. Eg, @+ would be roughly equivalent to (a,b)=>a+b. But only using it for such a narrow reason, I felt I could give it new life as an equivalent to ()=>
I mean how big of a scale are we talking about. A single line? The whole code block? Should I be rethinking my whole terrain generator to avoid choosing a lake's radius based on a boolean?
If your code is so cluttered that if/else is a burden then yes you should be restructuring.
Sometimes the framing at a bigger scale is already decided
@RadvylfPrograms ...You're deciding l lake's radius based on a Boolean?
Yes, as I said at the outset, sometimes the failure is in language design.
00:01
@ATaco yeah, there's big lakes and small lakes
@RadvylfPrograms How do you get the boolean that decides a lake's radius?
Checking if a "how many more lakes to make big" counter is nonzero
I could duplicate my lake generator stage and do N big lakes then N small lakes, or I could reuse all of the code except a single thing to decide on a radius
I suppose the cause of this is having a binary distinction.
I'd just do two loops to generate M big lakes and N smll lakes in that case, I guess
@ATaco So you're saying I should change my program's behavior to make the code more elegant? This is a novel approach to language design
00:04
Not knowing the specifics of what differentiates a big lake and a small lake, I can't really comment on how to refactor it, but an if/else or ternary is probably fine
or even have an array of pairs [(rad1, M), (rad2, N)] and loop over it
meaning M lakes of radius rad1 and N lakes of radius rad2
@Bubbler But the resulting code duplication is entirely unnecessary
@Bubbler That's such an inelegant way to do a simple task
Huh????
that seems way more elegant than adding an extra counter to check and weaving it through the code
00:05
That was the elegantest way to me
more adaptable, more modular
The array will only ever have two items. The pairs will only ever have two values that change.
How would you add the third lake size?
Who needs if/else when we have while/goto
@Bubbler I would add a third condition to the ternary...
Or switch to an array
if you'd switch to an array... maybe use it to begin with :)
But I'm not going to need a third lake size. This is ridiculously premature optimization.
...I'd use an Enum
@RadvylfPrograms This is not what is meant by "premature optimization".
The words I'd use are "extensible code".
00:08
Rate my conditional statement: while(cond){truthy(); goto afterElse;} falsey(); afterElse:
It's the same thing tho. You're making decisions that overcomplicate the code now in hopes it'll pay off later.
the code is literally less complicated this way
Not really...
Yeah, this is simpler code, that there's a decent chance you might have to write anyway in the future.
00:09
You need to remove empty lake sizes, whenever I reshuffle around the sizes I now need to account for the fact that the list can change, etc.
By "empty lake sizes", do you mean the lakes with count of zero?
the counter approach is the only one that requires long-distance structural changes to adapt
I can't just do big_lakes += 1; total_lakes -= 1;, I have to search through the array to find which one is the big lakes, and if I ever change the size of the big lakes, now how do I know which is the big lakes to increment it? I need a third item to identify them, or better, I just decide on the number of big and small lakes first and then...have what I currently do
00:11
This doesn't make much sense.
But just because *mumble mumble* extensibility you're saying I should take those, put them in tuples, stick those in an array, which I'd need to do with repeated code anyway, then iterate over that array whose size will always be known when I'm writing the code, no matter how many lake sizes there are?
...Why does there need to be a non-mathematical distinction between big and small lakes anyhow? Is it not just the radius that changes?
@ATaco Some other minor things change yes
Can't you just use your random generator and let random distribution take- that'll do it
Well I'm simplifying, the lake sizes are actually maximum sizes, there's additional randomization of the sizes
But there's differences in what structures can spawn in and around big and small lakes later on, and any sizes in between really small and really big looked weird, so having the distinction makes sense
00:13
I think it's impossible to determine best practice in this case without the greater source code.
Not that I'm the Paragon of Best practices.
Well, just trust me, the code's cleaner with if/elses or ternaries, and between those two ternaries are the better option
(and also I don't want to show y'all my code because you'll yell at me for this: var i, k, kk, w, x, y, xx, yy, z;)
Don't ask plz
i think in that case you want to separate the general lake generation code and the size-specific lake generation code
:)
At least you have a list of lakes stored somewhere, right?
No, they're just drawn directly to the terrain tiles
Then how do you decide on the structures generated later??
00:16
They require certain amounts of water
.......
How do they know how much water is in places?
Looking at the terrain tiles already placed
All water except puddles is placed before any features or structures generate
@ATaco Yeah, this style of conversation in which one person holds all the information about the code is not very productive imo. It's really hard to suggest good improvements if you know none of the details. Especially if the conversation is framed as adversarial.
00:19
@WheatWizard Everyone loves to gang up on someone writing bad code :P
But basically I'm saying, picking between two values is a perfectly valid thing to want to do, and when you have the option to do it elegantly, it becomes a good way to frame lots of problems
I'm not really sure what y'all's suggested alternative is, but there's plenty of code where nice little functional or OOP style abstractions aren't an option or would be more trouble than they're worth. More abstraction != more good, sometimes you just know what your code should do and want to do it.
What I'd say here is that picking between two values very easily generalizes to picking between N values, though it may or may not apply to your problem
(or your approach to your problem)
Turning all your conditionals into [a,b,c][n] is probably a horrible idea.
@Bubbler But there's plenty of situations where a bool's the only reasonable set of options. E.g., if you want to return one of two strings based on whether an external program succeeds or not. Sure maybe later you'll add more based on what code it returned, but you'll be rewriting way more than the ternary in that case anyway.
Does JS have enumerations?
00:23
No enums, no
No, but TS does
I doubt Radvylf would use TS since you have to compile it
This is heresy but I don't really like enums for a lot of things. They're just so big. I know the "you're just being a code golfer lol" joke is easy to reach for, but small code is nice.
What do you mean by big?
Verbose?
Or overly complicated?
Enums are just fancy magic numbersâ„¢
00:24
imo they're neither
@ATaco Well, in Java they're proper objects, and then some languages have ADTs
You need to define them, which is space wasted (and also usually somewhere fairly far from where you use it, meaning you have to move away from what you're reading for context), and LakeSize::Small is a lot bigger than 0 (or false but bool literals are for cavemen)
Can you not just do Ctrl+click or hover over them to see the definition?
@user I use a text editor
Enums should be used when you have a collection of static values that must be distinct but not necessarily meaningful.
I'm not all hip and rad like you kids these days
00:27
Not using an IDE for programming today is a sin
My text editor works perfectly fine, autocompletion and stuff just gets in my way
I switched to Github Copilot now I can't go back
I'm going to start using VS Code on my new desktop, but things like "do you want to open this file in secure mode" or whatever for a fking text editor is just ridicolous
Same
@ATaco ^
I don't use autocompletion but I rely on real-time errors and warnings
00:29
I have those, they're called my eyes :p
@Bubbler yeah, it's especially nice for compiled languages to have language servers altering you to type errors and stuff like that
@RadvylfPrograms A lot of "text editors" these days have plugins for that stuff. Yours might too?
@lyxal Altering me? To type more errors? Sounds counterproductive :p
Well yeah I can write Rust from scratch on ATO to some extent, but if it goes beyond certain threshold, uhh
@user It doesn't have plugins, anything I've added I've hacked in by repackaging the chrome app
00:31
@RadvylfPrograms Pretty sure you can tell it to shut up
@RadvylfPrograms Oh you still use Text
I do, it's wonderful
You are incorrigible
I am not a corgie
There's no real point debating good style with someone whose workflow is so radically different
@RadvylfPrograms You are a corgi without an e, right?
@user I mean code style and how you write the code are entirely different
Except maybe handwritten
00:33
Well, your opinion of enums is shaped by you not having an editor that lets you go to the definition of something
A lot of code isn't read in IDEs
Github, for example
I doubt anyone except Arthur Whitney cares about moving away from what you're reading for context
Github is becoming an IDE of some sort
Github has jump to definition
^
For most popular languages
00:34
Yeah but it's kinda hit or miss
Also, it's not that hard to guess what LakeSize::Small does
Anyone could guess that it's an enum for lake sizes, with a choice of small and other lake sizes
@RadvylfPrograms they're working on making it way better though
The new repo searching beta is shaping up to be really good
It's more important for code to be maintainable by the devs working on it, not for it to be able to be stuffed into one file so people don't need an IDE to read it (although making code simpler is generally a good idea)
and you can open any github repo in github.dev and read source there
GitLab also has a web IDE in case you're using that
00:37
which is basically vscode running in the browser
They're all VS Code running in the browser :P
well yeah, apparently
even Gitpod has shifted to that
Bless repositories that have devcontainers
If it's a ginormous repo that would kill your computer, you can just open up a codespace with that repo, then view it in VS Code on your computer
@RadvylfPrograms and infinitely more meaningful
Meaning's overrated, Absurdism Oriented Programming ftw
00:47
when the number of choices doesn't exactly correspond to the number of values in an existing type then using an existing type also means you have extra impossible values to consider everywhere
unless you're working in a language that has refinement types but that's just even sillier lmao
> refinement types
TS
Just don't create those values easy peasy pumpkin peasy pumpkin pie motherf***er
Us mere mortals can't stop ourselves from making mistakes like that
Well I mean unless you're doing math with enum values it's not hard
Enum values aren't necessarily numbers in all languages though
00:51
Well I'm talking about using ints in place of enums for compactness/in place of them existing
You might be able to keep from using invalid values, but someone using your library might pass 4 when they're only supposed to use 0-3
Well I wouldn't do that in a public facing thing lol
And then you need to throw in an assert(n >= 0 && n < 4) to defend against that
And then if you're using int literals, what happens if you decide that actually I need to swap the meaning of integers. What if lake size small for some reason is better suited as being 4 than 0. Using just literals means you have to find all instances where 0 means lake size small, which may not be immediately obvious
@Bubbler ah yes, goes to operator is best operator
@RadvylfPrograms I don't use different coding styles when I code for myself or for public facing stuff
^
If you leave the code alone for a while, you'll sorta be new to it when you come back
@RadvylfPrograms Weren't you working on some library for making SE userscripts? Or was that Ginger?
@user and if you're in a sane language it'll complain if you don't account for the extra values in switches :)
00:59
@RadvylfPrograms Did you mean Forte?
C complains even if you account for all enum values, because you need to handle values outside the enum if some idiot passes in an arbitrary number cast to that enum or something
Sandbox posts last active a week ago: Selection and Prediction, No, thanks!
keeping it classy i see
Which is probably C at its strictest considering (char*)(void*)((int)(int, int))n is perfectly valid.
Well, being able to cast to void* is a useful escape hatch for a low-level language with a limited type system
01:01
With enough coercing anything in C is possible.
Also applies to real life :P
3
also for what it's worth i hate having to spell out what the enum's from too lmao
i don't know why rust doesn't make stronger inferences with that kind of stuff but haskell's usually pretty good about it... granted it also doesn't really let you have constructor names collide so maybe that's a bad example :P
01:44
Is there a simpler way to write: ((f <$>) <*> (<$>)) g (not point-free)?
Ah I meant ((<$>) <*> (f <$>)) g, and the answer is g . f . g.
@UnrelatedString i think idris can figure that out right?
i've never used it but i sure hope so :P
i vaguely recall it being a thing when i tried lean a while back
Java lets you import everything inside the enum but i guess imports don’t work the same way in all languages
@UnrelatedString wait, not while matching, right?
i think rust has some feature like that but i haven't had a ton of success with it :P
i've had it while matching
Oh
That’s kinda dumb
01:55
yeah
@Bubbler how can you not like c style for loops
languages without them are... meh
@RadvylfPrograms im with you
How so?
Why do you want constructor name collisions?
@RadvylfPrograms lol me too
They’re almost always used for normal iteration, which ranges can do
01:56
when you have cases where the incrementer is not simple
@WheatWizard what?
@WheatWizard say you can have Number tokens and Number asts and Number runtime values in an interpreted language
@Seggan Not replying to you.
@Seggan like what?
@RadvylfPrograms why do we agree on this stuff?
if you do have some weird one off kind of loop where you do still have a piece of state that is "the loop variable" the general c-style for loop providing an obvious way to handle the scope is nice, but that's pretty rare
01:58
@Seggan because you’re both weird :p
@WheatWizard i don't particularly but it can be expedient in the way user mentioned
@user a certain optimized prime sieve, when writing lexers
@UnrelatedString assuming seggan is talking about kotlin, you can use while loops instead
@user yeah but its very crude compared to the simple c style for
bending the c style for too hard just gets confusing
01:59
Imo the c style for is crude too
In haskell I usually put them in different modules and use qualified imports when there could be ambiguity.
yeah that's smart
@RadvylfPrograms eeeeeeeeee me too
e.g. AST.Number, Runtime.Number etc.
@UnrelatedString when do you bend it too hard?
also it works nice with java iterators
02:00
@Seggan sorry, my brain isn’t working right now, what do primes have to do with lexers?
when you start having one of the sections empty, or you're changing more loop variable state inside the loop body, etc.
@Seggan not every language has java iterators, only jvm languages
i feel like most iterator interfaces play pretty well with c-style for... but they play way better with dedicated for ... in ... loops :P
@UnrelatedString if one of the sections is empty i usually use a while loop (in real life java code, not when golfing)
@user rust has pretty much the same interface, c++ is slightly akin
@user nothing
just giving 2 use cases
02:03
Oh
For the prime sieve, you could use a while loop (or a haskell-style recursive solution)
i know but its so much messier
I’d use a while loop or rexursion foe the lezer too
i occasionally do end up having one section empty in for loops in c just because i'd rather have an empty condition/increment than either have the loop variable in the enclosing scope or add extra brackets/indentation :P
but it definitely does have a readability tradeoff
I generally find a while loop to be more understandable than a c-style for loop in pretty much all cases tbh.
02:04
oops not prime sieve, i meant brute force prime checker
@Seggan but why add a whole construct to a language just because a handful of cases need it?
because theres a lot of cases that can use it
i.e. incrementing by 2
or 3
or 4
you can just use a step range for that
@WheatWizard only problem is you might forget to do the incrementing part because it’s not right at the top, but an ide would warn you about that anyway
Actually wait, it might not
no it wont
@UnrelatedString true, but what if the step is someComplexFunction(i)?
though that might be better with while
still
02:07
then have a functional construct for iterating that :P
might not be optimized
@Seggan you can still use a list
An infinite list if necessary
@user I'm just talking about reading it.
My actual preference though of course is to not write any loops at all.
@Bubbler I do, since I don't use identifiers containing es for code only I see
I'm guessing that's not a normal practice tho :p
02:08
@Seggan i really doubt that would be a major bottleneck in your application
The hands down best method to ensure readable code is always to not write any code at all.
6
Unless you’re writing some performance critical code, in which case i guess while loops and the like are more acceptable
@user It has basically zero cost
The cost is readability
C-style for loops can be turned into whiles super early on, so not really any bugs or maintenance cost either
@user No, nobody forces you to use them
There are cases, niche cases, where it's more readable
02:09
@RadvylfPrograms This is not how readablitiy works.
Nvm, didn’t see which message you were replying to
@WheatWizard ?
i think one slight readability boost for a conventional use of for versus using while for the same thing is that all of the "loop logic" is in the "same place" but that isn't enforced so it's really just a hint to the reader
and any conventional use of a c-style for can just be anything range-based instead
@RadvylfPrograms yep
That's exactly what a C-style for loop should be used for IMO. Syntax sugar for while loops that provide a hint to the reader how they're used.
02:11
@RadvylfPrograms with that logic, a language should have every construct possible as long as it isn’t a pain to add it
It's purely syntax sugar for readability's sake, and it's entirely opt-in
@RadvylfPrograms If a construct is present people will use it. The number of wizards writing code from an ivory tower where they don't have to interact with other people is negligible and shouldn't really be a consideration when designing language.
3
@user + @WheatWizard Sure, but there's precedent for this syntax, and people will always find ways to write bad code
I don't think C-style for loops existing makes that much worse
If java had goto because it was useful in a handful of cases, there would be people using it even when completely unnecessary
02:12
there's also precedent for long range goto :P
Yeah, and good reasons not to allow it other than readability :p
@RadvylfPrograms This "People will always find a way to write bad code" cop-out is pretty weak. Language design matters.
@user I kind of agree with this to an extent
If a feature costs very little to add, and won't have any negative impacts, and fits with the language, there's not really a reason not to add it
Do you like coffeescript?
Coffeescript does a lot of stupid stuff that does have a cost and is not internally consistent
02:14
Because it has a ridiculous amount of syntax sugar at little cost to the language devs
I think the opposite is true. If a feature brings nothing of significant value, don't add it.
How much is "significant"?
That’s subjective
if nothing else, adding a feature tells users "there is some reason for this to exist"
I'd argue C-style for loops are "significant" but you might not
02:15
@RadvylfPrograms Problem with this approach is that readers have to be aware of all the syntaxes used in the wild, and the users of the language will constantly fight over which is better
you're giving it a privileged position in the universe of things that exist in and around the language
They fit my coding style, they look cool, and they can aid readability when used in place of some while loops. If I was designing a language, that's why I'd include them.
which is what we're experiencing right here
@Bubbler That's fair I guess
I think a big factor here is familiarity honestly. If you come from a C/Java/JS background, you'll be more familiar with C-style for loops, like how they look as a result, and have used them more so be more biased to think they're necessary and commonly used. I think that's why Steggan and I both like them and y'all don't. The real answer's probably somewhere in the middle, where they on average don't necessarily hurt readability but probably aren't all that necessary nowadays either.
if anything that's an argument to cut them out of a new language, because people used to them will overuse them if they get to :P
02:19
If I designed a language I'd definitely include them, but that's just because I'd be starting from a language I know I mostly like, JS, and refining it to add things from other good languages (Rust) and removing things that are clearly bad (most of JS besides the syntax)
I do think they should be included in Rust, which like Go feels kind of uncanny valley to me since they're going for a C-style look but with little things slightly different
But like, I wouldn't argue Python would benefit from C-style for loops :p
Yeah if a feature requires you to be used to another language to be intuitive then that sounds to me like a strike against it to me.
Rust is imo pretty far from C-style look at this point
@WheatWizard That is...literally every feature lol
Nothing's intuitive out of the box
@RadvylfPrograms There are plenty of features which are quite directly intuitive.
and if something takes a bit of getting used to it should still only rely on the internal logic of the language it's in
02:22
But ultimately I don't care about for loops. They are ugly imo, but it really doesn't matter much in the scheme of things.
02:32
@RadvylfPrograms i did the same when designing rol. based on kotlin, with some c, python and rust mixed in
and yes i still hate python
it just has some nice features
 
2 hours later…
04:58
Hello
 
1 hour later…
06:18
Never mind, I was being stupid
06:41
Is there a challenge for 2SAT yet?
19
Q: Solve 2-SAT (boolean satisfiability)

Keith RandallThe general SAT (boolean satisfiability) problem is NP-complete. But 2-SAT, where each clause has only 2 variables, is in P. Write a solver for 2-SAT. Input: A 2-SAT instance, encoded in CNF as follows. The first line contains V, the number of boolean variables and N, the number of clauses. ...

Thanks, I searched without the - and found nothing
my query was 2 sat is:q
and just 2 sat gives that challenge at the top for me
Yea it isn't hard, I'm just dumb
 
2 hours later…
09:12
opinions please...should I give the bounty to the C or the Julia answer? codegolf.stackexchange.com/questions/256106/…
C
Just my opinion
Reason: It's harder to golf in C than in Julia, AFAICT
but that sounds dumb, so Julia
0
Q: Intersection area of two rotated rectangles

alephalphaGiven two rectangles, which are possibly not in the orthogonal direction, find the area of their intersection. Input You may take the rectangles as input in one of the following ways: The coordinates of the four vertices of the rectangle. These coordinates are guaranteed to represent a rectangl...

09:53
@Ginger it does? Let me try
It oneboxes all images
But xkcd.com/2720 isn't a image, it's a direct link
It turns out 2712 will fail
00:00 - 10:0010:00 - 00:00

« first day (4360 days earlier)      last day (781 days later) »