DigestedSet

There's nothing actually digested.

0%

找了一波资料

当我真正下决心去学的时候,才发现前端的学习路径简单枯燥到可怕:看MDN就完事了。
所以从现在开始每日打卡吧~

阅读全文 »

背景

刚把blog重新弄起来,这次挂到了自己的server上而不是GitHub Pages,所以弄CI弄了比较久,尝试了Github Actions,有点难用,但是总算是搞定了。搞完以后看了下上一篇写完的markdown文件,已经是一年前。

一点想法

实际上还有三篇没有写完的,当时刚开始学前端的时候试图写的,webpack配置入门、前端技术认知、萌新的js工程和开发环境构建。
现在看来,这三个部分还是非常有必要梳理的技术之一。

也许长歪了的技能树

初学的时候试图去学的这些玩意,现在已经是工作中较为熟悉的部分,把这些复习一波并且补齐自然不难。问题在于,我终究是开始反思自己究竟有没有足够的成长。
上面这些明明在工作中非常紧密地在使用,但是我却对他们一无所知。
另一方面,对于正常的前端环境,我又毫无认识。
这里存在着一大片需要恶补的知识。

简单规划

首先是转技术栈,接下来react是必须要学的。
其次是补充前端基础,但这块其实短时间内需求不大。
还有则是是补全blog,巩固工具链。

2023-03-25补充

规划失败,blog长期搁浅,前端也准备完全放弃了

webpack是构建js工程的基础,然而webpack的配置相当复杂,并不是仅掌握原理就能够很好地应用的,其中最复杂的就在于各种loader和plugin。

首先从vue工程开始

在学习了一堆demo以后,有两个核心问题一直没解决,而且查了资料以后发现学习难度并不低。
两个难点,
第一个就是js工程如何构建,另一个则是npm在整个工程中扮演了什么样的角色,为什么npm install xxx以后后续就能require和import。

一年前买的CLR via C#还没看完,趁现在还有心,赶紧看起来,这块影响还是非常大的。

第一章 CLR的执行模型

第二遍看这一章了,收获一般,书中很多东西只是抽象的介绍,一提到具体内容就“见某章”,翻过去又觉得一下要看的太多,总的来看,CLR提供了一系列执行机制,刨除历史因素,托管模块在CLR下运行主要利用了几个机制:

IL和元数据(metadata)

一般来说CLR运行的程序以Assembly的形式存在,而Assembly中最重要的组成部分就是IL和MetaData。

JITCompiler机制

IL代码在第一次运行时才会被即时地编译为机器语言,编译器被称为JIT编译器,技术也就是JIT技术,正是由于这种机制深刻地了解了IL代码的执行环境,最终编译出来的代码反而能够取得更高的效率(存疑,未验证)。

.NET Framwork类库

目前还不是很理解为什么会把类库放在这一块,我的理解是,类库这种第三方代码集成方式,并不是一个理所当然的存在,不同语言提供了不同的程序包引用方式,而CLR提供的这种方式虽然没有细讲,但是可以认为,只需要把DLL交给CLR,由于该DLL即其他周边的文件通常被视为是一个完整的Assembly,且可以自描述,所以完全不需要担心CLR内部如何组织,在.NET平台上,程序员只需要关心命名空间、类型兼容这些问题就行了。

通用类型系统CTS

公共语言规范是互操作技术,或者说COM的一个延申,COM的实践在事实上失败以后,微软试图再一次在CLR上提供语言的整合,但是这种整合看起来非常优秀,实际上实现起来也许更加糟糕了,或者说,没有公司会下力气去基于CLR重新编译其他语言的代码?以至于文档缺失,缺乏广泛的使用者。
这个技术在刘佳亮的CurlWrapper工程中应用了,正是这个工程,激发了我对互操作这一块的兴趣,他还写了篇文章吐槽(C++/CLI——想说爱你不容易)[https://zhuanlan.zhihu.com/p/33450706],然而两年过去了,情况似乎并没啥改善……

互操作性

也许互操作性有一部分是基于上面的通用类型系统CTS的,后面的互操作性介绍写了三种典型的互操作方式:托管代码调用DLL中的非托管函数(DLL由非托管语言实现),托管代码使用现有的COM组件(COM组件的实现应该是没啥限制的),非托管代码可以使用托管类型(服务器)。
这部分存在很大问题,需要仔细研究一下。

在.NET平台上,C#可以用的互操作技术主要就是P/Invoke和COM,本文基于MSDN进行了一些理解和说明。

Platform Invoke

Platform invoke是一种可以让托管代码调用DLL中的非托管函数的服务,比如Windows API,

Google面试居然走到了2nd onsite,不可思议…已经是梦一样的体验了啊,回顾一下自己面的几道题给好友一起参考下……由于实习报告还没写完,简单题先不写解法了。

视频面

中文面,面试官很nice,这轮面试因为我自己的问题,电脑面到一半没电了,思路说完了代码还没来得及动,面试官说可以第二天早上继续面,这时候我以为我的Google面试之旅就此结束了,没想到面试官还是给了我一次机会,感动。题目很简单,我给了O(nm)的解法,我觉得这已经是最优了。

一个nxm的grid,若干房间有黄金,部分房间没有,且这些房间的黄金数量不等,房间之间四联通,每次能走一格,但是只能一次拿走全部黄金并且不允许走到没有黄金的房间里,且有黄金的房间没有环!求一条路径,拿走最多的黄金。

1st onsite#1

这一面是英文技术面,也是一道图。可以看得出来面试官对我的英语已经绝望了,尤其是说到各种terminology我觉得面试官能猜到我说了啥已经很不容易,毕竟我把无向图都说成了,不过我最后还是写了代码。解法O(石子数+n+m),我觉得还有优化空间但是面试官似乎没有让我优化的意图。

Given an nxm grid, some positions are occupied by a stone.

Define operation as eliminate stone with another stone exist on the same row or same column.

you could only do operation on the grid step by step, and calculate the most amount of elimination operation you could do.

1st onsite#2

中文面,这一面几乎炸了,上来先让我写一个数据结构,要求给一个数组,实现Set, Get, SetAll三种方法,并且三者全都要O(1),方法是弄个标记。非常无脑地写了,然后面试官问我如果这个数据结构需要用很久会不会出错,我说如果tag到了INT_MAX就对数组的每个元素都赋一次真实值并且把tag继续置0.

第二道题我觉得就有点复杂,但是应该还是属于middle的难度,毕竟算法上不存在难点。

给定二维平面上若干个虫洞,一个虫洞包含两个点,可以从虫洞的一端进去然后另一端出来,给你一个点,然后运动方向一定是x轴正方向,求这个点是否会进入一个循环当中。
其实就是找循环,但是我没理解题意,给想复杂了,直到时间用完了也没写出来,感觉得到了面试官一些不太好的评价,我觉得很可惜。

2nd onsite

(一年以后update)嗯,挂了以后就没心思写这些了,果然自己心态还是不行。今后努力!

I’m trying to practice my english skills, if you are willing to help me with terminology and grammar, please contact me by email or wechat or qq, great rewards await.

As I have learned lots of knowledges in work, writting cleanner C# codes are still challengeable for me.
The book “effective C#”(referd as “The book” in context) is expected to be the saver for me.

item1 Prefer Implicitly Typed Local Variables

According to the book, implicit type “var” is introduced to support anonymous types in C#.
In most cases, for example var foo = new MyType(); almost every one could recognize foo’s type at glance, but some cases behave in opposite manner.
if you write something like

1
2
3
var f = GetMagicNumber();
var total = 100 * f / 6;
Console.WriteLine($"Declared Type: {total.GetType().Name}, Value: {total}");

the output could be ambiguous.
So such situation should be avoid on whatever.

msdn gives some examples and we can do more in practice

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Example #1: var is optional because
// the select clause specifies a string
string[] words = { "apple", "strawberry", "grape", "peach", "banana" };
var wordQuery = from word in words
where word[0] == 'g'
select word;

// Because each element in the sequence is a string,
// not an anonymous type, var is optional here also.
foreach (string s in wordQuery)
{
Console.WriteLine(s);
}

// Example #2: var is required when
// the select clause specifies an anonymous type
var custQuery = from cust in customers
where cust.City == "Phoenix"
select new { cust.Name, cust.Phone };

// var must be used because each item
// in the sequence is an anonymous type
foreach (var item in custQuery)
{
Console.WriteLine("Name={0}, Phone={1}", item.Name, item.Phone);
}

For the 1st example, it could be more efficient to let the compiler select a IQueryable<string> interface, and for the 2nd example, the anonymous type could be assigned as variables without type cast.

Type relationship in linq query operations

The following illustration shows a LINQ to Objects query operation that performs no transformations on the data. The source contains a sequence of strings and the query output is also a sequence of strings.

Relation of data types in a LINQ query

The type argument of the data source determines the type of the range variable.

The type of the object that is selected determines the type of the query variable. Here name is a string. Therefore, the query variable is an IEnumerable.

The query variable is iterated over in the foreach statement. Because the query variable is a sequence of strings, the iteration variable is also a string.

Prefer readonly to const

C# has two types of const variable, one in compile-time, other one is runtime. They behave quite different.

for example,

1
2
3
4
//compile-time constant
public const int Millennium = 2000;
//Runtime constant
public static readonly int ThisYear = 2004;

the compile-time is just a declaration and the number 2000 will replace all Millennium token appeared.

thus, const declaration shouldn’t be used to userdefined type or the type you prefer it to be a reference.

and const is used to define those variables must be resolved.