Wednesday, April 19, 2023

"Teen Takeover"

Dozens of teens terrorized downtown, beat and robbed a terrified woman. https://news.yahoo.com/disturbing-video-shows-terrified-woman-161836419.html

This is the street where I used to walk by everyday to work, and to school. Not too long ago there was endless looting and every store was boarded up and I don't know know if those looters were ever get caught (probably not).

The mayor-elect's response was "It was unacceptable", and "but don't demonize youth" https://abc7chicago.com/chicago-violence-brandon-johnson-teens-new-mayor/13143044.

People debate whether this is adequate response or not. What do you think? Well I think it was adequate, at least he didn't say it was acceptable. What did the police say? "... won't be tolerated" and "We strongly encourage parents to accompany their teens or have them remain under the supervision of a responsible adult. " Like their parents (if not null) still able to control these teenagers.

Waita minute just what is this "Yay we got active" thing on the video? These teenagers take joy of torturing the terrified victim!

Not too long ago some clueless traveler thing crowned Chicago as the "Best Big City in the United States" https://www.nbcchicago.com/news/local/chicago-voted-best-big-city-in-the-us-by-conde-nast-traveler-for-6th-year-in-a-row-heres-why/2957641/. I am not sure if crime was ever in its clueless magazine's cluessless consideration.

Look, it was unacceptable, and shameful and some strong response is needed as well as addressing the root cause.

Just why it happened in the first place? Do these teenagers have any demands? Were they protesting against something or demanding something I have no clue. Is it because they rob and terrorize, "because they can" because cops are so useless? Since even looting was fine what else is not fine? There are already dozens of gun violence just about everyday. Police basically can't put crimes in check.

Besides criticizing, what can you do about it?

Move out of Chicago is definitely a good move but that isn't the solution because that's avoiding the problem.

Why can't these kids just study hard, find work, live a good life and not terrorize others? Read the rest of Johnson's response: "...not constructive to demonize youth who have otherwise been starved of opportunities in their own communities". Yes, youth is not to be demonized, but waita minute, these youths were demonic!

Problem 1: is lack of opportunites a reason to terrorize downtown? Problem 2: why is there lack of opportunities in their communities?

Solution 1: I already do see flashing police cars on most intersections of the magnificent mile Michigan Avenenue. There needs to be the same in the less magnificent mile State Street. Every intersection needs one. The police need to keep its words: catch them put them on jail, although I have some doubt their ability to do so.

Now the bigger problem (#2) is why isn't there opportunities in their communities? I believe if there are any business in their communities they get robbed everyday and that's why nobody open business in there, and vicious cycle of poor beget violence, and violence beget more poor, etc.

This means: someone must invest in their communities (not my money please). Those who are super well to do (like top Hollywood, sports stars etc) that they admire, descend down to talk to these people, tell them what is proper and what is not. Create jobs. Promote Peace.

Now talk is easy to "create jobs". Decent paying jobs now have ridiculously high requirements and people prefer to loot instead of doing difficult jobs that pays little. Bump up the minimum wage to even higher does not solve that either.

Walmart had to close money-losing stores https://www.cnn.com/2023/04/12/business/walmart-chicago-stores-closing/index.html. Yes theft was one reason why they lose money.

So the long term solution is first the police must be fearful enough, must be capable enough. Stronger effective punishment needed. Then the city offer incentive to create business (for example low tax) and promise safety for business (security cameras, cops patroling etc) Jobs: there must be attainable jobs out there for those willing to work. Talk is easy, but who is willing to hire these teens and change their lives?

The ultimate solution is actually education. Brandon Johnson was a teacher he should have a better idea than me that education is actually the best solution here. But do the schools even talk about this after this incident? They go back to their endless (and useless) curriculum: alliteration, onomatopoeia, simile and metaphor, endless boring math drills and native Americans history (they don't even teach modern US history nor any world history and forever obsessed with explorers era). Schools should talk about this! and focus less on other (controversial) social issues.

Clueless travel magazine: do you still think Chicago is the best big city?

Wednesday, April 5, 2023

Chicago's new mayor

Brandon Johnson has won the mayor race in a tight race: 51% over 49%, in the second round against Paul Vallas. First round had 10 candidates and Vallas had 32% over Johnson's 21%. Voter turnout was just 33%. There are people dying to get right to vote and there are people who don't bother to vote.

Chicago is a mess. Can this new mayor fix all the problems? We will wait and see.

Tuesday, April 4, 2023

Javascript gotchas

Javascript truly is the most universal language as it runs in your browser and your phone('s browser) and also serverside. People nowadays can't stand types and don't like compiling and just obsessed with javascript frameworks. Decades ago it was mostly used for a little onclick event handler of your button or some annoying alert() or do some simple form validation.

I was astonished to find out that the computer science classic MIT textbook Structure and Interpretation of Computer Programs now has a Javascript version in placce of its original Scheme version which I have used in college!

New versions of Javascript come out every year See https://www.w3schools.com/js/js_versions.asp. It is hard to keep up and its caveats can be confusing.

Copy objects

Consider this little code, suppose you have a car object, then make a copy of it. change something in the copy, do you expect the original change?

let car = {
    model: 'Corolla',
    make: 'Toyota'
};
let car2 = car;
car2.model = 'Camry';
console.log(car);
console.log(car2);
console.log(car==car2);  
The output is
{ model: 'Camry', make: 'Toyota' }
{ model: 'Camry', make: 'Toyota' }
true
You changed the original car by modifying the copy and they are same object! This works like a pointer in C++. Now how do you actually make a distinct copy of an object? There are few ways to do this and there is shallow copy and deep copy. See this excellent tutorial: https://www.javascripttutorial.net/object/3-ways-to-copy-objects-in-javascript/

Let, var, const

In the beginning there was "var" and the "function", probably derived from Pascal as it faded into oblivion. Now there is this "let" and "const". "const" is a bit more straight forward, which is constant like other languages, to make you feel more secure that your variables aren't changing.

const a=1
a =2; // boom error trying to modify constant
But wait, redifining variable is not allowed but you can still change things within the variable
const mycar = {
    model: 'Corolla',
    make: 'Toyota'
};
mycar.model = 'RAV4'  // valid to change things inside the const myvar
console.log(mycar) 
mycar = {     // error: assignment to constant variable
    model:'Focus', 
    make:'Ford'
}
What's difference between "let" and "var"? "let" is local scope and "var" is global scope. "var" can be redeclared but "let" does not.
var a = 1
let b = 2
var a = "John" // ok
let b = "Mary" // not ok
Number type coersion
// adding is concat, if you have a string adding number both are like strings
console.log("10"+5); //105
console.log(10+"5");  //105
// but this only apply to add, other math operations treat it as number
console.log(10 - '5'); //5
console.log(10 * '5'); //50
console.log(10 / '5'); //2
console.log(10 % '5'); //0

//convert string to number
var a = '10';
var b = 5
var c = a-'0' + 5 // to convert string to number so you can do a add, one way is minus '0'
console.log(c) // 15
var d = Number(a)+b // or be explicit about it, or do parseInt
console.log(d) // 15

//boolean is coverted to 1 for true, 0 for false
console.log(true + 2);  // 3
console.log(false + 2); // 2
// string and number are considered double equal, but not triple equal
console.log(10 == '10') // true
console.log(10 === '10') // false