Cpy provides you a C-like way to write Python programs. And now, Cpy is open source(the ANTLR grammar files).
-
2012-11-17
Cpy is now open source
Views: 16320 | No Comments -
2012-07-24
Why Cpy Beats Python
Views: 17154 | 2 CommentsA few ignorant Python programmers said that Python never neads a C-like for statement, they thought they can replace every C-like for looping to Python’s for.
Cpy‘s way to loop:
for(i=s; i<num; i+=step){ }
Python’s way to loop:
for i in range(num)[s:e:step]:
Recently I wrote a looping to loop 100000000, unfortunately (and as expected) Python eat up all memory(2 GB) of the whole machine and OS forces it to quit.
But a Cpy looping works fine.
-
2012-07-15
Odds in Python Grammar, and Replacement
Views: 12393 | No CommentsWhitespace indentation to delimit block is bad
Python’s syntax is said to be clear and elegant. It is good for small peace of codes, but not good for more than 100 lines of codes. I usually mis-understand the number of indents when first glance at a more than 10 lines block of codes after an if.
And TAB vs SPACE is particularly annoying! Couldn’t it be an annotation to set TAB=4 SPACE or TAB=8 SPACE?
The curly braces are quit clear and elegant, most people feel comfortable at curly braces.
i++
i++ is very usefull.
Unnecessary “self” in class member function definition
Python requires you to put an unnecessary “self” as the first argument of a function definition in a class, but to omit it when invoking that function. What’s the meaning of that? It’s total garbage.
“this” is that!
Confusing expression of calling function in parent class
Couldn’t it be as simple as “parent.f()”?
Useless lambda expression
The lambda body can only be a single expression – useless! Ah-ha, now you are regret for discriminating curly braces, aren’t you? Look at the really ELEGANT syntax of JavaScript’s anonymous function.
Unwelcomed None/True/False
Just let those be: null, true, false. “i is None” is no more elegant than “i == null”.
Implicit static variable(Non-primative default argument)
Non-primative default arguments in function definitions are implicitly static, that cause many hidden bugs by mistake.
Cpy – The comfortable way to write Python codes in C syntax
Cpy is a C-like scripting language. Cpy codes are converted into python code first, then run by Python at the same time.
-
2012-07-14
Cpy – Wrting Python in C Syntax
Views: 12611 | No CommentsCpy is a C-like scripting language. It is based on Python runtime, and inherits all Python(Python 2.*)’s type system. So you can write script in C syntax, and also have the powerfull Python Engine!
Documents and Downloads: http://www.ideawu.com/cpy/
A Hello World of Cpy –
class A{ public a = 0; public static s = 1; function init(a){ this.a = a; print 'A init', a; } function f(a, b=1){ return a + b; } } print A.s; // 1 a = new A(1); // A init 1 print a.f(1, 2); // 3
-
2010-08-28
Delegate in Python(Python Asynchronous Programming)
Views: 14859 | No CommentsThe .NET Framework enables you to call any method asynchonously, by the two methods BeginInvoke and EndInvoke. The BeginInvoke method is used to register a function execution to Delegate(background threads), it quickly returns, so you can execute other codes after. In later time, you can use EndInvoke to get the return of the execution of that registered function, or you may had register a Callback function in the mean time you register that function, so this Callback will be automatically executed.
The structure of source code can be demonstrate in this steps:
- handle = BeginInvoke(my_function)
- do other work
- result = handle.EndInvoke()
- deal with result