Spring Boot+React.js

Bootiful Development with Spring Boot and React
https://developer.okta.com/blog/2017/12/06/bootiful-development-with-spring-boot-and-react

Spring Boot API with React UI
https://github.com/oktadeveloper/spring-boot-react-example


Build a CRUD Application with React, Spring Boot, and User Authentication
https://stormpath.com/blog/crud-application-react-spring-boot-user-authentication

React App with Spring Boot
https://github.com/stormpath/stormpath-spring-boot-react-example


Building Spring Boot, MongoDB and React.js CRUD Web Application
https://www.djamware.com/post/5ab6397c80aca714d19d5b9c/building-spring-boot-mongodb-and-reactjs-crud-web-application

Building Spring Boot, MongoDB and React.js CRUD Web Application
https://github.com/didinj/spring-boot-mongodb-react-java-crud


How to Setup Spring-Boot with ReactJS and Webpack
https://medium.com/@benjaminliu_42474/how-to-setup-spring-boot-with-reactjs-and-webpack-9b190edeb0c8

Spring Boot with ReactJS using WebPack and Yarn.
https://github.com/liuben10/spring-boot-react-js-example

LeetCode解题日志

Algorithms

2. Add Two Numbers

用链表模拟十进制加法运算,linked list有点犯晕,在Eclipse IDE上调试了半天才跑通了,只会瞎用框架和库的人算法方面果然是菜鸟。

一开始出来的结果顺序老是逆着。在网上找了个Function to reverse the linked list,incline到自己那代码里,最后总算在LeetCode上跑过了。

Java

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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
class Solution {
public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
ListNode node1 = l1, node2 = l2;
ListNode node = null, tmpNode = null;
int sum = 0;
boolean b = false;
while (node1 != null || node2!=null) {
node = new ListNode(0);
sum = (node1!=null?node1.val:0) + (node2!=null?node2.val:0);
if (b) sum++;
node.val = sum<10?sum:sum%10;
b = sum>=10 ? true : false;
if (tmpNode!=null)
node.next = tmpNode;
if (node1!=null)
node1 = node1.next;
if (node2!=null)
node2 = node2.next;
tmpNode = node;
}
if (b) {
ListNode node3 = node;
node = new ListNode(1);
node.next = node3;
}
ListNode prev = null;
ListNode current = node;
ListNode next = null;
while (current != null) {
next = current.next;
current.next = prev;
prev = current;
current = next;
}
node = prev;
return node;
}

/**
* Definition for singly-linked list.
*/
class ListNode {
int val;
ListNode next;
ListNode(int x) {
val = x;
}
}

Submission Detail

  • 1562 / 1562 test cases passed.

写完了过上一段时间,又忘了是怎么做对的,在IDE上debug出来的代码,可能做得比较勉强。

1. Two Sum

Java

Brute Force

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class Solution {
public int[] twoSum(int[] nums, int target) {
int[] idxArr = {0,0};
for(int i=0;i<nums.length;i++)
for(int j=nums.length-1;j>i;j--) {
if (nums[j]+nums[i]==target) {
idxArr[0] = i;
idxArr[1] = j;
return idxArr;
}
}

return idxArr;
}
}
Submission Detail
  • 20 / 20 test cases passed.
  • Your runtime beats 30.47 % of java submissions.

Hash Table

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class Solution {
public int[] twoSum(int[] nums, int target) {
int a = 0, b = 0;
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
for (int i = 0; i < nums.length; i++) {
int complement = target - nums[i];
if (map.containsKey(complement)) {
a = i;
b = map.get(complement);
} else {
map.put(nums[i], i);
}
}
return new int[]{a, b};
}
}

Submission Detail

  • 29 / 29 test cases passed.
  • Runtime: 2 ms, faster than 72.04% of Java online submissions for Two Sum.
  • Memory Usage: 39.2 MB, less than 98.23% of Java online submissions for Two Sum.

Database

175. Combine Two Tables

mysql

1
2
3
select p.FirstName FirstName,p.LastName LastName,a.City City, a.State State 
from Person p
left outer join Address a on p.PersonId=a.PersonId

Submission Detail

  • 7 / 7 test cases passed.
  • Your runtime beats 84.70 % of mysql submissions.

Transact-SQL

1
2
3
SELECT P.firstName AS 'firstName', P.lastName AS 'lastName', A.city AS 'city', A.state AS 'state' 
FROM Person AS P
LEFT OUTER JOIN Address AS A ON A.personId = P.personId

Submission Detail

  • 8 / 8 test cases passed.
  • Your runtime beats 44.40 % of mssql submissions.

176. Second Highest Salary

mysql

1

1
2
select IF(count(distinct Salary)>1,min(t.Salary),null) SecondHighestSalary from 
(select Salary from Employee order by Salary desc limit 2) t
Submission Detail
  • 7 / 7 test cases passed.
  • Your runtime beats 90.90 % of mysql submissions.

2

1
2
3
4
select
(
select distinct Salary from Employee order by Salary desc limit 1,1
) AS SecondHighestSalary
Submission Detail
  • 7 / 7 test cases passed.
  • Your runtime beats 88.73 % of mysql submissions.

Transact-SQL

1
2
3
4
5
6
7
8
9
10
11
12
13
SELECT 
CASE
WHEN COUNT(V.salary) > 1 THEN MIN(V.salary)
ELSE NULL
END AS 'SecondHighestSalary' FROM
(
SELECT TOP 2 SA.salary FROM
(
SELECT DISTINCT EM.salary
FROM Employee AS EM
) AS SA
ORDER BY SA.salary DESC
) AS V

Submission Detail

  • 8 / 8 test cases passed.
  • Runtime: 603 ms, faster than 85.83% of MS SQL Server online submissions for Second Highest Salary.
  • Memory Usage: 0B, less than 100.00% of MS SQL Server online submissions for Second Highest Salary.

177. Nth Highest Salary

1
2
3
4
5
6
CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
DECLARE fromRow INT;
SET fromRow = N-1;
RETURN (select (select distinct Salary from Employee order by Salary desc limit 1 offset fromRow));
END

Submission Detail

  • 14 / 14 test cases passed.
  • Your runtime beats 86.66 % of mysql submissions.

178. Rank Scores

1
2
3
4
5
6
7
8
9
select a.Score,b.`Rank` from Scores a,
(
select t.Score,(@row_number:=@row_number+1) as `Rank` from
(
select distinct Score from Scores order by Score desc
) t,(SELECT @row_number:=0) t2
) b
where a.Score=b.Score
order by a.Score desc

Submission Detail

  • 10 / 10 test cases passed.
  • Your runtime beats 98.24 % of mysql submissions.

181. Employees Earning More Than Their Managers

1
select t.Name as Employee from Employee t where t.Salary>(select e.Salary from Employee e where e.Id=t.ManagerId)

Submission Detail

  • 14 / 14 test cases passed.
  • Your runtime beats 39.24 % of mysql submissions.

182. Duplicate Emails

1
2
select t.Email as Email from 
(select Email,count(Email) from Person group by Email having count(Email)>1) t

Submission Detail

  • 15 / 15 test cases passed.
  • Your runtime beats 76.83 % of mysql submissions.

183. Customers Who Never Order

1

1
2
select c.Name as Customers from Customers c where c.Id not in 
(select distinct o.CustomerId from Orders o)

Submission Detail

  • 12 / 12 test cases passed.
  • Your runtime beats 84.65 % of mysql submissions.

2

1
2
3
select c.Name as Customers from Customers c
left outer join Orders o on c.Id=o.CustomerId
where o.Id is null

Submission Detail

  • 12 / 12 test cases passed.
  • Your runtime beats 83.24 % of mysql submissions

196. Delete Duplicate Emails

虽然难度标为Easy,居然也被卡住了,还以为要用临时表,google关键字 mysql delete duplicate rows keep one搜到Delete all Duplicate Rows except for One in MySQL? [duplicate],原来是自己未完全理解mysql的delete关于多表删除的语法。

DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]

Or:

DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
USING table_references
[WHERE where_condition]

看来这种技术问题,google+stack overflow 一点就破,自己坚持独立思考在那里死磕纯属浪费时间。

1

1
delete p from Person as p, Person as t where p.Id>t.Id and p.Email=t.Email;

Submission Detail

  • 22 / 22 test cases passed.
  • Your runtime beats 18.50 % of mysql submissions.

2

1
delete p from Person as p, Person as t where p.Email=t.Email and p.Id>t.Id;

Submission Detail

  • 22 / 22 test cases passed.
  • Your runtime beats 83.82 % of mysql submissions.

3

1
delete p from Person as p inner join Person as t where p.Email=t.Email and p.Id>t.Id;

Submission Detail

  • 22 / 22 test cases passed.
  • Your runtime beats 80.14 % of mysql submissions.

180. Consecutive Numbers

被卡了好几天,百思不得其解,又开始怀疑是不是select还不足以,难道要用到游标与临时表之类,再琢磨下去也是浪费时间,遇到什么问题,就去问google,尤其是这种自己不会别人会的技术问题,搜 mysql consecutive queries 定位到 MySQL query for 3 consecutive integers between records,冥思苦想就是想不对路,一看到人家的解就恍然大悟,自己怎么会想不到这一点,看来自己的sql还是需要外部启发,没有点拨,自己就迷失在思维定势里了。

不过这题有点让人犯糊涂,如果id不连续呢?那是不是还得用计算列row_num?反正题意是id连续

1
2
3
select distinct t.Num as ConsecutiveNums from Logs t
where exists (select 1 from Logs x where x.Id-1=t.Id and x.Num=t.Num) and
exists(select 1 from Logs x where x.Id+1=t.Id and x.Num=t.Num);

Submission Detail

  • 21 / 21 test cases passed.
  • Your runtime beats 50.90 % of mysql submissions.

185. Department Top Three Salaries

琢磨了好几天也没思路,问题的难度标为hard,难道用select无法实现?难道要用到cursor与临时表?最后google -> mysql top 3 per group在Stack Overflow找到Get top n records for each group of grouped results,思路顿开,原来还是要用到查询结果序号的计算列,T-SQL与PL/SQL都有Rank()函数,mysql可以用变量模拟实现,在178. Rank Scores中已经用到,只是本题需要用到两个列,需要用两个@变量。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
select d.Name as Department,e.Name as Employee,b.Salary as Salary from 
(
select a.DepartmentId,a.Salary from
(
select t.DepartmentId,t.Salary,(@num:=if(@deptId = t.DepartmentId, @num +1, if(@deptId := t.DepartmentId, 1, 1))) as row_number from
(
select distinct DepartmentId,Salary from Employee
) t
CROSS JOIN (select @num:=0, @deptId:=null) c
order by t.DepartmentId,t.Salary desc
) a
where a.row_number<=3
) b
left outer join Employee e using(DepartmentId,Salary)
inner join Department d on e.DepartmentId=d.Id
order by b.DepartmentId,b.Salary desc;

Submission Detail

  • 20 / 20 test cases passed.
  • Your runtime beats 98.70 % of mysql submissions.

184. Department Highest Salary

也蒙了几天,group by得到部门max salary是显然的,怎么得到员工姓名?发现用部门id与salary同时作为join的条件就ok了,用using连接从句显得更自然。

1

1
2
3
4
select d.Name as Department,e.Name as Employee,t.Salary from Department d 
left outer join (select DepartmentId,Max(Salary) as Salary from Employee group by DepartmentId) t on t.DepartmentId=d.Id
inner join Employee e on t.Salary=e.Salary and t.DepartmentId=e.DepartmentId
order by t.Salary desc;

Submission Detail

  • 15 / 15 test cases passed.
  • Your runtime beats 77.87 % of mysql submissions.

2

1
2
3
4
select d.Name as Department,e.Name as Employee,t.Salary from Department d 
left outer join (select DepartmentId,Max(Salary) as Salary from Employee group by DepartmentId) t on d.Id=t.DepartmentId
inner join Employee e on e.DepartmentId=t.DepartmentId and e.Salary=t.Salary
order by t.Salary desc;

Submission Detail

  • 15 / 15 test cases passed.
  • Your runtime beats 87.87 % of mysql submissions.

3

1
2
3
4
select d.Name as Department,e.Name as Employee,t.Salary from Department d 
left outer join (select DepartmentId,Max(Salary) as Salary from Employee group by DepartmentId) t on d.Id=t.DepartmentId
inner join Employee e using(DepartmentId,Salary)
order by t.Salary desc;

Submission Detail

  • 15 / 15 test cases passed.
  • Your runtime beats 91.84 % of mysql submissions.

197. Rising Temperature

这题果然Easy, 不过自己还是在mysql手册里查了下函数DATEDIFF(expr1,expr2),不用google就ok了,在LeetCode第一次就通过了,此题的问题结构好像跟 180. Consecutive Numbers 类似。

想到人家刷LeetCode都是光用脑子调代码直接在网页上Run,而自己离不开IDE与数据库运行环境,人家那叫刷题,自己只是在做题。

1
select w.Id from Weather w, Weather t where datediff(w.RecordDate,t.RecordDate)=1 and w.Temperature>t.Temperature;

Submission Detail

  • 14 / 14 test cases passed.
  • Your runtime beats 90.59 % of mysql submissions.

262. Trips and Users

这题又耗了两天,一开始没看懂题意,虽然不能迅速做不出,倒也没怎么被卡住,不过免不了又要在纸上比划一下,还有在mysql上一遍遍执行验证想法,也没啥可以google的,提交Leetcode第一遍就通过了,没想到。自己对left outer join与right outer join的理解似乎有误,这两者是有区别的,自己之前似乎以为这两者是对称的。

1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
select b.Request_at as Day,round(IFNull(a.cancel_num,0)/b.total_num,2) as `Cancellation Rate` from 
(
select t.Request_at,count(*) as cancel_num from Trips t
where t.Client_Id in (select Users_Id from Users where Role='client' and Banned='No') and
t.Driver_Id in (select Users_Id from Users where Role='driver' and Banned='No') and
t.Status in ('cancelled_by_driver','cancelled_by_client') and t.Request_at between DATE '2013-10-01' and DATE '2013-10-03'
group by t.Request_at
) a right outer join
(
select t.Request_at,count(*) as total_num from Trips t
where t.Client_Id in (select Users_Id from Users where Role='client' and Banned='No') and
t.Driver_Id in (select Users_Id from Users where Role='driver' and Banned='No') and t.Request_at between DATE '2013-10-01' and DATE '2013-10-03'
group by t.Request_at
) b on b.Request_at=a.Request_at;

Submission Detail

  • 9 / 9 test cases passed.
  • Your runtime beats 82.92 % of mysql submissions.

2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
select a.Request_at as Day,round(IFNull(b.cancel_num,0)/a.total_num,2) as `Cancellation Rate` from 
(
select t.Request_at,count(*) as total_num from Trips t
where t.Client_Id in (select Users_Id from Users where Role='client' and Banned='No') and
t.Driver_Id in (select Users_Id from Users where Role='driver' and Banned='No') and t.Request_at between DATE '2013-10-01' and DATE '2013-10-03'
group by t.Request_at
) a left outer join
(
select t.Request_at,count(*) as cancel_num from Trips t
where t.Client_Id in (select Users_Id from Users where Role='client' and Banned='No') and
t.Driver_Id in (select Users_Id from Users where Role='driver' and Banned='No') and
t.Status in ('cancelled_by_driver','cancelled_by_client') and t.Request_at between DATE '2013-10-01' and DATE '2013-10-03'
group by t.Request_at
) b on b.Request_at=a.Request_at;

Submission Detail

  • 9 / 9 test cases passed.
  • Your runtime beats 61.34 % of mysql submissions.

595. Big Countries

这题确实Easy,or条件或用据说性能更好的 union (Set operations)

1

1
select name,population,area from World where area>3000000 or population>25000000;

Submission Detail

  • 4 / 4 test cases passed.

2

1
2
3
select name,population,area from World where area>3000000 
union
select name,population,area from World where population>25000000;

Submission Detail

  • 4 / 4 test cases passed.

596. Classes More Than 5 Students

这题也Easy,group by + having子句

1
2
3
4
select t.`class` as `class` from 
(
select `class`,count(distinct student) as n from courses group by `class` having n>=5
) t;

Submission Detail

  • 9 / 9 test cases passed.

601. Human Traffic of Stadium

这题又被卡了好几天,google也没搜到什么直接的线索,PL/SQL与T-SQL有分析函数ROW_NUMBER(), RANK(), and DENSE_RANK(),还以为需要mysql模拟这种功能。

卡在这一步里

select s.* from stadium s where s.people>=100 
and exists(select 1 from stadium t2 where t2.people>=100 and t2.`date`=DATE_SUB(s.`date`,INTERVAL 1 DAY)) 
and exists(select 1 from stadium t3 where t3.people>=100 and t3.`date`=DATE_ADD(s.`date`,INTERVAL 1 DAY));

最后发现用 join + union就好了,显示执行效率不高,可能还有更好的写法

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
27
28
select x.* from 
(
select a.* from
(select s.* from stadium s where s.people>=100) a,
(
select s.* from stadium s where s.people>=100
and exists(select 1 from stadium t2 where t2.people>=100 and t2.id=s.id-1)
and exists(select 1 from stadium t3 where t3.people>=100 and t3.id=s.id+1)
) b
where a.id=b.id-1

union

select s.* from stadium s where s.people>=100
and exists(select 1 from stadium t2 where t2.people>=100 and t2.id=s.id-1)
and exists(select 1 from stadium t3 where t3.people>=100 and t3.id=s.id+1)

union

select c.* from
(
select s.* from stadium s where s.people>=100
and exists(select 1 from stadium t2 where t2.people>=100 and t2.id=s.id-1)
and exists(select 1 from stadium t3 where t3.people>=100 and t3.id=s.id+1)
) b,
(select s.* from stadium s where s.people>=100) c
where c.id=b.id+1
) x order by x.id;

Submission Detail

  • 14 / 14 test cases passed.
  • Your runtime beats 57.13 % of mysql submissions.

620. Not Boring Movies

这题确实Easy, 可以不假思索地写出SQL,但执行效率还是不够高,而且也查了下MOD函数与mod运算符。

1
select * from cinema where id%2=1 and description not like '%boring%' order by rating desc;

Submission Detail

  • 8 / 8 test cases passed.
  • Your runtime beats 72.39 % of mysql submissions.

Submission Detail

626. Exchange Seats

这题确实Medium,不难,但也不是很简单就能写出,inner join 与 outer join 进行union,执行效率还是不算高。

1
2
3
4
5
6
7
8
9
10
11
12
select * from 
(
select t1.id,t2.student from
(select * from seat where id%2=1) t1 join
(select * from seat where id%2=0) t2 on t1.id=t2.id-1

union

select IFNULL(t2.id,t1.id) as id,t1.student from
(select * from seat where id%2=1) t1 left outer join
(select * from seat where id%2=0) t2 on t1.id=t2.id-1
) t order by id;

Submission Detail

  • 12 / 12 test cases passed.
  • Your runtime beats 58.11 % of mysql submissions.

627. Swap Salary

算是Easy吧,不过还是看了下mysql的update语法,用IF()函数或者 case 都可以。

1

1
update salary set sex=IF(sex='m','f','m');

Submission Detail

  • 8 / 8 test cases passed.
  • Your runtime beats 53.28 % of mysql submissions.

2

1
update salary set sex=case sex when 'm' then 'f' when 'f' then 'm' end;

Submission Detail

  • 8 / 8 test cases passed.
  • Your runtime beats 49.22 % of mysql submissions.

Shell

195. Tenth Line

自己对linux shell果然是一无所知,连这个Easy的题也需要google 搜 linux sh read nth line,到 Bash tool to get nth line from a file,原来有个sed命令可以很简单地实现读第n行,此题存在一题多解,需要举一反三

1
2
3
#!/usr/bin/env bash

sed '10q;d' 'file.txt'

Submission Detail

  • 7 / 7 test cases passed.

193. Valid Phone Numbers

linux shell的题自己本来就不懂,只能从头学起,想也没用,不如google,linux shell regex phone number,直接出来个原题的答案,Regex Coding Exercise – Valid Phone Numbers,一个要点是正则表达式,一个要点是Linux的grep命令,学习了。这篇文章里说用 awksed 也行。题目要求用1行shell解决,也搜到个 Valid Phone Numbers with shell script 是用shell 的while及if语句来实现。

1
2
3
#!/usr/bin/env bash

grep -P "^((\([0-9]{3}\) )|([0-9]{3}\-))[0-9]{3}\-[0-9]{4}$" file.txt

Submission Detail

  • 26 / 26 test cases passed.

192. Word Frequency

这题标为medium,linux shell自己本来就不了解,又有点难度,独立思考不过是浪费时间,不如看看相关专题博客,google关键字linux shell word frequency,搜到 How to create a frequency list of every word in a file?,参考里面的左试右试总是不太对,又搜到个答案大全 Shell Coding Exercise – Word Frequency,人家高手一题多解给出N种异曲同工的方法,用了很多linux的内置功能命令比如cat, tr, awk, sed, sort,grep, uniq,自己也看不大懂,又参考评论里的解释改了下,原来是要sort两次,第二次逆序sort,终于运行通过,但效率不高。

1
sed -r 's/\s+/\n/g' words.txt | grep -v "^$" | sort | uniq -c | sort -r | awk '{print $2" "$1}'

Submission Detail

  • 14 / 14 test cases passed.

194. Transpose File

google关键字shell command transpose,搜到 An efficient way to transpose a file in Bash ,原来是要用awk写一小段程序,还没看懂,只有慢慢消息理解了。

Transposing rows and columns: 3 methods 则提到

  • Transposing rows and columns is indeed easy if you have the GNU datamash utility on your system.
  • The mighty text-processing program AWK can also do transposing.

对高手来说,方法多得很,殊途同归,条条道路通罗马。

自己的linux shell要学的东西比sql要多得多,sql好歹工作当中经常用,linux shell用得少就处处是问题,形式上先过上一遍,还得慢慢消化理解。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
awk '
{
for (i=1; i<=NF; i++) {
a[NR,i] = $i
}
}
NF>p { p = NF }
END {
for(j=1; j<=p; j++) {
str=a[1,j]
for(i=2; i<=NR; i++){
str=str" "a[i,j];
}
print str
}
}' file.txt

Submission Detail

  • 17 / 17 test cases passed.
  • Your runtime beats 11.53 % of bash submissions.

mysql知识点

limit

LIMIT row_count is equivalent to LIMIT 0, row_count

LIMIT {[offset,] row_count

limit row_count offset offset

For compatibility with PostgreSQL, MySQL also supports the LIMIT row_count OFFSET offset syntax.

With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1)

GROUP_CONCAT

This function returns a string result with the concatenated non-NULL values from a group. It returns NULL if there are no non-NULL values. The full syntax is as follows:

GROUP_CONCAT([DISTINCT] expr [,expr ...]
         [ORDER BY {unsigned_integer | col_name | expr}
             [ASC | DESC] [,col_name ...]]
         [SEPARATOR str_val])
1
2
3
4
SELECT student_name, 
GROUP_CONCAT(DISTINCT test_score ORDER BY test_score DESC SEPARATOR ' ')
FROM student
GROUP BY student_name;

MySQL Emulate row_number

LeetCode SQL Problem

178. Rank Scores

select a.Score,b.`Rank` from Scores a,
(
select t.Score,(@row_number:=@row_number+1) as `Rank` from 
(
select distinct Score from Scores order by Score desc
) t,(SELECT @row_number:=0) t2
) b
where a.Score=b.Score 
order by a.Score desc;

185. Department Top Three Salaries

select t.DepartmentId,t.Salary,(@num:=if(@deptId = t.DepartmentId, @num +1, if(@deptId := t.DepartmentId, 1, 1))) as row_number from 
(
select distinct DepartmentId,Salary from Employee
) t 
CROSS JOIN (select @num:=0, @deptId:=null) c  
order by t.DepartmentId,t.Salary desc;

JOIN

INNER JOIN vs. CROSS JOIN

In MySQL, JOIN, CROSS JOIN, and INNER JOIN are syntactic equivalents (they can replace each other). In standard SQL, they are not equivalent. INNER JOIN is used with an ON clause, CROSS JOIN is used otherwise.

In MySQL, For example:

SELECT * FROM t1 LEFT JOIN (t2, t3, t4)
             ON (t2.a=t1.a AND t3.b=t1.b AND t4.c=t1.c)

is equivalent to:

SELECT * FROM t1 LEFT JOIN (t2 CROSS JOIN t3 CROSS JOIN t4)
             ON (t2.a=t1.a AND t3.b=t1.b AND t4.c=t1.c)

LEFT JOIN vs. RIGHT JOIN

RIGHT JOIN works analogously to LEFT JOIN. To keep code portable across databases, it is recommended that you use LEFT JOIN instead of RIGHT JOIN.

User-Defined Variables

You can store a value in a user-defined variable in one statement and then refer to it later in another statement. This enables you to pass values from one statement to another. User-defined variables are session-specific. That is, a user variable defined by one client cannot be seen or used by other clients. All variables for a given client session are automatically freed when that client exits.

User variables are written as @var_name, where the variable name var_name consists of alphanumeric characters, “.”, “_”, and “$”. A user variable name can contain other characters if you quote it as a string or identifier (for example, @’my-var’, @”my-var”, or @`my-var`).

User variable names are not case sensitive.

One way to set a user-defined variable is by issuing a SET statement:

SET @var_name = expr [, @var_name = expr] …

For SET, either = or := can be used as the assignment operator.

You can also assign a value to a user variable in statements other than SET. In this case, the assignment operator must be := and not = because the latter is treated as the comparison operator = in non-SET statements:

SET @t1=1, @t2=2, @t3:=4;
SELECT @t1, @t2, @t3, @t4 := @t1+@t2+@t3;
@t1 @t2 @t3 @t4 := @t1+@t2+@t3
1 2 4 7
SELECT (@aa:=id) AS a, (@aa+3) AS b FROM tbl_name HAVING b=5;

The reference to b in the HAVING clause refers to an alias for an expression in the select list that uses @aa. This does not work as expected: @aa contains the value of id from the previous selected row, not from the current row.

Multi-Table Deletes

You can specify multiple tables in a DELETE statement to delete rows from one or more tables depending on the condition in the WHERE clause.

For the first multiple-table syntax, only matching rows from the tables listed before the FROM clause are deleted. For the second multiple-table syntax, only matching rows from the tables listed in the FROM clause (before the USING clause) are deleted. The effect is that you can delete rows from many tables at the same time and have additional tables that are used only for searching:

DELETE t1, t2 FROM t1 INNER JOIN t2 INNER JOIN t3
WHERE t1.id=t2.id AND t2.id=t3.id;

Or:

DELETE FROM t1, t2 USING t1 INNER JOIN t2 INNER JOIN t3
WHERE t1.id=t2.id AND t2.id=t3.id;

These statements use all three tables when searching for rows to delete, but delete matching rows only from tables t1 and t2.

If you declare an alias for a table, you must use the alias when referring to the table:
DELETE t1 FROM test AS t1, test2 WHERE ...

Table aliases in a multiple-table DELETE should be declared only in the table_references part of the statement. Elsewhere, alias references are permitted but not alias declarations.

Correct:

DELETE a1, a2 FROM t1 AS a1 INNER JOIN t2 AS a2
WHERE a1.id=a2.id;

DELETE FROM a1, a2 USING t1 AS a1 INNER JOIN t2 AS a2
WHERE a1.id=a2.id;

Incorrect:

DELETE t1 AS a1, t2 AS a2 FROM t1 INNER JOIN t2
WHERE a1.id=a2.id;

DELETE FROM t1 AS a1, t2 AS a2 USING t1 INNER JOIN t2
WHERE a1.id=a2.id; 

DISTINCT

The ALL and DISTINCT options specify whether duplicate rows should be returned. ALL (the default) specifies that all matching rows should be returned, including duplicates. DISTINCT specifies removal of duplicate rows from the result set. It is an error to specify both options. DISTINCTROW is a synonym for DISTINCT.

数据库概论(陈立军, 北大)

成功的七项习惯

第一项习惯:积极主动
第二项习惯:一开始就想到最后的目标
第三项习惯:重要的事首先做
第四项习惯:双赢
第五项习惯:先了解别人,再让别人理解自己
第六项习惯:合作协调
第七项习惯:磨刀不误砍柴功

名言

科学根源于交谈,在不同的人的合作之下,可能孕育出极为重要的科学成果。 —— 海森堡

由于搭便车行为的存在,理性、自利的个人一般不会为争取集体利益作贡献 —— 奥尔森,《集体行动的逻辑》

不同文化的社会中都存在一些利他主义者,一个群体或社会中如果有百分之三的利他主义者,整个社会的风气和行为规范就会出现可喜的变化

格言

  • 戴手套的猫逮不着老鼠
  • 倒塌的灯塔比暗礁更危险
  • 对青少年火一样的激情,岁月是最好的灭火器
  • 不掷色子,就永远别想得到六点
  • 统计数字就像超短裙,掩盖起来的部分才是关键
  • 老鼠夹上总会有免费蛋糕

其他

Jim Gray Summary Home Page
http://jimgray.azurewebsites.net/
His primary research interests are in databases and transaction processing systems – with particular focus on using computers to make scientists more productive.

Football Joke

Bud Wilkinson, former football coach at the University of Oklahoma, was in Dallas for a series of lectures on physical fitness. A TV reporter interviewed him about the President’s physical fitness program and asked: “Mr Wilkinson, what would you say is the contribution of modern football to physical fitness?” The reporter expected a lengthy speech.

As if he had been waiting 30 years for this question, he said, “Absolutely nothing.”

The young reporter stared and squirmed and finally stuttered, “Would you care to elaborate on that?”

Wilkinson said, “Certainly. I define football as 22 men on the field who desperately need rest and 50,000 people in the stands who desperately need exercise.

记者问前俄克拉荷马大学橄榄球队主教练巴德·威尔金森,美式橄榄球对体育锻炼有何贡献?

“绝对没有”,威尔金森先生立即回答。

“绝对没有?”吃惊的记者问,“你能说得详细一点吗?”

“当然”,威尔金森先生说,“橄榄球赛事说白了就是:二十二个需要休息的人在场上拼命地跑,而五万个需要运动的人却坐在那里看。

七牛许式伟的感言

  • 我为谁提供服务的认知,比我是哪个领域的程序员(工种认知)更重要
  • 有些程序员只关心技术,而不关心业务,我认为这会制约他们的发展,所以才给了这样的忠告。只关心技术的人很快就会遇到成长的天花板。
  • 大部分人学习的时候太功利,不太重视学习基本功,比如编译原理。事实上我认为编译原理是非常非常重要的一门基础知识。某种程度上说可能是名字不够好,我个人更喜欢把这个领域叫做文本处理。
  • 没有正确的编程语言,只有合适自己的语言。选择语言需要基于你对要解决的问题域的理解而做出抉择。当然,这事也和品味有关,不同语言实际上体现的是创始人的个性。不少程序员喜欢把语言看做阵营。我个人没有这种想法,语言说白了只是个工具。
  • 学习新语言的最好办法是实践。你用它写几个程序解决你实际生产环境你遇到的问题,这比任何方式都有效。我记得我第一个C语言程序是在DOS环境下模仿实现了一个doskey,这个东西挺复杂,涉及编辑器、TSR驻留这些领域知识,一个程序写下来有好几千行。这就是我自己的学习方法。

Wolfram MathWorld selected

Recreational Mathematics

Beast Number
http://mathworld.wolfram.com/BeastNumber.html

Hardy-Ramanujan Number
http://mathworld.wolfram.com/Hardy-RamanujanNumber.html

Tangram
https://mathworld.wolfram.com/Tangram.html

Magic Square
https://mathworld.wolfram.com/MagicSquare.html

Pythagorean Square Puzzle
https://mathworld.wolfram.com/PythagoreanSquarePuzzle.html

Tic-Tac-Toe
https://mathworld.wolfram.com/Tic-Tac-Toe.html

Chess
https://mathworld.wolfram.com/Chess.html

Go
https://mathworld.wolfram.com/Go.html

Poker
https://mathworld.wolfram.com/Poker.html

Dice
https://mathworld.wolfram.com/Dice.html

Bowling
https://mathworld.wolfram.com/Bowling.html

Icosian Game
https://mathworld.wolfram.com/IcosianGame.html

Maze
https://mathworld.wolfram.com/Maze.html

String Figure
https://mathworld.wolfram.com/StringFigure.html

Illusions

Ambihelical Hexnut
https://mathworld.wolfram.com/AmbihelicalHexnut.html

Angle Illusions
https://mathworld.wolfram.com/AngleIllusions.html

Benham’s Wheel
https://mathworld.wolfram.com/BenhamsWheel.html

Bullseye Illusion
https://mathworld.wolfram.com/BullseyeIllusion.html

Café Wall Illusion
https://mathworld.wolfram.com/CafeWallIllusion.html

Continuous Line Illusion
https://mathworld.wolfram.com/ContinuousLineIllusion.html

Delboeuf Illusion
https://mathworld.wolfram.com/DelboeufIllusion.html

Ehrenstein Illusion
https://mathworld.wolfram.com/EhrensteinIllusion.html

Fraser’s Spiral
https://mathworld.wolfram.com/FrasersSpiral.html

Freemish Crate
https://mathworld.wolfram.com/FreemishCrate.html

Goblet Illusion
https://mathworld.wolfram.com/GobletIllusion.html

Hering Illusion
https://mathworld.wolfram.com/HeringIllusion.html

Illusory Contour Figures
https://mathworld.wolfram.com/IllusoryContourFigures.html

Impossible Fork
https://mathworld.wolfram.com/ImpossibleFork.html

开源GIS

Server

开源GIS服务器主要有map server和geo server。

Map server

Map server有两个版本,完全免费的那个那个版本是由明尼苏达大学开发的,全部是用C语言完成,效率很高可以媲美ARCGIS SERVER,并且支持我所知道的所有GIS数据源,但是相对来说简陋一些,并且没有内置AJAX支持。而map server的企业版本来是auto desk公司的map guide,这个版本功能很强大,而且还有IDE支持,当然IDE也有两个版本(付费的和不付费的),此外auto desk还封装了很多AJAX组建,因此这个版本可以说是真的企业级支持了。

GEO SERVER

而 geo server则是另外的选择了,它是基于JAVA平台做的,安装时需要JDK1.4(高版本的也不行),其功能上和map server的完全免费版类似,但是性能上次之,只是如果对跨平台要求比较高的话,可以考虑使用它。

Client

桌面GIS

QGIS和GRASS是很好的桌面GIS,当然基于ECLIPSE平台的UDIG也是另外一个选择。QGIS 的最大特点在于界面很友好,熟悉ARCGIS的人都能很快的掌握QGIS的操作,另外QGIS对WMS的支持也不错。再者QGIS可以无缝集成 POSTGIS,最后QGIS几乎完全照搬了GRASS的分析功能,因此其分析功能也很强大。GRASS本是美国军方开发的GIS,开源后一直受到美国大学老师们的青睐,它可以提供很多ARCGIS能提供的分析功能(当然每一种功能可选的算法没后者多),但是GRASS的界面比较丑陋,很多功能需要手动运行命令,因此不太适合大多数人用。基于eclipse平台的UDIG是桌面GIS的又一个选择,由于它是基于eclipse平台的,运行起来比较慢一点,而且比较耗内存。与前两者相比,它的优势在于操作的简单性,而且支持很多种空间数据源,包括很多商业空间数据库,缺点主要是分析功能比较弱。不过现在 UDIG发展很迅速,也建议尝试一下。

OpenLayers for Javascript

OpenLayers 是由 MetaCarta公司开发的, 用于WebGIS客户端的JavaScript包,目前的最高版本是2.5 V,通过BSD License 发行。它实现访问地理空间数据的方法都符合行业标准,比如OpenGIS的WMS和WFS规范, OpenLayers采用纯面向对象的JavaScript方式开发,同时借用了Prototype框架和Rico库的一些组件。

空间数据库

开源的空间数据库主要是postgresql和mysql的空间插件,分别是postGIS和 mySpatial。由于PG对于面向对象支持的更好一些,所以postGIS在性能上和功能上都比myspatial要强一些。但是两者都有一个最重要的缺陷,就是不直接支持栅格数据。解决方案是将栅格数据存储为BLOB类型,并且对其建立四叉树索引,用以模拟商业数据库对栅格数据的存储。相对来说我更喜欢POSTGIS一些,原因有三:1,MYSQL本身不是在所有情况下免费,而PG在所有情况下都免费;2,POSTGIS性能和功能上都强于 myspatial;3,国外已经有很多基于POSTGIS的成功应用,可以降低风险。


码农话题

Algorithms + Data Structures = Programs

Five Pervasive Myths About Older Software Developers
http://www.lessonsoffailure.com/developers/pervasive-myths-older-software-developers/

Where Do The World’s Software Developers Live?
https://www.benfrederickson.com/github-developer-locations/

Why Do Some Programming Languages Live and Others Die?
https://www.wired.com/2012/06/berkeley-programming-languages/

Twenty Questions for Donald Knuth
http://www.informit.com/articles/article.aspx?p=2213858

John Carmack discusses the art and science of software engineering
https://blogs.uw.edu/ajko/2012/08/22/john-carmack-discusses-the-art-and-science-of-software-engineering/

It’s about social interactions between the programmers or even between yourself spread over time.

软件工程实际是一门社会科学

在计算机学科中,真正谈得上科学的只有算法,“优化”也只能算工程。然而,真正花在算法及其优化上的时间在编程中所占比例很小。90%程序员所做的只是将功能需求以顺序、分支这样的程序形式实现出来。在这方面,我越来越不觉得有什么客观的方法能带来更好的软件。

自然科学的根本在于测量和重现,在于估计和验证。软件工程中除算法和优化外,其他与此毫无关系。相反,它们只跟程序员之间,甚至同一程序员在不同时间,自己跟自己之间的社会化交互有关。程序员总在不断犯错,这已是老生常谈的事实。问题就在于,如果一种错误的做法能以正确的语法形式输入到程序中,那它就肯定会进入我们的程序。因为这个,我本人对静态代码分析极度热衷。因为我们总在不断犯错,我宁愿使用编程语言的一个更为严格的子集,并对程序员写的代码施以更加严格的限制。

最近一段时间,我开始坚持每天做一点代码复查。每天看看提交的代码,找点有启发性的问题给团队讲一讲。有些问题,例如最大限度地保持参数的常量性,相对客观,争议较少。但也有很多东西更像风格问题,虽然多年来我发现它们不断地带来麻烦,但仍有很多人说:“我没见过这样的问题,对我来说这不是问题,我也不会犯这种错误。”因此,能够找到一个实际例子来指出“这就是由它引发的问题”,真是件好事。

意识到软件工程并非科学之后,我希望找到更好的方法来对付人性的弱点。然而,考虑到铁打的团队流水的开发者,想用一致的方法培训团队谈何容易。应对程序员犯错的方法肯定有好坏之分,但很难量化。而且代码会存在很长时间,将有成百上千的程序员看到一段代码,使用它并以某种方式与之交互。

除了通过静态代码分析实施严格限制外,在软件API设计的层面上还有规模更大的问题,艺术的、技术的都有,我希望能在这方面找到更多可量化的方法。

我们正处在一个激进的后开源时代:开源的过去和未来

We’re in a brave, new post open source world

谈谈技术选型
http://www.infoq.com/cn/news/2017/02/Technology-selection

John Carmack discusses the art and science of software engineering

What I heard instead was a hacker’s hacker talk about his recent realization that ** software engineering is actually a social science **.

It’s about social interactions between the programmers or even between yourself spread over time.

John Carmack discusses the art and science of software engineering (2012) (uw.edu)

http://bellard.org
Fabrice Bellard 法国著名的计算机程序员 http://www.bellard.org
FFMPEG, the Open Source Multimedia System. I launched this project in year 2000 and led it for several years.
QEMU is a generic machine emulator and virtualizer.
2000年,他化名Gérard Lantau,创建了FFmpeg项目。

Fabrice Bellard,5年前的FFmpeg政变之夜依稀在眼前

FFmpeg官网上有一个很有意思的耻辱柱(Hall of shame),专门用来列举那些偷用了FFmpeg开源代码却违背FFmpeg遵守的开源协议,也就是说没有在软件发行中进行代码使用的声明,甚至还恬不知耻的表示自主研发。国内几乎所有的播放器和转码工具都在这个耻辱柱上,比如QQ影音、暴风影音、格式工厂等。

https://ffmpeg.org/shame.html

Hall of Shame: companies violating the ffmpeg license (GPL/LGPL) (ffmpeg.org)

FFmpeg Hall of Shame

John Carmack discusses the art and science of software engineering

But those don’t actually occupy that much of the total time spent programming.

It’s about social interactions between the programmers or even between yourself spread over time.

these are all conventions that help software engineering in the large when you’re dealing with mistakes that people make. But they’re not fundamental about what the computer’s doing.

programmers are making mistakes all the time and constantly.

I would like to be able to enable even more restrictive subsets of languages and restrict programmers even more because we make mistakes constantly.

but a lot of people will just say, I’ve never seen that problem. That’s not a problem for me, or I don’t make those mistakes.

there are clearly better and worse ways of doing things but it’s frustratingly difficult to quantify.

It’s kind of fun to think that the game engines, things that we’re playing games on, have more sophisticated software than certainly the things that launch people to the moon and back

I tell people that there’s a good chance that whatever you’re writing here, if it’s not extremely game specific, may well exist a decade from now and it will have hundreds of programmers, looking at the code, using it, interacting with it in some way, and that’s quite a burden.

未来属于算法,而不是代码

编码作为新数字经济的关键技能,就像学习如何阅读一样,已经模糊了我们对算法的理解。算法正逐渐成为我们生活的组成部分,从电影推荐到新闻过滤和寻找合作伙伴。

github

The Impact GitHub is Having on Your Software Career, Right Now…

I spent 2004–2014 working at Red Hat, the world’s largest open source software engineering company. On my very first day there, in July 2004, my boss Marty Messer said to me: “All the work you do here will be in the open. In the future you won’t have a CV — people will just Google you.”

GitHub has become a singular social network that ties together issue tracking and distributed source control.

GitHub is a social network where your social capital, created by your commits and contribution to the global conversation in whatever technology you are working, is yours — not tied to the company you happen to be working at temporarily.

Smart people will take advantage of this — they’ll contribute patches, issues, and comments upstream to the languages and frameworks that they use on the daily in their job — TypeScript, .NET, Redux.

Now that same pathway is open for everyone, into just about any technology. As the world is eaten by open source, the same dynamic is now prevalent everywhere.

In a recent interview Linus Torvalds (49k followers, following 0 on GitHub), the inventor of Linux and git, put it like this:
“You shoot off a lot of small patches until the point where the maintainers trust you, and at that point you become more than just a guy who sends patches, you become part of the network of trust”

However, if that work has been on GitHub, it’s not gone. It’s visible. It’s connected to a network of trust that is visible.

It’s not your code on GitHub that counts — it’s what other people say on GitHub about your code that counts.

That’s your portable reputation.

四五十岁之后,还在编程的程序员都有谁
SOFTWARE DEVELOPERS AFTER 40, 50 AND 60 WHO ARE STILL CODING (PHOTO)
美国劳动力的中值年龄是42岁,而StackOverflow的一项有关年龄的调查表明,40岁之后的开发人员只占开发人员总数的13%。那么其他人到哪里去了?他们被解雇了或者上升到管理岗位了吗?软件开发对于过了40岁的人来说,是不是就意味着终结?

Rob Fletcher,Netflix(Los Gatos,CA)的高级软件工程师,45岁
我每天都写代码。目前最喜欢的语言是Kotlin。我想学习Go语言,平常用得比较多的是Java、Scala和Groovy。我一直在学习新的东西,哪怕是很小的事情。我知道自己会是一个糟糕的管理者,所以我压根没有想往管理方向发展。
很多事情取决于你的态度。不要成为厌恶新技术的老技术人,也不要嘲笑那些正在使用新技术的人。在进行技术选型时,你的经验应该成为决策的基础。如果选择了老技术,那是因为它们正好适合当前的需求,而不是因为要保护你那积攒了多年却即将过时的专业知识,也不是因为害怕那些后进者带着NodeJS和Go语言来抢夺你的工作。

Ebbe Kristensen,Prevas A/S(Denmark)的高级软件设计师,62岁
有时候,你几天甚至几周都不会学进去什么东西,而有时候几个小时学进去的东西就可以把之前“损失”的时间弥补回来。重要的是,你总是想方设法地去学习,时刻准备着,等待机会的出现。

John Brothers,Make&Build(Atlanta,GA)的高级软件架构师,47岁
我最近正在使用Node.JS开发一个项目,之前也用过Hadoop、NoSQL,开发过Android应用,也写过Go语言代码,还熟悉JQuery和Bootstrap的各种特性。
我也关注Java的最新动态,还有Spring、JMS、REST、JSON和JPA,以及其他相关的技术。
在过去的几年,我使用了IntelliJ、Eclipse、Sublime、Emacs和Vi这些开发工具,我很喜欢使用这些工具来解决各种问题。我一开始使用的是CVS,后来学习了Subversion,最近在学习git。我也有AWS相关的经验。我还是一个获得认证的Scrum Master、产品经理和开发者。

Roger Whitcomb,Actian公司(Palo Alto,CA)的软件架构师和软件工程师,60岁
我现在要跟上Web和移动开发的速度有点吃力,但离“垂暮”还很远,尽管我已经60岁了。
我认为最关键的是,你要为你的雇主持续地创造价值。
我目前是Apache软件基金会Pivot项目的PMC主席。作为一名Java开发人员(Java相关项目的提交者),我希望Java会永生。最起码不要出现更好的语言,要我把所有的代码都移植过去……

Scott Gartner,Silverback Learning Solutions(Boise,ID)的高级软件工程师,50多岁
我发现我的记忆力大不如前,也没办法记住大型系统的全部模型。不过,我发现我那些丰富的经验变得越来越有价值。
每两年我就会学习一种新的编程语言,有一些是我自己想学的,不过大部分是因为技术发展的需要(也有的是因为新工作的要求)。这样很有趣。目前我在学习数据仓库(OLAP)、ETL处理、Star Schemas和Cubes。

Brian Bowman,SAS(Cary,NC)的首席软件工程师,56岁
我通过四项主要的计算机技能生存下来。
汇编语言级别的大型机系统编程。
基于C语言的多主机平台的可移植编程,包括桌面、中型Unix网络、小型机的后续产品(如VAX),以及大型机。
多层集群服务器环境,由后端的多线程C以及处于中间层满足高可用要求的Java组成,主要面向Windows服务器和Unix环境,也包括Linux。
基于多线程C的大规模并行网格计算,满足虚拟的无限伸缩。
虽然我所拥有的这些技能可以干到退休,但在未来的几年,我还会将我的专业知识领域扩展到机器学习方面。

Alec Cawley,DisplayLink(Palo Alto,California)的首席软件研究员,60多岁
现在的世界与我的职业生涯刚开始的时候(穿孔纸带时期的Fortran)已经很不一样了,而变化仍然在持续。但反过来说,需要解决的问题总是很相似的,无非就是如何将人类的需求转成计算机可以做的事情,以及如何避免犯错、如何找出不可避免所犯下的错误。编程语言、开发环境、工具套件、API等东西只是解决问题的手段,我们只是在需要它们的时候才去学习如何使用它们。
我所在的嵌入式领域似乎比应用程序更加能够扛住潮流的冲刷。应用程序每几年就会有新的东西出现,有些几乎是昙花一现,有些会持续一段时间,经历巅峰,然后逝去。而嵌入式一直保持坚挺,以C语言为基础,再融合一点C++。另一方面,硬件也在持续发生变化,这让事情变得更加有趣。

Victor Volkman,Proquest(Ann Arbor,MI)的高级软件工程师,54岁

Kurt Guntheroth,软件工程师,50多岁
好的开发人员会持续学习,直到他们退休,比如Ken Thompsons和Bjarne Stroustrups。不过,我们大多数人(特别是40岁左右的)最终都会意识到,我们并不能成为行业的大神。
编程是一件很容易的事情。你告诉它们做什么,它们就做什么。它们是可以信赖的,也是可靠的。
代码可能会是难啃的骨头,它们要求对细节的重度关注和相当程度的脑力付出。
编程是关于创新,而不是操纵。

James Grenning,软件顾问,60多岁

Reflections of an “Old” Programmer

Half of what a programmer knows will be useless in 10 years.

Father of Java James Gosling slams cloud vendor lock-in

Medium网站的技术栈

Medium是一个在线发布平台,最初由Twitter联合创始人Evan Williams开发。该平台于2012年启动,现在每个月有6000万独立访客。该网站部署在AWS上,使用NodeJS和Go作为应用程序和服务的开发语言,使用DynamoDB作为数据存储,并使用Amazon Redshift作为数据仓库。

Don’t learn to code. Learn to think.

学会思考,而不只是编程

Interview with Ken Thompson
http://www.drdobbs.com/open-source/interview-with-ken-thompson/229502480

Go Language

It’s expanding every day and not being forced down anybody’s throat. It’s hard to adopt it to a project inside of Google because of the learning curve. It’s brand new and there aren’t good manuals for it, except what’s on the Web. And then, of course, its label of being experimental, so people are a little afraid. In spite of that, it’s growing very fast inside of Google.
Yes. When the three of us [Thompson, Rob Pike, and Robert Griesemer] got started, it was pure research. ** The three of us got together and decided that we hated C++. ** [laughter]
** It’s too complex. And going back, if we’d thought of it, we’d have done an object-oriented version of C back in the old days. **
Yes, but we were not evangelists of object orientation. [Returning to Go,] we started off with the idea that all three of us had to be talked into every feature in the language, so there was no extraneous garbage put into the language for any reason.

Java

Java 积累了最强大的生态系统,你可以说它无所不包, 毋庸置疑,Java 早已是一艘航空母舰的巨大身躯,这足以证明它的地位与成功。但是其语言、库、框架和生态系统的复杂度,对技术人员构筑其巨大的障碍。历史沉淀下来的,让 Java 提供的选项太多,深入后就知道 Java 的学习成本比 C++ 更高,对程序员的要求比 C++ 更高,除非掉队了,还在用 7 年甚至 10 年前的 Java 技术,技术人员要非常精心地组织框架和设计,否则各种复用的结果就是堆砌出一个异常臃肿的程序,其运行时对资源的消耗有时候会让你感到恐惧,而这是太多的基于 Java 所开发的平台被广泛诟病的关键所在,重用是个双刃剑,需要量体裁衣而不是一锅端,拿捏的尺度对开发人员要求无疑是最高昂的,除非语言和标准库提供了最好最直接的选项。

如今 Java 的学习成本和对开发人员的技能要求,已经远高于 C/C++ 的,也许大多数的开发人员无法驾驭 Java 这艘航空母舰。若要长期使用 Java,务必跟上 Java 的最新技术,同时在重用方面一定要拿捏好尺度,这会对人员技能提出更高要求,否则极其容易写出资源占用和运行时效率让人感到恐惧的应用。