Xah Programing Blog Archive 2018-08

random thoughts: jupyter notebook, python 3 problem, golang interface

the jupyter notebook, looks like a exact copy of Mathematica of 1990.

here's what Mathematica notebook looks like Wolfram Language


one of the problem of python 3 is that, print becomes a function, thus need parenthesis. Nobody likes to type that, and python doesn't have short syntax to omit paren. And print is now a function, yet python sneer functional programing everywhere.


golang's interface is fishy. A mesh of logical levels, a cause of confusion. When go compiler run into a val whose type is interface, its behavior changed. Instead of checking type, it checks if the val has the methods. go interface really shouldn't be a type.

am retiring my last perl script. this one written in 2004, validate local links of all html files in a dir

Perl: Validate Local Links

it's replaced by golang

Golang: Validate Links

Python: Count Word Frequency

someone should create a lisp wrapper over golang

Proliferation of Programing Languages

apparently, there is no lisp wrapper to golang but someone created a embedded lisp scripting lang inside go.

https://github.com/glycerine/zygomys

coding in golang, error checking every 10 lines

coding in golang is like, every 10 lines you have

if err != nil { panic(err) }

golang no exceptions 2015-07-14 13208
golang no exceptions 2015-07-14

there are probably lots of things you don't know about exceptions. langs python ruby java lisp their concept of exceptions differ. see Why I Hate Exceptions

math, Z notation

there are these Z notation ⋿ ⦁ ⦂ ⨾ ⨟ ⨠ ⨡ ⩤ ⩥ ⦇ ⦈ ⦉ ⦊ apparently designed for “formal” spec of computer programs. See also APL Symbols Unicode: APL Symbols ⍋ ⍟ ⍝

hard link, soft link, alias, virtual store. ban them.

ancient articles.

unix has hardlink softlink. Mac has alias. Microsoft Windows has Shortcut and VirtualStore. They should all be ban'd.

Windows Vista VirtualStore Problem

File Aliases Considered Harmful

the only link should be allowed is symbolic link. and the destination path should be visible as file content.

bing map. looks pretty good

bing map. looks pretty good. https://www.bing.com/maps/ i've tried some other open source ones. sometimes for street map, sometimes for geography or history. they pretty suck. Bing looks good.

this is why mastodon will never be popular

mastodon never be popular 2018-08-28 2462a
golang 2018-08-28

this is why mastodon will never become mainstream. not even that. it'll remain a little coner among nerds only.

recall in the 90s up to mid 2000s, that nerds cry out about html validation, and alt for images, and against shortened links? all's forgotten. Today, it's actually impossible for a commercial site to pass html validation.

the nerds, thought they are fighting for good. rather, they are just like any other superficial idiots. Today, it's net neutrality. And google Facebook Apple are probably smiling, all for it.

look at some history here. History of Web Tech

shorted url, began as solution to unreadable long google search result link around 2007. Then, it became means to track who clicked it. Nerds fought for it, lost. today, totally forgotten, the idiotic nerds find something else to fight about.

The tracking is so bad, that all major sites track your scroll so they know which section your eyeballs sit. e.g. twitter. That even sites nerds use a lot, medium, do it.

machine learning programing language syntax?

if you take a machine learning system say TensorFlow, and feed it all available public source code of a language, say, C. what are the chances it can identify few lines you typed is valid C syntax or not?

it's interesting, cuz AlphaZero beats human go champion. but if it can't validate comp lang syntax, it means that's much harder than beating go human champion. and i think that give us a sense just how difficult beating human was. i.e. not hard with respect to all problems.

Julia lang

Julia is good. from my hacker acquaintances i've heard. Julia is super fast, similar to golang. Julia should replace all the industrial math langs. e.g. matlab, R, python numpy, javascript, etc. Julia is a proper lang if u want to do math. e.g. haskell is not.

context https://twitter.com/newsycbot/status/1034305201824509952

one easy way to tell if a lang is math lang, is this: If its array starts at 1, its math lang. They include: FORTRAN, SASL, MATLAB, Julia, Mathematica, Smalltalk, Lua , Erlang, APL. see Should Array Index Start at 0 or 1?

one thing always bugged me about industrial coders is that, they are not math oriented people. but am really from a math background. What i see, they don't see, and call me a troll instead. While they've never done scientific computing nor used a math oriented lang in their life.

math langs, in general are 2 classes: numerical, and symbolic. Majority out there are numerical. e.g. R matlab python numpy fortran. Symbolic is rare: Mathematica, Maple. Another class of math language are proof systems. coq, isabelle, HOL Light.

julia vs golang 2018-08-27 db233
here's julia vs rustlang vs golang. quite amazing. (note, the plot is focused on math orented tasks.)

here's a short intro about proof systems, based on America Math Society article. 10 years anniversary! State of Theorem Proving Systems 2008 State of Theorem Proving Systems 2008

symbolic math lang is typically called computer algebra systems. They can also do numerical computation, since lots math prob don't have symbolic solution. Rather, we say matlab R etc are numerical, because usually that's what they focus on. and typical numerical systems can't do symbolic computation. (because, symbolic computation and numerical requires entirely different system.)

note, there is no reason why a lang can't do all 3: numerical, symbolic, and also as proof systems. PLUS presentation e.g. TeX. Because, tech maturity wasn't there. and we don't understand proof system that much before.

Computer Languages Characters Frequency

updated. now includes golang.

golang's date time handling problem

[Monotonic Elapsed Time Measurements in Go By Russ Cox. At https://golang.org/design/12914-monotonic ]

by the way, the problem is fixed.

just came off reading Russ Cox's extremely verbose article on time.

that guy wrote a famous article on regex a decade ago

[Regular Expression Matching Can Be Simple And Fast By Russ Cox. At https://swtch.com/~rsc/regexp/regexp1.html ]

did read that yesterday again. though, skipped most of the tech detail. i think russ cox is somewhat old fashioned and interesting guy. what he said is correct, but, rather, somewhat useless. many old fashioned geeks are like that.

all the examples he gave, are rather concocted cases. sure, still, it's good to fix since we know the solution. but, in that perspective, tons of things in industry need fix, with higher priority.

2018-08-27 to read. golang, using go routine on spawn lots of file reading but avoding problem of too many files open. https://bitbucket.org/tumdum/findserver/src/73ca1776e336d9f256c39dc50b4dbd69c2f76f18/server.go#lines-149

ah, so this is what Russ Cox looks like. https://www.youtube.com/watch?v=6wIP3rO6On8 he's discussing upcoming golang 2 design. looks good.

Paul Graham on What You Can't Say

[What You Can't Say By Paul Graham. At http://www.paulgraham.com/say.html ]

Paul Graham. i wonder, if he still have control at hackernews the forum. and, wonder if he is pressed at his company by the sjw.

i wonder if i should follow paul graham. in general, i no follow celebrities. cuz typically, when u got to that size, whatever good u have is gone. but i wonder if i should follow just to see gossips, and comment on top now and then.

Golang: Random Number

Seagate 8TB External Hard Drive. You Buy amazon I make bread.

go routine 2018-08-27 0433c
go routine 2018-08-27

golang lol. slapped on a “go” in front of file opening function in filepath.Walk(inDir, pWalker). and this is what i get. maybe i need a buffered go routine. :D but actually, how does one deal with this problem?

programing languages i've learned

my 1st lang is HP-28s 1991 HP-28S Advanced Scientific Calculator wrote 8 queens. Then Mathematica, 1992~1999 buried myself in it. Wolfram Language perl 1998. some java 2001. python 2005. php 2007. elisp 2005. some js 2005. LSL 2007 Second Life LSL Tutorial Deep js 2013. some clojure 2014

Programing Language Tutorials Index

golang is now my fav lang. (not counting Mathematica) it's simple. go ≻ ruby ≻ python. unlike haskell of pseudo math. Not clojure a skin of Java monster and for enterprise coding ONLY. Not racket, who lives in ivory tower. If we remove go's concurrency and speed, it remains my fav.

golang has this way of methods and interfaces. that is, Interface is just a set of methods, and it can be attached to any data. No hierarchy. none of the OOP class tree model complexity. If you want methods like OOP, you can. if you want functional programing, sure.

i used to despise Rob Pike. even though i don't know him much, but simply because he's one of those associated with unix philosophy fcuk. but now i've seen a few of his writings, i like his ideas. he's a bit loud mouthed, but not crackpot as some other e.g. M Fowler. L Wall.

text processing task, reading disk is the bottle neck

python vs golang 2018-08-26 86e1f
spent the past 3 hours wondering why my golang isn't faster than my python script. It's find/replace on few thousand text files. maybe for this task it makes no difference.

yeah. the problem is reading disk.

golang struct 2018-08-26 d60b2
holy cow, first time using struct, coding for 27 years. golang

Golang: Defer

russian keyboard programing 2018-08-25 e1fc9
Russian Keyboard Layout and Programing

Russian had it bad. they have to switch between russian layout and qwerty constantly

Git: Revert to Old Version

baidu about page 2018-08-23 be404
baidu about page 2018-08-23

百度。真漂亮。呵呵。 材料:机械手一个。魔术方块一个。小鲜肉一个。

lol, so attractive. Ingredients: One robotic arm. One magic cube. One pretty boy.

Python 3 Adoption

Golang: Rune

Python: Script to Find Replace Multi-Pairs Regex in a Directory

major update.

Unicode utf8 encoding is now used 92% on the web, world wide. Not sure if the source properly counte china traffic. See also: What Character Encoding Do Chinese Sites Use? Chinese Websites Character Encoding Survey, Year 2012

How Popular is Unicode UTF-8

tedious to dig into a new lang

it's quite time consuming to dig into a new lang. Things you thought are trivial, but tedious to get it right. stumble here and there every 5 minutes.

like a million monkey banging on keyboard. eventually, you'll get the syntax right.

golang regex is beautiful

i've never seen a regex lib as beautiful as golang's https://golang.org/pkg/regexp/ more concise, readable, and powerful than perl python php emacs lisp.

golang regex 2018-08-23 60f01
golang regex 2018-08-23

draft tutorial Golang: Regular Expression

JavaScript is the worst wart in humanity

JavaScript is the worst wart in humanity. not only the language sucks utmost (even consider only pure es2015+), but i find the community, its people, are typically elite snob millennials.

nim lang, and Uniform Function Call Syntax

looks like https://nim-lang.org/ is a great lang. typed, same niche as golang. but very neat! though, it sports python syntax. (but a better cleaner one)

and via nim lang, i learned Uniform Function Call Syntax. i.e. any function call can use dot notation. e.g. g(f(x,y)) can be written as x.f(y).g , for any functions f g.

see also Ontology of Postfix Notation, Method Chaining, and Unix Pipe Ontology of Postfix Notation, Method Chaining, and Unix Pipe

golang site super slow

one problem with golang is that the website https://golang.org/ is slow. When you lookup package docs, it takes 5 seconds to load.

which programing language is best for unicode text processing?

for unicode text processing, the superiority order of lang is golang ≻ ruby ≻ python 3 ≻ python2 ≻ perl ≻ JavaScript

golang's string is ingenious, and better than python2 python3 ruby perl JavaScript. go string is actually byte sequence, and “😂 that's gonna be problem for unicode”. but actually, the lang is such that it's much easier to process unicode characters than other langs.

here's tutorials:

and here's JavaScript string. JS: String Overview it's the worst. it's sequence of 16bits in utf16 clothing, and ALL its builtin string functions will fail if your string contains emoji. Note, ALL.

Golang: Walk Directory, List Files

The Visual Display of Quantitative Information

there's a famous book The Visual Display of Quantitative Information, 2001 by Edward Tufte Buy at amazon which made visualization “science” pop. there is lots tutorials or courses about it. becoming a fad. yet, linux idiot dunno the basics. not in writing, not in pics.

context https://benchmarksgame-team.pages.debian.net/benchmarksgame/which-programs-are-fast.html

nobody interested in “box plot”. just do a simple bar chart. The label is hard to read. also, make the image bigger. you can see lots better plots, e.g. lang popularity by pypy, github, etc. You want simple, easy to read chart. you are not doing quantum math with ya “box plot”.

Golang: String

graphics card 2018-08-21 55ae2
latest and greatest. graphics card, something like that gtx 1080ti gtx 1080 ti

actually that's not the greatest. there are $4k ones.

exceptions is the worst invention in programing language.

watch this video, starting at 38:40, about exceptions is the worst invention in programing language. https://www.youtube.com/embed/TH9VCN6UkyQ?rel=0

added to Why I Hate Exceptions

lua seems idiotic. 3 times slower than the dog python. Well, Mathematica is slow too, but 1 line of Mathematica is 10 thousand lines of python. or 1 thousand lines of haskell. That's the point. That's the context of speed.

Google Advanced Searched removed search by year range

Google has gone completely evil.

golang doesn't have copy file function

1st golang sweetness. reading 2 thousand files, split into array, and print first line, in 0.5 second. 1st bitterness. seems i have to write my own copy function? or call unix cp? i was thinking with go, i no longer have to call shell.

apparently, copy file function is discussed and turned down. https://go-review.googlesource.com/c/go/+/1591

movie Upgrade, AI went wrong. How real is it?

【喵嗷污】人类发明了人工智能,智商是人类几万倍,那它们究竟在想什么?几分钟看暗黑科幻片《升级》

apparently, in recent years, there's a new profession. That is, some guy summarize movie in ~7 minutes. This chinese girl's doing that. She's done perhaps hundreds, new and old. I haven't seen this in usa yet.

(twitter @kingcrimson08 told me, 鼻祖应该是谷阿莫 后来好多人纷纷效仿 都有各自一定规模的粉丝群)

but also note, the content of this movie. (basically, AI went wrong) driverless car went wrong, you have no control. how real is it? looking at today's events, corps, Google Facebook FBI big govs, it's very real. it can be accident, can be cloak n dagger, can be hacker deed.

in this age as AI march on, doesn't matter what a genius hacker u r, what mastery, u r powerless in society. u a coder? u knew already, there is nothing u can do about any Google FB AI pol. However, there's 1 type person that r impervious. Powerful persons, rich, politician.

the voodoo you wanna believe. unix linux

The Elements Of Style: UNIX As Literature

programing language speed comparison sites gone

it seems, programing lang speed/benchmark comparison sites are gone these days. Used to be, e.g. 10 years ago, there are lots, by many. but today, seems only one https://benchmarksgame-team.pages.debian.net/benchmarksgame/ which i think is very low quality

now and then there are competent coders who did benchmark of 2 or more languages in depth, on blogs. but now, google hackernews facebook etc censorship and clickbait induction, you cannot find them.

pointer = the abomination in programing languages

the concept of pointer, or reference, is the number 1 source of abomination in programing languages. for a decade, i wasn't able to express this to hacker faks, they, C C++ compiler fops, call me a troll. but now i can express it firmly in a way they can understand.

pointer, like closure, callcc (aka continuation. e.g. tail recursion), has 0 mathematical value. That is, they have nothing whatsoever to do with computer science. They are, as i say, the side effects of computer engineering.

what's “side effects of computer engineering”? that is, hack. something convient, but ugly, undesirable, that you rather not have.

the problem of pointer, gave us complexities like all sorts of equality (e.g. == === and in JavaScript impossible to compare objects. In other langs, equality is all ad hoc) , shallow copy, deep copy, lisp cons, nested array/list issues. And its problem also sipped into object wrapper primitive types, and the way OOP Object, dot notation expression, etc, concepts are implemented.

one way to see how it's a computer engineering side effect is, ask yourself, what's the pointer of a pointer? if none or can't, why not? you see, immediately, you are tied to a hardware. If it is math, then, you could have nth order reference.

See also:

Golang: Pointer

garbage collection, the jargon

in the programer geekdom, there is obsession with garbage collection. They, gets nerdy with Rust. Rust this n that, Rust day n night. I truly despise these faks. Listen, if u not a idt, go'd be faster than 80% apps out there written in C C++.

the vary problem with this obsession, began with the jargon “garbage collection”. collect ya as. if the term is changed to automatic memory management, there'd be much less fanfare. Jargons, does tremendous damage to computing industry. see

Jargons of Software Industry

this jargon problem is similar to tail recursion (scheme lisp), call cc, lisp1 vs lisp2 (common lisp), lisp macro, closure, list comprehension python, currying, monad (haskell). Whizzing to and fro in different eras.

Golang Tutorial

worked a lot on my Golang by example for beginners. Especially for those coming from high level Python Ruby PHP JavaScript languages. Spend 1 hour, and you pretty much can start coding.

someone asked about argument for my height of unix.

here they are

golang walk dir 2018-08-17 ad8ea
golang walk dir 2018-08-17

now i fully understand golang traverse directory. tutorial coming up

what language should retire, based on pure technicality

(1) as you may know, most lang popularity are due to inertia. but, if we ignore that, then, what langs are left? i want to get a picture. golang in my view crosses out python ruby php perl. java is also out, by one or all of scala clojure kotlin.

(2) i dunno rustlang, but pretty sure it or golang wipes C C++. • Racket wipes scheme common lisp elisp. • swift prob wipe ObjectiveC D. • bash is out, by powershell. • julia wipes R matlab

(3) here's some am unsure: • shen ocaml fsharp haskell elixir • erlang clean mercury • Csharp nim • tcl lua • elm haxe • vala genie factor and more. can you help? but i should say some criteria in next post first.

(4) a lang must be at least 5 years old AND used by several or sizable companies to be considered, for “wiping” other. e.g. swift. but maybe not Dart, Pyret. lang to be wiped also should be somewhat popular, used by some corps. Not niche that few knows. e.g. purescript.

See also: Proliferation of Programing Languages

Brendan Eich on JavaScript history.

modeled on perl, that did it.

https://twitter.com/BrendanEich/status/1030513587926720512

some old unix rant year 2002.

  1. What is the Max Number of Directories a Directory Can Have?
  2. Unixer Plain-Text Email Fetish
  3. Laziness, Perl, and Larry Wall

to my patreons, thank you and notes https://www.patreon.com/posts/20816906

perl 6 book

after 15 years. i dunno if this happy or sad. One brian d foy, the last perl monger. https://twitter.com/LearningPerl6/status/1029864498285301760

etymology links 2018-08-16 20d74
etymology links 2018-08-16

reworking on my HTML/CSS links to english etymology. that's emacs screen. the script is python. will be golang by next week.

what's a struct?

if you code in scripting lang (js php python ruby perl), you probably never heard of struct or record. but its in go, racket lisp, clojure lisp, and of course, C C++. here's a quick introduction. xahcode

Why Does Struct Datatype Encroach Namespace?

golang doc is the best

Which Programing Language Has Best Documentation?

here's what not to do for tech writing:

doc by dummies, Technical writing at its worst

Python Web Crawler in 40 lines Python: Web Crawler

Google interview problem. Programing Problem: Construct a Tree Given Its Edges

lang creators, who do you like?

Of the lang creators, i think Rob Pike of golang knows what he's talking about, and Rich Hickey clojure. And Guy Steele, Gerald Sussman, Matthias Felleisen, Scheme Racket lisp. Anders Hejlsberg of C and TypeScript. Those dunno what they talking about: Larry Wall of perl, Guido of python.

clojure concurrency, by Rich Hickey

here's Rich Hickey, giving a talk about concurrency in clojure. I always liked him. He gives it as is. Not shy, not cocky, not crackpot. He just give his point of view and fairly confident about it.

clojure concurrency, by Rich Hickey

golang rune means unicode codepoint

somewhat annoyed that golang invented a new word for unicode codepoint: rune.

this is a good article https://blog.golang.org/strings

See also: Unicode Basics: Character Set, Encoding, UTF-8

note that golang uses CamelCase, departure from C. No more pesky _

Computer Languages Characters Frequency

can someone go plot your go code. post screenshot. thanks.

concurrency, clojure vs golang

when it comes to concurrency, with clojure, there is lots philosophy and after a month you still dunno how to. with golang, you get it within 10 minutes. compare:

programing languages and their computational model

Programing Languages and Their Computational Models

new version of my ∑ Xah Code site is out ∑ Xah Code if you like my work, buy it. Thanks.

git tip of the day. to copy a BIG git directory without the .git , do git clone --depth 1 file:///Users/xah/web/dirname this is probably fastest way.

git clone no history 2018-08-10 aad8f
git clone no history 2018-08-10
id num of digits 2018-08-07 91ad1
id num of digits 2018-08-07

i have a obsession about this. everytime i have a random string as id, i fuzz about if i can save 1 digit. ID System, Number Base vs Number of Digits

according to the math, using just digits 0 to 9 for base is good enough. Adding more char to base e.g. a to z does not increase the pool much. Rather, you want to add string length, this way, the pool increases exponentially.

but but but, am thinking, maybe add a to f to make it hexadecimal is good. why not? because it increases the pool, and also has the property of easy convert to number, and no disadvantage of generating actual words such as fsck

then i dither, why not go all the way to use a to z. adding 26 extra char would reduce collision. the chances of generating annoying actual word such as yousuck is minimal. then i thought removing aeoui and 0o1l so it has property of being readable for verbal communication!

then i thought, let's go full out, 0 to 9, a to z, A to Z. This will further reduce collision, and less chance of creating actual english words. but then, i worry, for some file system or situation, case sensitivity is a problem. also, now it's hard for verbal communication.

then, you survey what google etc do.

then, there is uuid. e.g. 838f9f38-f241-11de-a663-002421597a5c but it's unwieldily. too long. Windows CLSID GUID UUID

What Are the Differences Between Clojure, Scheme/Racket and Common Lisp?

What Are the Differences Between Clojure, Scheme/Racket and Common Lisp? https://ift.tt/2AP7AsR (cmts https://ift.tt/2LXHXLV )

let me answer that. Clojure is not a traditional lisp. Rather, a newish functional programing language with focus on immutabe data structure, with lisp syntax.

However, the language ties heavily with java, to such a degree that you need to master java to be a master of clojure. Also, it runs on the Java Virtual Machine monster.

Scheme/Racket is old school lisp, known for its miniminalism, and said to be most elegant. Mostly used in academia, and particularly good for programing language research. That is, it provides mechanisms to let you experiment with different evaluation strategy (e.g. eager, lazy) and other language features.

Common Lisp = old monster. It is comittee result of merging the lisp language wars of 1980s. Said among some lispers as the most practical. Most used in industry, before clojure.

Note, both Racket/Scheme and Common Lisp are deadish, and clojure is struggling in industry among the many choices, e.g. kotlin, scala, haskell, ocaml.

related articles:

Unicode Search 🔎

updated to unicode 11. Still some lose ends to work on, but want to announce now.

ghost characters: 妛挧暃椦槞蟐袮閠駲墸壥彁

there are character created from Japan copy editing mistakes, but have since been in unicode.

[A Spectre is Haunting Unicode By Paul Mccann. At https://www.dampfkraft.com/ghost-characters.html ]

Unicode: Geometric Shapes 🔴🟥🔺. added some 20 new ones.

amazon is now doing amazon coins amazon coins looks like it's for use in video games only.