The long way through Software Craftsmanship

Self-Study in August 2022

Aug 1, 2022 - 5 minute read - Comments - self-study-aggregation2022augustalgorithmarc42architecturearxivbinary-treebugcc4-modelcalculatorcfficlosurecloudflareconfidence-intervalconnecting-languagesconnectioncreative-workcreativitycurrycurryingdata-structuredocumentationdsaemulatorffiforeign-function-interfacefunctional-programminggooglehacker-newshammock-driven-developmenthave-i-been-pwnedhenri-poincarehigher-order-functionimportedintegrationisomorphismjavajavascriptjideofor-onwugbenujsjuliajump-tableleisurelibrarymisraopcodeoptimizationpaperpartial-applicationpasswordperformancepeter-druckerprivacypurgatorypythonquoteresourcerich-hickeyrustsafety-criticalskiplistspamspammerstandardstatistically-relevantstatisticsswitch-statementsystem-thinkingti-84troy-huntv8workzip-tree

A Tutorial on Portable Makefiles (2017)

https://news.ycombinator.com/item?id=32303193

Tags: imported, hacker-news

Id: a4860376-c1a0-11ed-ae57-0242ac110004 Read: Mon Aug 1 07:43:01 2022

Software engineering books

https://news.ycombinator.com/item?id=32305997

Tags: imported, hacker-news

Id: a23a4924-c1a0-11ed-a585-0242ac110004 Read: Mon Aug 1 13:57:25 2022

Show HN: Emery – Personal productivity workspace

https://news.ycombinator.com/item?id=32312413

Tags: imported, hacker-news

Id: a6dab644-c1a0-11ed-b024-0242ac110004 Read: Mon Aug 1 21:42:53 2022

Minify your container

https://news.ycombinator.com/item?id=32334741

Tags: imported, hacker-news

Id: a94d30aa-c1a0-11ed-bb01-0242ac110004 Read: Wed Aug 3 17:42:44 2022

Against Discipline

https://news.ycombinator.com/item?id=32340703

Tags: imported, hacker-news

Id: d8ec98f6-c1a4-11ed-aa3b-0242ac110004 Read: Thu Aug 4 08:56:08 2022

Sending Spammers to Password Purgatory with Microsoft Power Automate and Cloudflare Workers KV

Troy Hunt has created an automated tunnel (as a form), that makes spammers to spend time trying to set up an account.

Tags: troy-hunt, purgatory, spammer, spam, password, cloudflare, have-i-been-pwned

Id: 5bc3da5a-13db-11ed-b88e-0242ac110003 Read: Thu, 04 Aug 2022 09:53:57 +0000

Currying

Tags: javascript, curry, currying, partial-application, functional-programming

Id: 8aaa2bd0-13db-11ed-b98a-0242ac110003 Read: Thu, 04 Aug 2022 09:55:16 +0000

A closer look at JavaScript closures, higher-order functions, and currying

Tags: closure, javascript, higher-order-function, partial-application, functional-programming

Id: a93f40f8-13db-11ed-81c7-0242ac110003 Read: Thu, 04 Aug 2022 09:56:07 +0000

Documenting software architecture with arc42

https://news.ycombinator.com/item?id=32353500

Tags: documentation, architecture, arc42, c4-model, system-thinking, imported, hacker-news

Id: 8e1e992e-16e5-11ed-85fc-0242ac110003 Read: Fri Aug 5 09:01:57 2022

Ask HN: What are some good resources to learn safety-critical C/C++ coding from?

https://news.ycombinator.com/item?id=32354471

Tags: safety-critical, c, misra, resource, standard, bug, imported, hacker-news

Id: bcbf73ca-16e5-11ed-a7fd-0242ac110003 Read: Fri Aug 5 11:13:25 2022

Ask HN: What are some good resources to learn safety-critical C/C++ coding from?

https://news.ycombinator.com/item?id=32354471

Tags: imported, hacker-news

Id: cf69d690-c1a4-11ed-8acd-0242ac110004 Read: Fri Aug 5 11:13:25 2022

Decentralized Identifiers (DIDs) v1.0 Becomes a W3C Recommendation

https://news.ycombinator.com/item?id=32354669

Tags: imported, hacker-news

Id: b50f356e-c1a0-11ed-b09a-0242ac110004 Read: Fri Aug 5 11:35:48 2022

Let’s Talk SkipList

A guide on how to implement a SkipList data structure

https://news.ycombinator.com/item?id=32374278

Tags: skiplist, data-structure, zip-tree, isomorphism, dsa, algorithm, binary-tree, imported, hacker-news

Id: 4352df2c-16e5-11ed-abbc-0242ac110003 Read: Sun Aug 7 06:08:09 2022

Learning algebra in my 60s

https://news.ycombinator.com/item?id=32375955

Tags: imported, hacker-news

Id: db443992-c1a4-11ed-ae4b-0242ac110004 Read: Sun Aug 7 12:28:43 2022

I 10x’d a TI-84 emulator’s speed by replacing a switch-case

Increasing the performance by helping the compiler to optimize switch statements.

@LGB actually in V8 (JS engine used by google chrome) you need to jump through a lot of hoops to get switch case optimized: All the cases must be of same type. All the cases must either be string literals or 31-bit signed integer literals. And there must be less than 128 cases. And even after all those hoops, all you get is what you would have gotten with if-elses anyway (I.E. no jump tables or sth like that)

https://news.ycombinator.com/item?id=32381550

Tags: emulator, calculator, optimization, switch-statement, jump-table, javascript, js, v8, google, opcode, ti-84, imported, hacker-news

Id: fa4d5126-16e5-11ed-bc8f-0242ac110003 Read: Mon Aug 8 01:20:41 2022

To Become Wise, Do Less!

The need to integrate leisure in creative work. It is rephrased as “Leisure gives the scribe the chance to acquire wisdom”. This is a similar idea to Hammock Driven Development (Rich Hickey)

Tags: leisure, creativity, creative-work, work, henri-poincare, rich-hickey, hammock-driven-development, peter-drucker, quote, jideofor-onwugbenu

Id: 4e335ae4-16e4-11ed-a924-0242ac110003 Read: Mon, 08 Aug 2022 06:35:33 +0000

Uses for an old Android device

https://news.ycombinator.com/item?id=32383835

Tags: imported, hacker-news

Id: b065e346-c1a0-11ed-a41d-0242ac110004 Read: Mon Aug 8 10:00:08 2022

De-anonymizing programmers from binaries (2017)

How to identify (de-anonymize) programmers (code authors) from its binaries

https://news.ycombinator.com/item?id=32384147

Tags: arxiv, privacy, paper, imported, hacker-news

Id: 2e5f6d24-17da-11ed-9b75-0242ac110003 Read: Mon Aug 8 11:02:10 2022

The productivity tax you pay for context switching

https://news.ycombinator.com/item?id=32390499

Tags: imported, hacker-news

Id: ae0f6900-c1a0-11ed-b21b-0242ac110004 Read: Mon Aug 8 20:18:05 2022

Doomed to repeat history? Lessons from the crypto wars of the 1990s (2015) [pdf]

https://news.ycombinator.com/item?id=32390605

Tags: imported, hacker-news

Id: b2c3a9d4-c1a0-11ed-89f9-0242ac110004 Read: Mon Aug 8 20:29:30 2022

The case against a C alternative

https://news.ycombinator.com/item?id=32392161

Tags: imported, hacker-news

Id: abb54828-c1a0-11ed-b0ed-0242ac110004 Read: Mon Aug 8 22:56:18 2022

Statistically Rigorous Java Performance Evaluation

Java performance is far from being trivial to benchmark because it is affected by various factors such as the Java application, its input, the virtual machine, the garbage collector, the heap size, etc. In addition, non-determinism at run-time causes the execution time of a Java program to differ from run to run. There are a number of sources of non-determinism such as Just-In-Time (JIT) compilation and optimization in the virtual machine (VM) driven by timerbased method sampling, thread scheduling, garbage collection, and various system effects.

There exist a wide variety of Java performance evaluation methodologies used by researchers and benchmarkers. These methodologies differ from each other in a number of ways. Some report average performance over a number of runs of the same experiment; others report the best or second best performance observed; yet others report the worst. Some iterate the benchmark multiple times within a single VM invocation; others consider multiple VM invocations and iterate a single benchmark execution; yet others consider multiple VM invocations and iterate the benchmark multiple times.

This paper shows that prevalent methodologies can be misleading, and can even lead to incorrect conclusions. The reason is that the data analysis is not statistically rigorous. In this paper, we present a survey of xisting Java performance evaluation methodologies and discuss the importance of statistically rigorous data analysis for dealing with non-determinism. We advocate approaches to quantify startup as well as steady-state performance, and, in addition, we provide the JavaStats software to automatically obtain performance numbers in a rigorous manner. Although this paper focuses on Java performance evaluation, many of the issues addressed in this paper also apply to other programming languages and systems that build on a managed runtime system.

(copied from the abstract)

Tags: java, performance, statistics, statistically-relevant, confidence-interval

Id: dec739e6-17dd-11ed-9806-0242ac110003 Read: Tue, 09 Aug 2022 12:22:01 +0000

JNumPy: Writing high-performance C extensions for Python in minutes

A way of writing modules in Julia, then compile them to C, then connect them to Python

https://news.ycombinator.com/item?id=32407451

Tags: julia, ffi, foreign-function-interface, cffi, python, connecting-languages, connection, integration, library, imported, hacker-news

Id: ba6208f8-188a-11ed-883f-0242ac110003 Read: Wed Aug 10 03:03:32 2022

Electric Vehicles Are Going to Suck; Here’s Why [video]

https://news.ycombinator.com/item?id=32409272

Tags: imported, hacker-news

Id: dd93cb7c-c1a4-11ed-adf1-0242ac110004 Read: Wed Aug 10 08:35:01 2022

PyO3

A way of connecting Python to Rust.

Tags: cffi, ffi, foreign-function-interface, rust, integration, connection, connecting-languages, library

Id: fd98378c-188a-11ed-bb0a-0242ac110003 Read: Wed, 10 Aug 2022 09:01:15 +0000

Tell HN: Unpaid home assignments are not ok

https://news.ycombinator.com/item?id=32437078

Tags: imported, hacker-news

Id: dfec522c-c1a4-11ed-8f09-0242ac110004 Read: Fri Aug 12 11:51:30 2022

Self-Study in July 2022

Jul 1, 2022 - 1 minute read - Comments - self-study-aggregation2022julyaesapplicationclicryptographyfzfguidehacker-newsimportedpersonal-knowledgesearchsoftwaretooltutorialwikizettelkasten

Zetk: CLI utilities, fzf-based scripts, C++ lib for managing your Zettelkasten

Zettelkasten notes implemented as a library with a set of CLI utils

https://news.ycombinator.com/item?id=31969931

Tags: zettelkasten, software, personal-knowledge, application, tool, cli, fzf, search, wiki, imported, hacker-news

Id: 5017abd4-fb79-11ec-ad8c-0242ac110003 Read: Sun Jul 3 18:38:57 2022

Show HN: C3 – A C alternative that looks like C

https://news.ycombinator.com/item?id=32005678

Tags: imported, hacker-news

Id: d665c1c0-c1a4-11ed-a153-0242ac110004 Read: Wed Jul 6 19:31:01 2022

Formally Verifying Industry Cryptography

https://news.ycombinator.com/item?id=32066370

Tags: imported, hacker-news

Id: 98fd7b9c-c1a0-11ed-a0b4-0242ac110004 Read: Tue Jul 12 06:34:16 2022

Rolling your own crypto: Everything you need to build AES from scratch

A guide to understand AES in depth

https://news.ycombinator.com/item?id=32078749

Tags: aes, cryptography, tutorial, guide, imported, hacker-news

Id: c93acb66-13db-11ed-9c8a-0242ac110003 Read: Wed Jul 13 03:30:52 2022

Ask HN: What are some cool but obscure data structures you know about?

https://news.ycombinator.com/item?id=32186203

Tags: imported, hacker-news

Id: 9b457f58-c1a0-11ed-9849-0242ac110004 Read: Thu Jul 21 22:50:29 2022

How to Stop Procrastinating on Your Goals by Using the “Seinfeld Strategy”

https://news.ycombinator.com/item?id=32245545

Tags: imported, hacker-news

Id: 9d9617ae-c1a0-11ed-9bee-0242ac110004 Read: Wed Jul 27 00:03:04 2022

How to create a Python package in 2022

https://news.ycombinator.com/item?id=32258783

Tags: imported, hacker-news

Id: 9fe13d68-c1a0-11ed-a2c3-0242ac110004 Read: Thu Jul 28 00:06:31 2022

Connecting from Python to C, using Cython

Jun 18, 2022 - 3 minute read - Comments - bindingcythonpythoninvestigationforeign-function-interfaceffigenerate-kat-core

Connecting from Python to C, using Cython

Have a look at the generate-kat-core repo. At the time of writing, it’s not open-source yet.

Takeaways

Automate the creation of the library

Create a make goal to:

  1. Copy the library LIBRARY from its origin to its destination
  2. Compile the cython code
  3. Execute the above when executing the test goal (to always have an up-to-date version when committing)

If needed, in PyCharm, require the test configuration to execute the make goal first (as a prerequisite)

ORIGIN_PROJECT:=.
ORIGIN:=${ORIGIN_PROJECT}/binaries

DESTINATION:=.

all: clean list copy clean-post-copy

list:
	ls -d $(shell realpath ${ORIGIN}) || true
	find ${ORIGIN} -iname "*\.a"
.PHONY: list

clean:
	rm -f ${DESTINATION}/*a ${DESTINATION}/*h
.PHONY: clean

copy:
	cp ${ORIGIN}/lib/libLIBRARY*.a ${DESTINATION}/libLIBRARY.a
	cp -R ${ORIGIN}/include/ ${DESTINATION}
.PHONY: copy

clean-post-copy:
	rm -f *.zip
	rm -rf ${ORIGIN}
.PHONY: clean-post-copy

Use the *.pyx files to connect Python to the C functions

You can use the *.pyx files to define the functions that will be called from Python. The *.pyx files are Cython files that can be compiled to C.

In these *.pyx files, you can define the glue code that will call the C functions.

As such, we write test code for those *.pyx files, to ensure the C functions are called correctly. Those tests are end-to-end, allowing no test doubles.

Introduce restrictions in the glue code

  1. Because C requires the size of the array, you can inject a python array (e.g., bytes or bytearray). Python will know the size of the array, and you can pass it to the C function:
def my_function(data: bytearray):
    size = len(data)
    c_function(c_data, size)
  1. If the C function requires a specific size (e.g., 4 bytes), you can check the size in the Python function:
def my_function(data: bytearray):
    assert len(data) == 4, f"The data must be 4 bytes long. Currently = {len(data)} bytes"
    c_function(c_data) # size can be optional if it's mandatory to be 4
  1. Bytes are immutable, while bytearray is mutable.

When a bytes is passed to a C function, it’s passed as a pointer to the data.

Be careful when modifying the data in the C function. If you need to change the data, use a bytearray.

Debugging

To remove defects in the *.pyx files, convert once (“cythonize”).

from setuptools import setup
from Cython.Build import cythonize

setup(
    ext_modules = cythonize("helloworld.pyx")
)

(From Cython: Basic Tutorial)

Look around here, with the tag generate-kat-core

Cython: Extension types

How to create a Cython class that can wrap a cdef field.

Tags: cython, generate-kat-core, python, integration, binding

Id: eaf09838-ec8c-11ec-b5c3-0242ac110003 Read: Wed, 15 Jun 2022 09:24:12 +0000

Cython: Connecting function pointers in Python

Tags: stack-overflow, function-pointer, python, cython, generate-kat-core, integration, binding

Id: 143138ce-ec8d-11ec-aa16-0242ac110003 Read: Wed, 15 Jun 2022 09:25:21 +0000

Cython: Defining fields in a Cython.cclass

Pointing to “WaveFunction” (#id8).

Examples of how a @cython.cclass with attributes gets converted to C.

Tags: cython, binding, generate-kat-core, cython.cclass, python, integration

Id: 4c981052-ec8d-11ec-a7c9-0242ac110003 Read: Wed, 15 Jun 2022 09:26:56 +0000

Cython: Using a struct from a different library

Tags: cython, struct, integration, generate-kat-core, python, binding

Id: 6356b910-ec8d-11ec-8ba6-0242ac110003 Read: Wed, 15 Jun 2022 09:27:34 +0000

Self-Study in June 2022

Jun 1, 2022 - 2 minute read - Comments - self-study-aggregation2022juneairplaybindingcythoncython.cclassdebuggingfunction-pointergenerate-kat-corehacker-newsimportedintegrationkernellinuxmac-osprogramming-languagepythonruststack-overflowstructtouch-bar

Meet developers 1:1 every week and team up on projects

https://news.ycombinator.com/item?id=31627089

Tags: imported, hacker-news

Id: 96b84628-c1a0-11ed-b3f2-0242ac110004 Read: Sun Jun 5 01:42:05 2022

AirPlay and Touch Bar = Network Disaster

An account of the interaction between AirPlay and Touch Bar (in mac)

https://news.ycombinator.com/item?id=31706283

Tags: airplay, debugging, touch-bar, mac-os, imported, hacker-news

Id: f82bd9d0-ebf2-11ec-a47b-0242ac110003 Read: Sat Jun 11 17:31:03 2022

Cython: Extension types

How to create a Cython class that can wrap a cdef field.

Tags: cython, generate-kat-core, python, integration, binding

Id: eaf09838-ec8c-11ec-b5c3-0242ac110003 Read: Wed, 15 Jun 2022 09:24:12 +0000

Cython: Connecting function pointers in Python

Tags: stack-overflow, function-pointer, python, cython, generate-kat-core, integration, binding

Id: 143138ce-ec8d-11ec-aa16-0242ac110003 Read: Wed, 15 Jun 2022 09:25:21 +0000

Cython: Defining fields in a Cython.cclass

Pointing to “WaveFunction” (#id8). Examples of how a @cython.cclass with attributes gets converted to C.

Tags: cython, binding, generate-kat-core, cython.cclass, python, integration

Id: 4c981052-ec8d-11ec-a7c9-0242ac110003 Read: Wed, 15 Jun 2022 09:26:56 +0000

Cython: Using a struct from a different library

Tags: cython, struct, integration, generate-kat-core, python, binding

Id: 6356b910-ec8d-11ec-8ba6-0242ac110003 Read: Wed, 15 Jun 2022 09:27:34 +0000

Schluss – A secure vault for personal data

https://news.ycombinator.com/item?id=31833026

Tags: imported, hacker-news

Id: d1b56a18-c1a4-11ed-8c56-0242ac110004 Read: Wed Jun 22 07:31:04 2022

Linus Torvalds: Rust for the Kernel Could Possibly Be Merged for Linux 5.20

https://news.ycombinator.com/item?id=31848499

Tags: rust, linux, kernel, programming-language, imported, hacker-news

Id: 6ffdee10-17dd-11ed-950f-0242ac110003 Read: Thu Jun 23 13:05:47 2022

Becoming a Better Engineering Team

https://news.ycombinator.com/item?id=31873967

Tags: imported, hacker-news

Id: d411469c-c1a4-11ed-b68f-0242ac110004 Read: Sat Jun 25 10:06:57 2022