Hacker Newsnew | comments | show | ask | jobs | submit | BobTurbo's comments login

I would like to point out that I am actually the creator of this idea, and not the author. The author has created a variation in C#, that has some differences.

The original repository is at:


I came up with this idea 2 years ago. Some differences I see between my idea and this c# implementation are:

Or() is confusing by itself. In mine, you pass in objects or strings, such as:

   var regex = new RegExpBuilder()

   var regex = new RegExpBuilder()
Also, all the special characters are escaped properly (\ is not escaped).

There are shortcuts - you don't have to do

you can just do:

In terms of differences between this and VerbalExpressions, verbal expressions is very limited. It cannot represent many quantifiers (eg, at least 3 of something), does not have decent ways to group subexpressions, and so on. It can only represent (in a practical way), about 0.000001 % of regular expressions, as opposed to RegExpBuilder.


You have my support! I read a blogpost showing off your RegExpBuilder and I got inspired to create something similiar (as a chance to improve my regex and coding skills)in C#, although I have some things I would love to do differently than how your lib does it.

Thank you for a great library, after I have reached stable with this C# port, i'd like to create a TypeScript version. I hope you do not have anything against me writing spinnofs? :)


How do you know that they're not censoring edits to make articles reflect more positively on a company with which they have a donating relationship?


I have little knowledge of the latest trends in programming languages, but if your example of a good PL theorist is someone who designed LINQ, then I am going to have to take your opinion with a grain.OfType(Salt).Where(m => m.Value.Contains(nothing)).ToList<Salt>().OrderBy(m => m.irrelevance).FirstOrDefault<Salt>();


Actually, you would write that query as:

    var q = from m in grains.OfType<Salt>()
            where m.Value.Contains(null)
            orderby m.irrelevance
            select m;

    return q.FirstOrDefault();
which fits in 80 characters on one screen. From this post and your reply, it seems like the your complaint is that LINQ is hard to understand if you write it poorly. But that's true of most programming.


Yes if you write it like that, it removes one of my complaints, but it leaves the other. You now have inconsistency in the language because LINQ is basically being used as a new type of language added to an existing language. You are working with two languages at once. Why stop there? Why not add python to c#? And every other language. The super language that has everything from everywhere. It is a total mess.


LINQ solves a real business need -- how to access sets of data, regardless of the source, in a uniform teachable way. If you can teach people how to query data structures using a one syntax that is integrated into the language, then you don't have to teach them a different API for every different data source. By encouraging the few API designers to target a standard, the many API consumers can build more reliable code faster.

If you approach it as what it is, yes, a language-integrated query syntax, and avoid the fluent-chaining style most of the time, then you'll see an information-dense productivity booster instead of a "total mess".

The LINQ syntax fits on 1 sheet of paper:

Personally, I look at the two-tier language and library support as a case of "the easy things should be simple, and the hard things possible." That's just my own take, but I find that it guides thought process a little better. I look for a syntax solution first, then rewrite it using a chaining style if I need to (e.g. SelectMany), or possibly split into multiple queries. I don't think I've ever written one longer than 10 lines, properly formatted.

Now, as far as python and other languages are concerned, LINQ is less "python in C#" and more "PEP 202 in C#".


Do you have a specific criticism of Linq, or suggestions to how it could have been designed better?


Yes, it requires a wide-screen monitor. I don't think I can answer the other question as I don't see any value in it. Turning loops and so on into a giant, inflexible (unless you want two wide-screen monitors) daisy-chain of methods does not improve the readability or maintainability of code. It also encourages programmers to perform actions that should otherwise be in "repository" classes, in inappropriate places.

The from item in blah syntax is just SQL rearranged, and SQL isn't as expressive as programming language constructs, so why try to emulate it?

It encourages you to write the grain of salt statement I mentioned earlier, which requires programmers to read through and understand the implementation of what you are doing, instead of it being embodied in a meaningful method and called. Of course you could just wrap that in a method, and slowly grow the line to 2-3 wide-screen monitors as you add more conditions.

The more tools you add to the core of a language, the more of a monstrosity of a kitchen sink it becomes (c#/.NET). Now you can loop over a list in 6 different ways! Hooray! That is why Dart looks good - a few basic concepts that can be used to build things suited to a particular problem.


Well, if your example were meant seriously, it is needlessly verbose. ToList is not necessary in this context, and the type arguments to ToList and FirstOrDefault are not necessary since they can be inferred. And anyway, you can just insert line breaks if you think the chain is too long. So:

          .Where(m => m.Value.Contains(nothing))
          .OrderBy(m => m.irrelevance)
I don't really get your verbosity criticism, sine any alternative I can think of (eg. using for loops) is much more verbose.


I'm not familiar with LINQ, but is that roughly equivalent to

      g.is_a?(Salt) && g.value.blank?
      a.irrelevance <=> b.irrelevance


Ruby tip: Instead of .sort you can use .sort_by.

      g.is_a?(Salt) && g.value.nil?
Edit: Changed from blank? to nil? since that is probably closer to nothing in C#.


thanks. I've been writing Ruby for a few years now and I never knew about sort_by. Looks like is works in 1.8 too, but without the &: syntax

source: http://www.ruby-doc.org/core-1.9.2/Enumerable.html#method-i-...


I actually believe the &:symbol syntax was added in 1.8.7 since I am 100% positive we use that in our codebase which still has not been ported to 1.9.

  $ ruby -e 'puts VERSION; p ["10", "2", "3"].sort_by(&:to_i)'
  ["2", "3", "10"]


Rails adds it too, even if your version of Ruby does not support it. Yay monkeypatching!

EDIT: said duck typing first. It's too early for thinking.


var saltGrains = new List<Salt>();

foreach (var g in grains) {

    if (g.TypeOf() == "Salt" && g.Value == nothing)


saltGrains.sort(m => m.Value.irellevance);

return saltGrains.First();

or something.


The devices are fast enough, but with that speed came massive battery life problems. Therefore, the same problem exists, its effects have just moved somewhere else. It is therefore not comparable with the desktop.


google+ is dead. Google doesn't have the talent.


google+ is dead. Google doesn't have the talent.

They have the talent, they just aren't sure what to clone.


Applications are open for YC Winter 2016

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact