Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #95210 > unrolled thread

Re: Is Django the way to go for a newbie?

Started byChris Angelico <rosuav@gmail.com>
First post2015-08-10 11:27 +1000
Last post2015-08-10 22:57 +1000
Articles 3 — 2 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Is Django the way to go for a newbie? Chris Angelico <rosuav@gmail.com> - 2015-08-10 11:27 +1000
    Re: Is Django the way to go for a newbie? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-08-10 13:58 +0200
      Re: Is Django the way to go for a newbie? Chris Angelico <rosuav@gmail.com> - 2015-08-10 22:57 +1000

#95210 — Re: Is Django the way to go for a newbie?

FromChris Angelico <rosuav@gmail.com>
Date2015-08-10 11:27 +1000
SubjectRe: Is Django the way to go for a newbie?
Message-ID<mailman.22.1439170072.3627.python-list@python.org>
On Mon, Aug 10, 2015 at 3:41 AM, Michael Torrie <torriem@gmail.com> wrote:
> Web development is very a very hard problem, largely because it involves
> quite a few different domain-specific languages that you have to be
> proficient in...
>
> In this area, node.js is getting very popular. I don't care much for
> javascript but using it on the server as well as the web browser itself
> reduced the number of languages you have to know by one.

There's another thing you absolutely have to know when you do web
development, and that's i18n. This is why I don't recommend Node.js
for server-side work - because Python's Unicode support is better than
JS's. Stick with Python (and avoid Python 2 on Windows) and you get
great Unicode support. Do anything in JavaScript/ECMAScript and you
get UTF-16 as the official representation. What's the length of the
string "Hello, world"?

>>> len("Hello, world")
12

> "Hello, world".length
12

So far, so good. What if those weren't ASCII characters?

>>> len("πŸ„·πŸ„΄πŸ„»πŸ„»πŸ„Ύ, πŸ…†πŸ„ΎπŸ…πŸ„»πŸ„³")
12

(That's Python 3. In Python 2, you'd need to put a u"" prefix on the
string, but it's otherwise the same, modulo the Windows narrow-build
issue.)

> "πŸ„·πŸ„΄πŸ„»πŸ„»πŸ„Ύ, πŸ…†πŸ„ΎπŸ…πŸ„»πŸ„³".length
22

ECMAScript stipulates that strings are not codepoints, but UTF-16 code
units, so whenever you work with astral characters (which includes a
lot of emoticons, Chinese characters, and other symbols that your end
users *will* use), they'll get things wrong. The length of the string
counts astral characters twice; indexing/slicing can take half of a
character; any manipulation at all could corrupt your data.

So, use Python for all your text processing. Life's better that way.

ChrisA

[toc] | [next] | [standalone]


#95218

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2015-08-10 13:58 +0200
Message-ID<7619054.rZZqoS0ge9@PointedEars.de>
In reply to#95210
Chris Angelico wrote:

> There's another thing you absolutely have to know when you do web
> development, and that's i18n. This is why I don't recommend Node.js
> for server-side work - because Python's Unicode support is better than
> JS's.

Your posting shows again that your knowledge of "JS" is full of gaps at 
best, so you should refrain from making bold statements about "it" and 
making design decisions and recommendations based on that.

-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#95219

FromChris Angelico <rosuav@gmail.com>
Date2015-08-10 22:57 +1000
Message-ID<mailman.41.1439211434.3627.python-list@python.org>
In reply to#95218
On Mon, Aug 10, 2015 at 9:58 PM, Thomas 'PointedEars' Lahn
<PointedEars@web.de> wrote:
> Chris Angelico wrote:
>
>> There's another thing you absolutely have to know when you do web
>> development, and that's i18n. This is why I don't recommend Node.js
>> for server-side work - because Python's Unicode support is better than
>> JS's.
>
> Your posting shows again that your knowledge of "JS" is full of gaps at
> best, so you should refrain from making bold statements about "it" and
> making design decisions and recommendations based on that.

Do please enlighten me! Tell me how Node changes the underlying
ECMAScript specification and gives true Unicode support. In
particular, I would expect the length of a string to be based on
either code points or combining character sequences, and indexing
(including slicing) should be based on the same thing. It should not
be possible to split a character during iteration over a string.
(Whether you iterate over "é" as a single character or as two (U+0065
U+0301) is a matter of debate, and I'd accept both answers as
correct.)

ChrisA

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web