HNHacker News
TopNewBestAskShowJobs

nrdvana

270 karma · joined January 30, 2018

submissionscomments
nrdvana··on Lead poisoning causes more death, IQ loss than thought: study
I had a house where a brand new copper line corroded and started leaking 2 years from installation, and I don't mean at joints or anything, I mean the local water just ate right through the wall of the pipe. I switched to Pex and was fairly happy with it.

I never did do the research to figure out what was up with the water, but similarly, when I tried inventing my own sump-pump sensor by dipping copper wire into the sump well, it ate the copper wires apart in 3 days. I tried again with stainless rods and discovered that there was about .05 Volt per inch deep I put the sensor, i.e. the stainless rod near the top of the well would be about 2V higher (or lower, don't recall) than the stainless rod that ran to the bottom. Made it kind of annoying to design the circuit.

nrdvana··on Perl 5.38
"one big game of code golf" would probably be a decision by the author, wouldn't it? I know a person or two who could fall into that category, but it's hardly the fault of the language.
nrdvana··on Perl 5.38
sigh no, the plan now is to get something completely different into core that is fundamentally incompatible with many of the things we like about Moo. It puts up firm barriers between parent and child classes which forces all the interaction to go through methods, resulting in a huge extra API burden for authors reminiscent of Java, especially for constructors. The end result is worse performance, too.
nrdvana··on Ask HN: What are some of the most elegant codebases in your favorite language?
This was true for me as well until I used DBeaver (a universal database browser tool) I only realized it was java after I tried connecting to a really old server that needed me to change my ssl settings in the JRE. The user interface feels fairly snappy. DBeaver is a really fantastic tool and I don't see myself changing any time soon. It even supports making its own SSH tunnels to your database server using your local ssh agent.

I can attest that AWT and Swing were hot garbage 20 years ago, though. The cross-platform aspect worked great, but the algorithms weren't worth making cross-platform to begin with. It was basically a giant GUI ecosystem written by people with no understanding of how to implement graphics efficiently. My favorite was how they bragged about their "lightweight" visual components that don't require OS-level window objects. Except, OS window objects are part of an algorithm that tracks exposure regions and repaints it efficiently without needing to redraw the whole screen. Swing took the approach of repainting the entire application window in a back-buffer on every visual change and then copying that up to the entire application window area, even for things as small as tooltip pop-ups or menus.

I haven't checked which GUI framework DBeaver is using. I suppose it's possible that it is Swing and my workstation is just so fast these days that the inefficiency doesn't matter.

nrdvana··on Ask HN: What are some of the most elegant codebases in your favorite language?
I'll agree with everything here except the clean code. Clean code is about optimizing human perception and there can't be a standard for that because humans think in a wide variety of ways and it's further impacted by the level of understanding the human already has on the subject matter the code is dealing with. One person's "clean code" can be another person's nightmare.

I'll back this up with the example of Magento 1. It's a PHP e-commerce platform that has (at first glance) some of the cleanest code you'll ever see in PHP. It looked like the entire development team had come from a Java background. Every component was neatly divided into a PHP object with documented private and public methods. There was a clean MVC separation, with lots of shared behavior abstracted into "Helpers", and a Theme system handling the rendering of the front-end. I have no doubt that the authors of Magento prided themselves on how clean their code was. For them, having spent full-time careers structuring all the many features of their platform into these files, it probably did feel like a clean organization. And when I initially reviewed the code to evaluate using Magento, I also thought it was clean and was part of my choice to use it.

The problem was that when you take something as complex as a full-featured e-commerce system and modularize it so thoroughly, you end up with a literal 7000 classes, and it becomes impossible to figure out the sequence of execution of a single page request through that massive tangle. Is it "clean code" if I have to add debugging print statements to 57 source files to figure out the path of execution that renders a single page?

If I had to choose a circle of hell where I would edit Cyrus IMAP (the worst C code ever) for the rest of eternity, or edit Magento for the rest of eternity, I think I would actually choose Cyrus.

nrdvana··on Ask HN: What are some of the most elegant codebases in your favorite language?
C++

An old one, but the FTGL library (renders truetype fonts in old-school OpenGL in half a dozen different ways: texture-per-letter, texture-per-word, 2D polygons, 3D polygons, etc) is the best example of C++ inheritance I've ever run across. The code formatting isn't my favorite, and comments are sparse, but the hierarchy of objects subclassed for all the different rendering modes is just about perfect. https://sourceforge.net/p/ftgl/code/HEAD/tree/trunk/

Perl

The Mojolicious / Mojo toolkit. Great minimalist API and great documentation and clean code all around. https://metacpan.org/release/SRI/Mojolicious-9.33/view/lib/M...

nrdvana··on 24-core CPU and I can’t move my mouse (2017)
I found the opposite in a very real-world analysis of my hobby project to build a digital dashboard for my DeLorean. I spent 5 years making very slow progress with C++, and then switched to perl, started mostly from scratch, and finished in a year. I gave a talk about this exact topic at YAPC 2014: https://youtu.be/SERH3_gZOTo?t=1018 The CPU usage on the embedded PC went from 15% to 40%, but in the grand scheme I'd rather have it finished and pay a little more for the hardware.
nrdvana··on Paul Graham is leaving Twitter for now
And that's exactly my point, that his new decisions seem petty and self-centered, where his old decisions (sinking his significant wealth into risky car and rocket companies and sleeping in the factory instead of buying a Caribbean island and living out his years in paradise) seemed to be more about lofty goals and ambition. Something changed. $40B could have done sooo much more for his previous ambitions; it's a crime to see it wasted like this. If he starts gold-plating his toilets, we'll know he's really gone forever. Thank goodness he wasn't born in the USA.
nrdvana··on Paul Graham is leaving Twitter for now
Or the easier explanation, that Elon has changed. He was my favorite billionaire back when all his prospects related to colonization of Mars and all his investments were aimed at creating new technology. But power can corrupt people, and he seems particularly prone to it. The entire Twitter episode is at odds with everything he did 10 years ago; Mars doesn't need a social network, and he's not innovating anything here. Not to mention that part where he's spent the last 7+ years sleeping around and fathering as many children as possible.

A different way of looking at "power corrupts" is that negative social interactions are an important part of the feedback loop that calibrates a person's sense of right and wrong. When a person decides that they don't want to hear conflicting opinions, they loose out on accurate feedback, and de-calibrate, unless they have a strong internal sense of empathy. Empathy is a disadvantage to becoming a billionaire in the first place, so very few of them have much of it. Guys like Musk and Bezos and Trump end up victims of their own success and echo chamber.

nrdvana··on Ten influential programming languages (2020)
C did compile to more efficient code than Pascal, but The Delphi compiler processed code 10x faster than the C compiler, and hit an amazing sweet spot for the 300Mhz workstations of the day, where you could iterate through edit/compile/run in Delphi just as fast as Visual Basic, and when you were done the program ran an order of magnitude faster than VB (and maybe 90% as fast as C). Also, because the language was easier to parse, the tooling was able to interact with your code way better than Borland's same product for C++ or any of Microsoft's products, so you were getting more accurate code completion and context-sensitive help and all that.

I believe that Delphi was a vastly superior product to any of its contemporaries, and was killed purely by corporate forces.

nrdvana··on Ten influential programming languages (2020)
Pascal graduated to Delphi (Object-pascal with built-in GUI designer), and had a very healthy run for a decade and was my favorite language until Borland corporate stuff happened and a cross-licensing deal with Microsoft that turned Delphi into a sort of bastard sibling of .NET, and new owner Embercadero raised prices out of the reach of most of the small-time users that made up a bulk of the userbase. I was in a tiny factory-automation engineering group that used it to build user interfaces and data reporting for all the factory stations. Well, on that note, 3M corporate shut down the factory and moved it to China, so maybe other forces were in play to kill the userbase.
nrdvana··on Ask HN: I have diagnosed ADHD and cannot work with Slack anymore – advice?
If you really want to run linux, get a Lenovo Thinkpad. They actually test the hardware with linux distros and even have bios options for Linux sleep states, labeled as such. Give the Macbook to someone who wants to run MacOS. The X1 Carbon line is my favorite, with excellent battery life for basic coding and video watching. Also, power options to set the maximum charge to 80% to preserve the life of the battery. (lithium ion batteries last nearly forever if you keep the charge between 20% and 80%) And yes, it has so much battery to spare that that middle 60% is enough to last a day of coding.
nrdvana··on SpaceX launches Starlink ‘flat high-performance’ dish for moving vehicles
From what I read, Musk doesn't want your money for SpaceX/Starlink precisely because he doesn't want the funds of the company to be chained to a public perception war that distracts him from running the company, like happened with Tesla during the doubtful years when half of the market was betting against him. Why take public funding when you can reap all the revenue directly?
nrdvana··on Why did Airbnb dump React Native? (2021)
20 years ago I worked on some Java applications as a college student curious to compare AWT/Swing to other options, and I found that the cross-platform rendering worked decently well, but that the underlying architecture and algorithms were hot garbage. For instance, if you had a full-screen panel nested in a full screen panel, and you put the CPU under heavy load, you could watch it fill both background colors despite the front panel completely obscuring the back panel. Using Windows native API "windows" the paint events would only happen for the un-obscured components and only for the regions exposed. Java advocates advertised how "lightweight" their components were because they "didn't depend on a heavy-weight operating system window object" when in fact those "heavyweight" window objects were part of an algorithm that performed much better. Another big annoyance was that every UI event was delivered in its own thread, so you had to deal with all the complexities of multithreading just trying to write simple user interfaces. I had a whole blog-sized article I wrote once about all the design deficiencies; I've forgotten most of the rest of those details.

Java actually succeeded quite well at being cross-platform, it just wasn't a design worth being cross-platform in the first place.

Hopefully they fixed some of this in 20 years.

nrdvana··on Facebook's TikTok-like redesign marks sunset of social networking era
The experience for each person is probably different. I never had that sort of stuff in the first place; mostly just pictures of people's concerts, vacations, dance events, car shows, family gettogethers, home improvement projects, new cars, lots of kid pictures, etc. None of these could compare to the level of "interaction" of the 2016 political cycle, though, so all the good stuff got buried under vitriol and arguments and un-friending and I feel like it never recovered.
nrdvana··on Facebook's TikTok-like redesign marks sunset of social networking era
I used to see posts from 50-100 friends/family each week. Now I see posts from about 5 of them. I barely use facebook because it crashes my iPad browser (I refuse to install the app) and because the feed is so packed full of autoplay videos I can't stand it. Facebook is "dying" for myself and my entire sphere of friends/family but of course that's just an anecdote.
nrdvana··on Facebook's TikTok-like redesign marks sunset of social networking era
And they were on Facebook instead of MySpace because Facebook worked better for sharing news snippets. Then facebook changes to the "most interacted-with posts", then politics took a dump on everypne's sharing from about 2015 onward, then facebook changed to a bunch of spammy videos from "content creators", and most of everyone gave up and left.

I lost track of the number of people saying (myself included) "Give me all my friends posts, in chronological order", and facebook just ignored us and slowly removed the ability to do anything close to that.

Ironic how Google tried Google+ and failed because Facebook had all the users and content. If Google had just shelved theirs as-is for 10 years and pulled it back out now, people would flock to it because it would actually be a feed of your friends/family posts in chronological order, with user-customized filtering, again.

nrdvana··on I've been abusing HTTP Status Codes in my APIs for years
501 is for unrecognized methods. As I was about to say this would then be incorrect usage, it occurred to me that you could in fact use this for an RPC system if the procedure name were used as the HTTP Method.

So instead of

    GET /api/v1/employee/100
    Accept: application/json
You sent

    GetEmployee /1000
    X-API-VERSION: 1
    Accept: application/json
Then if the actual procedure name was "get_employees", the correct response to this request would be 501, and /1000 referring to a non-existent employee would be a 404.

If making an RPC and restricting yourself to the known HTTP methods, the closest is

    GET /api/v1/employee?id=100
    Accept: application/json
which would return 404 only if the controller endpoint didn't exist, and would return whatever the application wanted if userid=100 didn't exist, such as 422 or 200 with a response indicating non-existence. It would be just like a local procedure call that could return a false value, or throw an exception instead of returning a value.
nrdvana··on I've been abusing HTTP Status Codes in my APIs for years
> Route params _identify_ the object

Well... in REST they do :-)

HTTP is designed to give access to a tree of files. The REST design says "lets fully embrace the idea that we are representing our data and program state as a virtual tree of files." You can embrace or reject that to various degrees, but the closer a design is to a virtual tree of files, the more "RESTful" I say it is.

In a RPC ("procedure call") paradigm, you have a collection of named procedures, each of which takes parameters/input and returns a result/output. Anything that isn't the procedure name is a parameter to the procedure. Some are mandatory parameters, and some are optional parameters, but in the most straightforward implementation of "HTTP RPC", the path indicates which procedure, and parameters to the procedure should be a HTTP parameters (or request body). Also note that in this case the HTTP status '404' would indicate the presence or absence of the RPC endpoint, like the author wanted, and the procedure would be expected to return 200 for a within-spec return value, or possibly 422 or 5xx to represent an application-level exception to be propagated to the caller.

There's nothing stopping us from mixing the paradigms, and in fact nobody is forcing anyone to use any paradigm at all, since we can literally do whatever we want with the HTTP path, uri, method, and headers. But when the original article claims to be doing RPC and not REST, I think that is just sowing confusion onto the topic.

nrdvana··on I've been abusing HTTP Status Codes in my APIs for years
Yes I used the wrong word. I meant "instead of encoding the employee id in the path?"

And instead of "if its not rest" I meant (in the context of the article) "if it's HTTP RPC" because the author clarified that they were talking about RPC rather than REST.

Remote Procedure Calls typically identify "endpoints" such that a specification of the endpoints could be compiled into a host language's function-calls. The logical way to do that with HTTP is to have a path be the function, and HTTP parameters (whether url or posted) be the parameters of the function.

Using a URL that has both a resource ID encoded in the path and also query parameters is a mixture of REST and RPC. Since the example given in the article does not show parameters, I think it is reasonable to call it REST, as many other commenters here have inferred. The author claiming it is RPC doesn't jive with my expectations for RPC.

Maybe I'm just complaining about calling it RPC. If it's neither RPC nor REST then it's just some random mismash of HTTP-ish stuff, and I don't think that's a particularly strong argument for "things should be done like this".

nrdvana··on I've been abusing HTTP Status Codes in my APIs for years
If it's not REST then shouldn't the url be /api/v1/employees?id=1000 instead of encoding the employee id in the URL? In this case the path is the endpoint, so a employee id is a parameter and not a controller action.
nrdvana··on I've been abusing HTTP Status Codes in my APIs for years
jQuery gives you the body. ExtJS gives you the body. Webix gives you the body. Maybe this is an Angular problem?
nrdvana··on I've been abusing HTTP Status Codes in my APIs for years
Use a better framework? In any good framework, returning a json body with a status code should be a one-liner.

One topic the article didn't even touch was flagging bad parameters in the request which didn't make sense on the application level. HTTP has 422 for that. I commonly write things like

    validate_my_param($c->req->params->{format})
       or $c->detach(HTTP => 422, ['Invalid format']);
(the HTTP view renders that string either as text/plain or json as {"message":"Invalid format"} depending on the accept header of the request.)

I've used that for years and been quite happy with the downstream results.

Edit: I should elaborate on the downstream results.

On the javascript side, the ajax methods often contain separate success and failure callbacks. You often need to handle the failure callback to ensure the user knows that something broke. If you also have an error path in the success callback, it clutters the code.

    ajax({
      success(data, ...) {
        if (data.wasActuallyAnError) {
          // lines
          // of code
          // to handle
          // the error
        }
        else useTheData(data);
      },
      error(response, ...) {
        // lines
        // of code
        // to handle
        // the error
      }
    })
vs.

    ajax({
      success(data, ...) {
        useTheData(data);
      },
      error(response, ...) {
        // lines
        // of code
        // to handle
        // the error
      }
    })
This problem is not insurmountable of course. you could wrap up your error code in helper functions and reduce the boilerplate. You could write a completely generic error handler for your front-end framework and automatically include it in all ajax calls. You could also write a custom ajax method that interprets the 200 status error messages and diverts to the error callback. But I still think the 404/422 status code is a better pattern to start from, since most of the client-side frameworks I've used switch code paths based on the status code.
nrdvana··on Ask HN: Where have all the forums gone?
Agree with everything here, and I'll also add that spam was a major problem for the simpler forums. It takes a lot of effort to combat, (at least until Google's recaptcha) and some forums stopped accepting new users from the public. Adding recaptcha requires a programmer, and not all forums have one. I joined one classic-style forum in the last 5 years and it required sending a email to the admin to add my account by hand. It also didn't have SSL...
nrdvana··on Show HN: KittenDNS – Easy to setup, rule engine, LetsEncrypt compatible
There is a parser and producer for yaml in all the major languages. I mean, even

    perl -MYAML -E 'say YAML::LoadFile("filename.yaml")->{foo}{bar}'
what level of tooling do you mean?
nrdvana··on Show HN: KittenDNS – Easy to setup, rule engine, LetsEncrypt compatible
Toml is not much more than a standardization of how to represent trees with INI. INI has been in use since at least the 90's and it persists because it is easy to read and edit, and supports comments.

I actually find traefik quite nice to configure vs. the old conf disaster of apache. I've configured it by hand and also generated config by scripts with ease.

If you want to complain about a design on HN the better way is to suggest a design you think is superior.

nrdvana··on Perl, the first postmodern computer language (1999)
HAH, yes, "safe mode" which is really set-uid mode, meaning that if an admin restores a .php file from a backup and forgets to set the ownership, they have suddenly granted that user root access to the server. and it's called "safe mode". I hate PHP so much...
nrdvana··on Perl, the first postmodern computer language (1999)
Was CGI.pm ever "ready"? Modern Perl releases dropped it because it was such a bad design.
nrdvana··on Ask HN: What languages have true native cooperative multitasking?
This answer is growing on me. My first reaction was "well that's not really what I meant", but actually my question could have been phrased as "I want to use one-process-per-logical-task design, but this is too heavyweight, so I want a solution designed around (lightweight process technical details)" and your answer is basically "Elixir and Erlang have lightweight processes allowing you to use one process per logical task". It doesn't really matter if it's using the exact technical details I specified; it has one process per task, and therefore no library fragmentation because that basic design scales well.
nrdvana··on Running GUI apps within Docker containers
You got me curious, so I looked it up:

  Transports
  
  To date all known Wayland implementations work over a
  Unix domain  socket. This is used for one reason in
  particular: file descriptor messages. Unix sockets are
  the most practical transport capable of transferring file
  descriptors between processes, and this is necessary for
  large data transfers (keymaps, pixel buffers, and
  clipboard contents being the main use-cases). In theory,
  a different transport (e.g. TCP) is possible, but someone
  would have to figure out an alternative way of
  transferring bulk data.
So, that is why I hear about needing X11 compat for remote connections; wayland connections are still sockets (not e.g. shared mem), but they require the ability to pass file descriptors through the socket, which can only be done with Unix sockets. (and those file descriptors provide access to shared mem)

I don't see any details about how this interacts with OpenGL, like whether indirect rendering is possible or if applications would need /dev mounted.

← PreviousPage 3 of 6Next →