nhaliday + pls   127

coding style - C++ code in header files - Stack Overflow
There is occasionally some merit to putting code in the header, this can allow more clever inlining by the compiler. But at the same time, it can destroy your compile times since all code has to be processed every time it is included by the compiler.

Finally, it is often annoying to have circular object relationships (sometimes desired) when all the code is the headers.

Bottom line, you were right, he is wrong.

EDIT: I have been thinking about your question. There is one case where what he says is true. templates. Many newer "modern" libraries such as boost make heavy use of templates and often are "header only." However, this should only be done when dealing with templates as it is the only way to do it when dealing with them.
q-n-a  stackex  programming  best-practices  c(pp)  pls  compilers  types 
2 days ago by nhaliday
python - Short Description of the Scoping Rules? - Stack Overflow
Actually, a concise rule for Python Scope resolution, from Learning Python, 3rd. Ed.. (These rules are specific to variable names, not attributes. If you reference it without a period, these rules apply)

LEGB Rule.

L, Local — Names assigned in any way within a function (def or lambda)), and not declared global in that function.

E, Enclosing-function locals — Name in the local scope of any and all statically enclosing functions (def or lambda), from inner to outer.

G, Global (module) — Names assigned at the top-level of a module file, or by executing a global statement in a def within the file.

B, Built-in (Python) — Names preassigned in the built-in names module : open,range,SyntaxError,...

As a caveat to Global access - reading a global variable can happen without explicit declaration, but writing to it without declaring global(var_name) will instead create a new local instance.


Essentially, the only thing in Python that introduces a new scope is a function definition. Classes are a bit of a special case in that anything defined directly in the body is placed in the class's namespace, but they are not directly accessible from within the methods (or nested classes) they contain.
q-n-a  stackex  programming  intricacy  gotchas  python  pls  objektbuch  cheatsheet 
november 2017 by nhaliday
What is the best way to parse command-line arguments with Python? - Quora
- Anders Kaseorg

Use the standard optparse library.

It’s important to uphold your users’ expectation that your utility will parse arguments in the same way as every other UNIX utility. If you roll your own parsing code, you’ll almost certainly break that expectation in obvious or subtle ways.

Although the documentation claims that optparse has been deprecated in favor of argparse, which supports more features like optional option arguments and configurable prefix characters, I can’t recommend argparse until it’s been fixed to parse required option arguments in the standard UNIX way. Currently, argparse uses an unexpected heuristic which may lead to subtle bugs in other scripts that call your program.

consider also click (which uses the optparse behavior)
q-n-a  qra  oly  best-practices  programming  terminal  unix  python  libraries  protocol  gotchas  howto  pls  yak-shaving  integration-extension 
august 2017 by nhaliday
Broadcasting — NumPy v1.13 Manual
When operating on two arrays, NumPy compares their shapes element-wise. It starts with the trailing dimensions, and works its way forward. Two dimensions are compatible when

they are equal, or
one of them is 1
If these conditions are not met, a ValueError: frames are not aligned exception is thrown, indicating that the arrays have incompatible shapes. The size of the resulting array is the maximum size along each dimension of the input arrays.

Arrays do not need to have the same number of dimensions. For example, if you have a 256x256x3 array of RGB values, and you want to scale each color in the image by a different value, you can multiply the image by a one-dimensional array with 3 values.
python  libraries  programming  howto  protocol  numerics  pls  linear-algebra 
august 2017 by nhaliday
Reproducing bugs is awful. You get an issue like “Problem with Sidebar” that vaguely describes some odd behavior. Now you must somehow reproduce it exactly. Was it the specific timing of events? Was it bad data from the server? Was it specific to a certain user? Was it a recently updated dependency? As you slog through all these possibilities, the most annoying thing is that the person who opened the bug report already had all this information! In an ideal world, you could just replay their exact session.

Elm 0.18 lets you do exactly that! In debug mode, Elm lets you import and export the exact sequence of events from a program. You get all the information necessary to reproduce the session exactly, from mouse clicks to HTTP requests.
worrydream  functional  pls  announcement  debugging  frontend  web 
november 2016 by nhaliday
I don't understand Python's Asyncio | Armin Ronacher's Thoughts and Writings
Man that thing is complex and it keeps getting more complex. I do not have the mental capacity to casually work with asyncio. It requires constantly updating the knowledge with all language changes and it has tremendously complicated the language. It's impressive that an ecosystem is evolving around it but I can't help but get the impression that it will take quite a few more years for it to become a particularly enjoyable and stable development experience.

What landed in 3.5 (the actual new coroutine objects) is great. In particular with the changes that will come up there is a sensible base that I wish would have been in earlier versions. The entire mess with overloading generators to be coroutines was a mistake in my mind. With regards to what's in asyncio I'm not sure of anything. It's an incredibly complex thing and super messy internally. It's hard to comprehend how it works in all details. When you can pass a generator, when it has to be a real coroutine, what futures are, what tasks are, how the loop works and that did not even come to the actual IO part.

The worst part is that asyncio is not even particularly fast. David Beazley's live demo hacked up asyncio replacement is twice as fast as it. There is an enormous amount of complexity that's hard to understand and reason about and then it fails on it's main promise. I'm not sure what to think about it but I know at least that I don't understand asyncio enough to feel confident about giving people advice about how to structure code for it.
python  libraries  review  concurrency  programming  pls  rant  🖥  techtariat  intricacy 
october 2016 by nhaliday
compiles to both OCaml and JS i think?
facebook  pls  functional  announcement  ocaml-sml 
may 2016 by nhaliday
« earlier      
per page:    204080120160

bundles : engtechie

related tags

:)  abstraction  acm  acmtariat  advice  aggregator  ai  analysis  announcement  approximation  automata  backup  barons  bayesian  benchmarks  best-practices  better-explained  blog  books  brands  browser  build-packaging  c(pp)  career  carmack  cheatsheet  checking  clojure  cloud  cog-psych  commentary  community  comparison  compilers  computer-vision  concurrency  contrarianism  cool  cornell  course  creative  critique  crypto  culture  dan-luu  data  data-science  database  dbs  debate  debugging  deep-learning  dennett  design  devtools  discussion  distributed  documentation  dynamic  editors  education  eh  embedded  empirical  engineering  erlang  evan-miller  evidence-based  examples  exocortex  explanation  exploratory  facebook  formal-methods  forum  frameworks  frontend  functional  gnon  golang  google  gotchas  graphics  guide  hardware  haskell  hci  history  hmm  hn  homepage  howto  huge-data-the-biggest  ide  idk  init  integration-extension  internet  interview  intricacy  invariance  javascript  julia  jvm  learning  len:short  libraries  linear-algebra  linear-models  links  linux  lisp  list  llvm  lol  longitudinal  machine-learning  markov  measure  memory-management  metaprogramming  mit  model-class  models  monte-carlo  multi  network-structure  networking  neurons  nibble  nitty-gritty  nlp  notation  numerics  objektbuch  ocaml-sml  occam  oly  oly-programming  org:bleg  org:edu  org:junk  org:med  organization  os  oss  overflow  packaging  papers  parsimony  pdf  people  performance  philosophy  planning  pls  plt  poll  ppl  pragmatic  prediction  presentation  programming  project  protocol  psychology  puzzles  python  q-n-a  qra  quora  r-lang  randy-ayndy  ranking  rant  rec-math  recommendations  reddit  reference  reflection  review  rhetoric  rsc  rust  sampling  scala  scale  scaling-tech  security  sequential  shipping  skunkworks  social  software  stackex  stats  strings  study  subculture  summary  systems  teaching  tech  techtariat  terminal  thiel  things  thinking  time-series  tip-of-tongue  tools  top-n  trends  trivia  tutorial  twitter  types  ui  unit  unix  urbit  ux  via:popular  via:Soft  video  visual-understanding  visualization  web  wiki  woah  workflow  working-stiff  worrydream  yak-shaving  yarvin  yc  🖥 

Copy this bookmark: