Xah Programing Blog Archive 2023-01

Google Deepmind Claims it Discovered Faster Sorting Algorithm

have not updated my webfeed for 2 months. busy. check Xah Programing Blog, posts are there.

xtodo

for programers. here are few critical article for programing language syntax designers. and if you are a lisp fan or WolframLang fan. you get an in-depth understanding of syntax issues.


repost

Generative Art, Raytracing, Myers-Briggs, Personality Test, Psychology, Lex Fridman Xah Talk Show 2022-11-24 Generative Art, Raytracing, Myers-Briggs, Personality Test, Psychology, Lex Fridman

get sha256 hash of a file

Get-FileHash -Algorithm SHA256 filename

# get sha256 hash of a file
Get-FileHash filename
PowerShell get file hash sha256 2023-05-02
PowerShell get file hash sha256 2023-05-02
xtodo

misc updates

updated.

Programing Exercise: Show Difference of Sorting Unicode Characters by Code Point vs Code Unit

/* unicode exercise.
2023-04-04
come up with example to demonstrate sorting by code unit and code point
*/

const xx = ["fi","πŸ˜†"];
console.log( xx.sort() )
// [ "πŸ˜†", "fi" ]

const yy = ["ο·½","πŸ˜†"];
console.log( yy.sort() )
// [ "πŸ˜†", "ο·½" ]

/*

πŸ˜† codepoint 128518
name: SMILING FACE WITH OPEN MOUTH AND TIGHTLY-CLOSED EYES

fi codepoint 64257
name: LATIN SMALL LIGATURE FI

ο·½
codepoint 65021
name: ARABIC LIGATURE BISMILLAH AR-RAHMAN AR-RAHEEM

*/

JavaScript. the other example to demonstrate sorting by code unit and code point, is bismilla ο·½ . Unicode Arabic Ψ΄ Unicode: Arabic Ψ΄

js sort bismilla 2023-04-03 163406
js sort bismilla 2023-04-03 163406

Microsoft Windows snip and sketch problems and shareX

on Microsoft Windows, the screenshot software snip n sketch sucks. it has multiple problems. 10% of time you got error saying app cannot open. does not auto-save. and when you manually save, it takes a whopping second to popup a save dialog. and then with offensive β€œplease wait while we let ink dry”.

shareX been using for 2 years, but also have sundry problems. major problem is that it has a delay when you start to drag a region with touchscreen or drawing tablet. this means, you cannot select a precise region. (workaround is to double click on the starting point then drag) but it's builtin drawing tool also does not support stylus or touchscreen well. also a delay problem, so you cannot use it to write anything. (it's also using jagged bitmap lines.) its user interface is extremely complex and sucks donkey ass, with tiny font you cannot read.

currently trying flameshot. ok, flameshot also got the delay problem. in flameshot, no delay when starting to select a region. great. but when u start to write notes, there's a 0.3 sec delay. e.g. try to write the word β€œwith” in cursive, the dot and horizontal line for letter t won't appear, unless you wait for a fraction of sec before each stroke. much better than sharex and simpler, but still sucks.

one major problem i found with the elaborate setup i eventually did with sharex and have it launch paint.net is that, after u write something in paint.net, it won't copy result into clipboard. u have to do select all and copy, if u want the screenshot with notes u've written on it, to paste somewhere. this select all and copy, is a major problem when u on a tablet sans keyboard

gosh. some a simple need, no satisfactory solution.

here's a summary. all i want, is do a screenshot, select region of interest, and write some notes on it with touchscreen or drawing tablet, and have the final result auto saved and auto copied to clipboard. all this done on a tablet (Microsoft surface pro 4), sans a keyboard.

actually, Microsoft snip and sketch is the solution. except Microsoft is pretty lousy, that the app fails to start 1 in 20 times or so. and once a month, it completely fail to start, unless u restart windows. but so far, all other complex solutions, seems require more work.

ai bot chats a hogwash.

google bard ai chat xah lee 2023-04-02
google bard ai chat xah lee 2023-04-02

xtodo review/repost

Steve Yegge has a new blog

xtodo

minor updates and new

some old articles.

What is functional programing

Let me give u a quick guide about functional programing. There's an academic definition. Basically, ur code mostly are just function calls. Function here means like mathematical function. The important thing is, no side effects, means, the function's behavior purely depends on its arguments. Same args, same output, always. And this practically means, don't use global vars, etc in ur subroutine. That's the academic def of fp. Which then can get more complex. This is when, u hear currying, first class citizen, monad, referential transparency, and faaks like that.

the above is academic view of functional programing. which often is a math based view.

now, let me give practical view, which is more or less how i began it. the practical view, is that, when you write a subroutine, any lang, you notice, usually it's better if you no use global vars inside it. because that makes your subroutine behavior less predicable, more bug prone, etc.

i notice, it's nice, if you always write your subroutine such that the behavior just depends on the parameters. aka known as no-side effects, or, pure function.

this also makes your subroutine independent, you can move it from code to code. and, once you write subroutines that way, it becomes widely usable across, aka code-reuse.

once you started to write your code this way, in any lang, after a few years, gradually, you'll notice other things you tend to do. e.g. you want the lang to be able to take a subroutine as arg, or output a subroutine. (this is known as function being 'first class' object, academic speak a la scheme lisp)

also now, if most or all your subroutines are side-effect free, that's called referential transparency, academic speak. meaning, you can just move any function to any other place.

once you are used to moving function around, you notice, why not other things, such as if statements. i.e. you want if statement to be expression, example: like c's (test ? doTrue : doFalse) so that you can move if expression just like you mave functions about.

and then, why not make for-loop as expression, or any other. basically, you started to want all statement being expressions. this is why, in many functional programing languages, everything are expressions.

The AI Threat, Year 2023

the ai threat 2023-03-16 SxMqX
the ai threat 2023-03-16 SxMqX

File path functions in various langs. You can compare their design.

Short History of Ocaml

major updates.

Windows terminal wt not found

updated.

reposts and minor updates

updates and repost

misc updates.

added new images

misc minor updates

updated.

updated.

misc updates

how much you make on YouTube

xahlee youtube money 2023-01-05 2D8Bm
xahlee youtube money 2023-01-05 2D8Bm

updated or new

xtodo

more js updates. worked in past week.

massive update on my JavaScript tutorial in past week

JavaScript Regex Functions, major rewrite. they are very confusing, badly designed.

some new custom functions

one example of the worst JavaScript function design. Cannot say which is worse, JavaScript or Python. JS: String.prototype.match (tech writing aspect: page rewritten with clarity. compare it to mozilla mdn (i have not looked))

updates

lots JavaScript in depth updates.

xtodo