Haskell to Perl 6 - <AUTHOR> https://docs.perl6.org/language/haskell-to-p6 <comment><USER2> Perl 6 is for people who are very smart and have a great spirit in seeking and having fun in programming, I really admire that. That's my thought after two failed attempts (each lasted about two days) to learn it in 2012 and 2014. I felt the use of sigils, syntax oddities and the cleverness were beyond my ability to master the language. I should mention in 1998 I used (modified it a little bit) Selena Sol's shopping cart script. Since then I have only written a few small Perl 5 scripts, am not familiar with recent development. To learn Perl 6 today, what kind of practice projects/applications, or approaches, one can use?

<comment><USER3> > Perl 6 is for people who are very smart and have a great spirit in seeking > and having fun in programming

Not sure why you felt the need to include this. How did you come to this conclusion? Is this in comparison to Haskell, or what?

<comment><USER2> It was tongue in cheek, haha... I was only frustrated by my own inability to get the hang of Perl 6. As an old casual fan of Perl, I still want to take another shot at learning it very much.

<comment><USER4> The perl6intro website shows you the essentials of what you need and the ecosystem has matured a lot since 2014 as well as many good books being published. Laurent Rosenfield has a Think Perl6 book that you can buy in paper or read online for free. If you can already code, getting proficient in basic Perl6 is easy. Becoming a master is outside my current grasp.

<comment><USER2> Thanks for the recommendations.

One liners are fun, and life-saving. I am curious about this aspect compared to Perl 5. With Perl 6's new syntax and language features, can we still easily [ab]use one liners for fun and profit?

<comment><USER5> Cons:

* Rakudo -- the only P6 compiler for now (and likely many years, maybe forever) -- has a slow startup, around 0.1 seconds or so.

* Rakudo is still a work in progress. What's done is pretty solid but, for example, no one has implemented the `-a` awk/autosplit command line option (cf [https://gist.github.com/raiph/1d0cbefcb3cfe45b0b906282e6e405...](https://gist.github.com/raiph/1d0cbefcb3cfe45b0b906282e6e40519)) and command line usage is currently `use strict;` by default so you have to declare variables with `my`.

* Pros

P6 makes for sweet oneliners...

25 one liners being written up this month: [https://perl6.online/category/advent- calendar/](https://perl6.online/category/advent-calendar/)

9 categories last updated a year ago: [https://github.com/dnmfarrell/Perl6-One- Liners](https://github.com/dnmfarrell/Perl6-One-Liners)

[https://www.google.com/search?q=perl6+oneliners](https://www.google.com/search?q=perl6+oneliners) [https://www.google.com/search?q=perl6+one+liners](https://www.google.com/search?q=perl6+one+liners)

</comment></comment></comment></comment></comment></comment><comment><USER6> Perl 6 feels a bit "ad hoc" to me... It looks like it has very interesting features but it lacks the uniformity present in most languages...

<comment><USER7> Perl has never been about uniformity.

Perl is a great experiment in language design, or, rather, a battery of experiments. It's the opposite of a cleanly _designed_ language.

<comment><USER8> No, it's designed. It's just not designed the way everyone expects a computer language to be designed. It was designed by a linguist. He produced a language with some of the flexibility (and messiness) of _human_ languages, which is completely foreign as a goal to other languages.

One of the places this shows up to me is being able to say "it" (in essence). That is, we humans, when talking to each other, we say things like "Read in a line of input. If it looks like an XML tag, pass it to the XML handler function". But you can't talk to a computer that way. The computer says, in effect, "Read in a line of input _from where?_ And put it _where?_ And what do you mean 'if it ends in a newline'? If _what_ ends in a newline?"

But in Perl, you can write it just like the humans say it, and Perl says, "Well, you didn't say where to read the input from, so I assume I should read it from the standard place (which is perfectly well defined in Perl). You didn't say where to put the line of input, so I'll put it in the default variable. You didn't say what to check to see if it looks like an XML tag, so I will check the default variable." The default variable, essentially, plays the role of "it" in human language.

And the whole language is like that. There are shortcuts that work most of the time, and precise ways of saying things that work when the shortcut isn't what you want. And what the shortcut does is well defined (in the docs; it can be very opaque in code).

None of this makes Perl an ideal language. But it has a perspective on language that is (as far as I can tell) unique among programming languages. It is only fair to judge the coherence of the design within the framework of what Perl is trying to be.

<comment><USER9> Except the resulting code will look nothing like "the humans say it", and instead will be a cryptic charade requiring a ton of knowledge to decipher - ending up being neither natural language nor machine code.

<comment><USER10> > Except the resulting code will look nothing like "the humans say it",

Actually, I find it maps rather directly to how a lot of people explain things. For example, "Examine each number, and as long as it's greater than 10 and odd, then pass it to the the work function."

        for my $number ( @numbers ) {
            next unless $number > 10;
            next unless $number % 2;
            work($number);
        }

Perl generally allows you to structure your code as you would explain how to accomplish something to another person. This can be beneficial or detrimental depending on how deep you go with this concept. A lot of becoming a good Perl programmer is learning where a sane line is for this, but each language usually has a similar feature which the user needs to decide where the sane point to stop is before taking it to an extreme that is detrimental.

There are definitely aspects of Perl that I think are better left untouched, and thankfully the community has pretty much come to consensus about the most problematic missteps the language allows.

<comment><USER11> One can write pretty much the same code in python/c++11/whatnot and it also feels quite natural to read:

       for number in numbers:
           if number <= 10: continue
           work(number)

Do you have a better example where the Perl syntax would shine?

<comment><USER10> Note: This is all in the context of Perl 5. You can assume the following works with little or no changes in Perl 6, along with probably 3+ other new ways to do it (which is actually one of my peeves about Perl 6).

There's a few things. Full word but lower precedence boolean operators (and, or, not) which allows for combining statements in a way that &&, || and ! doesn't always facilitate, but really shine in making boolean statements more readable. e.g.

        die "some problem" unless defined $some_var and not $some_var eq "foo";

But I think you somewhat missed my point. What you've done in your example, is easy to read, but you've either unconsciously or consciously switched the order of some statements so they are valid in the context of Python. This is trivial and easy with simple conditionals, but if they are complex it can hide the point of the statement, which is that this is a shortcut to the next loop iteration. I find putting the "verb" first can make for much easier understanding of what's going on when it gets more complex. A comparison of that might be something like the following:

        for my $item ( @items ) {
            # Standard barrage of tests
            next if test1($item) or test2($item) or test3($item)
                or test4($item) or test5($item);
            # If it's a special item, do a couple more tests
            next if test_guard($item) and ( subtest1($item) or subtest2($item) );
            # If it's an end marker, skip the rest
            last if is_last_processable($item);

            ...
        }

Even though the actions are condensed, I quickly know what the _point_ of each one is, and what it does. Condensing them also allows me to comment each without feeling I'm cluttering the logic and making it more verbose than needed (too verbose, and you raise the likelihood related code will be off- screen or not as easily visually associated, which hampers comprehension), but event without the comments having the defining action start the line helps clarify intent. I imagine in Python, the continue statement would either be far to the right from larger conditionals, or moved to a more traditional scope underneath taking up an extra line, or split into multiple if statements. This is also a good example in Perl of where the community has come to a fairly good consensus that while you _can_ make very complex postconditional statements, _don 't_, as it defeats the purpose (just split it into multiple simple ones or use a traditional precontitional if formatted to be more readable, or some other technique such as computing portions of the condition separately and comparing them later).

Also, regarding if pre or post positioning, I feel that Perl allows the statements to be expressed as you might say them or think of them. That's the point of postconditionals in Perl. Also, like how you would express them verbally to someone, a postconditional only works on a single statement (it does not support blocks through braces). You wouldn't normally say "do X, do Y, do Z if A is true" and expect it to apply unambiguously to tasks X, Y and Z. On the flip side, a preconditional not only supports braces, it _reqiures_ them, since the simple one statement case is easily handled through the postconditional. e.g.

        # Valid
        if ( $A ) {
            do_something();
        }
        if ( $A ) { do_something(); }
        do_something() if $A;

        # Invalid
        if ( $A ) do_something();
        { do_something(); } if $A;

This is an example of one of the places Perl not only allows you to use natural expressions to express yourself, but guides you away from odd or problematic ways of doing so (i.e. ambiguous speech patterns).

As for sigils, some people really dislike them, but I find the useful. I see them a little signifiers of the nouns in any statement (and the type of noun, of which there are only a few).

Finally, there's "context", which has a specific meaning in Perl, and is probably the most interesting and unique thing about the language. It can be very useful, but the complexities can sometimes cause interesting behavior that was unintended or non-obvious initially. That said, its also what makes a lot of the "magic" (really just the rules put into action) of the array and hash data types work, so it's not something that could feasibly be removed (and nor would I want it to be). Instead, knowledge of the problematic spots is acknowledged by the community, so we try to avoid those problems, and for the most part they are old problems (this is usually a function that may produce multiple values being using within the definition of a hash or array in list context, exemplified by decades old projects based on CGI.pm which has been deprecated).

<comment><USER9> Lots of other languages have postfix conditionals.

On the readable boolean ops, all the Perl people recommend shying away from them except for a few specific constructs (do or die, eval or do, etc), since the weaker precedence rules make it really easy to shoot yourself on the foot:

        $a = $b or $c;

Where $a will never be assigned the value of $c.

<comment><USER10> > Lots of other languages have postfix conditionals.

I didn't make a case as Perl being the only language, just that it's an interesting aspect of Perl. That said, I would be interested in what languages you are referring to. I haven't seen many.

> On the readable boolean ops, all the Perl people recommend shying away from > them except for a few specific constructs (do or die, eval or do, etc), > since the weaker precedence rules make it really easy to shoot yourself on > the foot:

They are perfectly acceptable in a boolean statement. You only need to shy away from them when mixing them with assignments or higher precedence boolean constructs. The only case where you would have to worry is in non-simple boolean statements with assignment in the statement, or functions that omit parens for arguments in some cases, or mathematical operations without grouping parens, all of which I would argue should include their own grouping parenthesis for clarity anyway.

That said, I devoted space in both of my comments in this thread to noting that there are definitely places where you might shoot yourself in the foot with some of these features, and you'll note the examples I used them in are exactly as you've described, where they are either after a postconditional (in which case it's kept to a simple boolean statement which has no ambiguity), or to affect control flow (e.g. return or die), in which that assignment doesn't matter anyway.

> Where $a will never be assigned the value of $c.

Which I never used as an example for that reason, but that's the _point_ of those operators. Being lower precedence allows for some alternate constructs than is possible in many other languages without them.

Someone asked for examples of constructs that help Perl match mental models of how might think of an algorithm, so I decided to explain a few. The purpose isn't to point out how Perl is better than Python or some other language, but how it's different in an interesting way. A lot of that was planned, but sometimes that came out to its benefit, and sometimes to its detriment. Like most interesting new things (because at the time it was), it's not entirely one thing or the other.

<comment><USER12> >I didn't make a case as Perl being the only language, just that it's an interesting aspect of Perl. That said, I would be interested in what languages you are referring to. I haven't seen many.

I'm not the one you replied to, but Python has got, not postfix conditionals, but what I might call infix ones, for lack of a better name. Here is a nested example:

Using nested conditional expressions to classify characters:

[https://jugad2.blogspot.com/2017/04/using-nested- conditional...](https://jugad2.blogspot.com/2017/04/using-nested-conditional- expressions-to.html)

</comment></comment></comment></comment></comment></comment></comment></comment></comment></comment><comment><USER13> Not to be trollish, but is anyone actually using Perl 6 for more than just for kicks? It is a super interesting language, but has it been battle tested over the years similar to Perl 5?

<comment><USER14> Perl 6 is still 9 times slower than Perl 5 when parsing log files with a regex. I don't quite get why the feature which made Perl famous has now taken a back seat. Why should I take a 9x performance hit?

<comment><USER15> The Perl 5 core is hack upon hack, to the point that it's been mostly abandoned due to how hard is to change things without breaking anything. Perl 6 was born as a specification, which allows for a "first make it right, then make it fast" approach.

<comment><USER14> That's assuming it can be made fast. It's been stagnant around this level of performance for quite some time now.

<comment><USER16> Unfortunately, the performance of regexes has not been improved much in the past years, that is true and on the radar. Yes, it can be improved (very much indeed).

Most other subsystems of Rakudo Perl 6 __have __been improved significantly, some by orders of magnitude. And then there 's work on the basic runtime of MoarVM and its JIT that will benefit _all_ programs running on MoarVM.

The Perl Foundation recently approved another grant for the JIT: [http://news.perlfoundation.org/2018/11/september-2018-grant-...](http://news.perlfoundation.org/2018/11/september-2018-grant- votes.html) about [http://news.perlfoundation.org/2018/10/grant-proposal- moarvm...](http://news.perlfoundation.org/2018/10/grant-proposal-moarvm-jit- comp.html)

<comment><USER14> Perl with poorly-performing regexes is beta software, as far as I'm concerned. Why OOP, junctions and all the less relevant stuff has taken priority over regexes baffles me.

<comment><USER16> Well volunteered!

</comment></comment></comment></comment></comment></comment></comment><comment><USER17> It may be that it's of interest, as an early Perl 6 implementation was written in Haskell (Pugs)

<comment><USER18> I think this Haskell version (pugs) came at a time when perl6-development was somewhat stuck, and it enabled the Perl 6 developers to test new language constructs on an improved runtime (I believe); so Haskell was actually key to Perl 6 development. ([https://gist.github.com/masak/479846/4908b28645b8815d1afe2b4...](https://gist.github.com/masak/479846/4908b28645b8815d1afe2b4d79efa164984b759c))

<comment><USER19> HTML, more readable: [http://strangelyconsistent.org/blog/happy-10th- anniversary-p...](http://strangelyconsistent.org/blog/happy-10th-anniversary- perl-6)

</comment></comment></comment><comment><USER20> It seems to me that Haskell programmers are the least likely to need something like this.

<comment><USER21> To be interested in programming languages generally, I think, is an inherent feature of a passionate programmer.

<comment><USER22> Being neither a Haskellian nor a Perlist, I found the article interesting and I think you nailed the reason why.

</comment></comment></comment><comment><USER23> Actually Perl 6 comes off badly in this comparison. The Haskell expressions are almost always easier to read, understand, reproduce, and overall even shorter.

Nevertheless it shows that Perl 6 can do real functional programming. Even if the syntax looks exceptional sometimes, even for people familiar with Perl 5.

<comment><USER5> It's not a comparison. It's not an appetizer for P6 or ways in which P6 comes off better than Haskell. It's not an overview or tutorial for learning P6 if you come from a Haskell background.

It's for someone who has already decided they like P6, has learned the basics, and wants to tighten up their understanding of P6 as it relates to Haskell things they know. It deliberately picks things that are basic in Haskell even if they're not so basic in P6.

That's why it says:

> Note that this should not be mistaken for a beginner tutorial or overview of > Perl 6; it is intended as a technical reference for Perl 6 learners with a > strong Haskell background.

<comment><USER23> You're certainly right, but that doesn't change my point that, by just looking at the code, Haskell seems to have the better solutions for the problems.

This conclusion is clearly unfair because the author tried to port simple Haskell solutions to Perl.

<comment><USER5> > You're certainly right, but that doesn't change my point that, by just > looking at the code, Haskell seems to have the better solutions for the > problems.

Sure. But that's an inevitable consequence of what the document aims to achieve.

The problems chosen were the ones for which Haskell had simpler solutions.

The point of the document was to help someone who is already motivated to learn P6 and knows Haskell to get to grips with P6.

If the point were to motivate someone who knows Haskell to want to learn P6 then the examples chosen would be ones for which the P6 solution is better than the Haskell one.

</comment></comment></comment></comment><comment><USER24> What's the objective or rationale here? I don't understand why this is interesting.

<comment><USER25> Language compare and contrast is whats interesting to me.

I don't use either day to day but have had some exposure to both. I think both languages will have influence on future of language design at a minimum. Doubtful Perl does a phoenix routine but weirder things have happened.

</comment></comment><comment><USER26> There's also a Python version of this[1], which starts with a discussion about Perl 6's equivalent of print, which is put. This makes no sense to me whatsoever, as print is both a much easier way to say it and _what was used in Perl 5_, but not my circus, not my monkeys. But then it goes on to say:

> There is also say, which behaves similarly, but will call the gist method of > its argument.

And after having read the linked-to docs for say[2] and gist[3], I not only cannot understand what is being said, I have no idea how anyone else could, either.

1) [https://docs.perl6.org/language/py- nutshell](https://docs.perl6.org/language/py-nutshell) 2) [https://docs.perl6.org/routine/say](https://docs.perl6.org/routine/say) 3) [https://docs.perl6.org/routine/gist](https://docs.perl6.org/routine/gist)

<comment><USER27> I've never used Perl6, but it took me about 30 seconds to figure out what 'say' and 'gist' do from the linked docs? 'gist' prints a string representation of an object aimed at being human-readable at the expense of not necessarily being a complete representation (e.g. the doc page gives an example that an array has only its first 100 elements printed followed by a '...'). 'say' is a version of 'put' that does this for every object being printed.

<comment><USER26> So, I sort of took that away from it, but there's stuff in the gist page like:

> The default gist method in Mu re-dispatches to the perl method for defined > invocants, and returns the type name in parenthesis for type object > invocants. Many built-in classes override the case of instances to something > more specific that may truncate output.

And I have no idea how anyone that isn't already fluent in Perl 6 is expected to read that.

EDIT: My point is mostly that it just seems... weird. Like, I get the animating idea of Haskell, even if I don't understand all of the concepts. Perl 6 just seems... alien. It's incredibly funky.

<comment><USER28> I have no problem reading that. Sure, I dont understand it in fine technical detail (what's Mu? An implementation of Perl? A codename for Perl 6?) But I believe I understand enough of it to start using it.

This specific example seems similar to the __repr__ vs __str__ thing in Python, and not very alien at all.

<comment><USER29> As pointed out by others, Mu is the most _undefined_ value there is in Perl 6 and the base root for the immediate child classes ([https://docs.perl6.org/images/type-graph- Mu.svg](https://docs.perl6.org/images/type-graph-Mu.svg)). However, most classes (both built-in and user-defined ones) don't inherit directly from it. Instead, they inherit from Any, which in turns inherits from Mu.

More info about it:

\- [https://docs.perl6.org/type/Mu](https://docs.perl6.org/type/Mu)

\- [https://en.wikipedia.org/wiki/Mu_%28negative%29](https://en.wikipedia.org/wiki/Mu_%28negative%29)

<comment><USER12> Right. Here's a blog post, which, while not directly about Mu (it's about m, a shell script I wrote), has many excerpts about (the original) Mu (from which Perl6's Mu descends, pun intended, ha ha) near the end - some may find them interesting:

m, a Unix shell utility to save cleaned-up man pages as text:

[https://jugad2.blogspot.com/2017/03/m-unix-shell-utility- to-...](https://jugad2.blogspot.com/2017/03/m-unix-shell-utility-to-save- cleaned-up.html)

</comment></comment></comment></comment></comment></comment><comment><USER30> I still can't take Perl 6 seriously with that butterfly logo. Website looks like it's from 2003 as well.

<comment><USER31> Use this one [https://rakudo.org](https://rakudo.org)

<comment><USER30> See that looks nice and the website looks like it was made this decade.

</comment></comment></comment><comment><USER32> I'd like to hear opinions on how the use of sigils and the other syntax oddities like Int:D, Int:U, given, when, etc improves the codabliity/readability of Perl 6 vs other languages. The examples vs Haskell are not helping me understand. Personally I don't think the added verbosity is helping in any way.

<comment><USER5> > The examples vs Haskell are not helping me understand. Personally I don't > think the added verbosity is helping in any way.

It doesn't sound to me like you are the right audience for the document you're reading.

Quoting from that page:

> this should not be mistaken for a beginner tutorial or overview of Perl 6; > it is intended as a technical reference for Perl 6 learners with a strong > Haskell background.

It is not wise to start with a technical reference unless you are already fairly well versed in the basics of the technology you're learning and are motivated to deepen your knowledge of it.

If you are interested in P6 you should start with overview or beginner material. Then, if you have a strong Haskell background, you can refer to the technical reference if and when the overview or beginner material isn't working for you.

(If you are not genuinely motivated to have fun learning P6 then nothing related to P6 will work for you. Are you genuinely motivated to have fun learning P6?)

\----

> I'd like to hear opinions on how the use of sigils and the other syntax > oddities

If you view childishly simple and natural syntax as "oddities" then your mind is already made up that they are oddities.

So the rest of this comment is intended primarily for other readers and secondarily for you on the off chance that you are able to transcend your mind's confirmation bias against the following constructs actually being simple and natural.

> use of sigils

Many programmers think in terms of three fundamental primitive data types from which all other datatypes are composed:

* single items

* collections of numbered things

* collections of named things

P6 adopts this view and assigns three sigils to these three abstract notions.

This makes it both easier and quicker to both read and write code -- once you've learned how they work. In P5 sigils were onerously complex. In P6 they are childishly simple. So now it's also easy and quick to learn them as well as to use them.[1]

> Int:D, Int:U

In P6, every type that's created using any of its type constructors is a sum type with two sub-types. This includes types defined in the standard language such as Int. The sub-types are named D and U. For example, to refer to Int's D sub-type, use `Int:D`.

This makes it easy and quick to read and write code once you've learned what they are. Fortunately, it's childishly simple to learn what they are.[2]

> given

The `given` keyword means essentially the same as the English word `given`.

This makes it easy and quick to read and write code once you've learned the English meaning of `given`.[3]

> when

The `when` keyword hides a good deal of complexity. But one can hop on Wittgenstein's Ladder easily. Because for the first rung, it just means the same as the meaning of the English word `when` used in the context of something that's `given`.

The keyword `when` makes it easy and quick to read and write code once you've learned the English meaning of `when` in the context of `given` -- and it can then be used in other contexts.[4]

\----

[1] 27 second vide clip covers it all: [https://www.youtube.com/watch?v=Nq2HkAYbG5o&t=10m&list=PLRuE...](https://www.youtube.com/watch?v=Nq2HkAYbG5o&t=10m&list=PLRuESFRW2Fa77XObvk7-BYVFwobZHdXdK&index=92)

[2] They're called "type smilies" for a reason. :D is the definite, happy, valuable type. What's `42`? Simple. Definite. Happy. Valuable. Unlike :D, the other subtype, :U, is undefined, unhappy, not a value. What's `Int`? Is it `42`? No, because that would be defined. Every value/object is either definite/happy or it isn't.

[3] From dictionary.com: given: noun: "an established fact"

[4] From dictionary.com: when: conjunction: "in the event that"

<comment><USER29> > In P6, every type that's created using any of its type constructors is a sum > type with two sub-types. > This includes types defined in the standard > language such as Int. The sub-types are named D and U. > For example, to > refer to Int's D sub-type, use `Int:D`.

Probably your comment hints to this already in which case the following will be redundant but I wanted to mention them more explicitly. This is mainly for people unfamiliar with Perl 6.

Using the type smileys(:U, :D) are also ways to specifically match against a type object (`Int`, `Str`, `Rat`, etc.) and an instance object of a type object (-5, 'Hello', 1/5, etc.):

        Int ~~ Int:U;   # True
        -5  ~~ Int:U;   # False
        -5  ~~ Int:D;   # True
        Int ~~ Int:D;   # False

There is also the :_ smiley which is used by default whenever the other two aren't specified:

        Int ~~ Int;     # True, same as: Int ~~ Int:_;
        -5  ~~ Int;     # True, same as: -5  ~~ Int:_;

<comment><USER5> > Probably your comment hints to this already

Regardless, I'm glad you've written your comment to clarify. :)

I'd be delighted to hear about any of the several big or small mistakes I am about to make in the following.

Also an honest opinion about whether the following approach I take boils down to one that is complete gibberish, vaguely interesting but terribly complex, OK but meh, good but a bit abstract, enlightening, or something else. If you do let me know, please clarify whether you mean what you say for just you, or for what you think might be true for others that don't know P6 at all. TIA.

\----

Like a lot of P6 stuff this basic aspect of its type system is both childishly simple but also so general, abstract, and high level, and comes at things from such a different angle than pretty much all other languages, that it can be difficult to explain.

Another attempt at what I was trying to get at in my second footnote in my GP comment...

\----

A P6 type and its two standard sub-types are a simple and fun unification of the universal/existential "quantification" that our inner logician loves and the "article definiteness" distinction recognized by our linguistic side.

From [https://en.wikipedia.org/wiki/Article_(grammar)](https://en.wikipedia.org/wiki/Article_\(grammar\)):

> The articles in English grammar are "the" and "a/an" ... In languages that > employ articles, every common noun, with some exceptions, is expressed with > a certain definiteness, definite or indefinite

From [https://en.wikipedia.org/wiki/Quantifier_(logic)](https://en.wikipedia.org/wiki/Quantifier_\(logic\)):

> The two most common quantifiers mean "for all" [Universal] and "there > exists" [Existential].

\----

:D denotes a definite thing.

It is directly analogous to "the".

The value `42` is considered definite.

Definiteness implies that a thing actually exists. Its the linguistic analog of existential quantification.

Many coders talk about happy/sad path processing. :D is associated with the happy path, perhaps because it has no existential crisis. :D

\----

:U is related to Universal quantification.

As a type, it is also related to "a". Quoting wikipedia:

> An indefinite article indicates that its noun is not a particular one > identifiable to the listener.

:U corresponds to an indefinite thing, something that's only identifiable as a Universal, not a Definite thing.

:U is also associated with Undefined things, even if they are _supposed to be_ undefined.

In the context of talk about happy/sad path processing, :U is associated with the Unhappy path, because it can denote a thing that should be definite but isn't.

\----

As a _value_ , a type name without a `:D` or `:U` smiley is the same as the type name with a `:U`.

As a _type_ , a type name without a smiley is the same as the type name with a `:_`, where the `_` denotes either `D` or `U`.

Thus:

* `Int`, as a thing in of itself, is the same as an `Int:U`.

* `Int`, as a type of thing, denotes either an `Int:U` or an `Int:D`.

<comment><USER29> > ...the several big or small mistakes I am about to make in the following.

Everything you wrote seems fine to me and you even expounded on what I wrote! However, even if it wasn't, I'd be hardly pressed to come up with a response as clever and resourceful as your responses. For this reason, I quite enjoy reading your comments whenever I come across them on /r/perl6 and /r/programminglanguages.

> Like a lot of P6 stuff this... is both childishly simple but also so > general, abstract, and high level... that it can be difficult to explain.

You're totally spot on. The most recent example of my struggle (mainly due to my ignorance of Perl 6 and probably CS concepts too) was the concept of containers and how they interface most assignments in Perl 6. I think the fact that many Perl 6 constructs/concepts, which complex in nature, seem so natural can deceive people who haven't tried it yet. This is because it's easy to overlook (or plainly ignore) how much thought went into both integrating them into the language and make them play nicely together.

\---

Thanks for your comments!

<comment><USER5> > Everything you wrote seems fine to me and you even expounded on what I > wrote!

Given that your reply was just the right sort of clear answer that would make up for my original footnote I was especially happy to riff off your answer and get super detailed again. :)

> I'd be hardly pressed to come up with a response as clever and resourceful > as your responses.

.oO ( Ever too clever by half )

> The most recent example of my struggle (mainly due to my ignorance of Perl 6 > and probably CS concepts too) was the concept of containers and how they > interface most assignments in Perl 6.

Yeah. Simple on the outside so noobs can just do their thing. Rich on the inside so gurus can develop new candy and gourmet meals.

Anyhoo, thanks for your reassuring feedback. :)

</comment></comment></comment></comment></comment></comment><comment><USER33> The lack of maybe or nullable types in perl6 with the need to check for definedness at run-time (Int:D) is one of its major design blunders. Also this syntax!

In cperl I rather use proper maybe types as in every other language. ?Int is (Int | Undef) you cannot use Int? as this would confuse the parser to look for the matching :

<comment><USER5> > The lack of maybe or nullable types in perl6

P6 supports something more powerful and uses that instead:

[https://en.wikipedia.org/wiki/Tagged_union](https://en.wikipedia.org/wiki/Tagged_union)

In P6 the symbol Int, when treated as a type by the compiler, denotes Int:_, which is a sum type, with two subtypes, namely a generically existentially quantified Int (Int:D) and a generically universally quantified Int (Int:U).

Thus Int can be used in the role of a nullable type, but is an improvement in the sense that the equivalent to None (Int:U) encodes its type.

In P6 all constructable types are automatically sum types with :U and :D subtypes.

> need to check for definedness

There is relatively little need for users to check definedness. The language and compiler ensure basic type/memory safety and the user can just write code and it'll automatically be type safe at this basic level.

When the need arises, the user only need type one or two characters in almost all cases (either `:D` if writing a type constraint or `if foo` or `?foo` if writing an explicit check).

> at run-time

In P6 definedness refers to the notion that something actually exists and this is deliberately aligned with the notion that something exists _at run-time_.

Users seldom need to concern themselves with this but when they do the P6 approach is simple and convenient.

> one of its major design blunders. Also this syntax!

I see the Int, Int:D, Int:U semantics and syntax as a design triumph. See another comment in this thread for an introduction to my view: [https://news.ycombinator.com/item?id=18647590](https://news.ycombinator.com/item?id=18647590)

> I rather use proper maybe types as in every other language.

When I read things like "proper" and "as in every other language" in this manner I experience them as appeals to authority.

Perl 6 is not a typical language. Just as Perl 5 isn't either.

For example, a P6 compiler is allowed to statically check that types match at compile time:

        sub foo (Str $bar) {}
        foo 42

yields the compile time error:

        Error while compiling .code.tio
        Calling foo(Int) will never work...

but it doesn't view static type checking as a panacea any more than it considers dynamic type checking as a panacea.

P6, like Perl, is designed around the notion of a this _and_ that view of things rather than an _either_ / _or_ view.</comment></comment>


Ask HN: How to build a resume/get a job as a perennial slacker? - <AUTHOR> Hey everyone, wanted to get some thoughts on my situation.
To be brief: I'm a capable programmer, have been programming since I was 16 (I'm 30 now), built websites, APIs, etc. I have no college education. I live in the US & was born here.
I've never been employed consistently in a proper software development environment, or had a real job. Always made enough money through side hustles, affiliate revenue, app revenue, freelancing sites, etc.
Reality has stricken and it requires me to make more money. I'm very intimated about presenting myself to others. What the hell do I say I've been doing for the last 10 years? Hanging out, surfing, reading books, playing video games, making just enough to get by, not worrying about a career? Because that's the truth.
I don't even know if it's realistic to get a full-time programming job. I want to work remotely 35-40hrs a week and make around 100k. I don't feel that's unreasonable, but maybe it is.
I would be very grateful for any guidance that anyone could provide me. <comment><USER2> Without trying you made a career!

You do you.

Create a resume full of your real and legitimate experience. Chronologically newest to oldest.

For education put any and all certificates and learning you have done to get your projects complete.

Be prepared to be asked the question of why you worked at company x for y months and jumped around a lot. You moved around due to opportunity x or y because of factor a or b. Brush up on data structures and other CS topics. If you don't remember say so. If you have been successful at completing projects you have a work ethic. We hired a developer at 87k full time at my company with no degree based on a strong resume and a strong interview who had, during the interview, exactly what you have, a lack of self confidence. I saw the person under the lack of confidence.

Having a degree does not make the person. I have worked with folks from BS, MS, PhD and with no degree at all, and let me tell you we all screw up at times. It's how you recover and fix the issues that makes you a better programmer. As you self identify as a programmer, you know your limitations; therefore don't hesitate to state them (which has nothing to to with having or not having a degree by the way). If someone rakes you over the coal for not knowing something, it's them you should be concerned about and think twice before accepting a position.

Be you, be honest, try and try again. Nothing comes easy and everything has its price.

</comment><comment><USER3> Talk to a recruiter. They'll help you make your patchy resume look as good as possible.

You may not be a slacker in a different field that you enjoy more, so a career change is also something to consider.

</comment><comment><USER4> Hello, your country's unemployment rate is fairly low, you should be fine.And I believe that experience is more important than a college degree (although It could be nice to have one). And according to yourself you have been doing it professionally for a long time ( 14 years aprox.). Honestly I don't see a problem here, you probably have a nice portfolio already. Good luck.

</comment><comment><USER5> > Hanging out, surfing, reading books, playing video games

I hope you don't lose the above in your journey. It's really important to be content while working</comment>


Show HN: AI-based LifeTracker helps you do the right thing at the right time - <AUTHOR> https://www.producthunt.com/posts/lifetracker <comment><USER2> Interesting idea. Small thing, maybe use another word or phrase in place of "context?" That's word programmers see a lot and understand, but moat people don't.

</comment><comment><USER3> Thanks for mentioning! It's been a long day) Still ahead of Gmail a little bit.

</comment><comment><USER4> alistproducer2 thanks for suggestion - we're thinking about reffering to it as "area or aspect of life".

</comment><comment><USER4> Thanks for sharing, will take a look</comment>


IBM halting sales of Watson AI tool for drug discovery - <AUTHOR> https://www.statnews.com/2019/04/18/ibm-halting-sales-of-watson-for-drug-discovery/ <comment><USER2> I have a friend who is an OB/GYN Oncologist in Indianapolis. Her hospital had IBM Watson Health on campus last year, and she mentioned to me in passing last month that they finally had kicked IBM off of their (learning) university's campus. When I asked her why, she said: "Often times, Watson would recommend courses of treatment that would be completely incorrect, if not detrimental -- or even sometimes lethal -- to the patient. It became more of a hassle than a learning tool."

<comment><USER3> The purpose of such a system should be to give leads for further research. If you treat them as leads and only leads, then bad leads don't matter much.

Unless, the leads are so bad on average that too much effort is spent on vetting them that could be put to better use elsewhere.

<comment><USER4> I doubt that's how Watson is being marketed to customers, though. IBM tends to oversell and under deliver and have grown increasingly desperate with their shrinking market shares in both hardware and services.

<comment><USER3> You can only live on spin for so long.

<comment><USER5> Unless you work as a consultant. Or in Washington.

</comment></comment></comment></comment></comment><comment><USER6> Slightly over a year back, we were contacted by IBM to try out Watson under some program for startups. Starting out, they asked us to give them a try. We gave them a NLP related task and they were confident they would be able to do a good job of it. After multiple meetings over the next 2 months, they barely produced any useful output. In the meantime, an intern with us got a pretty decent solution using just Python. Our management did get invited to lunches and meetings for selling them some more products. During one of such invitations, since our CEO couldn't make it, I was sent. I was surprised by how shoddy their presentation was given that I thought they might not be doing a good job on the problem we gave them but they should be slick on the selling side. Their presentation seemed like it was out of 2005 or something.

<comment><USER7> You know, it would be very profitable for someone to profess an expertise in X, reach out to various companies to help them use X to solve their problems, then simultaneously gain experience in X while patenting the heck out of any problems solved with X.

<comment><USER8> You're describing a person who has a huge amount of expertise in sales.

But a person like that can very lucratively sell actual products that already exist, so why would they want to sell this mysterious X?

<comment><USER9> Because the person is actually a business that:

a) employs enough scientists who know what they're doing and lawyers who know what they're doing to file relevant and defensible patents; and

b) has enough entrenched relationships that they can pay for a sales force what knows what they're doing; but

c) doesn't employ enough engineers who know what they're doing to develop actual competitive products around those patentable ideas.

</comment></comment></comment></comment><comment><USER10> I sincerely hope IBM's failures do not deter further progress in trying to innovate in healthcare technology. I believe healthcare vitally needs GOOD/USEFUL technology and AI applications because medical progress is not advancing quickly enough by several metrics.

I hope IBM continues to fail and becomes a case study in the failure of massive bureaucracy.

<comment><USER11> IBM will not fail, Oracle will fail first than IBM and that's unlikely to happen.

You see, they are NOT tech companies. They have something you would call "tech", they sell something that looks like "tech" but they really solve problems people with access to large amounts of money have.

In other words, they produce cushy and warm beds for C-level execs to have a good night of sleep, and everyone needs some bed to sleep every night..

Technology is a risky and volatile business and IBM has more than 100 years in business.

<comment><USER12> Spot on.

IBM really does capitalize on the adage of nobody being fired for buying IBM. Their biggest strength has been in their marketing rather than actual technology.

Note that, being a large org, they do have teams doing excellent work too. IBM research, some of the cloud, design etc. teams seem to be doing good stuff. But most of it is still overpromising and underdelivering while charging clients a lot of cash.

<comment><USER13> This is less true than it used to be. Oracle/SAP are largely recognized as multi-billion dollar technology quagmires these days; integration has become so much easier that cobbling together a bunch of SaaS solutions to replace a centralized ERP is a viable approach.

Likewise, IBM has become known as a vaporware vendor. They combine the worst parts of management consulting with an offshore / outsourced development process, so I guess it's not a surprise they ended up like all the other companies that sell business tech solutions (Infosys, Wipro, etc). They're often mentioned in the same breath these days.

<comment><USER14> IBM has been banned from our data center for several years. The decision was before my time, but the answer I've been told is overly expensive, unreliable, and poor support when compared to other vendors.

<comment><USER15> In my experience, IBM's support is excellent, bordering on fanatical. It's just that their hardware (in this case, Spectrum Scale and Power9) are preposterously overpriced. Same for their software, if not more so.

<comment> pickle-wizard As a former IBMer I really like the POWER hardware. It is just a shame that it is made by IBM. Like you said IBM stuff is just too damn expensive.

<comment><USER15> Right, I should have pointed that out: the Power hardware is truly incredible, especially the fast I/O to GPUs. There's a reason why the national labs and Google have gone with that architectue.

</comment></comment></comment></comment></comment></comment></comment></comment><comment><USER16> Watson is more a marketing term than a technical connection between products.

I invite you to test "Watson Tone Analyzer" [https://tone-analyzer- demo.ng.bluemix.net/](https://tone-analyzer-demo.ng.bluemix.net/) :

\- "I like this product." => "this is an analytical opinion with neutral emotion."

\- "I like it" => "Tentative, 50% happy answer."

\- "It's not a bad product." => "analytical".

\- "It's not a bad tool" => "joyful answer".

<comment><USER17> \- "Spiders are not insects." => "fear"

Exactly what I expected, and also flat wrong.

\- "There's a monster under my bed." => "joy"

Fascinating.

<comment><USER18> You'd think they'd pair it up with a naive bayes classifier at least.

</comment></comment></comment><comment><USER19> Slowly, I am noticing that people are starting to question the abilities of machine learning systems and, in particular, seeing a lot of the transparent AI-washing that is now going on for systems that aren't AI at all. This is one of the most positive changes in the tech industry, honestly.

<comment><USER20> Machine learning and neural net systems seem to be the inverse of the "uncanny valley", call it the "miraculous hill" if you will.

They're just good enough to, with insane amount of computing resources, churn out economically viable results, but in my opinion they're the biggest setback in actually developing intelligence or cognition in a long time.

There's very little insight to be gained from what they pick up, and they function purely in a stochastic sense. Even the best ML algorithm has no ability to reason at a high level or produce counterfactuals, it works purely by correlation and still, in those 1% edge cases, will be as helpless as anything else.

That might be good enough when selling advertisements, but in automated cars and healthcare treatment, this sort of failure is not an option.

<comment><USER21> ML and neural nets work surprisingly well on a lot of boring but important use cases. Optimizing online ad placement might be humdrum but it's the foundation of a $100B market in the US alone. [0]

In my opinion the real hype is that ML has become so popular that new practitioners tend to forget other analytic techniques like SQL data warehouses. Interestingly these are starting to absorb ML capabilities like logistic regression, which are now accessible through SQL and can benefit from MPP and vectorwise query execute in DBMS types like ClickHouse, Vertica, and Google BigQuery.

[1] [https://www.forbes.com/sites/danafeldman/2018/03/28/u-s- tv-a...](https://www.forbes.com/sites/danafeldman/2018/03/28/u-s-tv-ad-spend- drops-as-digital-ad-spend-climbs-to-107b-in-2018/#31c701a77aa6)

Disclaimer: I work on ClickHouse.

</comment></comment></comment><comment><USER22> Slightly unrelated, but I hope IBM doesn't ruin Red Hat and CoreOS. I would love to see the CoreOS tools to gain more adoption.

<comment><USER23> I'm a long time Fedora user. I love the sane defaults. It's just a solid workhorse. But I've been feeling pretty uneasy about using it lately...

<comment><USER24> Alternatively, a lot more IBMers will be able to use Fedora and it may improve even more. I don't see them having a strong reason to do any damange there.

<comment><USER25> Maybe? IBM is mainly a Windows and Mac house for dev machines, with Ubuntu being a very, very small portion of workstations.

I'm not sure the acquisition will create a mass exodus from the status quo there.

</comment></comment></comment></comment><comment><USER26> I work with a group using machine learning for drug discovery (I'm not a biologist/chemist) but the bio people around me loved to talk poorly about Watson's drug discovery tool.

Lots of focus on the algorithms in the comments here, but from what I could glean generally they lacked domain experts when developing the datasets... we spend 90% just finding the best data... and even then it's tricky. I think they may have had lower standards for the input into the system... garbage in garbage out.

</comment><comment><USER27> a lot of these AI companies products are really terrible. Has anyone ever tried the AI API models from clarifai ? Just so unaccurate. It seems like a scam. I've also had a really bad experience with watson's speech to text apis.

<comment><USER28> Deep learning and machine learning don't work. Quantitative math will always prevail, as it always has. Unfortunately, mathematical research isn't there yet. We don't have models for vision, audition and linguistics. Neuroscience and psychology are in their infancy, a good analogy would compare these fields to where physics was pre-Newton, Galileo era of understanding. I suspect that in the decades to come, these fields will influence mathematics the same way physics influenced calculus. Physics historically had a huge influence on math, in the coming century it will be neuroscience and psychology, in linking brains to behavior, and the quantitative laws that allow brains to give rise to minds.

<comment><USER29> >Deep learning and machine learning don't work. Quantitative math will always prevail,

I have a neural net onboard my phone which automatically detects songs offline and tells me what they are. Is that semantically 'quantitative math' and not machine learning?

<comment><USER28> Quantitative math, or applied math isn't based on fitting data to an arbitrary mathematical structure. It's looking at real life, and deriving the mathematical laws that govern what you see. You could have a neural net predict planetary motion. However, it doesn't know jack shit about physics.

>I have a neural net onboard my phone which automatically detects songs offline and tells me what they are.

MP3 uses something called psycho acoustics, which is a quantitative model on human perception, which is used to eliminate frequencies that can't be heard based on this model.

Your neural network doesn't tell you what features make songs distinct, it's not a quantitative model at all, but a black box heuristic on what the important features are superficially. If actual mathematicians worked on this problem, I guarantee you they'd do a better job, and their models would work on a commadore64, with real time training. Moreover it would tell you things like who is singing, if it's a live performance, which concert it was.

<comment><USER30> " If actual mathematicians worked on this problem, I guarantee you they'd do a better job"

No, this is wrong.

Some of the most brilliant people in the world have been working on image recognition, voice recognition etc. and AI is crushing all of their work.

"Your neural network doesn't tell you what features make songs distinct, it's not a quantitative model at all" \- it doesn't matter at all if our objective is detecting the song. Neither does the mp3 compression algorithm.

<comment><USER28> >Some of the most brilliant people in the world have been working on image recognition, voice recognition etc. and AI is crushing all of their work.

This is very true. I take my stronger statements back, MAINSTREAM mathematicians attempting this problem are all wrong, and have been wrong for 50 years. But you do need the right theory, and the right math that realizes this theory.

"AI" is superficially beating the work in computer vision. Computer vision is complete bogus. The gabor filters, fourier transfroms etc. are all wrong conceptually. The known methods do abysmally on basic tasks like object recognition, texture segmentation etc. But they keep trying it.

I would take this one step further: computer vision, audio and NLP researchers have been stuck in a rut for the past 50 years. DL is beating THEIR math, but this is because of data and computation speed, not because of any insights. But DL is also wrong, and giving you an illusion of progress. Both of these things are doomed to go the way of GOFAI.

I can go into great detail and carefully explain why MAINSTREAM contemporary ideas in math for vision, audition and language are completely wrong, and have been wrong for 50 years. What is the right model? Like I mentioned before, the right ideas are emerging, neural networks will dominate, just not DL.

<comment><USER31> Ok so who are the real, non-mainstream mathematicians who would do better?

</comment></comment></comment></comment></comment></comment></comment><comment><USER32> It seems just like crypto the 'ai' hype cycle is coming to an end with zero achievements to show for itself beyond puffery and premature speculation about radiologists, drivers and others losing their jobs.

And its not just hype, like crypto the ai hype stepped well beyond the line to outright fraud and deception with tech folks trying to pass off backward looking pattern matching as 'intelligence' and hope no one notices. Every single commentator here knows there is nothing in computing or software engineering today that will allow one to 'create' an 'ai' as the world understands the term yet no one questioned pushing intentionally deceptive communication.

This end result of dystopian scaremongering amounting to nothing is there is now zero credibility and extreme suspicion of problematic in-built bias. At the minimum there must be some standards for machine learning solutions to be thoroughly transparent, open to verification and exhaustively tested for racist and sexist bias before any rollout, for anyone who cares about the impact of their work in the real world.

<comment><USER28> There is no "ai", it's the same bull crap we had in the 80s. We haven't had true innovation in this space for a very long time, the current hype was caused by GPU, cloud, and abundance of data for training.

</comment></comment><comment><USER33> How is Watson not the butt of jokes in the tech industry by now? Seriously, never heard anything that didn't end up being smoke and mirrors.

</comment><comment><USER34> I can't read most of that article because it's behind a paywall, but wow, is Watson just the largest attempt to sell vaporware of all time?? They had a super bowl ad!

A few friends from university were hired into the Watson team as hardly technical PMs. I have never heard any of them describe what Watson is or does.

<comment><USER35> I've commented this before, but Watson is nothing but branding for anything IBM does that is somewhat intelligent. There's pretty much no common technology between the different Watson products, so there's no 'core Watson' like many people believe.

Some products with Watson branding are great and industry leading. Others suck. The latter tend to appear in headlines and severely impact the brand they established with Jeopardy and their ads.

<comment><USER36> I suspect what happened was that Watson started out as a single product or focused suite of products. I'm just guessing, but then as the marketing induced hype started and growth/results were not on target , they realized there was a lot of interest in Watson so IBM pivoted and started rolling everything under the Watson brand - products, consulting, cloud stuff, etc. Basically that way they could say Watson was a "success" and internally/externally it would be opaque as to where exactly the profits and losses were.

I say all this because I'm at a place now where this is happening. Hugh company with a supposedly game changing product that is mediocre (at best). Massive marketing campaign for "Product X" that is 100% buzzwords and 200% BS. After constant missed revenue targets and product disappointments internally and externally, company is clearly pivoting (but not saying so) to rolling everything under "Brand X."

<comment><USER37> I worked there (Watson Health) a few years back. All that happened is IBM. That's right. They bought us (a small start-up) and this is what they did in a year to us: 1\. replaced managers with their own who didn't get anything, kind of old date executives taken away from mainframe 2\. banned remote work (this costed them a few brilliant engineers) 3\. opened one huge open space full of noise and chatter, I mean sales team next to the development team, etc (this cost them even more headcount among experienced developers) 4\. For months we did _nothing_! There were whole teams doing nothing for months on an end. I wrote zero lines of code in over 6 month period. Why? Because management didn't know which direction should be taken... and they kept hiring too! They kept hiring new developers when the ones already at place had absolutely nothing to do!

This is from my (simple developer) perspective. Not sure how it looked in sales, among executives, etc. But that was very weird environment.

I had great Manager who asked me to learn react and take courses in react (mind you it was two years back!) As we "might want to do something in react in the future". So I basically spent my last six months there learning React, aka preparing to the job interviews... they even got us paid courses and all. I mean... IBM.

And once they fired me (these were lay-offs, thousands affected, many of them just hired in past year, like myself) I was paid severance pay too. I went there worked a year, last 6 months was learning for job interviews... fantastic pay too. IBM is crazy.

<comment><USER38> What did you end up doing in a period of non-work work like that? Read books?

<comment><USER39> Advise you to read the comment again :).

Spoiler: (s)he learned React.

<comment><USER38> Not sure if I stopped reading early or just didn't comprehend what they had written. Thanks, lol.

</comment></comment></comment></comment></comment></comment></comment><comment><USER40> Basically, Triumph of Sales over Engineering.

</comment><comment><USER41> And now Google is pushing DeepMind Healthcare in England?! Do they not learn from these examples? Anyone who uses EMR knows very well the beauty of copy- paste and this single little convenience is creating more disinformation than the Mt Everest piles of illegible scrawl that used to be medical records. At least in those days, a HUMAN had to write something. And how did everybody forget this little gem from the 1960s: 'GIGO' = garbage in , garbage out. I dont care how many layers your RNN has, it will NEVER get accurate data. Sick people are not reliable sources of info and it takes a HUMAN to strip off all the emotional distortion to get the facts.

</comment><comment><USER42> No surprise here. IBM has stopped producing usable engineering solutions long time ago.

</comment><comment><USER43> Watson's applications outside of a quick search of existing datasets are vaporware. I'm amazed not a single customer has gone public with it when so many of them are whispering about it on LinkedIn.

</comment><comment><USER44> Even Watson wasn't a general AI. Hearing all the anecdotes from folks that tried to use it.. Narrow AI has the attribute that it can't be ported from one field to another. It might win at Jepordy but sucks at Oncology and Drug Discovery. All AI isn't the same. We are general AI and we can solve problems in asymmetrically bad situations. Narrow AI is not portable

</comment><comment><USER45> There have been a couple articles that a lot of issues with Watson was how it was sold. Watson was being sold as sort of a magic drop in solution that could do oh so many things.

In reality Watson took a great deal of work to carefully structure and process data, evaluation of the output, and more thoughtful of approaches to further refine the information and evaluate outputs. It also required a fair amount of involvement with the individual customer's staff. And there was always the possibility that because each use case was different... it simply wouldn't work out.

To some extent it seems like it should have been sold as a journey... not cookie cuter solution for things that Watson had never encountered before.

How do you sell that, I don't know, if I knew I'd probabbly be a pretty good salesman.

</comment><comment><USER46> Good. Focus on the use cases that actually work, namely a chatbot for handling customer service questions and an enterprise search engine.

<comment><USER25> Can't tell if sarcasm, but IBM's had massive headache and trouble in this segment too. Good customer service agents are expensive. Bad ones are cheaper. But both still have a far higher success rate than conversational bots do. And a hybrid approach is, again, harder than one would initially assume (you know... why it's painful and infuriating to press fifteen numbers on the phone to get to a real person? Same concept)

</comment></comment><comment><USER47> 'And the trough is coming...' \- Gartner

</comment><comment><USER30> For reference, here is the IBM Watson VP hustling it [1] on Charlie Rose. Funny in retrospect. Especially that haircut ...

[1] [https://charlierose.com/videos/29530](https://charlierose.com/videos/29530)</comment>


The Broken Promises of MRI/REE/YARV - <AUTHOR> http://timetobleed.com/the-broken-promises-of-mrireeyarv/

<comment><USER2> I think this is a problem that exists across any VM that implements a GC, not just Ruby.

.NET CLR has the exact same problem (perhaps a harder one, since CLR has a moving GC), so anytime they touch GC references (pointers to objects that are collectible) it's always wrapped in an explicit GC stack frame (think GC struct that lives on the stack). Furthermore, all reads/writes are carefully done with macros (which of course expands to volatile + some other stuff) to make sure the compiler doesn't optimize it away.

On the one hand, this is nice because they don't need to scan the C-stack (it scans the VM stack and the fake GC frame stacks -- well it's one stack but you skip the native C frames), on the other hand this means that any time a GC object is used in C code (ok, actually it's C++) they have to be real careful to guard it.

Of course bugs crop up all the time where an object gets collected where it shouldn't have, it happens so often that there is a name for it -- "GC Hole".

Astute readers and users of p/invoke may remark that they don't have to set up any "GC frames" -- that is because this complicated scheme is not exposed outside of the CLR source. Regular users of .NET who want to marshal pointers between native/managed can simply request that a GC reference gets pinned, at which point I'm mostly sure it won't get collected until it's unpinned.

The bad news is I'm almost positive there is nothing you can do with just C here to make this problem go away. You'd want stuff to magically just happen under the hood, and C++ is the right way to go for that.

It's probably possible to create an RAII style C++ GC smart pointer that would be 99% foolproof at the expense of some performance. It gets a little bit trickier if we are doing a moving collector. I am thinking it could ref/unref at creation/destruction, and disallow any direct raw pointer usage not to shoot yourself in the foot.

Of course the people writing the GC still need to worry about this..

<comment><USER3> Anyone who has written an extension to a garbage-collected language in C will have run into this issue. Personally I've written extensions for Guile, OCaml, Ruby, MLton, and Java, and all of them have tricky rules for making your C code safe for garbage collection. Using volatile is the wrong way to do this though... this tells me that the people figuring this stuff out for Ruby don't really know C that well.

</comment></comment><comment><USER4> I do appreciate the technicality of the article, but I'm not sure to agree with the first point of conclusion: how does it makes MRI (and related) 'fatally flawed' though? (real question).

What makes it 1/ irreversible and 2/ bad for today's users?

EDIT: as well, I wouldn't stop using Ruby because of that; I would use JRuby or Rubinius or IronRuby (if I understand well, these ones are not affected?)

<comment><USER5> I fail to see how this is an all hands abandon ship issue. If its a critical issue in all 3 interpreters they should be fixed asap if possible. At worst with a flag.

If rubinius/ironruby/jruby have no issues, this may become moot eventually as rubinius is gaining lots of traction recently and is becoming faster by the release outperforming standard ruby vms in many cases.

<comment><USER6> Neither Rubinius nor JRuby (and probably IronRuby too) have this issue because they all use accurate garbage collection rather than conservative. Accurate requires much more bookkeeping since all pointers must always be properly identified, but if you start writing a system with accurate GC, it's pretty easy. Bugs like this are a direct result of a conservative GC strategy (and these bugs, as I'm sure you got reading Joe's post, really really suck to find).

<comment><USER7> This class of subtle bugs exists whether or not your GC is accurate as soon as you take the red pill and leave the VM environment. If you forget to add your C pointer to the accurate GC's root set, you're just as dead. Related story: <http://news.ycombinator.com/item?id=217189>

<comment><USER6> But that is by definition a tractable problem because the source will show that the root set isn't being used properly. (additionally, in practice this proves to be a rare and easy to fix bug)

</comment></comment></comment></comment></comment><comment><USER8> This post is a weird mix of careful technical analysis and douchey, Zed Shaw- style hysterical overstatement.

However, I would like to see Matz' response to the recommended steps for a fix at the end. Sounds like a reasonable goal to add for Ruby 2.0.

Note to self: Listening to Papoose while writing a technical blog post turns your otherwise important observations into a Chicken Littleish, end-of-the world rant.

<comment><USER9> I kind of branded it a bit "douchey" at first too but then as I thought about it, it seemed remarkably restrained considering he debugged this issue. It's not like this happened all the time, had to get kind of lucky and build and calibrate a system just right to capture it.

I don't intend this to be an inflammatory question, I'm sort of a perpetual ruby novice, it's never been my day job and I've never managed to sort of catch up with the community, as soon as I feel pretty good with something I find it's been obsoleted a couple times. I like it but how does the community at large deal with stuff like this? This guy found a real bug and invested some time in it, do other rubyists just deal with crashes and restart their stuff? Do they just consider it part of "being on the cutting edge?" Or do they not even notice?

<comment><USER10> In practice crashes due to this issue simply do not occur very often. I think I've had the VM segfault twice in the last two or three years.

That's what makes the hyperbolic tone of this article so douchey; he wrote up an interesting dissection of an edge case issue as though it were an ongoing catastrophe, mostly just to inject a bunch of chest-thumping rock-star bravado that added nothing of value to the discussion.

<comment><USER11> I've actually had an ungodly metric ton of ruby segfaults in the past month or so, and almost never before that. At least one of them has definitely been GC- related - see "therubyracer is not thread safe" for one problem I've been running into. You also have to use PassengerSpawnMethod conservative to avoid GC-related failures in passenger with rails 3.1.

I'm not sure if those are both related to this or not, but I've had drastically more segfaults lately than in my past 6 years of ruby programming. It's getting pretty bad imo.

<comment><USER12> but how much of that is the interpreter's fault?

I know I can't run typhoeus + thin on 1.9.2 on OSX as it reliably crashes every ten minutes and I have no clue on how to debug it, but it is not a problem with the interpreter, it's a problem with external libraries.

</comment></comment></comment></comment></comment><comment><USER13> I think this goes to a pretty simple point: anything you have to do by hand you will eventually get wrong. Thus, to a first approximation anything that can be automated, probably ought to. To show off this principle I'm going to show off some of the PyPy source code: [https://bitbucket.org/pypy/pypy/src/default/pypy/module/sele...](https://bitbucket.org/pypy/pypy/src/default/pypy/module/select/interp_epoll.py)

This is the implementation of `select.epoll`. Somethings you'll notice there's no GC details (allocations outside the GC of C level structs are handled nicely with a context manager), and we have a declarative (rather than imperative) mechanism for specifying argument parsing to Python level methods, this ensures consistency in readability as well error handling, etc.

</comment><comment><USER14> Cute. The Boehm-Demers-Weiser collector has GC_reachable_here for this reason. Guile has scm_remember_upto_here since before it switched to libgc. I'm sure other systems have their things too.

That said, I like Handle, the RAII thing that V8 uses. It also allows for compacting collection. Too bad C doesn't do RAII.

<comment><USER4> .Net has GCHandle [1] and I believe the JVM calls to JNI have a similar mechanism (GetXXCritical [2])

[1] <http://www.shafqatahmed.com/2008/05/memory-control.html>

[2] [http://publib.boulder.ibm.com/infocenter/javasdk/v5r0/index....](http://publib.boulder.ibm.com/infocenter/javasdk/v5r0/index.jsp?topic=/com.ibm.java.doc.diagnostics.50/diag/understanding/jni_copypin.html)

</comment></comment><comment><USER15> Can someone dissect this a little more? My understanding is the pointer to str never gets written to the stack, and so str on the heap might get freed before zstream_append_input makes use of it. But how could the GC see this/what is the faulty assumption?

<comment><USER16> The point is that the GC _cannot_ see that and so assumes that the object is no longer referenced and can be freed. A conservative collector works by scanning the live memory of the process for things that look like pointers into the same live memory and then assumes that all objects that are not the target of any of these pointers are garbage. Tough luck if the only reference to a live object lives in a register.

<comment><AUTHOR> registers are scanned, too. the bug is not that the ref is in a register. the bug is that there are no refs anywhere. not on the stack and not in any register.

<comment><USER17> This statement confused the heck out of me (wow! magic free memory) but of course, the pointers are being held to the contents of the memory, just not to the start of the object, which is what the GC cares about.

Perhaps the GC could be modified to track pointers not just to the head of object but to any address within it. Alternatively, C-coders working with Ruby could just say "I'm using this gc object" before calling C code.

I don't see this is a fatal flaw at all. Sounds like its just a bug. Now if, as many here assert, this bug is present all over the Ruby VM, then that's pretty unfortunate. Is that the case, or just hyperbole?

</comment></comment></comment></comment><comment><USER18> So, what this really seems to boil down to, is:

The Ruby C API is returning objects that are not correctly reference-counted for a short period of time and are incorrectly subject to GC.

This doesn't seem fatal to me, just not reasonably fixable from the GC side. It _might_ be true, that a new API is needed to hold refs in the C side.

<comment><USER19> I am apparently in that foolish minority that believes language runtimes should not segfault/corrupt themselves while running correct code. That this problem requires significant effort just to hack around, while actually fixing it would take a major architectural change, is what elevates this from mere "lolwut?" to fatally flawed. There are good alternative runtimes for Ruby, such as the JVM and the CLR, that do not suffer from this problem. Y'all should use them.

Funktacularly yours,

Lil' B

<comment><USER8> If edge case segfaults were fatal flaws Windows should never have shipped. I say 'edge case' because obviously there are millions of lines of Ruby code running for years on MRI/YARV/REE that have not encountered this error often enough to cause the kind of breathless panic you seem to think is appropriate.

BTW the CLR is not a good alternative runtime for Ruby, might not ever be: [http://www.zdnet.com/blog/microsoft/whats-next-for- microsoft...](http://www.zdnet.com/blog/microsoft/whats-next-for-microsofts- ironruby/7034)

You did good work here -- don't hurt your credibility with overstatement.

<comment><USER20> Well, the problem here is that C using gems are going to often be memory corruptingly buggy until and unless either the gem source is updated to declare the proper parts volatile or Ruby's own C API is reworked to evolve this bug out of existence and then gems would have to be updated to use the API anyway.

Both problems are hard and the current state of affairs is apparently some random amount of the time we'll get memory corruption bugs.

<comment><USER21> It's worse than that. We don't actually know where it occurs. There are clearly some gems where it does, but it could also be occurring elsewhere in the VM.

Just figuring this out is a non-trivial project.

</comment></comment></comment></comment></comment><comment><USER22> "Very few people out there know that the volatile type qualifier exists"? Only if there are "very few" kernel programmers, embedded programmers, and others who have used C for anything low-level and/or multi-threaded. Otherwise, no. Sorry, but knowing about it doesn't make you special.

"Volatile" is the wrong fix, by the way. That's just depending on yet another non-required behavior. There is in fact no further reference to "str" between the function call and the reassignment at the start of the next iteration, so there's nothing for "volatile" to chew on. This particular version of this particular compiler just happens to add an extra pair of stack operations in this case, but it's not truly required to. A real fix would not only mark the variable as volatile but also add a reference after the function call. The same "(void)str;" type of statement that's often used to suppress "unused argument/variable" warnings should count as a reference to force correct behavior here.

</comment><comment><USER23> Well plus one for a blog post with a theme song, anyway.</comment>


Is the Internet of Things Secure? - <AUTHOR> http://midsizeinsider.com/en-us/article/is-the-internet-of-things-secure

<comment><USER2> Absolutely not secure.</comment>


We're Bullish on AMP - <AUTHOR> https://trackchanges.postlight.com/were-bullish-on-amp-abfc6e1f10a1 <comment><USER3> I thought AMP was an anti-ad-blocking play. It smells to me like Google is trying to use its dominant position in search to reduce consumer control of the browser; it's a risky road to go down for everyone, including Google.

For me, as long as I disable javascript, the modern mobile web is plenty fast enough. That is, the bits of the web I want to use on the move: mostly text, occasional pictures. It takes real effort to break this with javascript disabled. Most JS on e.g. news sites, blogs, aggregators etc. is tracking and ad related, dynamically adding links to viral content, all that stuff you don't need and dramatically slows down sites through repeated reflow.

<comment><USER4> Yep, this was also incredibly obvious to me when google introduced it. It's such a typical Google move to market something as "better for the web" when what they really mean is "better for our pockets."

Fortunately for anyone with Apple phones, content blockers should still work on AMP pages.

<comment><USER5> Won't things like AdBlock still work on AMP pages? Do people outside the HN bubble turn off javascript to block ads (or for any other reason)?

<comment><USER6> i've seen this assumption made just about every time AMP is mentioned, that it's somehow about preventing adblock. AMP _requires_ that all your ads are specifically tagged as ads, and that no javascript is modifying the page after it has loaded. Instead of making adblocking more difficult, it seems to be going out of its way to make adblocking easier to do and more difficult for publishers to prevent.

</comment></comment></comment></comment><comment><USER7> Working at a media conglomerate I probably have a different take than some - <USER2> love AMP, compared to the alternatives. For personal sites I don't see it as a big deal, but for news sites it's amazing.

The devs working on news sites understand the current state of bloated pages is bad and are eager to create fast, sexy pages. Unfortunately there are entities such as BizDev and AdOps that want to add more stuff to the pages to make more money, and it's easier to quantify ROI for a new ad placement compared to shaving 100ms off page load times. So we end up with dozens of scripts and script loaders and all sorts of other things. Editors and product managers want responsive pages with ad placements and enhanced functionality.

Along comes AMP, and all of the above are freaking out at the loss of control while I'm gleefully looking at super fast loading times and pages that still have most of the important functionality and ads.

Yes, the script size is large, but it will be cached amongst all AMP pages and it's refreshing to not have to think about implementing responsive pages, lazy loading, etc. because AMP handles all that.

<comment><USER8> I have a different media take. Any attempt at making something other than a text article with a photo slideshow attached now carries an SEO penalty. I think that's a shame - not that every article should be some crazy one off creation, but in an industry that desperately needs to innovate and provide value to readers, closing off that many doors strikes me as dangerous.

<comment><USER9> You forgot high CPM auto play video ads.

</comment></comment></comment><comment><USER10> AMP would be commendable if it came about as a open standard, and won in the marketplace.

But it's come out controlled by the major search engine, that will promote and highlight pages in it's search rankings if you adhere to their new "open" standard.

It may still be good, but leaves a bad taste in my mouth.

<comment><USER11> I mean, AMP is a bunch of custom elements and instructions not to use certain features that degrade performance. I'm not sure what part of this you want to be an "open standard", can you be more specific? AMP is more of a best practices guide than anything else.

<comment><USER10> I mean google will show a lightning icon next to pages that follow the AMP standard (and plausibly use it as a positive signal in their ranking algorithm). A competing standard would not have these benefits.

<comment><USER11> I was told by cramforce that there's no need to use AMP if your page is already fast on its own.

<comment><USER10> Would you get the lightning icon without AMP?

<comment><USER11> The lightning icon is a carrot, you're assuming malice where it doesn't exist. The lightning icon will go away when being fast is the expectation.

<comment><USER10> These carrots drive ad dollars, hence my distaste to calling this a "open standard".

As an example, w3c got together to say solid HTTPS websites get a green color in the URL bar. Banks, etc get a higher, more highlighted green color for a special class of certificates. These are open standards that everyone agreed on.

I hope this makes it more clear why AMP is not a open standard.

</comment></comment></comment></comment></comment></comment></comment><comment><USER12> Google reinvented WAP/WML in 2016 because cancerous news sites gone mad with javascript. Cool hack. Waiting for return of ringtones and pagers.

<comment><USER13> And tiny phones as a status symbol. And making sure you are the same network as your mates to call them for free after 6pm and at the weekends. Those were the days.

</comment></comment><comment> squeaky-clean Has anyone else noticed how Google is using AMP to provide content for searches without you ever leaving google.com? Here's an example of a quick search I did for "Sausage Party review" [0]. You can quickly flip through AMP articles by comicbook.com, USAToday, and others while clearly staying within Google.

It seems to me like they're trying this a lot lately, Structured Data is the other example that comes to mind. Creating "web standards", that are supposed to help a website, but are really most helpful to Google and their crawler. Then giving an SEO boost to anyone who uses those standards. And then once enough people are using those standards, just display the relevant parts of the results directly on google.com

I get that it being hosted on Google allows the servers to respond more quickly, but do you think news websites that added these features with the promise of better performance and an SEO boost were aware their articles would be one thumb-swipe away from a competitor's articles?

[0] [http://imgur.com/a/ZDXbQ](http://imgur.com/a/ZDXbQ)

<comment><USER14> Of all the conspiracy theories in this thread, I think "make easily crawlable pages popular again" is the most realistic.

</comment></comment><comment><USER15> I'm not convinced of AMP. I've written before on HN about my own webpage[0] were the average page weighs in at around ~10kb. At one point I was working on integrating AMP and some of the constraints from AMP has made it into the site. Ultimately though the 170kb weight of AMP(17x my average page) is a no go. I think imposing the same constraint AMP imposes on you without actually using their JS is a good idea if you aren't after the special treatment from google. Another downside of AMP is that it just display a completely blank page if the user doesn't have JS enable or blocks 3rd-party JS.

0: [https://hugotunius.se](https://hugotunius.se)

<comment><USER16> If your pages are 10kb then I think you aren't the target audience for amp. They say themselves that amp pages will never be the most light weight of all pages and never faster then perfectly hand tuned pages, just way way better than the current median website that loads MBs from 75 domains and relayouts 50 times before it's done loading.

<comment><USER15> You have a good point all though I'd like to put forth the argument that many websites could just as well focus on reducing their page sizes and external resources instead of/before adopting AMP.

<comment><USER16> As an outsider (not remotely in any position to use amp or not) it looks like one of the positive aspects of amp is a utility with some associated carrot and stick to just get publishers to realize those things really are bad and need to be taken seriously.

</comment></comment></comment></comment><comment><USER17> I recently setup a simple Jekyll blog that conforms to amp[1]. I used Amplify[2], a repo that was on Show HN[3] a few months ago.

There are still a few issues with their docs at this point, but its basically just inline css/js.

[1] [http://ryanmaynard.co/](http://ryanmaynard.co/) [2] [https://github.com/ageitgey/amplify](https://github.com/ageitgey/amplify) [3] [https://news.ycombinator.com/item?id=11287540](https://news.ycombinator.com/item?id=11287540)

<comment><USER18> I loaded this on a 4g connection and it took 14 seconds from click to progress bar disappearing. AMP talks about sub second load times on mobile. What might be in the way of that being realised?

<comment><USER19> I just opened the site in chrome and did a hard refresh on the Good 2G setting of the chrome tools, only took 3 seconds. Maybe you're cell phone dropped the connection or something.

<comment><USER20> It takes about 12 seconds on a 64k connection (the default if you used up your data cap).

In contrast, HN loads in half a second on that connection.

Obvious result: AMP is bloated.

<comment><USER17> I don't think its AMP. I think its my fault. Out of the box, you can't place analytics on the page. There is a special tag for any analytics. It seems I'm getting an error, and so Google has not cached it. Thank you for telling me. I need to debug that.

That being said, I just received 239 ms with Pingdom.[1]

[1] [http://i.imgur.com/qeEyKqL.png](http://i.imgur.com/qeEyKqL.png)

<comment><USER20> Well, cache doesn't matter when the page is almost a quarter megabyte, but you have only a 64kib connection.

The majority of time spent will be on getting the 170kiB AMP lib.

</comment></comment></comment></comment></comment></comment><comment><USER21> I still don't get AMP. It's a different markup. Am I supposed to detect mobile devices (which is a massive pain) and serve them this separate HTML/JS/CSS? Doesn't that defeat the purpose of the responsive design that we've been fighting for? And why is it for mobile only? If it's so fast, why not make it general purpose?

<comment><USER22> Google are very good at pumping out "standards" that fill short term commercial goals while in the meantime making a fragmented pig's breakfast of the rest of the web. Aside from HTML 5 (which I'm coming to accept was justifiably hostile to the W3 process), I have yet to see anything from Quic, SPDY, WebSockets, and now AMP that demonstrates any kind of long term thinking.

WebSockets for a long time (is it still true?) could not run over a SPDY/HTTP 2 connection. SPDY itself had multiple fundamentally incompatible versions in the wild before things settled down (they changed how negotiation was implemented), WebSockets and SPDY duplicate many of the same concepts (yes, really), Quic seems utterly ignorant of the early history of the Internet and the importance of flow control, and now AMP.

AMP it seems to me, is a standard designed around the current era shortcomings in the implementation of Google Chrome (and similar browsers). It's hard to get more myopic than that.

</comment></comment><comment><USER23> > the bad one, in a suit and wingtips, that jets from office to office and > shuts down Google Reader

Ouch, that hit a nerve. Too early in the day, man.

I've seen more AMP pages on the web than I have the Facebook version of it for what it's worth. The article went in to detail about how the pages were designated as an AMP. it seems somewhat elegant. It's opt-in but there's definitely an advantage to adding the mark-up to your page.

</comment><comment><USER24> AMP = the page you should have created originally without bulk, light, fast and readable. But you didn't, and now you have 2 pages to maintain.

</comment><comment><USER25> "The Google AMP Cache is a proxy-based content delivery network for delivering all valid AMP documents. It fetches AMP HTML pages, caches them, and improves page performance automatically. When using the Google AMP Cache, the document, all JS files and all images load from the same origin that is using HTTP 2.0 for maximum efficiency."

So the proxy learns all about my traffic patterns, usage stats and userbase.

It looks like you can't opt-out of this feature or at least I couldn't find it.

</comment><comment><USER26> I like this write up, but it raised a question for me: if Google is serving amp pages directly, how quickly will updates to your page get reflected in Google's cache?

Hardening back to "only two hard problems in programming" and all that.

<comment><USER27> "We're currently working on a programmatic solution for invalidation. We respect max-age headers for deciding when to refetch a page, but will keep serving the last known version until we have done so."

[https://github.com/ampproject/amphtml/issues/1901](https://github.com/ampproject/amphtml/issues/1901)

</comment></comment><comment><USER28> I don't understand why should I put a JavaScript (AMP) file to my web pages while it doesn't have any JavaScript file.

</comment><comment><USER25> From the how-to:

"Contain a <script async src="[https://cdn.ampproject.org/v0.js"></script>](https://cdn.ampproject.org/v0.js"></script>) tag as the last element in their head (this includes and loads the AMP JS library)."

This is the big no go for me here - why would I need an AMP library, hosted on a third party domain I have no control watsoever. They can inject what they like, track initial script load etc.

The same goes on if you want to include further content such as tweets etc.

What do other folks think about these requirements?

</comment><comment><USER29> I love the markets, but would be happy to never see market terms like "bullish" on HN.

</comment><comment><USER30> With Web = HTML + CSS - JavaScript we don't need AMP.</comment>