News for hackers. Stuff that matters.
Re:Parallelism in Crystal by DSingularity on Friday September 06, 2019 @07:24PM (#20900772)
Why Crystal over C++?
Re:Parallelism in Crystal by coldtea on Friday September 06, 2019 @08:59PM (#20901127)
Because it's a much saner, coherent, and easier to use language with less footguns...

Now, why not Crystal over C++? Because it's way less mature, with way less documentation, way less resources, way worse tooling, way less libraries, way more implementation bugs, and, if we're realistic, it might never go anywhere...

Re:Parallelism in Crystal by dragonwriter on Friday September 06, 2019 @09:12PM (#20901165)
> Because it's a much saner, coherent, and easier to use language with less footguns...

Which for parallelism probably switches the question to “why Crystal over Pony”, since Crystal seems to preserve the key C++ footguns specifically linked to parallelism.

Re:Parallelism in Crystal by Jenz on Saturday September 07, 2019 @11:41AM (#20904446)
> and, if we're realistic, it might never go anywhere...

I don’t see why this should be the case, unless we as a community decides it will not go anywhere.

Re:Parallelism in Crystal by coldtea on Saturday September 07, 2019 @11:49AM (#20904511)
Most languages never get anywhere.

Languages of the quality of Smalltalk, and Ada, and Dylan, and Self, and CL have vanquished in the margins, and e.g. even something as celebrated as Haskell does hardly better in the industry (some financial companies, this or that project, and so on), so the chances of a new language like Crystal are slim to begin with...

Re:Parallelism in Crystal by Jenz on Saturday September 07, 2019 @01:11PM (#20905091)
Oh yes, been there, done that, created proglangs, and they certainly did not get anywhere. But I feel Crystal has already gained such momentum that it indeed will get somewhere, it’s beyond that phase "to begin with." After all, if any language can get anywhere, why not Crystal?
Re:Parallelism in Crystal by coldtea on Saturday September 07, 2019 @06:08PM (#20906902)
>But I feel Crystal has already gained such momentum that it indeed will get somewhere, it’s beyond that phase "to begin with."

Let's hope so, but I fear that's wishful thinking. What proof do we have of that?

It's not used anywhere important ("killer app"), barely makes the rest of the TIOBE index, along with staples like NATURAL, Alice, BBC Basic, Euphoria, Factor, Forth, and Icon, and has no major force like Google or Mozilla backing it.

It's only us here in HN who keep hearing about it.

Julia has had tons more publicity (even from some major outlets), and it's still going nowhere fast.

Re:Parallelism in Crystal by Jenz on Sunday September 08, 2019 @02:14PM (#20912265)
> It's only us here in HN who keep hearing about it.

Don't you think us here at HN include quite a number of people standing centrally when it comes to "anywhere" in the tech industry? This is what I mean, when talking about "us as a community." Of course this does not go for everyone... but for a considerable amount, I'd say. (Myself am certainly not one of them.)

> Julia has had tons more publicity (even from some major outlets), and it's still going nowhere fast.

Well, Julia being made for extensive numerical computations and the like, I think it is doing very well, esp. in academical use, which is somewhere it's right at home. If not yet very much in use yet, at least many academics in relevant fields--which frankly are quite a lot days--have heard of the language. If Julia holds enough of its' promises, I don't see why they wouldn't migrate eventually, given time.

I don't see how any lang could get anywhere "fast," no matter how superb it'd be, "anywhere" tends to be sceptical of change if they're fine with what they have.

Re:Parallelism in Crystal by ravenstine on Friday September 06, 2019 @08:02PM (#20900919)
Why C++ over assembly?
Re:Parallelism in Crystal by imtringued on Saturday September 07, 2019 @07:38PM (#20907446)
Because you are tying yourself to a specific ISA. This is bad even within the same chip family. If you want to migrate your x86 32 bit code to 64 bit then you have to rewrite everything.
Re:Parallelism in Crystal by DSingularity on Friday September 06, 2019 @11:38PM (#20901644)
I’m asking because they presented Crystal as Ruby with OOP and high performance. I’m asking because I’m curious, is it the ruby syntax that much better?
Re:Parallelism in Crystal by pmontra on Saturday September 07, 2019 @03:01AM (#20902242)
Coming from C (no ++) and Java the first thing I noticed after a month with Ruby (in 2005?) was that I didn't write any for loop. I mean, those useless for (i = 0; i < length (array); i++). They become array.each. Then I loved the blocks and later on the postfix if and unless. It's not perfect, it's got its quirks and metaprogramming sometimes is easier in Python, sometimes not, but overall it's the easiest language I used so far. I never tried Crystal because of the compilation step. I really don't need the extra speed for my sw and no customer asked me Crystal so far. I guess it's going to be a similarly pleasant experience.
Re:Parallelism in Crystal by e12e on Saturday September 07, 2019 @05:43AM (#20902800)
> metaprogramming sometimes is easier in Python, sometimes not

Now, I've been exposed to more ruby, and more metaprogramming in ruby, than in python - but this stil surprises/intrigues me.

What kind of metaprogramming do you find easier in python?

Re:Parallelism in Crystal by pmontra on Saturday September 07, 2019 @05:55AM (#20902827)
If I'm not wrong I can add a methods like this

  def m2():
   print("nuovo")

  object.new_method = m2
instead of redefining the class. It's similar to JavaScript. However I don't have a computer at hand now. I can't check the details and what could be done on Ruby.
Re:Parallelism in Crystal by qquark on Saturday September 07, 2019 @08:21AM (#20903326)
This may be what you're looking form, to add a method to a single instance, although the syntax is clearly not as smooth: https://stackoverflow.com/questions/1887845/add-method-to-an...

OTOH, if your problem is slightly different, I find the syntax to add methods to any class very practical and powerful, with of course the caveat that you can produce a maintainability nightmare if overused:

  irb(main):001:0> a = 1
  => 1
  irb(main):002:0> class Integer
  irb(main):003:1>   def hello
  irb(main):004:2>     puts "world"
  irb(main):005:2>   end
  irb(main):006:1> end
  => :hello
  irb(main):007:0> a.hello
  world
  => nil
Re:Parallelism in Crystal by weaksauce on Saturday September 07, 2019 @10:38AM (#20904004)
That’s a pretty shallow view of easier metaprogramming. Ruby allows for many different ways to metaprogram. You can open up any class at any time and create new methods on the class, you can even add a new method directly on an individual instance of a class without changing any other instantiated objects of the same class. I’m just scratching the surface of what’s available wrt metaprogramming in ruby. The ease of metaprogramming in ruby is specifically why rails was easy to write.
Re:Parallelism in Crystal by d_k_f on Saturday September 07, 2019 @07:52AM (#20903209)
True, unfortunately. You can't pass functions around as first class objects, you'll have to use lambdas or procs for that (although even then composition doesn't work like that in Ruby).

(No judgement from me on whether that's better/worse/about equal, just confirming.)

Re:Parallelism in Crystal by e12e on Saturday September 07, 2019 @02:28PM (#20905604)
I suppose in ruby you'd re-open Object and add new_method there... (in part by overriding method_missing, maybe).

I wouldn't recommend actually doing that, however.

If actually doing this (adding new method to a class) I think it's quite easy to re-open a class in ruby (see sibling comment(s)).

I can see adding methods actual instances (only) might be more work in ruby though.

What would be the typical use case for a special instance in a given scope, as opposed to a special class in a given scope?

Ed: i see qquark's so link address the technical part: define_singleton_method (so no need to open Object to add that...)

Re:Parallelism in Crystal by todd3834 on Friday September 06, 2019 @11:47PM (#20901675)
You’ll get different answers depending on who you ask but I think most will agree it is much more accessible to new programmers.
Re:Parallelism in Crystal by penagwin on Friday September 06, 2019 @07:26PM (#20900781)
For very similar reasons that they choose ruby over C++ ?
Re:Parallelism in Crystal by odiroot on Saturday September 07, 2019 @06:58AM (#20903035)
To me is just Python-like (or actually Ruby-like but close enough) but with much better performance. I still haven't learnt to use it well though.

It's a joy to write due to its syntax.