avatar
有人用Haskell吗# Programming - 葵花宝典
g*y
1
【 以下文字转载自 Dreamer 讨论区 】
发信人: mindamia (kevin), 信区: Dreamer
标 题: 当事人事件陈述(三)zz (转载)
发信站: BBS 未名空间站 (Mon Feb 25 18:57:47 2008), 站内
发信人: mindamia (kevin), 信区: Family
标 题: 当事人事件陈述(三)zz (转载)
发信站: BBS 未名空间站 (Mon Feb 25 18:57:19 2008), 站内
发信人: mindamia (kevin), 信区: Overseas
标 题: 当事人事件陈述(三)zz
发信站: BBS 未名空间站 (Mon Feb 25 18:55:19 2008), 站内
发信人: mindamia (kevin), 信区: THU
标 题: 当事人事件陈述(三)zz
发信站: BBS 未名空间站 (Mon Feb 25 18:53:44 2008), 转信
发信人: Lawson (凤智郎-心底无私天地宽), 信区: FamilyLife
标 题: 当事人事件陈述(三)
发信站: 水木社区 (
avatar
d*r
2
【此篇文章是由自动发信系统所张贴】
⊙ 博彩开启于:Sat Jan 30 17:57:38 2010 类别:单选
⊙ 主题:Superbowl
⊙ 博彩题目描述:
【选项如下】
(1) Colt -4.5 > Saint
(2) Colt -4.5 < Saint
(3) other
(4) backup
avatar
k*r
3
syntax很怪,也还没搞清楚functional programming是不是个big deal
avatar
m*g
4
谁把二补平的?害我白赌。。。
avatar
b*e
5
The syntax is pretty normal for functional languages. The problem is that it is
alignment sensitive, which means, it MATTERS how many space/tabs you put at
the front of the line, and THAT SUCKS. Any language that is alignment
sensitive should DIE, like Haskell and Python.
avatar
k*g
6
WO ...

【在 m******g 的大作中提到】
: 谁把二补平的?害我白赌。。。
avatar
w*g
7
Haskell曲高和寡,感觉发明这个语言不是为了解决实际问题。楼主还是别折腾了。我曾
经花不少时间研究haskell的monad到底是什么意思,最后还是没有练到可以使用的水平
。fu
nctional language限制太强,以至于一般语言中很容易实现的东西都需要引入非常深奥
的数学概念才能勉强解决。functioinal language前段时间又有点抬头是因为多核处理
器和集群计算的兴起对并行语言的需求。其实是否可并行化是由问题本身决定的。有些
问题本质上不可并行,用functional language即使极其艰难地实现了其实还是不能并行
的。
我同意python should DIE。haskell从来就没正经活过。

it is
at

【在 b***e 的大作中提到】
: The syntax is pretty normal for functional languages. The problem is that it is
: alignment sensitive, which means, it MATTERS how many space/tabs you put at
: the front of the line, and THAT SUCKS. Any language that is alignment
: sensitive should DIE, like Haskell and Python.

avatar
k*r
8
@blaze, @wdong,
I actually like Python very much. After you get pass the first
period, the indentation makes thing easier and you type less.
Among the languages I have used for any actual projects, Python
has been the most productive language for me when I need to
quickly get something done.
Even so, Haskell looks very foreign to me. wdong's comment
gives me a good perspective of the language in terms of the
shift to functional programming but remarks like python should
die has somewhat discount
avatar
n*t
9

it is
at
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Can not agree more on this point. Anyone who got this idea must have
some brain damages.

【在 b***e 的大作中提到】
: The syntax is pretty normal for functional languages. The problem is that it is
: alignment sensitive, which means, it MATTERS how many space/tabs you put at
: the front of the line, and THAT SUCKS. Any language that is alignment
: sensitive should DIE, like Haskell and Python.

avatar
c*t
10
At least that's better than spending 5 minutes just to count () again
and again for a line of code in lisp. That's a quantum leap in term
of readability for sure :P

it is
at

【在 b***e 的大作中提到】
: The syntax is pretty normal for functional languages. The problem is that it is
: alignment sensitive, which means, it MATTERS how many space/tabs you put at
: the front of the line, and THAT SUCKS. Any language that is alignment
: sensitive should DIE, like Haskell and Python.

avatar
b*e
11
Unfair comments. There're well many other functional languages that have "
normal" syntax, like ML/Caml/Ocaml. Why does Haskell have to be the asshole? As for lisp, any paren-matching tool in modern editors will help, e.g., emacs/vim.

【在 c*****t 的大作中提到】
: At least that's better than spending 5 minutes just to count () again
: and again for a line of code in lisp. That's a quantum leap in term
: of readability for sure :P
:
: it is
: at

avatar
k*r
12
i don't know much about these languages. haskell could be more
mature than the other languages because i've seen people who came from
ocaml to haskell...maybe there's some advantages to it.

asshole? As for lisp, any paren-matching tool in modern editors will help,
e.g., emacs/vim.

【在 b***e 的大作中提到】
: Unfair comments. There're well many other functional languages that have "
: normal" syntax, like ML/Caml/Ocaml. Why does Haskell have to be the asshole? As for lisp, any paren-matching tool in modern editors will help, e.g., emacs/vim.

avatar
b*e
13

我曾
fu
深奥
并行
哈哈, 这个高!
不过话说回来, Haskell作为language本身我并不看好, 但是有它而来的一些design
patterns确是值得借鉴的. 比如说这个monad, 做domain specific language
interpretation正好是物尽其用.

【在 w***g 的大作中提到】
: Haskell曲高和寡,感觉发明这个语言不是为了解决实际问题。楼主还是别折腾了。我曾
: 经花不少时间研究haskell的monad到底是什么意思,最后还是没有练到可以使用的水平
: 。fu
: nctional language限制太强,以至于一般语言中很容易实现的东西都需要引入非常深奥
: 的数学概念才能勉强解决。functioinal language前段时间又有点抬头是因为多核处理
: 器和集群计算的兴起对并行语言的需求。其实是否可并行化是由问题本身决定的。有些
: 问题本质上不可并行,用functional language即使极其艰难地实现了其实还是不能并行
: 的。
: 我同意python should DIE。haskell从来就没正经活过。
:

avatar
n*t
14
学Haskell我的感觉是,绝对比C,C++之类的东西简单。
欧洲很多大学计算机系一年级第一门语言就是haskell,
这里面还N多,非计算机专业的副修学生。
当然设计这么一个语言是另外一回事。

我曾
fu
深奥
并行

【在 w***g 的大作中提到】
: Haskell曲高和寡,感觉发明这个语言不是为了解决实际问题。楼主还是别折腾了。我曾
: 经花不少时间研究haskell的monad到底是什么意思,最后还是没有练到可以使用的水平
: 。fu
: nctional language限制太强,以至于一般语言中很容易实现的东西都需要引入非常深奥
: 的数学概念才能勉强解决。functioinal language前段时间又有点抬头是因为多核处理
: 器和集群计算的兴起对并行语言的需求。其实是否可并行化是由问题本身决定的。有些
: 问题本质上不可并行,用functional language即使极其艰难地实现了其实还是不能并行
: 的。
: 我同意python should DIE。haskell从来就没正经活过。
:

avatar
n*t
15

asshole? As for lisp, any paren-matching tool in modern editors will help,
e.g., emacs/vim.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is actually quite horrible too.

【在 b***e 的大作中提到】
: Unfair comments. There're well many other functional languages that have "
: normal" syntax, like ML/Caml/Ocaml. Why does Haskell have to be the asshole? As for lisp, any paren-matching tool in modern editors will help, e.g., emacs/vim.

avatar
b*e
16
What other languages have you tried? If you can do it with python, you must
be able to do it with perl as well. It all depends on which flavor you
like. As general purpose scripting, python has nothing over perl. Well,
perl has the leading symbol trouble, but hey, I would rather live with that
rather than counting spaces/tabs, which are FUCKING literally invisible.
Most of the time, it is not the problem of getting things done quickly, but
to get things done reasonably fast and in a controll

【在 k***r 的大作中提到】
: @blaze, @wdong,
: I actually like Python very much. After you get pass the first
: period, the indentation makes thing easier and you type less.
: Among the languages I have used for any actual projects, Python
: has been the most productive language for me when I need to
: quickly get something done.
: Even so, Haskell looks very foreign to me. wdong's comment
: gives me a good perspective of the language in terms of the
: shift to functional programming but remarks like python should
: die has somewhat discount

avatar
k*r
17
the languages I have used for real projects so far: c, c++, pascal, java,
python, php. I also tried to learn perl (a couple of times.) I personally
think python is a lot better than perl because every time i tried to learn
perl , i disliked it and gave up. I think my experienced is shared by many
given the declining number of perl users and rising number of python users.
Python has very smart design that makes it much easier (than perl) to
understand, maintain and think of a solution to a specif

【在 b***e 的大作中提到】
: What other languages have you tried? If you can do it with python, you must
: be able to do it with perl as well. It all depends on which flavor you
: like. As general purpose scripting, python has nothing over perl. Well,
: perl has the leading symbol trouble, but hey, I would rather live with that
: rather than counting spaces/tabs, which are FUCKING literally invisible.
: Most of the time, it is not the problem of getting things done quickly, but
: to get things done reasonably fast and in a controll

avatar
w*g
18
我不喜欢python的理由是python那批人打着反对premature optimization为理由编写劣
质代码,并且到处reimplement wheels。其中最典型的就是python解释器。同为解释型
或半解释型语言,python在速度上要比perl或者java慢一个数量级。我不知道除了不做
"premature optimization"以外还有别的任何理由能把一个解释器做的如此之慢。

【在 k***r 的大作中提到】
: the languages I have used for real projects so far: c, c++, pascal, java,
: python, php. I also tried to learn perl (a couple of times.) I personally
: think python is a lot better than perl because every time i tried to learn
: perl , i disliked it and gave up. I think my experienced is shared by many
: given the declining number of perl users and rising number of python users.
: Python has very smart design that makes it much easier (than perl) to
: understand, maintain and think of a solution to a specif

avatar
r*t
19
java 怎么算解释的?。解释器慢又是怎么比较的,你要是用 perl 实现和 python
object 等价的 object, 再来和对应的 python code 比较速度,没理由 perl 能执行
的快。oo has a cost as its overhead, oo scripting language 里面 python 不算
是慢的。
能举几个例子说下 in python, which wheels are unnecessary re-implementations?

【在 w***g 的大作中提到】
: 我不喜欢python的理由是python那批人打着反对premature optimization为理由编写劣
: 质代码,并且到处reimplement wheels。其中最典型的就是python解释器。同为解释型
: 或半解释型语言,python在速度上要比perl或者java慢一个数量级。我不知道除了不做
: "premature optimization"以外还有别的任何理由能把一个解释器做的如此之慢。

avatar
t*t
20
我老人家料到你会出来
别的不知道, 不过java应该算是个半解释的语言吧, 有些hotspot有编译而已

implementations?

【在 r****t 的大作中提到】
: java 怎么算解释的?。解释器慢又是怎么比较的,你要是用 perl 实现和 python
: object 等价的 object, 再来和对应的 python code 比较速度,没理由 perl 能执行
: 的快。oo has a cost as its overhead, oo scripting language 里面 python 不算
: 是慢的。
: 能举几个例子说下 in python, which wheels are unnecessary re-implementations?

avatar
s*n
21
if you want slow speed, use Ruby, hehe

implementations?
写劣
释型
不做

【在 r****t 的大作中提到】
: java 怎么算解释的?。解释器慢又是怎么比较的,你要是用 perl 实现和 python
: object 等价的 object, 再来和对应的 python code 比较速度,没理由 perl 能执行
: 的快。oo has a cost as its overhead, oo scripting language 里面 python 不算
: 是慢的。
: 能举几个例子说下 in python, which wheels are unnecessary re-implementations?

avatar
n*t
22
现在我怀疑goodbug会跳出来了。hehe

【在 t****t 的大作中提到】
: 我老人家料到你会出来
: 别的不知道, 不过java应该算是个半解释的语言吧, 有些hotspot有编译而已
:
: implementations?

avatar
g*g
23
thrust对java的描述没有错。

【在 n******t 的大作中提到】
: 现在我怀疑goodbug会跳出来了。hehe
avatar
k*r
24
I'm not sure about Perl. Is Perl really that much faster than Python?
I haven't used it myself but the benchmark data doesn't say so:
http://xodian.net/serendipity/index.php?/archives/27-Benchmark-PHP-vs.-Python-vs.-Perl-vs.-Ruby.html
Python is said to be slower than Java. I think Java benefits a lot
from its JIT compiler, in which case the code is indeed compiled.
Psyco makes portion of Python code a few times faster. But I think
performance is to some extent irrelevant to the discussions here.

【在 w***g 的大作中提到】
: 我不喜欢python的理由是python那批人打着反对premature optimization为理由编写劣
: 质代码,并且到处reimplement wheels。其中最典型的就是python解释器。同为解释型
: 或半解释型语言,python在速度上要比perl或者java慢一个数量级。我不知道除了不做
: "premature optimization"以外还有别的任何理由能把一个解释器做的如此之慢。

avatar
d*q
25
貌似ruby 1.9已经不慢了。
perl 6 的compiler似乎是用haskell写的。
avatar
r*n
26
I like Python, too.
I started using Python in company in 2005,
and never got into the trouble of spaces/tab problems,
actually, the indentation makes the programs look NEAT.
A another advantages are that it's so productive and
has a lot of libraries.
It's true which language you like depends on who you are,
but Python works very well for me,
by the way, I don't like perl, either, because of its symbols system.

【在 k***r 的大作中提到】
: the languages I have used for real projects so far: c, c++, pascal, java,
: python, php. I also tried to learn perl (a couple of times.) I personally
: think python is a lot better than perl because every time i tried to learn
: perl , i disliked it and gave up. I think my experienced is shared by many
: given the declining number of perl users and rising number of python users.
: Python has very smart design that makes it much easier (than perl) to
: understand, maintain and think of a solution to a specif

avatar
b*e
27
貌似是interpreter prototype.

【在 d***q 的大作中提到】
: 貌似ruby 1.9已经不慢了。
: perl 6 的compiler似乎是用haskell写的。

avatar
p*o
28
当然是个big deal
学了Haskell之后你会发现你甚至对Java和其他语言的的理解更加深刻了

【在 k***r 的大作中提到】
: syntax很怪,也还没搞清楚functional programming是不是个big deal
avatar
p*o
29
Significant indentation really sucks, because you won't be able to
automatically reformat your code in your editor. It's not because the editor
is not powerful enough. It's just impossible! The syntax is aimed to make
the language clean looking, but it causes more trouble than this minor
benefit.
But Haskell is too great a language to ignore, despite of this "defect
". I'm really sad to have to put up with its syntax.

it is
at

【在 b***e 的大作中提到】
: The syntax is pretty normal for functional languages. The problem is that it is
: alignment sensitive, which means, it MATTERS how many space/tabs you put at
: the front of the line, and THAT SUCKS. Any language that is alignment
: sensitive should DIE, like Haskell and Python.

avatar
k*r
30
I don't think it's a problem for Python, though.

editor

【在 p***o 的大作中提到】
: Significant indentation really sucks, because you won't be able to
: automatically reformat your code in your editor. It's not because the editor
: is not powerful enough. It's just impossible! The syntax is aimed to make
: the language clean looking, but it causes more trouble than this minor
: benefit.
: But Haskell is too great a language to ignore, despite of this "defect
: ". I'm really sad to have to put up with its syntax.
:
: it is
: at

avatar
b*e
31
Oh, really? How would that be?
If you mean Java Generics (which is new and ugly BTW), then Haskell probably
helps a little bit. But for the major OO concept, I don't see any help
from Haskell. Haskell does not have any OO, which determines its doomed
destiny.

【在 p***o 的大作中提到】
: 当然是个big deal
: 学了Haskell之后你会发现你甚至对Java和其他语言的的理解更加深刻了

avatar
w*g
32
perl is really much (an order of magnitude, I would say) faster than python
in string processing. The benchmark you posted is too simple to tell someth
ing practical.
(Two test programs were measured:
Hello - Prints "Hello World" to stdout.
Inc - Increments a variable, starting at 0.
Each program does one-million iterations, and is run ten consecutive times.)

【在 k***r 的大作中提到】
: I'm not sure about Perl. Is Perl really that much faster than Python?
: I haven't used it myself but the benchmark data doesn't say so:
: http://xodian.net/serendipity/index.php?/archives/27-Benchmark-PHP-vs.-Python-vs.-Perl-vs.-Ruby.html
: Python is said to be slower than Java. I think Java benefits a lot
: from its JIT compiler, in which case the code is indeed compiled.
: Psyco makes portion of Python code a few times faster. But I think
: performance is to some extent irrelevant to the discussions here.

avatar
n*w
33
我上次把一个perl的简单的text file parser改成python,快了接近十倍。

python
someth
.)

【在 w***g 的大作中提到】
: perl is really much (an order of magnitude, I would say) faster than python
: in string processing. The benchmark you posted is too simple to tell someth
: ing practical.
: (Two test programs were measured:
: Hello - Prints "Hello World" to stdout.
: Inc - Increments a variable, starting at 0.
: Each program does one-million iterations, and is run ten consecutive times.)

avatar
l*g
34
maybe just because of pyc.

【在 n*w 的大作中提到】
: 我上次把一个perl的简单的text file parser改成python,快了接近十倍。
:
: python
: someth
: .)

avatar
n*t
35
There should be some "funny" part in your perl code.

【在 n*w 的大作中提到】
: 我上次把一个perl的简单的text file parser改成python,快了接近十倍。
:
: python
: someth
: .)

avatar
p*o
36
I'm certainly talking about major OO concept: polymorphism, inheritance etc.
Java Generics really sucks. In fact many things are wrong with Java, but it
did something better than Python.
Essentially Haskell has OO, but only if you understand what OO really means.
Have you tried CLOS? That gives you a better idea what is OO.
But who told you that OO(in its conventional meaning) is the best way to do
things? I think the normal OO languages you use nowadays are doomed,
because "everything is an obj

【在 b***e 的大作中提到】
: Oh, really? How would that be?
: If you mean Java Generics (which is new and ugly BTW), then Haskell probably
: helps a little bit. But for the major OO concept, I don't see any help
: from Haskell. Haskell does not have any OO, which determines its doomed
: destiny.

avatar
p*o
37
Can you automatically reindent a block of code after you move it to a
different level? Can you delete a block of code by just one key stroke?

【在 k***r 的大作中提到】
: I don't think it's a problem for Python, though.
:
: editor

avatar
k*r
38
I believe this depends on the implementation of an IDE.
There is no reason you couldn't. And the rules are easy -
just add or remove a number of spaces/tabs at the beginning
of a line.
With indentation, it's not that there will be a fuzzy boundary
between code blocks. It's a clearly defined boundary
signified by indentation, instead of curly brackets.

【在 p***o 的大作中提到】
: Can you automatically reindent a block of code after you move it to a
: different level? Can you delete a block of code by just one key stroke?

avatar
g*g
39
The point is that you have to manually maintain indentation.
While when you use curly brackets, you can use a formatter
to format the code based on your preferred template (Eclipse
has this feature). Therefore, all the source code can have
the same style no matter how it is originally written.
Consider this python example, all 3 are equal.
>>> if 1 + 1 == 2:
... print "foo"
... print "bar"
... x = 42
>>> if 1 + 1 == 2:
... print "foo"; print "bar"; x = 42
>>> if 1 + 1 == 2: print

【在 k***r 的大作中提到】
: I believe this depends on the implementation of an IDE.
: There is no reason you couldn't. And the rules are easy -
: just add or remove a number of spaces/tabs at the beginning
: of a line.
: With indentation, it's not that there will be a fuzzy boundary
: between code blocks. It's a clearly defined boundary
: signified by indentation, instead of curly brackets.

avatar
k*r
40
I don't see why it has to be "manual", and I don't see why
a formatter wouldn't work. It's questionable if a good python
formatter has been implemented but I don't see anything that
prevents that from happening.
Yes, you can do:
if 1 + 1 == 2: print 'foo'; print 'bar'
The language syntax parser is able to determine that it's
equivalent to:
if 1 + 1 == 2:
print 'foo'
print 'bar'
So if you choose a template, it should be able to format it that way.
Once the syntax is parsed, the AST in mem

【在 g*****g 的大作中提到】
: The point is that you have to manually maintain indentation.
: While when you use curly brackets, you can use a formatter
: to format the code based on your preferred template (Eclipse
: has this feature). Therefore, all the source code can have
: the same style no matter how it is originally written.
: Consider this python example, all 3 are equal.
: >>> if 1 + 1 == 2:
: ... print "foo"
: ... print "bar"
: ... x = 42

avatar
g*g
41
With an explicit block marker like bracket, you don't need
compilation information to format the code. Eclipse formatter,
for one, can format the code well even if tons of compilation
errors exist. That's very helpful when you are doing some
copy and paste. Sometimes I copy a piece of code from web, and
integrate with my partial class, the formatting
is aweful due to web nature, the open and close bracket may not
match at all, there are often typo and other mess inside. Yet a
quick format and yo

【在 k***r 的大作中提到】
: I don't see why it has to be "manual", and I don't see why
: a formatter wouldn't work. It's questionable if a good python
: formatter has been implemented but I don't see anything that
: prevents that from happening.
: Yes, you can do:
: if 1 + 1 == 2: print 'foo'; print 'bar'
: The language syntax parser is able to determine that it's
: equivalent to:
: if 1 + 1 == 2:
: print 'foo'

avatar
k*r
42
When there are compilation errors, it's a matter of best effort,
no matter what language it is. I think the same is true for Python.
You can still figure out the boundaries (or the lack of it) of code
blocks. The only difference is what to look for, {} or spaces/tabs.
I think the algorithms work very similarly, if not exactly the same
way.
For all the Python IDEs I've tried, including eclipse with PyDev plugin,
all IDEs do indentation for you when you hit enter. PyDev's Python
support may not be

【在 g*****g 的大作中提到】
: With an explicit block marker like bracket, you don't need
: compilation information to format the code. Eclipse formatter,
: for one, can format the code well even if tons of compilation
: errors exist. That's very helpful when you are doing some
: copy and paste. Sometimes I copy a piece of code from web, and
: integrate with my partial class, the formatting
: is aweful due to web nature, the open and close bracket may not
: match at all, there are often typo and other mess inside. Yet a
: quick format and yo

avatar
g*g
43
The point is that indentation information will be lost or messed up
when you are integrating code from different sources, from
others, from a different indent level, or from web which may use
other ways to format text (CSS etc.). And certain labor is
inevitable. To compensate it, your IDE has to be much smarter than
the counterpart, whether it can be achieved is another question, but
Python is doing all this without real benefit, good enough for me to
consider a design flaw.

【在 k***r 的大作中提到】
: When there are compilation errors, it's a matter of best effort,
: no matter what language it is. I think the same is true for Python.
: You can still figure out the boundaries (or the lack of it) of code
: blocks. The only difference is what to look for, {} or spaces/tabs.
: I think the algorithms work very similarly, if not exactly the same
: way.
: For all the Python IDEs I've tried, including eclipse with PyDev plugin,
: all IDEs do indentation for you when you hit enter. PyDev's Python
: support may not be

avatar
k*r
44
The code structure info will not be lost. It's probably a bit
more work to implement but it's doable. Let me give you an example.
Let's say you have:
def f1():
____print 'f1'
def f2():
____print 'f2'
And we want to inline f2() into f1(). You cut f2's code,
and go to f1, right after the ":", hit enter. The carret will be
indented automatically because it's inside a function. Before you
do Paste, the code looks like this:
def f1():
________print f2
Then you hit "Past

【在 g*****g 的大作中提到】
: The point is that indentation information will be lost or messed up
: when you are integrating code from different sources, from
: others, from a different indent level, or from web which may use
: other ways to format text (CSS etc.). And certain labor is
: inevitable. To compensate it, your IDE has to be much smarter than
: the counterpart, whether it can be achieved is another question, but
: Python is doing all this without real benefit, good enough for me to
: consider a design flaw.

avatar
k*r
45
I just did a side by side comparison of java and python code.
I know it's subjective, but I find Python code is easier to read
and follow, in terms of coding style. Since you write more (maybe
10-20%, because of the savings on { and }) code lines in a page,
it's also easier to get a bigger picture of what the code is
trying to do.
The problem I have with Python is not indentations. It's dynamic
nature of types. Java compiler does catch a lot of potential
errors that Python compiler wouldn't.

【在 g*****g 的大作中提到】
: The point is that indentation information will be lost or messed up
: when you are integrating code from different sources, from
: others, from a different indent level, or from web which may use
: other ways to format text (CSS etc.). And certain labor is
: inevitable. To compensate it, your IDE has to be much smarter than
: the counterpart, whether it can be achieved is another question, but
: Python is doing all this without real benefit, good enough for me to
: consider a design flaw.

avatar
p*o
46
But
if 1 + 1 == 2:
print 'foo'
print 'bar'
is very different from
if 1 + 1 == 2:
print 'foo'
print 'bar'
How is it possible for any IDE to know what you think when you say "
autoindent" at the beginning of print 'bar'?

【在 k***r 的大作中提到】
: I don't see why it has to be "manual", and I don't see why
: a formatter wouldn't work. It's questionable if a good python
: formatter has been implemented but I don't see anything that
: prevents that from happening.
: Yes, you can do:
: if 1 + 1 == 2: print 'foo'; print 'bar'
: The language syntax parser is able to determine that it's
: equivalent to:
: if 1 + 1 == 2:
: print 'foo'

avatar
g*g
47
Let's say you have code
print 'f1'
print 'f2'
Now you go somewhere, copy/paste a piece of code in between, it becomes

print 'f1'
if 1+1 == 2 :
print 'f3'
print 'f2'
No matter how smart your IDE is, it must be confused when trying formatting
I really doubt you can just copy/paste without some manual indentation.
And it's certainly error-prone.

【在 k***r 的大作中提到】
: The code structure info will not be lost. It's probably a bit
: more work to implement but it's doable. Let me give you an example.
: Let's say you have:
: def f1():
: ____print 'f1'
: def f2():
: ____print 'f2'
: And we want to inline f2() into f1(). You cut f2's code,
: and go to f1, right after the ":", hit enter. The carret will be
: indented automatically because it's inside a function. Before you

avatar
k*r
48
if you have
print 'f1'
print 'f2'
and you want to paste:
if 1+1==2:
____print 'f3'
it'll become:
print 'f1'
if 1+1==2:
____print 'f3'
print 'f2'
Note that it's not suppose to change the 'f2' line.

formatting

【在 g*****g 的大作中提到】
: Let's say you have code
: print 'f1'
: print 'f2'
: Now you go somewhere, copy/paste a piece of code in between, it becomes
:
: print 'f1'
: if 1+1 == 2 :
: print 'f3'
: print 'f2'
: No matter how smart your IDE is, it must be confused when trying formatting

avatar
g*g
49
You don't get it. Let's I already have
if 1+1==2:
print 'f1'
print 'f2'
And I want to insert itself in between f1 and f2
if 1+1==2:
print 'f1'
if 1+1==2:
print 'f1'
print 'f2'
print 'f2'
Compare to
if 1+1==2 {
print 'f1'
if 1+1==2 {
print 'f1'
print 'f2'
} print 'f2'
}
An auto-format will adjust the latter correctly, same thing can't
be said for python..

【在 k***r 的大作中提到】
: if you have
: print 'f1'
: print 'f2'
: and you want to paste:
: if 1+1==2:
: ____print 'f3'
: it'll become:
: print 'f1'
: if 1+1==2:
: ____print 'f3'

avatar
k*r
50
You add or delete space/tab when necessarily, similar to what
you would do with { and }.

【在 p***o 的大作中提到】
: But
: if 1 + 1 == 2:
: print 'foo'
: print 'bar'
: is very different from
: if 1 + 1 == 2:
: print 'foo'
: print 'bar'
: How is it possible for any IDE to know what you think when you say "
: autoindent" at the beginning of print 'bar'?

avatar
g*g
51
I don't. In eclipse, I use Ctrl+Shift+F, and it's done automatically.
That's certainly easier and less error-prone.

【在 k***r 的大作中提到】
: You add or delete space/tab when necessarily, similar to what
: you would do with { and }.

avatar
k*r
52
You want to insert this to itself after the f1 line:
if 1+1==2:
____print 'f1'
____print 'f2'
You hit enter after 'f1', the carret stops right below letter "p",
then you paste. It becomes:
if 1+1==2:
____print 'f1'
____if 1+1==2:
________print 'f1'
________print 'f2'
____print 'f2'
Isn't this what you want?

【在 g*****g 的大作中提到】
: You don't get it. Let's I already have
: if 1+1==2:
: print 'f1'
: print 'f2'
: And I want to insert itself in between f1 and f2
: if 1+1==2:
: print 'f1'
: if 1+1==2:
: print 'f1'
: print 'f2'

avatar
g*g
53
In ideal world, maybe. But don't forget you copy the code
from internet, from 3rd party resource, you may or may not
have copied a leading or ending line break. People may use
2 or 4 space, or tab, or a mix of them. You just don't have
control of that.
At the end of the day, I am often lost after copying a long
piece of code, and format gets me back in no time if it's
in Java. But extra care is always needed on python side.

【在 k***r 的大作中提到】
: You want to insert this to itself after the f1 line:
: if 1+1==2:
: ____print 'f1'
: ____print 'f2'
: You hit enter after 'f1', the carret stops right below letter "p",
: then you paste. It becomes:
: if 1+1==2:
: ____print 'f1'
: ____if 1+1==2:
: ________print 'f1'

avatar
k*r
54
Only you know where you need the } to end a function, right?
Not your IDE. Similarly, " " will be added to every line
in a Python function. When you decide you are done with this
function, hit enter then backspace. You are done with this function.

【在 g*****g 的大作中提到】
: I don't. In eclipse, I use Ctrl+Shift+F, and it's done automatically.
: That's certainly easier and less error-prone.

avatar
g*g
55
No, } is generated by IDE when I type {. I always type in between.
And no matter where I copy the code from, as long as
it has matching {}, it will be formatted correctly.

【在 k***r 的大作中提到】
: Only you know where you need the } to end a function, right?
: Not your IDE. Similarly, " " will be added to every line
: in a Python function. When you decide you are done with this
: function, hit enter then backspace. You are done with this function.

avatar
k*r
56
- code copied from web pages where indentation is lost
code is screwed up. No question about that
- mixed spaces and tabs
This can be converted by IDE. You just need to tell your IDE
what's the equivalent of a tab. Python coding convertion
recommends 4 spaces and that's what people use most of the time.
The good thing is, if a different style is contained in one
module or function, you will be fine even if they are mixed.
So this is less likely to be a problem.
No doubt that Python is more sensi

【在 g*****g 的大作中提到】
: In ideal world, maybe. But don't forget you copy the code
: from internet, from 3rd party resource, you may or may not
: have copied a leading or ending line break. People may use
: 2 or 4 space, or tab, or a mix of them. You just don't have
: control of that.
: At the end of the day, I am often lost after copying a long
: piece of code, and format gets me back in no time if it's
: in Java. But extra care is always needed on python side.

avatar
k*r
57
No problem. IDE can generate } for you. Then you'll still need
to decide when to stop typing before the } and hit a few down arrows
to leave the function. Similarly, you need to decide when to hit
the backspace to end a function in Python. I really don't seel
a bit deal of difference here.

【在 g*****g 的大作中提到】
: No, } is generated by IDE when I type {. I always type in between.
: And no matter where I copy the code from, as long as
: it has matching {}, it will be formatted correctly.

avatar
t*t
58
真是说都说不明白啊.

【在 k***r 的大作中提到】
: No problem. IDE can generate } for you. Then you'll still need
: to decide when to stop typing before the } and hit a few down arrows
: to leave the function. Similarly, you need to decide when to hit
: the backspace to end a function in Python. I really don't seel
: a bit deal of difference here.

avatar
c*t
59
我怀疑他们为了灌水而故意的。。。

【在 t****t 的大作中提到】
: 真是说都说不明白啊.
avatar
t*t
60

usually (under the usual editor rules) it becomes:
if 1+1==2:
____print 'f1'
____if 1+1==2:
____print 'f1'
____print 'f2'
____print 'f2'

【在 k***r 的大作中提到】
: You want to insert this to itself after the f1 line:
: if 1+1==2:
: ____print 'f1'
: ____print 'f2'
: You hit enter after 'f1', the carret stops right below letter "p",
: then you paste. It becomes:
: if 1+1==2:
: ____print 'f1'
: ____if 1+1==2:
: ________print 'f1'

avatar
k*r
61
Yes. It's not implemented that way in many Python editors.
If you had followed the discussion, you would have known that
goodbug's argument is that the information would be lost. I tried
(and I think I did) to prove to him that the information is all
there. It's only a matter of implementation. I didn't mean PyDev
(or any other editors) does this at this point.

【在 t****t 的大作中提到】
:
: usually (under the usual editor rules) it becomes:
: if 1+1==2:
: ____print 'f1'
: ____if 1+1==2:
: ____print 'f1'
: ____print 'f2'
: ____print 'f2'

avatar
w*i
62
自动多空两格东西要在IDE里实现很容易吧,用C++/java写程序还不是要缩进,虽然语
法不要求,但实际中有人写不缩进的程序吗,而且还得在前后加{}
上次好象有人讲过,既然缩进已经是写程序的惯例,为什么不利用一下。
avatar
g*g
63
Current IDE can do that for you if it's Java or C++. One shortcut key
will do it all. There's a difference between you use indent and you
type indent.

【在 w****i 的大作中提到】
: 自动多空两格东西要在IDE里实现很容易吧,用C++/java写程序还不是要缩进,虽然语
: 法不要求,但实际中有人写不缩进的程序吗,而且还得在前后加{}
: 上次好象有人讲过,既然缩进已经是写程序的惯例,为什么不利用一下。

avatar
w*i
64
not in gedit

【在 t****t 的大作中提到】
:
: usually (under the usual editor rules) it becomes:
: if 1+1==2:
: ____print 'f1'
: ____if 1+1==2:
: ____print 'f1'
: ____print 'f2'
: ____print 'f2'

avatar
w*i
65
I use one key to do that in my editor too. I don't have any paste
identation issue particularly with python.
Yes there's a difference between use indent and type indent. Just like
there's a difference between automatic management memory in Java and manual
memory management in C++. You can't say one thing is always better than the
other.

【在 g*****g 的大作中提到】
: Current IDE can do that for you if it's Java or C++. One shortcut key
: will do it all. There's a difference between you use indent and you
: type indent.

avatar
n*w
66
不是我的perl,那人的程序有时是无端端的吧时间复杂度写高一个指数级。我也怀疑是
他的算法问题。但那个parser很简单,简单的一个循环,regex。
pyc可能是python快得原因。

【在 n******t 的大作中提到】
: There should be some "funny" part in your perl code.
avatar
b*e
67
Ah? Haskell has OO, please teach me. I'm not a professional Haskell
programmer, but I think I am proficient enough, and I never knew Haskell
developed OO mechanisms. Is it recently?
BTW by Haskell, we either refer to Haskell98 standard, or GHC, not the 10
million other dialects, like Hugs, O'Haksell, O'Hug...

etc.
it
means.
do
are

【在 p***o 的大作中提到】
: I'm certainly talking about major OO concept: polymorphism, inheritance etc.
: Java Generics really sucks. In fact many things are wrong with Java, but it
: did something better than Python.
: Essentially Haskell has OO, but only if you understand what OO really means.
: Have you tried CLOS? That gives you a better idea what is OO.
: But who told you that OO(in its conventional meaning) is the best way to do
: things? I think the normal OO languages you use nowadays are doomed,
: because "everything is an obj

avatar
b*e
68
That's exactly the point. Braces are truly needed, but braces are:
NON-CONTEXT-SENSITIVE
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! So this is a plug-and-play thing.
Spaces/tabs are context-sensitive, which means, how many spaces are there
depends on how many spaces there are already in the context. So this is a
fuked-up thing.

【在 k***r 的大作中提到】
: Only you know where you need the } to end a function, right?
: Not your IDE. Similarly, " " will be added to every line
: in a Python function. When you decide you are done with this
: function, hit enter then backspace. You are done with this function.

avatar
x*c
69
Why is copy/paste code such a big deal? you may save a couple of key stokes
with the curly brackets, that's it. That should save you no more than 0.1%
development time.
Eliminating brackets may also not bring you lots of benefits, but I do think
it
is certainly higher than a few extra key strokes.

【在 g*****g 的大作中提到】
: In ideal world, maybe. But don't forget you copy the code
: from internet, from 3rd party resource, you may or may not
: have copied a leading or ending line break. People may use
: 2 or 4 space, or tab, or a mix of them. You just don't have
: control of that.
: At the end of the day, I am often lost after copying a long
: piece of code, and format gets me back in no time if it's
: in Java. But extra care is always needed on python side.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。