HNHacker News
TopNewBestAskShowJobs

jhallenworld

4,965 karma · joined October 31, 2013

submissionscomments
jhallenworld··on Inflation rises to 7% in December (led by energy)
Newer vehicles have more DRM and more integrated systems, so they cost more to service and are therefore worth less than older vehicles. So these numbers make sense..
jhallenworld··on Goldman Sachs invests $250M in compressed air energy storage
Also you could do it underwater if you live near a coast. Basically an upside down cup with a pipe in it, sunk as deep as possible.
jhallenworld··on Ask HN: How to learn about text editor architectures and implementations?
I used a double-linked list of gap buffers (each in its own fixed length block that can swapped out to disk) for JOE. It works great on large files, but still I would start with rope these days.

Gap buffer was appealing on really slow machines, where you are counting cycles on each key-press. If the gap is at the right position, the cycle count is very low. But you can probably do the same even with a tree-structure: you need to keep a pointer to the leaf in the abstract pointer used for the cursor.

Also I would tie in the undo system to the data structure if possible. Rope does this with copy-on-write. Every version of the file could be a different top-node, and most middle and leaf nodes would be shared between revisions.

jhallenworld··on Ask HN: How to learn about text editor architectures and implementations?
I would say the key is to abstract the lower level data structure, so that it could be (relatively) easily swapped-out. So for example, don't start with a doubly-linked list of lines or for sure your upper level code is going to have pointers to line headers. Better to have some kind of smart pointer which is an abstract index into the edit buffer and provide functions like "find next line", "find previous line".

BTW, with any of these tree-based structures (like rope) you can store other meta-data in the the headers to make a fast index. For example, I would put a newline count in the rope headers, to make find a particular line a fast operation.

jhallenworld··on Ask HN: How to learn about text editor architectures and implementations?
Read technical documentation for existing editors, for example:

https://sourceforge.net/p/joe-editor/mercurial/ci/default/tr...

jhallenworld··on My Many Girlfriends
In the late 90s, my cousin (who is a recruiter) asked me where she could find a good programmer. I suggested contacting people who participated in certain USENET newsgroups (I was recruited this way). She was successful at finding someone, but she said they had to help relocate the guy's pet lizard.

Also: read Rule 34 by Charles Stross. The weirdest thing about this book is that it's written in 2nd person.

jhallenworld··on Hacking a VW Golf Power Steering ECU
Maybe it's safer than hydraulic power steering. With electronics, there could be all kinds of self tests, for example that one of the H-bridge MOSFETs is shorted or open, akin to a valve being stuck.
jhallenworld··on Show HN: Lisp with GC in 436 Bytes
Overlapping functions... (saves 14 bytes...)

Crazy, DNA uses this trick!

"-Os" should search for possibilities here..

I'm wondering if such code breaks any CPUs. I could imagine that it could confuse the code translation that modern x86s do. I mean I bet they don't test this particular corner case...

jhallenworld··on Why do we still permit tobacco use? (2015)
We should ban US companies from marketing cigarettes to people (kids) in other countries. They are doing it right now in Africa.
jhallenworld··on Type-Safe Printf for C
So I also have a custom printf, but there is a limitation: if you ask gcc to check it with "__attribute__((__format__ (__printf__", then you are forced into using gcc's idea of what the printf format string syntax.

How can I have strict type checking, but a user defined format string?

jhallenworld··on Ask HN: Why is building Windows apps so complicated?
I found this to be useful, make a Win32 GUI in the old-school 90s way using MingW so you don't even have to use any Microsoft tools. It has the advantage that nothing has to be installed on the target PC except your application.

https://www.transmissionzero.co.uk/computing/win32-apps-with...

I used it to make an application that downloads files over a serial port from an OptiCon bar-code scanner:

https://github.com/jhallen/cartscan

Coming from UNIX, the biggest annoyance was Microsoft's use of wide character strings.

jhallenworld··on Lead poisoning among US children
The tap water pH in my town is 9.3. This seems extreme until you realize the lead risk with anything lower.

https://www.belmont-ma.gov/dpw-water-division/faq/what-is-th...

jhallenworld··on “Risc V greatly underperforms”
All other things equal, you would prefer smaller code for better cache use.
jhallenworld··on “Risc V greatly underperforms”
What if the multi-precision code is written in C?

You can detect carry of (a+b) in C branch-free with: ((a&b) | ((a|b) & ~(a+b))) >> 31

So 64-bit add in C is:

   f_low = a_low + b_low
   c_high = ((a_low & b_low) | ((a_low | b_low) & ~f_low)) >> 31
   f_high = a_high + b_high + c_high
So for RISC-V in gcc 8.2.0 with -O2 -S -c

        add     a1,a3,a2
        or      a5,a3,a2
        not     a7,a1
        and     a5,a5,a7
        and     a3,a3,a2
        or      a5,a5,a3
        srli    a5,a5,31
        add     a4,a4,a6
        add     a4,a4,a5
But for ARM I get (with gcc 9.3.1):

        add     ip, r2, r1
        orr     r3, r2, r1
        and     r1, r1, r2
        bic     r3, r3, ip
        orr     r3, r3, r1
        lsr     r3, r3, #31
        add     r2, r2, lr
        add     r2, r2, r3
It's shorter because ARM has bic. Neither one figures out to use carry related instructions.

Ah! But! There is a gcc macro: __builtin_uadd_overflow() that replaces the first two C lines above: c_high = __builtin_uadd_overflow(a_low, b_low, &f_low);

So with this:

RISC-V:

        add     a3,a4,a3
        sltu    a4,a3,a4
        add     a5,a5,a2
        add     a5,a5,a4
ARM:

        adds    r2, r3, r2
        movcs   r1, #1
        movcc   r1, #0
        add     r3, r3, ip
        add     r3, r3, r1
RISC-V is faster..

EDIT: CLANG has one better: __builtin_addc().

    f_low = __builtin_addcl(a_low, b_low, 0, &c);
    f_high = __builtin_addcl(a_high, b_high, c, &junk);
x86:

        addl    8(%rdi), %eax
        adcl    4(%rdi), %ecx
ARM:

        adds    w8, w8, w10
        add     w9, w11, w9
        cinc    w9, w9, hs
RISC-V:

        add     a1, a4, a5
        add     a6, a2, a3
        sltu    a2, a2, a3
        add     a6, a6, a2
jhallenworld··on Is the four-day workweek finally within our grasp?
I don't have a problem with no minimum wage, but I do have a problem with people starving and homeless. So I'm willing to give up on the minimum wage for any viable alternative. For example, UBI paid for by taxes on employers.
jhallenworld··on The Prince symbol has been salvaged from a 1993 floppy disk
Their thinking is too small.. I mean why shouldn't everyone on earth be able to have their own personal symbol? The technical challenge does not seem that insurmountable.

Also it's a business opportunity along the lines of the star name registry.

jhallenworld··on Features of PL/I not realized in a modern language
I think the more relevant language was PL/M (actually PL/M-86) since it was available for 8086 early on. I don't think PL/M had any of these features, and C for the 8086 was better than it so that was the end of it.

Maybe if IBM chose 68K for the PC, we would have gotten the full blown PL/I.

Edit, well actually I found this "X3.74, PL/I General Purpose Subset (Subset G)" from 1983. This version at least has strings.

Look at manual disk here:

https://winworldpc.com/product/digital-research-pl-i-compile...

jhallenworld··on SPI: The serial peripheral interface [video]
Some FTDI chips can do I2C (also SPI), will i2c-tools work for it?

Otherwise the Arduinos with USB are a convenient way to connect I2C to a PC..

jhallenworld··on SPI: The serial peripheral interface [video]
I've done similar things with UARTs over long distance- I was about to write about it, but I actually have it on github:

https://github.com/jhallen/joes-sandbox/tree/master/hw/lined...

CAN is interesting in that the protocol is pretty complex, but from software point of view it's just send_packet() and register a handler for receive packets. The annoying thing is that MCUs don't have built-in CAN line drivers.

A new thing is 1000BASE-T1- Gigabit Ethernet over a single twisted pair. This is supposed to be the future in the auto world..

jhallenworld··on SPI: The serial peripheral interface [video]
A nice advantage of SPI is that it can not lock up the master.

This is not true of I2C, where the slave could stretch the clock forever.

This is also not true of UART, where the slave just might not respond. But in fact both SPI and I2C can be simpler than UART since they are strictly master/slave. With a UART, the slave could send you unrequested data, which means your software has to handle asynchronous events. Even if it doesn't you probably have to implement timeouts and input flushing.

SPI is simpler than I2C in that it is a single-master bus, so accesses are atomic (at least at the bus level, within your RTOS is another story...).

You can use simple logic gates as SPI peripherals: for example, 74HC595 works as a SPI accessible 8-bit output port. This is important because such chips are the cheapest available (vs. I2C output port or UART to parallel..)

Despite all this simplicity, SPI is very fast.

Where UART has the advantage is software: picocom on Linux or Teraterm on Windows. Basically you don't have to develop any host-side software if you use a UART. I like to use the old ymodem protocol for embedded system firmware updates.. since again no host-side software has to be developed.

jhallenworld··on Nuclear radiation used to transmit digital data wirelessly
But won't the range be limited by neutron decay?
jhallenworld··on I'm “still afraid to use spaces in file names” years old
Yep, I recently got bit by this, someone checked in a branch named something like "x<-->y", Windows was unhappy. I think this is a git bug: git should escape these names for the native platform.

https://stackoverflow.com/questions/1976007/what-characters-...

jhallenworld··on An original Apple-1 computer sells for $400k
I would argue that the TRS-80 model 1 was more significant as the first home computer: $400 instead of $1300. Like the Apple-][ it also was usable out of the box, it just lacked color.

http://www.trs-80.org/was-the-trs-80-once-the-top-selling-co...

jhallenworld··on Macron says France will build new nuclear energy reactors
They call them e-fuels.. but the overall efficiency is low. There is a recent Engineering Explained video about this:

https://www.youtube.com/watch?v=0d0MPg7DxbY

But liquid fuels are incredibly convenient, so maybe they will be worth the high price in certain applications. For example in jet engines for airplanes.

jhallenworld··on Macron says France will build new nuclear energy reactors
We really need to locate the panels near the equator, and combine it with one day of storage. There is a project like this:

https://electrek.co/2021/09/27/the-worlds-longest-subsea-cab...

The problem for doing this large scale if the right of way for the HVDC lines. I'm watching this on a smaller scale in Massachusetts, where Maine voters are blocking a HVDC link to Hydro Quebec. But I think this is a game between established interests.. in this case NextEra funded the ballot question and advertising, I think because they lost out on their SeaLink project (HVDC to Seabrook nuclear power plant).

https://www.energy.gov/sites/prod/files/2020/09/f79/EXHIBIT%...

https://www.newscentermaine.com/article/news/politics/refere...

jhallenworld··on The Great Tree-List Recursion Problem (2000)
This reminds of a similar problem: visit all nodes of a tree without using recursion or an explicit stack (or any extra storage). It's useful for marking live nodes during mark & sweep garbage collection with a guarantee that the mark process itself will complete and not cause you to run out of memory.

So this is my amended problem: convert the tree to a same-ordered doubly-linked list without using recursion or an explicit stack.

jhallenworld··on Facebook Renames to Meta
The new logo almost looks like the Space:1999 Meta

https://www.youtube.com/watch?v=LFf5uavxYGQ

jhallenworld··on Radio Station WWV
Easier for me to pick up CHU:

https://en.wikipedia.org/wiki/CHU_(radio_station)

jhallenworld··on Kicad 6: new feature review for open source EDA tool
This is not a new idea: EDIF has been around for a long time:

https://en.wikipedia.org/wiki/EDIF

At least for netlists, it is a popular format.

jhallenworld··on Kicad 6: new feature review for open source EDA tool
Altium used to be known as Protel, and it was the cheap option back in the 90s.

I've not tried Altium's autoplacer, but its autorouter is crap. I bought into PADS in the 90s (it was better than Protel, but not as expensive as OrCAD PCB). It used Specctra and then their own Blaze router. Both were excellent. I can not believe how bad Altium's autorouter still is (it leaves your board full of drc errors including shorts).

It is difficult to convey how well auto-routers can work to people who are used to manually routing boards in Altium because of it's broken auto-router. Seriously you hit the auto-route button, and a few minutes later it's done. You do want to ensure you have good constraints, all of the work is there, and it's a good idea to have them even when manually routing. It's very feasible to move parts around and do trial full routes to help find the best placement.

PADS did have an autoplacer, but it did not work very well as I remember.

← PreviousPage 21 of 34Next →