HNHacker News
TopNewBestAskShowJobs

ceronman

2,861 karma · joined January 27, 2011

Programmer
submissionscomments
ceronman··on Python Extension Proposal 498: Literal String Formatting
You're right, you can't do {age+1} in a string right now. I just edited to fix it.
ceronman··on Python Extension Proposal 498: Literal String Formatting

    Although practicality beats purity.
ceronman··on Python Extension Proposal 498: Literal String Formatting
This proposal doesn't affect security in any way. It's just syntactic sugar.

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.

ceronman··on Python Extension Proposal 498: Literal String Formatting
C# 6.0 is also adding literal string formatting: http://www.codeproject.com/Articles/846566/What-s-new-in-Csh...
ceronman··on Saving Zelda (2012)
I think this sense of discovery is one of the reasons I love Minecraft so much. Wandering in a deep cave, trying to follow the sounds to find a stronghold or spawner is amazing. Mining a wall and suddenly finding some diamonds is so rewarding!

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...

ceronman··on Living in Switzerland ruined me for America and its lousy work culture
> Vacation time is also the lowest (2 weeks) compared to Europe which on average has 4 weeks of vacation time.

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.

ceronman··on Moving Fast with High Code Quality
There is more to code reviews than just preventing issues. Code review is a valuable tool for maintaining code quality, and share code knowledge across the team. Those two things can be achieved with post-commit reviews.
ceronman··on Reasons to work from home

    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.
ceronman··on RPerl – optimizing compiler for Perl 5
It's similar. The difference is that Cython is a super set of Python, while RPerl is subset of Perl. With Cython you can take fully dynamic Python and slowly convert it into some static equivalent (cdef) that runs as fast as C / C++. It also has some additional helpers for interacting with existing C/C++ code in an almost transparent way.
ceronman··on What’s New in Python 3.5
Think of async/await as syntactic sugar for doing the kind of asynchronous programming when you pass callbacks/continuations and have an explicit event loop. For example, assume that you have an http_request function that looks like this:

    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.
ceronman··on SlopPy: An error-tolerant Python interpreter that facilitates sloppy programming
This is a very interesting project. It makes Python behave a bit more like Perl. By default, Perl is very forgiving with errors. Instead of stopping everything when a non fatal error is found, Perl will try to continue and will throw a warning instead.

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.

ceronman··on Bling – the $ of jQuery without the jQuery
Yes, you can re-implement jQuery in 10 lines of code... if you only support 0.1% of the functionality of jQuery.

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.

ceronman··on Perl Cannot Be Parsed: A Formal Proof (2008)
It's not the same thing. In Python this is a run-time error. The code you posted is parsed and compiled to byte-code just fine. Then, depending on the time, a new function is created dynamically at run-time or a NameError is raised at run-time.

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.

ceronman··on Python Coroutines with Async and Await
The idea of using coroutines for asynchronous programming is quite old actually. ML has used it since the 80s [1]. Python itself had it way before C# with Twisted's inlineCallbacks [2].

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-...

ceronman··on The demise of America's once-mighty streetcars
I live in Amsterdam and I agree that a subway system is probably faster and more efficient. However I find the street cars' ride more enjoyable. I don't like the idea of getting into the ground, with nothing to see from your window different than concrete. With the tram, you might take longer, but you can appreciate the beautiful city around you.

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.

ceronman··on Tmux 2.0 released
I recently discovered Tmux after years of using GNU Screen. I love it. It feels much easier to use and more intuitive, easier to script. Also integration with terminal emulators such as iTerm2 on OS X or Byobu on Linux is fantastic. Tmux earned a place in my list of favorite daily used tools.
ceronman··on Three Tales of Second System Syndrome
I don't see how this is a language killer feature. It looks more like a library feature. And yes, Perl 6 has a superb unicode library. In other languages, you can add the functionality as libraries. This is an example in Python:

    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/issue18406
ceronman··on Three Tales of Second System Syndrome
> Seriously?? Have you even looked at Perl 6.

Yes I have. Many interesting features. Most of them not good enough to be considered killer, IMO. What are your suggestions?

ceronman··on Three Tales of Second System Syndrome
Inline::Perl5 is just a very thin layer to communicate with a Perl 5 process. This works well for small things but it's not practical for more complex ones. You can call code of any language from any language using this technique, that doesn't mean the languages are integrated.
ceronman··on Three Tales of Second System Syndrome
Inline::Perl5 is just some glue to communicate to a Perl 5 interpreter from Perl 6. It's a simple form of inter-process communication between Perl 5 and 6. It's not that you can continue writing your Perl 5 program/library in Perl 6.

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

ceronman··on Three Tales of Second System Syndrome

    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.

ceronman··on Ask HN: What newsletters do you read every day or week?
My List:

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/

ceronman··on Microsoft Launches Visual Studio Code, a Free Cross-Platform Code Editor
Cross platform developers tools by Microsoft! Great news! MS has some of the best developer tools out there. In my opinion, the only downside has been the dependency on the Windows platform. As a developer, I feel much more comfortable in a Unix environment.

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.

ceronman··on Switching to Atom from Sublime Text
Not only these features are already in Sublime. They were there long before Atom was released. They also work much better than in Atom. For example, the fuzzy file finder feels slow with a 50K files repo. Go to symbol doesn't work with many languages, e.g. Perl.

Also, I miss a few things in Atom: Macro recording. Go to Symbol in Project.

ceronman··on Switching to Atom from Sublime Text
Sublime 3 user here. I wanted to try Atom mainly because it's open source, and I was a bit concerned with Sublime not getting updates. I tried Atom when it first came out and it was really slow and buggy. I decided to try it again a couple of months ago and, while it's faster and more stable than it was before, it's still way slower and less stable than Sublime.

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.

ceronman··on PEP 492 – Coroutines with async and await syntax
This is explained in the Rationale and Goals[1] section of the PEP:

    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...
ceronman··on The confusing CAP and ACID wording
Are you able to do full atomic transactions in Cassandra now? Like the ones described in the article:

    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.
ceronman··on Dot matrix printer playing “Eye of the Tiger” [video]
I loved this. This fit's perfectly with Stallman definition of hacking [1].

    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] https://stallman.org/articles/on-hacking.html

ceronman··on “We have decided not to integrate the Dart VM into Chrome”
I believe a lot of Dart criticism comes from people who haven't actually used it. I personally find it almost always more enjoyable than JavaScript. I've also used other languages that transpile to JS but there some features that I find superior in Dart:

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.

ceronman··on Contributing to Servo
If you are interested in contributing to Servo. I also recommend the talk "Servo and You: a beginners to contributing to Servo" given by Josh Matthews at FOSDEM a couple of months ago. You can find the video here:

http://mirrors.dotsrc.org/fosdem/2015/devroom-mozilla/ud2218...

← PreviousPage 7 of 9Next →