|
i am constantly amazed at how terrible the c standard library is. nearly every function it provides is dangerous, unusably broken, obviously incomplete, riddled with subtle undefined behavior, or some absurd combination of the above
|
# ? Nov 13, 2021 15:48 |
|
|
# ? Jun 8, 2024 18:22 |
|
Xarn posted:C++ is garbage
|
# ? Nov 13, 2021 15:49 |
|
Internet Janitor posted:i am constantly amazed at how terrible the c standard library is. nearly every function it provides is dangerous, unusably broken, obviously incomplete, riddled with subtle undefined behavior, or some absurd combination of the above You forgot slow
|
# ? Nov 13, 2021 16:36 |
|
Internet Janitor posted:i am constantly amazed at how terrible the c standard library is. nearly every function it provides is dangerous, unusably broken, obviously incomplete, riddled with subtle undefined behavior, or some absurd combination of the above so time travel back to the 70s and do something about it. yes, the c standard library wasn't officially made a standard until the 80s, but much of the work it incorporated goes back to the dawn of unix and c
|
# ? Nov 13, 2021 17:02 |
|
how to choose a language: first, time travel back to the 70s
|
# ? Nov 13, 2021 17:11 |
|
Unironically yes, so that you can change the language the project has been started in
|
# ? Nov 13, 2021 18:03 |
|
somebody learning python as a first lang posted:is there a reason to use # comment instead of ''' comment ''' quote:Or, not quite as intended, you can use a multiline string.
|
# ? Nov 13, 2021 20:47 |
gonadic io posted:hmm that seems odd syntax I say to myself, I should look it up # should be used for comments, string literals are typically reserved for documentation strings - they’ll automatically show up if someone does help(foo.Bar) on your library
|
|
# ? Nov 13, 2021 20:49 |
|
lol what, they actually standardized using ignored multiline string literals as doc comments
|
# ? Nov 13, 2021 20:55 |
|
rjmccall posted:lol what, they actually standardized using ignored multiline string literals as doc comments yes, so-called docstrings were standardized a long time ago python has a lot of accreted history
|
# ? Nov 13, 2021 21:07 |
|
docstrings are only immediately after a function declaration, right? string literals after anything else are just ignored string literals also they don't have to be multiline iirc
|
# ? Nov 13, 2021 23:08 |
pokeyman posted:docstrings are only immediately after a function declaration, right? string literals after anything else are just ignored string literals yes, though also in other contexts e.g. class definitions or module start and yes, triple quotes are the special case multi line syntax
|
|
# ? Nov 13, 2021 23:16 |
|
right forgot class definition. didn't know about module start, that's handy
|
# ? Nov 13, 2021 23:31 |
the real cursed poo poo is package docstrings, which is the module docstring of root-level __init__.py
|
|
# ? Nov 13, 2021 23:59 |
|
lol what at that point maybe just bless having a readme.rst
|
# ? Nov 14, 2021 00:10 |
|
my favorite thing about python syntax lately is thatcode:
|
# ? Nov 14, 2021 00:22 |
|
which was so gtk (iirc) could docode:
|
# ? Nov 14, 2021 00:27 |
pokeyman posted:lol what https://www.python.org/dev/peps/pep-0257/#what-is-a-docstring pep-257 to the “rescue” quote:A package may be documented in the module docstring of the __init__.py file in the package directory.
|
|
# ? Nov 14, 2021 00:28 |
|
Internet Janitor posted:i am constantly amazed at how terrible the c standard library is. nearly every function it provides is dangerous, unusably broken, obviously incomplete, riddled with subtle undefined behavior, or some absurd combination of the above I recently was confused at why 'pow(x,2)' was much slower than 'x*x'. Well, not confused at the performance difference ('pow' is a libm call), but that the C compiler wouldn't optimise the former to the latter even under -O3. Eventually I realised that all the math functions can set loving errno, so they have side effects. Now I need to look into whether -fno-math-errno is enough to fix this. (Or the comedy option -ffast-math which implies -fno-math-errno.)
|
# ? Nov 14, 2021 00:42 |
|
.
Joe Chip fucked around with this message at 00:15 on Nov 19, 2021 |
# ? Nov 14, 2021 00:46 |
|
Athas posted:I recently was confused at why 'pow(x,2)' was much slower than 'x*x'. Well, not confused at the performance difference ('pow' is a libm call), but that the C compiler wouldn't optimise the former to the latter even under -O3. Eventually I realised that all the math functions can set loving errno, so they have side effects. Now I need to look into whether -fno-math-errno is enough to fix this. (Or the comedy option -ffast-math which implies -fno-math-errno.) i can't reproduce that, both gcc and clang flatten pow(x, 2) to a single instruction without any special flags https://godbolt.org/z/xd4Gr7TEb
|
# ? Nov 14, 2021 01:00 |
|
dougdrums posted:my favorite thing about python syntax lately is that that's amazing. wait, can you use an arbitrary expression as a decorator?
|
# ? Nov 14, 2021 02:29 |
|
animist posted:that's amazing. wait, can you use an arbitrary expression as a decorator? I think it’s because the lambda is a function and a decorator applies a function to a function, it’s just anonymous in this case
|
# ? Nov 14, 2021 02:39 |
yeah, functions are first class, and the pie (don’t ask) syntax is just syntactic sugar to avoid doing foo_decorator(foo()) every time you call foo. lambdas in decorator is imo a crazy code smell, but there’s no reason for that to not work
|
|
# ? Nov 14, 2021 02:52 |
|
cinci zoo sniper posted:the pie (don’t ask) I’m asking e: found it. PEPs are useful for historical research I guess quote:Barry Warsaw named this the 'pie-decorator' syntax, in honor of the Pie-thon Parrot shootout which occurred around the same time as the decorator syntax, and because the @ looks a little like a pie. Guido outlined his case [8] on Python-dev, including this piece [9] on some of the (many) rejected forms. cinci zoo sniper posted:lambdas in decorator is imo a crazy code smell, but there’s no reason for that to not work agreed on both points prisoner of waffles fucked around with this message at 05:22 on Nov 14, 2021 |
# ? Nov 14, 2021 05:15 |
|
rjmccall posted:lol what, they actually standardized using ignored multiline string literals as doc comments 'use strict'
|
# ? Nov 14, 2021 06:37 |
|
repiv posted:i can't reproduce that, both gcc and clang flatten pow(x, 2) to a single instruction without any special flags that's because pow(x, 2) cannot set errno. try with a negative or non-integral exponent (which will set errno for zero and a negative x respectively)
|
# ? Nov 14, 2021 09:27 |
|
b0lt posted:that's because pow(x, 2) cannot set errno. try with a negative or non-integral exponent (which will set errno for zero and a negative x respectively)
|
# ? Nov 14, 2021 12:58 |
|
https://twitter.com/m_ou_se/status/1459856266440941574?s=20
|
# ? Nov 14, 2021 14:57 |
|
animist posted:that's amazing. wait, can you use an arbitrary expression as a decorator? code:
https://www.python.org/dev/peps/pep-0614/ dougdrums fucked around with this message at 15:04 on Nov 14, 2021 |
# ? Nov 14, 2021 14:59 |
|
Cool, but also, gross.
|
# ? Nov 14, 2021 14:59 |
|
dougdrums posted:yup code:
dougdrums fucked around with this message at 15:21 on Nov 14, 2021 |
# ? Nov 14, 2021 15:18 |
|
also I got qt mixed up with gtk lol
|
# ? Nov 14, 2021 15:26 |
|
redleader posted:'use strict' dunking on javascript in the PL thread is easier than shooting ducks in a barrel
|
# ? Nov 14, 2021 15:47 |
im going to very slowly poop in keyboards of every person involved in making this happen
|
|
# ? Nov 14, 2021 15:48 |
|
prisoner of waffles posted:dunking on javascript in the PL thread is easier than shooting ducks in a barrel
|
# ? Nov 14, 2021 16:00 |
|
cinci zoo sniper posted:im going to very slowly poop in keyboards of every person involved in making this happen mara does some pretty great rust shitposts https://twitter.com/m_ou_se/status/1368632701448818691
|
# ? Nov 14, 2021 16:02 |
gonadic io posted:mara does some pretty great rust shitposts ah, respect then. unfortunately some people unironically enjoy using matplotlib
|
|
# ? Nov 14, 2021 16:29 |
|
mystes posted:Have you tried to get the ducks into the barrel? easier than getting a good create-react-app config
|
# ? Nov 14, 2021 17:24 |
|
|
# ? Jun 8, 2024 18:22 |
|
prisoner of waffles posted:e: found it. PEPs are useful for historical research I guess
|
# ? Nov 14, 2021 19:14 |