Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Visions of Valerie
Jun 18, 2023

Come this autumn, we'll be miles away...

Carthag Tuek posted:

imo the best garbage collector is aliasing the compiler name to rm -f

big fan of #!/bin/rm -f

Adbot
ADBOT LOVES YOU

Bloody
Mar 3, 2013

Dijkstracula posted:

all I know is I spent six months programming in Rust and having just migrated back to something else in a GCed language I gotta say: it's nice to have a garbage collector, just use a strongly-typed functional language with a garbage collector

ah, f#

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!


very acceptable choice

Athas
Aug 6, 2007

fuck that joker
It is tolerable, but every programming task where you cannot use Standard ML is an indication that we do not inhabit the best timeline.

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

Athas posted:

It is tolerable, but every programming task where you cannot use Standard ML is an indication that we do not inhabit the best timeline.

can i interest you in c#?

mystes
May 31, 2006

fart simpson posted:

can i interest you in c#?
have you given up on haskell to become a c# stan? Is that why you posted a video about how early return is good and implicit return is bad?

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

mystes posted:

have you given up on haskell to become a c# stan? Is that why you posted a video about how early return is good and implicit return is bad?

i didn’t watch that video and didn’t know what it was about i just thought guys face was funny

mystes
May 31, 2006

fart simpson posted:

i didn’t watch that video and didn’t know what it was about i just thought guys face was funny
I'm making a funny face now too!

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



mystes posted:

I'm making a funny face now too!

:cawg:

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

fart simpson posted:

i didn’t watch that video and didn’t know what it was about i just thought guys face was funny

turn on your monitor

prisoner of waffles
May 8, 2007

Ah! well a-day! what evil looks
Had I from old and young!
Instead of the cross, the fishmech
About my neck was hung.

Nomnom Cookie posted:

it is not possible, as a golang library author, to create a struct type that is public and also retain control over how that struct is created or initialized. the only way to do that is to keep the struct private and expose an interface.

let me play devil’s Rob Pike’s advocate for a second: if my struct type is public and it has a private field or private fields, then every new(MyStruct) or MyStruct{} will have zero values for those fields. In any of the methods of your structure type or functions in the same package, you may choose to check those values and either do some form of late-initialization or to error out (or panic if you really want to punish client code for not calling NewMyStruct()).

So while you are technically correct(no control over creation or initialization of a public struct), it definitely is possible to control the initialization of a public struct’s non-public fields if you’re willing to do a stupid bullshit dance and delay initialization until a first method call. ;-)

Idiomatically, the thing to do if you should need specific initialization is one of:
- write a NewMyStruct() constructor, move on with life
- (do some silly poo poo) make all the public fields nonpublic, then expose them as func (m *MyStruct) Field() *T { return &m.t }, which is technically less boilerplate than having to write both a setter and a getter

I guess what I’m saying is, your statement applies most meaningfully to the public fields of public structs and there are options which do not involve a single interface.

Nomnom Cookie
Aug 30, 2009



prisoner of waffles posted:

let me play devil’s Rob Pike’s advocate for a second: if my struct type is public and it has a private field or private fields, then every new(MyStruct) or MyStruct{} will have zero values for those fields. In any of the methods of your structure type or functions in the same package, you may choose to check those values and either do some form of late-initialization or to error out (or panic if you really want to punish client code for not calling NewMyStruct()).

So while you are technically correct(no control over creation or initialization of a public struct), it definitely is possible to control the initialization of a public struct’s non-public fields if you’re willing to do a stupid bullshit dance and delay initialization until a first method call. ;-)

Idiomatically, the thing to do if you should need specific initialization is one of:
- write a NewMyStruct() constructor, move on with life
- (do some silly poo poo) make all the public fields nonpublic, then expose them as func (m *MyStruct) Field() *T { return &m.t }, which is technically less boilerplate than having to write both a setter and a getter

I guess what I’m saying is, your statement applies most meaningfully to the public fields of public structs and there are options which do not involve a single interface.

none of the idiot hell fucker options you presented address the fact that golangs mutex can be copied as a necessary consequence of the idiot hell fucker language design

mr Scoop
Feb 13, 2006

Help! Someone! Cut my head off, it's trying to murder the rest of me!


Grimey Drawer
they called it golang because when you see it you go use another language

prisoner of waffles
May 8, 2007

Ah! well a-day! what evil looks
Had I from old and young!
Instead of the cross, the fishmech
About my neck was hung.

Nomnom Cookie posted:

none of the idiot hell fucker options you presented address the fact that golangs mutex can be copied as a necessary consequence of the idiot hell fucker language design

yep. it's not a good ergonomics choice, but it does allow you to embed a mutex directly in a struct which, as someone observed upthread, has the (small but not meaningless) performance benefit of allowing you to use a mutex on a struct without an extra indirection; this makes golang's sync.Mutex potentially better for use inside "tight loops", "heavily-called code", etc.

Nomnom Cookie posted:

it is not possible, as a golang library author, to create a struct type that is public and also retain control over how that struct is created or initialized. the only way to do that is to keep the struct private and expose an interface.

these are the goalposts you put up, I aimed at a similar but maybe not the same pair of uprights, and the kick was good. was it an idiot hellfucker kick? yes.

I agree that the ability to copy mutexes is dumb as hell and that the attitude of the go language designers is basically, "hey, sync.Mutex is a real programmer thing; if you use it wrong it's your fault" and that attitude is, in general, a lovely way for PL designers to act. at this point Everyone In The Know knows that go is somewhere near "C made easier with some footguns, mostly in concurrency"

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



mr Scoop posted:

they called it golang because when you see it you go use another language

yep

raminasi
Jan 25, 2005

a last drink with no ice

FlapYoJacks posted:

Rust is excellent because of the borrow checker. If it's bopping you on the head with a newspaper, it's for a good reason. It is designed from the ground up to be an extremely safe language regarding thread and memory safety. If you have a multi-threaded program or a program that needs to be 100% secure, then you can be sure of those things if your program compiles. There's a reason why the kernel accepts rust and a lot of crypto applications are moving to or have moved to Rust.

this completely got me, well done

Sweeper
Nov 29, 2007
The Joe Buck of Posting
Dinosaur Gum
me, a very smart person, acquiring a mutex in my tight loop and performance sensitive code: :classiclol:

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

mystes posted:

have you given up on haskell to become a c# stan? Is that why you posted a video about how early return is good and implicit return is bad?

I also absolutely did not watch the video

but this reminds me of the time I was the lab instructor for an intro-to-C class and the professor forbade the use of, in addition to goto, break and continue, and failed to tell anyone this

so people would just lose marks for totally reasonable implementations outside the language subset he inexplicably wanted

(you can imagine that when teaching the class came around to me I not only backed this rule out but went on a tear about why goto in a small number of common cases, can be fine actually (e: https://docs.google.com/presentation/d/1MmfYZLQO6eEZuP0wQl_w4VnVSi2y786MHMLh-Et_Dwg/edit#slide=id.gca5b8bd19c_0_121)

Dijkstracula fucked around with this message at 17:39 on Jan 27, 2024

mystes
May 31, 2006

Dijkstracula posted:

but this reminds me of the time I was the lab instructor for an intro-to-C class and the professor forbade the use of, in addition to goto, break and continue, and failed to tell anyone this

so people would just lose marks for totally reasonable implementations outside the language subset he inexplicably wanted
that's absolutely infuriating

it's fine to have style preferences like that but don't not state them and then take off points for people failing to read your mind as if your personal style preferences are a universally agreed upon standard, which they aren't.

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

mystes posted:

that's absolutely infuriating

it's fine to have style preferences like that but don't not state them and then take off points for people failing to read your mind as if your personal style preferences are a universally agreed upon standard, which they aren't.

he went on a tear in the instructors' meeting about how students weren't following this rule, and I was all "uh, what rule" and he was very concerned that I might have demonstrated the use of break and continue with students

then the other lab instructor, who'd taught with this guy before, stepped in and apologised, saying she should have informed me of the rule, and it's like "first of all this 'rule' is idiotic and also second you have no reason to apologise and third if nobody, students or lab instructors, knows about it then maybe the problem is with the greybeard at the front of the classroom virtual zoom distance learning video feed"

Tunicate
May 15, 2012

Didn't you read the syllabus? The only breaks you get are university mandated.

Visions of Valerie
Jun 18, 2023

Come this autumn, we'll be miles away...

mystes posted:

it's fine to have style preferences like that

It is not fine to have style preferences like that. It's reading a Dijkstra paper title without understanding what Dijkstra was actually mad about (goto that can change frames, which isn't what C has). It's perpetuating second-hand FUD, reading XKCD and nodding while repeating "the raptors won't get me this way". It's encouraging people to create complex state machines of sentinel variables to exit loops, and making GBS threads all over readability of function exit paths that need to deallocate memory. Blind "don't use that" doesn't teach anything, whether it be why a construct exists, or how to think about its tradeoffs.

tef
May 30, 2004

-> some l-system crap ->
hey left recursion nerds, what's your favourite way to handle left recursion in top down parsing

i have this parsing evaluation grammar, i want to extend it with means of defining stuff like infix operators. like `e := e "+" e`, and i'm mulling over the various ways of trying to make it work

1. don't do it, and just force users to write right recursive grammars

2. rewrite the grammar internally to something without left recursion, but return the original parse tree

3. shove an operator precedence parser into the back of the peg engine, and let the user define operators for a given parse rule

3. extend the peg algorithm to handle left recursive grammars, either through bounded recursion or memoization

option 1 isn't great, option 2 and 4 are kinda the same in that they both lose the execution model of pegs, option 3 is basically a pratt parser, or something with precedence climbing. i'm really not sure what the best option is. it feels like "just handle left recursion" is a more invisible ux, but "here is a means to define operators" is a better way to define grammars.

i've been leaning towards implementing the memoization trick to just make left recursion work, but then it's easy to write something left associative over right associative by accident, and i'm not quite sure if making operator precedence implicit is the right choice either

Voodoo Cafe
Jul 19, 2004
"You got, uhh, Holden Caulfield in there, man?"

Dijkstracula posted:


(you can imagine that when teaching the class came around to me I not only backed this rule out but went on a tear about why goto in a small number of common cases, can be fine actually (e: https://docs.google.com/presentation/d/1MmfYZLQO6eEZuP0wQl_w4VnVSi2y786MHMLh-Et_Dwg/edit#slide=id.gca5b8bd19c_0_121)

your lecture slides are good and i would have very much appreciated hearing the actual rationale for delineating good/bad practices in my java/c++/c classes when i was in uni rather than being expected to memorize charts of operator precedence

Lonely Wolf
Jan 20, 2003

Will hawk false idols for heaps and heaps of dough.
ometa added left recursion to peg and wrote at least one paper about it. I think it was using memoization but do not recall at this point.

tef
May 30, 2004

-> some l-system crap ->
yep, that's the one https://web.cs.ucla.edu/~todd/research/pepm08.pdf

the other one i'm aware of is the https://arxiv.org/pdf/1207.0443.pdf bounded left recursion one

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Voodoo Cafe posted:

your lecture slides are good and i would have very much appreciated hearing the actual rationale for delineating good/bad practices in my java/c++/c classes when i was in uni rather than being expected to memorize charts of operator precedence

aw ty :shobon:, love to beat bad habits learned from the other instructors out of my kids

(you better believe the first thing I ripped out from the other instructor's material was the operator precedence table)

Dijkstracula fucked around with this message at 19:53 on Jan 27, 2024

Nomnom Cookie
Aug 30, 2009



mystes posted:

that's absolutely infuriating

it's fine to have style preferences like that but don't not state them and then take off points for people failing to read your mind as if your personal style preferences are a universally agreed upon standard, which they aren't.

hard disagree it is not fine to forbid use of break and continue. that is utterly deranged. even more deranged than permitting use of unary -

Nomnom Cookie
Aug 30, 2009



tef posted:

hey left recursion nerds, what's your favourite way to handle left recursion in top down parsing

i have this parsing evaluation grammar, i want to extend it with means of defining stuff like infix operators. like `e := e "+" e`, and i'm mulling over the various ways of trying to make it work

1. don't do it, and just force users to write right recursive grammars

2. rewrite the grammar internally to something without left recursion, but return the original parse tree

3. shove an operator precedence parser into the back of the peg engine, and let the user define operators for a given parse rule

3. extend the peg algorithm to handle left recursive grammars, either through bounded recursion or memoization

option 1 isn't great, option 2 and 4 are kinda the same in that they both lose the execution model of pegs, option 3 is basically a pratt parser, or something with precedence climbing. i'm really not sure what the best option is. it feels like "just handle left recursion" is a more invisible ux, but "here is a means to define operators" is a better way to define grammars.

i've been leaning towards implementing the memoization trick to just make left recursion work, but then it's easy to write something left associative over right associative by accident, and i'm not quite sure if making operator precedence implicit is the right choice either

pop up a message box that says here’s a lookahead kid go get yourself a real grammar

Nomnom Cookie
Aug 30, 2009



the real answer is it sounds to me like you’ve boxed yourself in by choosing peg too early. first figure out what set of accepted grammars has the right ergonomics then make a judgment on how you’re going to handle them. imo

prisoner of waffles
May 8, 2007

Ah! well a-day! what evil looks
Had I from old and young!
Instead of the cross, the fishmech
About my neck was hung.

Visions of Valerie posted:

It is not fine to have style preferences like that. It's reading a Dijkstra paper title without understanding what Dijkstra was actually mad about (goto that can change frames, which isn't what C has). It's perpetuating second-hand FUD, reading XKCD and nodding while repeating "the raptors won't get me this way". It's encouraging people to create complex state machines of sentinel variables to exit loops, and making GBS threads all over readability of function exit paths that need to deallocate memory. Blind "don't use that" doesn't teach anything, whether it be why a construct exists, or how to think about its tradeoffs.

I do think that is the understanding of the Dijkstra paper that has been handed down to the present. If I understand that context correctly, it was before structured programming (i.e. control flow stays within a given function except for function calls and returns / gotos must remain in the same function) had become standard practice in all programming languages. Certainly it's notable that Dijkstra doesn't refer to being several levels deep into procedures and subprocedures with the word "stack" or "call stack".

If I had to say *why* it had such memetic strength, it would be the first sentence:

quote:

For a number of years I have been familiar with the observation that the quality of programmers is a decreasing function of the density of go to statements in the programs they produce.

A very concise, objective or objective-sounding way to figure out who deserves abuse as a bad programmer is a meme that has legs.

Disallowing the use of break and continue just feels like an intensified sort-of-hazing attitude towards what constitutes "good programming" in an imperative (and to be more exact I guess ALGOL-family?) language.

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

mr Scoop posted:

they called it golang because when you see it you go use another language

Shaggar
Apr 26, 2006

mr Scoop posted:

they called it golang because when you see it you go use another language

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

prisoner of waffles posted:

Disallowing the use of break and continue just feels like an intensified sort-of-hazing attitude
this is also the class whose curriculum involved students implementing a memory allocator before they learned what malloc is, so the hazing observation is actually fairly on point

(when I taught the class I simply swapped it with the final assignment to fix this and lo and behold the assignment average wasn’t in the 30s any longer)

Nomnom Cookie
Aug 30, 2009



quote:

goto that can change frames, which isn't what C has
nah it has that too but that works more like a delayed blast COME FROM than the branch-into-the-void machines are perfectly fine with and dijkstra railed against

Nomnom Cookie
Aug 30, 2009



dijkstra was really good at shitposting and definitely on the right side of history but he was writing at time where computing was just barely growing out of unimaginable resource constraints. writing software for basic rear end business processing on a machine so limited that you literally cannot afford a frame pointer. like you do not have enough budget to get a computer big enough that you can both have a frame pointer and deliver to spec

Nomnom Cookie
Aug 30, 2009



that drives a style of programming with horrific side effects that absolutely did need to be abandoned asap, but it’s also true that dijkstra was a contemptuous rear end in a top hat who gets far more respect than he deserves

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Nomnom Cookie posted:

it’s also true that dijkstra was a contemptuous rear end in a top hat who gets far more respect than he deserves
never respect a computer scientist, better safe than sorry

tef
May 30, 2004

-> some l-system crap ->

Nomnom Cookie posted:

the real answer is it sounds to me like you’ve boxed yourself in by choosing peg too early. first figure out what set of accepted grammars has the right ergonomics then make a judgment on how you’re going to handle them. imo

i mean, i could give up on having negative lookahead and ordered choice, yes, but i've decided that returning shift/reduce errors isn't an improvement

especially because i'm also parsing markup languages

Adbot
ADBOT LOVES YOU

Presto
Nov 22, 2002

Keep calm and Harry on.

pseudorandom name posted:

C++ is asking the important question of how many different prefixes can we slap on "value" before the language is abandoned en masse

inline static const std::unordered_map<const unsigned long long* const, const unsigned long long* const>* const butts = nullptr;

You can use a std::tuple if you want to keep going. But using the STL might be cheating.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply