HackerTrans
TopNewTrendsCommentsPastAskShowJobs

b2gills

no profile record

comments

b2gills
·2년 전·discuss
I didn't downvote, but this is by far not the first time something like that was stated (Raku being similar to Roku).

I know I'm tired of seeing it, I'm sure others are as well.
b2gills
·2년 전·discuss
I'm sure that there has been more changes from Perl 5.8 to Perl 5.40 than there is between Python 2.0 to Python 3.x (Whatever version it is up to at the moment.)

What's more is that every change from Python 2 to Python 3 that I've heard of, resembles a change that Perl5 has had to do over the years. Only Perl did it without breaking everything. (And thus didn't need a major version bump.)
b2gills
·2년 전·discuss
I've often thought of Raku as being a lot like the English language. It borrows heavily from other languages.

Of course since Raku has the benefit of an actual designer, it is more cohesive than English.
b2gills
·2년 전·discuss
I've heard that the best way to solve a hard problem is to create a language in which solving that problem would be easy.

Basically creating a Domain Specific Language.

Raku isn't necessarily that language. What it is, is a language which you can modify into being a DSL for solving your hard problem.

Raku is designed so that easy things are easy and hard things are possible. Of course it goes even farther, as some "hard" things are actually easy. (Hard from the perspective of trying to do it in some other language.)

Lets say you want a sequence of Primes. At first you think sieve of Eratosthenes.

Since I am fluent in Raku, I just write this instead:

  ( 2..∞ ).grep( *.is-prime )
This has the benefit that it doesn't generate any values until you ask for them. Also If you don't do anything to cache the values, they will be garbage collected as you go.
b2gills
·2년 전·discuss
This has nothing to do with the halting problem. And I have no idea why you think there would be 'terrible consequences'.

  2, 4, 8 ... *
The `...` operator only deduces arithmetic, or geometric changes for up-to the previous 3 values.

Basically the above becomes

  2, 4, 8, * × 2 ... *
Since each value is just double the previous one, it can figure that out.

If ... can't deduce the sequence, it will error out.

  2, 4, 9 ... *

  Unable to deduce arithmetic or geometric sequence from: 2, 4, 9
  Did you really mean '..'?
  in block at ./example.raku line 1
So I really don't understand how you would be horrified.
b2gills
·2년 전·discuss
That's nothing, use it to calculate the sum of range of values

  say [+] 1..10000000000000000000000000000000000000000000
Which will result in you getting this back in a fraction of a second

50000000000000000000000000000000000000000005000000000000000000000000000000000000000000

(It actually cheats because that particular operator gets substituted for `sum` which knows how to calculate the sum of a Range object.)
b2gills
·2년 전·discuss
I once heard of a merger between a company that used Java, and another one that used Perl.

After that merger, both teams were required to make a similar change.

If I remember right, the Perl team was done before the Java team finished the design phase. Or something like that.

The best aspect of Java is that it is difficult to write extremely terrible code. The worst aspect is that it is difficult to write extremely awesome code. (If not impossible.)
b2gills
·2년 전·discuss
Many of the features that make Perl harder to write cleanly have been improved in Raku.

Frankly I would absolutely love to maintain a Raku codebase.

I would also like to update a Perl codebase into being more maintainable. I'm not sure how much I would like to actually maintain a Perl codebase because I have been spoiled by Raku. So I also wouldn't like to maintain one in Java, Python, C/C++, D, Rust, Go, etc.

Imagine learning how to use both of your arms as if they were your dominant arm, and doing so simultaneously. Then imagine going back to only using one arm for most tasks. That's about how I feel about using languages other than Raku.
b2gills
·2년 전·discuss
Java inspired the Design Patterns book.

Every Design Pattern is a workaround for a missing feature. What that missing feature is, isn't always obvious.

For example the Singleton Design Pattern is a workaround for missing globals or dynamic variables. (A dynamic variable is sort of like a global where you get to have your own dynamic version of it.)

If Raku has a missing feature, you can add it by creating a module that modifies the compiler to support that feature. In many cases you don't even need to go that far.

Of course there are far fewer missing features in Raku than Java.

If you ever needed a Singleton in Raku (which you won't) you can do something like this:

  role Singleton {
    method new (|) {
      once callsame
    }
  }

  class Foo does Singleton {
    has $.n is required
  }

  say Foo.new( n => 1 ).n;
  say Foo.new( n => 2 ).n;
That prints `1` twice.

The way it works is that the `new` method in Singleton always gets called because it is very generic as it has a signature of `:(|)`. It then calls the `new` method in the base class above `Foo` (`callsame` "calls" the next candidate using the "same" arguments). The result then gets cached by the `once` statement.

There are actually a few limitations to doing it this way. For one, you can't create a `new` method in the actual class, or any subclasses. (Not that you need to anyway.) It also may not interact properly with other roles. There are a variety of other esoteric limitations. Of course none of that really matters because you would never actually need, or want to use it anyway.

Note that `once` basically stores its value in the next outer frame. If that outer frame gets re-entered it will run again. (It won't in this example as the block associated with Foo only gets entered into once.) Some people expect `once` to run only once ever. If it did that you wouldn't be able to reuse `Singleton` in any other class.

What I find funny is that while Java needs this Design Pattern, it is easier to make in Raku, and Raku doesn't need it anyway.
b2gills
·2년 전·discuss
"Actual parsers" aren't powerful enough to be used to parse Raku.

Raku regular expressions combined with grammars are far more powerful, and if written well, easier to understand than any "actual parser". In order to parse Raku with an "actual parser" it would have to allow you to add and remove things from it as it is parsing. Raku's "parser" does this by subclassing the current grammar adding or removing them in the subclass, and then reverting back to the previous grammar at the end of the current lexical scope.

In Raku, a regular expression is another syntax for writing code. It just has a slightly different default syntax and behavior. It can have both parameters and variables. If the regular expression syntax isn't a good fit for what you are trying to do, you can embed regular Raku syntax to do whatever you need to do and return right back to regular expression syntax.

It also has a much better syntax for doing advanced things, as it was completely redesigned from first principles.

The following is an example of how to match at least one `A` followed by exactly that number of `B`s and exactly that number of `C`s.

(Note that bare square brackets [] are for grouping, not for character classes.)

  my $string = 'AAABBBCCC';

  say $string ~~ /
    ^

    # match at least one A
    # store the result in a named sub-entry
    $<A> = [ A+ ]

    {} # update result object

    # create a lexical var named $repetition
    :my $repetition = $<A>.chars(); # <- embedded Raku syntax

    # match B and then C exactly $repetition times
    $<B> = [ B ** {$repetition} ]
    $<C> = [ C ** {$repetition} ]
  
    $
  /;
Result:

  「AAABBBCCC」
  A => 「AAA」
  B => 「BBB」
  C => 「CCC」
The result is actually a very extensive object that has many ways to interrogate it. What you see above is just a built-in human readable view of it.

In most regular expression syntaxes to match equal amounts of `A`s and `B`s you would need to recurse in-between `A` and `B`. That of course wouldn't allow you to also do that for `C`. That also wouldn't be anywhere as easy to follow as the above. The above should run fairly fast because it never has to backtrack, or recurse.

When you combine them into a grammar, you will get a full parse-tree. (Actually you can do that without a grammar, it is just easier with one.)

To see an actual parser I often recommend people look at JSON::TINY::Grammar https://github.com/moritz/json/blob/master/lib/JSON/Tiny/Gra...

Frankly from my perspective much of the design of "actual parsers" are a byproduct of limited RAM on early computers. The reason there is a separate tokenization stage was to reduce the amount of RAM used for the source code so that further stages had enough RAM to do any of the semantic analysis, and eventual compiling of the code. It doesn't really do that much to simplify any of the further stages in my view.

The JSON::Tiny module from above creates the native Raku data structure using an actions class, as the grammar is parsing. Meaning it is parsing and compiling as it goes.
b2gills
·2년 전·discuss
>> magic functions—which behave differently on lists-of-scalars vs. lists-of-lists by special default logic ...

That is completely the wrong way to think about it. Before the Great List Refactor those were dealt with the same by most operations (as you apparently want it). And that was the absolute biggest problem that needed to be changed at the time. There were things that just weren't possible to do no matter how I tried. The way you want it to work DID NOT WORK! It was terrible. Making scalars work as single elements was absolutely necessary to make the language usable. At the time of the GLR that was the single biggest obstacle preventing me from using Raku for anything.

It also isn't some arbitrary default logic. It is not arbitrary, and calling it "default" is wrong because that insinuates that it is possible to turn it off. To get it to do something else with a scalar, you have to specifically unscalarify that item in some manner. (While you did not specifically say 'arbitrary', it certainly seems like that is your position.)

Let's say you have a list of families, and you want to treat each family as a group, not as individuals. You have to scalarize each family so that they are treated as a single item. If you didn't do that most operations will interact with individuals inside of families, which you didn't want.

In Raku a single item is also treated as a list with only one item in it depending on how you use it. (Calling `.head` on a list returns the first item, calling it on an item returns the item as if it had been the first item in a list.) Being able to do the reverse and have a list act as single item is just as important in Raku.

While you may not understand why it works the way it works, you are wrong if you think that it should treat lists-of-scalars the same as lists-of-lists.

>> This attempt to fuse higher-order functional programming with magic special behaviors from Perl comes off to me as quixotic.

It is wrong to call it an attempt, as it is quite successful at it. There is a saying in Raku circles that Raku is strangely consistent. Rather than having a special feature for this and another special feature for that, there is one generic feature that works for both.

In Python there is a special syntax inside of a array indexing operation. Which (as far as I am aware) is the only place that syntax works, and it is not really like anything else in the language. There is also a special syntax in Raku designed for array indexing operations, but it is just another slightly more concise way to create a lambda/closure. You can use that syntax anywhere you want a lambda/closure. Conversely if you wanted to use one of the other lambda/closure syntaxes in an array indexing operation you could.

The reason that we say that Raku is strangely consistent, is that basically no other high level language is anywhere near as consistent. There is almost no 'magic special behaviors'. There is only the behavior, and that behavior is consistent regardless of what you give it. There are features in Perl that are magic special behaviors. Those special behaviors were specifically not copied into Raku unless there was a really good reason. (In fact I can't really think of any at the moment that were copied.)

Any sufficiently advanced technology is indistinguishable from magic. So you saying that it is magic is only really saying that you don't understand it. It could be magic, or it could be advanced technology, either way it would appear to be magic.

In my early days of playing with Raku I would regularly try to break it by using one random feature with another. I often expected it to break. Only it almost never did. The features just worked. It also generally worked the way I thought it should.

The reason you see it as quixotic is that you see a someone tilting at a windmill and assuming they are insane. The problem is that it maybe it isn't actually a windmill, and maybe you are just looking at it from the wrong perspective.
b2gills
·4년 전·discuss
I don't think Perl is really that hard to learn. It does have a few traps for people new to the language though.

Raku on the other hand is easy to learn. Of course it is so easy to learn that knowing another language, any other language, can make it more difficult to fully grasp. That is because Raku is strangely consistent.

Most languages have a set of syntaxes for different actions. Raku has a set of features, and the syntax mostly just falls out from that.

When someone who knows another language tries to learn Raku they naturally translate what they already know to Raku features. That will only get you a surface level understanding of the language. No other language is really comparable.

Raku also has a new view of regexes. In Raku a regex is just a DSL for matching text. So rather than bolt on feature after feature like other languages have done it allows you to embed regular Raku code for situations where that is easier. You can also combine them using grammars (a type of class) to get a full parser out of several parts.

In fact the grammar feature in Raku is the only one that is powerful enough to parse Raku easily. Part of that has to do with the ability to mutate the language.

It has been said that the best way to solve a programming problem is to create a language in which solving the problem is easy. Raku, using that ability, allows you to do that easily.
b2gills
·7년 전·discuss
Note that:

    while (<>) { ($h{$_}++ == 1) && push (@outputarray, $_); };
Would be written as the following in Raku:

    my @output-array = lines.unique;
b2gills
·7년 전·discuss
He has long hair now, which is often under a cowboy hat. He of course still wears hawaiian shirts.
b2gills
·7년 전·discuss
I want to know who taught you math.

Because 2015 - 2000 does not equal 20.

The project started in 2000.

---

It would have been a much worse language if it had been released even a few months earlier. (That was before the GLR landed.)

---

Also just about every time a new feature was added in the first few years the existing features were redesigned so that everything was consistent.

So despite having many features from many languages, it feels like all of those features belonged together.

Because of the time taken back then, it is actually really easy to add new features to the language now. (Try adding first-class regexes to any other existing language.)

For example, all of the normal operators are just subroutines with a special name. Which means you can create a new operator that works exactly like a built-in operator by giving it a similar special name. (From a certain viewpoint, Raku doesn't have built-in operators.)

Also regexes (which have been redesigned to be easier to read) and string literals are actually Domain Specific Languages in Raku. Which means you can also add your own similar feature if you felt so inclined.

---

I like to think of it this way:

A language like Python is a good toolbox.

Raku is also like a good toolbox, except it is also a fully decked out machine shop for creating new tools that no one has thought of yet.

Everyone who has worked in a machine shop knows it takes a few years to get one setup just-right.

---

Also there is a saying:

It can be good, fast, or cheap. Pick at most two.

Raku was created entirely by volunteers, so by definition it has to be cheap.

Which means there was only ever a choice between fast or good.

I'm glad the choice was to make it good rather than fast.

(Especially since the whole reason to create it was to make something that was more good than Perl was at the time.)
b2gills
·7년 전·discuss
Yeah, I don't think that anyone learning Raku that way would realize that the {} in the following is actually a lambda.

    for @a { .say }
So this works in basically the same way:

    my $lambda = { .say }

    @a.map( $lambda );
Or that the pointy block syntax …

    for @a -> $item { say $item }
… works on every keyword of the form `KEYWORD (CONDITION) {BLOCK}`.

    if $a.method() -> $result { say $result }
The pointy block is of course also a lambda.

    my $lambda = -> $result { say $result }
---

Raku is a much more consistent language than beginners expect. The above is just one example of this.

Because it is so consistent; once you learn something in one place, you can use that knowledge everywhere in the language.

But first you have to realize that is even a possibility.

It would take a long time to come to that conclusion if you write Raku by copy-pasting code.

That is because very few languages are as strangely consistent as Raku.
b2gills
·7년 전·discuss
What's surprising is that there is evidence that they originally evolved to deal with the snows of the arctic.

So those feet that are great on sand were made for walking on snow covered ground.

Likewise food is scarce in both the arctic during the winter and in the desert.
b2gills
·7년 전·discuss
I think it would be a better idea to make the minor number be the major number. So skip to 32.
b2gills
·7년 전·discuss
Microsoft had to skip 9 because programmers are lazy.

A lot of programs refused to work if there was a `9` in the version name.

That was of course because those programs needed something newer than Windows 95 or Windows 98. So they just did a string search for `9` in the version name.

There may be a few programs that wouldn't work on `8.9` or `10.9` if they were released for the same reason.
b2gills
·7년 전·discuss
This has the benefit of showing that Perl gets a new version released every year.

I have previously stated that I would like it to be an alias of sorts.

    use v5.30;

    use v2019;
Basically have both of those lines do the same thing.

---

Perhaps even something like:

    use Perl v2019;
(I actually considered posting a module that would make that work.)