2,861 karma · joined January 27, 2011
Although practicality beats purity.Instead of writing this:
'My name is ' + format(name) + ' my age next year is ' + format(age+1)
or 'My name is {name}, my age next year is {age}'.format(name=name, age=age+1)
You just write f'My name is {name}, my age next year is {age=1}'
It's shorter, it's more readable and more convenient. I can't wait for this PEP to be accepted.Edit: Fixed small errors in the examples.
Discovery creates an amazing gaming experience, but it takes some patience to get it. It might be frustrating at the beginning. Back in the early 90's you just had a few games, you had to get most of them. Now, people are exposed to millions of games for several platforms. If a game doesn't catch the attention of a player in the first few minutes, it's ditched for another one.
It's the market what's sinking Zelda, sadly...
As far as I know, no law requires employers to give their workers paid vacation days in the US. Although the most common vacation time is 2 weeks, there are some jobs with no paid vacation time at all. Also, from what I've heard, what the article mentions about people feeling guilty for taking vacation time is very real in American's work culture.
Here in the Netherlands, in contrast, the minimum paid vacation time by law is four times the number of working days in a week. For full time that's 20 days. Typically, companies provide a bit more than that.
I need to concentrate and can get work done without the distractions
I'm surprised that this one has so many down votes. I use it frequently and for me is one of the best reasons for WFH. http_request(url, callback)
If you want to make a request, get a value, and then make another request depending on that value, you would need something like: def callback(result):
url2 = get_from_value(result)
def inner_callback(result):
print('Final result:', result)
http_request(url2, print)
http_request(url1, callback)
This is very complicated, specially because in Python it's not easy to inline callbacks like in JavaScript. And even then, it's sometimes messy and becomes a callback hell.With async/await you could do something like:
result1 = await http_request(url1)
result2 = await http_request(get_from_value(result1))
print('Final result:', result2)
The await keyword doesn't block like in Perl 6. It suspends the execution and returns the control to the even loop. Then the event loop calls other functions in response to other events. All this happens in a single process and a single thread.This model is more explicit than the Goroutines of Go or the multiple threads of Perl 6. But it has the advantage that the user has more control over when the execution control flows between different parts of the program. For example, if I have this code:
await request1()
# some synchronous code
await request2()
I am completely sure that nothing will run while the code in the middle of the two request is running. This simplifies a lot of synchronization problems.This behavior is very practical when writing quick scripts to automate things or process data. And this is the reason I often prefer Perl over Python for these kind of tasks.
Of course, this has a downside: when you just continue with errors, it's often hard to find the real source of them, or even notice them at all. For bigger application this might end up in weird errors in production that are hard to debug. In this case I very much prefer the behavior of vanilla Python.
jQuery was a game changer for web client side development. Thousands of work hours have been spent on it. It had a specially important role of dealing with all the inconsistencies between browsers. If you don't use all the features, nowadays you can just create a custom build with the stuff you want.
If you don't need jQuery, maybe because you only care about modern browsers, or you use another library or you don't mind a bit of extra boilerplate for DOM manipulation, that's perfectly fine. But these kind of posts seem like mockery on the developers of a library that has provided extreme value for thousands for developers over many years.
In Python and other dynamic languages the compilation part is very simple, the code is parsed (the grammar is very simple) and converted to byte-code. Then the byte-code is executed. Things like function and class definitions happen at run-time, not at compile-time.
In Perl 5, the line between compilation-time and run-time is very fuzzy. It doesn't have a simple grammar that you can use to convert Perl to op-code. You can run code at compilation-time and change the way the compiler interprets things.
What C# (actually it was F#) introduced was the specific 'await' and 'async' syntax keywords. Those are being copied in other languages, and they're just sugar over coroutines.
[1] http://www.cambridge.org/gb/academic/subjects/computer-scien...
[2] http://blog.mekk.waw.pl/archives/14-Twisted-inlineCallbacks-...
Also, stations for a subway systems requires more space, they're much harder to build and they're really expensive.
So I disagree with the idea that subways are superior in every way. Street cars have some advantages as well.
import unicodedata
def count_graphemes(string):
count = 0
for codepoint in string:
if not unicodedata.category(codepoint).startswith('M'):
count += 1
return count
print(count_graphemes("ปฏิบัติจริง")) # prints 7
This example is over simplified as grapheme clusters are trickier to detect, but proper support is coming to Python's standard library: http://bugs.python.org/issue18406Yes I have. Many interesting features. Most of them not good enough to be considered killer, IMO. What are your suggestions?
This approach is not only really bad for performance, it's also very limited. For example, you can't just share data between both interpreters, however you can send some basic datatypes from one to the other.
This has been done for other languages as well, for example, check Inline::Python [1]. It's an interesting thing, but not very useful for production.
[1] http://search.cpan.org/~nine/Inline-Python-0.49/Python.pod
It just might be possible that Perl 6's crazy long development process can
produce the best-adopted second system around
Unfortunately, I don't share the same optimism as the OP. In the real world, adoption is not only driven by how cool a language is, but the ecosystem of tools and developers around it. There are lots of Perl 5 codebases which won't be migrated because it's too expensive.The true lesson learned for language developers is: Don't break backwards compatibility. Ever.
The Python community made this mistake, and they acknowledge it. Guido said this won't happen again. But at least for the case of Python 3, the number of breakages is relatively small, and the migration from 2 to 3 while tedious, it's not that hard. Even so, the migration of the whole ecosystem has been really really slow. But I think in the end the community will move.
The Perl case, on the other side, is much worse. Migrating a relatively complex project from 5 to 6 is extraordinarily hard. It's probably the same as a whole rewrite. Also, the community is divided, with some developers keeping the improvement of Perl 5, fixing bugs and adding new features. There is no incentive for migration.
If the migration has been so slow for Python 3, which had a much smaller barrier, I don't see how it could be better for Perl 6.
New languages are able to develop a new ecosystem when they introduce innovative features, e.g. Rust. But Perl 6 while being a nice language, doesn't seem to have any killer feature compared to mainstream languages.
Hackernewsletter: http://hackernewsletter.com/
Python Weekly: http://www.PythonWeekly.com
JavaScript Weekly: http://javascriptweekly.com/
GameDev.js Weekly: http://gamedevjsweekly.com/
HTML5Weekly: http://html5weekly.com/
Perl Weekly: http://perlweekly.com/
This move was unthinkable a decade ago. I'm very glad to see MS moving in this direction. Just because of this announcement I want to start playing with TypeScript and C# again.
Also, I miss a few things in Atom: Macro recording. Go to Symbol in Project.
Now Sublime is getting frequent updates again. It's a beautiful piece of software. Fast, stable and pleasant to use. I payed the license without hesitation.
I would like to see an article telling me the advantages of Atom over Sublime, because so far, I'm unable to identify any one but the fact that it's open source. All the packages that I use in Sublime are either non existent on Atom or not as good.
it is easy to confuse coroutines with regular generators, since they share
the same syntax; async libraries often attempt to alleviate this by using
decorators (e.g. @asyncio.coroutine [1] );
it is not possible to natively define a coroutine which has no yield or
yield from statements, again requiring the use of decorators to fix
potential refactoring issues;
support for asynchronous calls is limited to expressions where yield is
allowed syntactically, limiting the usefulness of syntactic features, such
as with and for statements.
[1] https://www.python.org/dev/peps/pep-0492/#rationale-and-goal... begin
val1 = read(account1)
val2 = read(account2)
newVal1 = val1 - 100
newVal2 = val2 + 100
write(account1, newVal1)
write(account2, newVal2)
commit
Last time I checked this was not possible, only light compare-and-swap operations. composing a funny joke or a beautiful piece of music may well involve
playful cleverness, but a joke as such and a piece of music as such
are not hacks, however funny or beautiful they may be. However, if the
piece is a palindrome, we can say it is a hack as well as music; if it
is empty, we can say it is a hack on music
Playing The Eye of the Tiger per se is not hacking. Playing it with a dot matrix printer is. In its purest form. :)1. Tree shaking. The compiler can detect unused code and remove them automatically from the JS output, resulting in smaller files. (Yes I know that Hello World is a bit big, but real projects are not hello world)
2. A really nice IDE with autocomplete, error highlighting, code formating, refactoring, debugger, profiler. It really makes a difference.
3. A VM that's actually faster than JavaScript useful for writing server side applications.
4. A nice an well integrated standard library.
http://mirrors.dotsrc.org/fosdem/2015/devroom-mozilla/ud2218...