dotnetrocks о Nemerle
От: Ziaw Россия  
Дата: 06.10.11 07:39
Оценка: 7 (1) +1
http://www.dotnetrocks.com/default.aspx?showNum=704

Автор LinFu из Австралии рассказывает о метапрограммировании и Nemerle в частности.

Кто-то может передать общий смысл беседы? Я пытался слушать, но ничего толком не понял, английского не хватило.
Re: dotnetrocks о Nemerle
От: Ziaw Россия  
Дата: 06.10.11 08:09
Оценка:
Здравствуйте, Ziaw, Вы писали:

Z>Кто-то может передать общий смысл беседы? Я пытался слушать, но ничего толком не понял, английского не хватило.


Внимательно послушал, вобщем Карл и Ричард стебутся конечно, но о слушают жадно и достаточно впечатлены возможностями языка.

Я не удивлен вобщем-то, когда мс так пиарит рослин, узнать, что есть опенсорсный проект который уже давно умеет все, что обещает рослин должно быть забавно.
Re[2]: dotnetrocks о Nemerle
От: CodingUnit Россия  
Дата: 06.10.11 09:17
Оценка:
Здравствуйте, Ziaw, Вы писали:

Z>Здравствуйте, Ziaw, Вы писали:


Z>>Кто-то может передать общий смысл беседы? Я пытался слушать, но ничего толком не понял, английского не хватило.


Очень забавная беседа, о Н правда только после 30 минут говорят. Но забавно, нас помянули как "russian guys builds nuclear reactor in the basement"
Re: dotnetrocks о Nemerle
От: WolfHound  
Дата: 06.10.11 09:56
Оценка:
Здравствуйте, Ziaw, Вы писали:

Думаю можно попробовать завербовать Филипа для того чтобы он помог решить проблемы с бекендом.
... << RSDN@Home 1.2.0 alpha 4 rev. 1472>>
Пусть это будет просто:
просто, как только можно,
но не проще.
(C) А. Эйнштейн
Re[2]: dotnetrocks о Nemerle
От: VladD2 Российская Империя www.nemerle.org
Дата: 06.10.11 12:13
Оценка:
Здравствуйте, Ziaw, Вы писали:

Z>Я не удивлен вобщем-то, когда мс так пиарит рослин, узнать, что есть опенсорсный проект который уже давно умеет все, что обещает рослин должно быть забавно.


Ты преувеличиваешь. Рослин пока что ровным счетом ничего не обещает. Это шаг в эфолюции. И я уверен, что то что Nemerle есть (и не загнулся) в немалой мере повлияло на них.

До полноценного метапрограммирования в росление еще далеко. Пока что, как я понимаю, он на стадии продвинутого R#-а. Там есть объектный АСТ (но качественный и неизменяемый, что плюс) и отдельный типизатор. Это немаловажная, но далеко не самая сложная и интересная часть. Расширяемого языка нет и пока что даже не озвучиваются планы по его появлению.

Я очень надеюсь, что на базе Рослина можно будет создать более компактную и надежную реализацию немерла, а может и создать аналог немерла с чисто C#-пным синтаксисом. Эдакий Meta C#.
Есть логика намерений и логика обстоятельств, последняя всегда сильнее.
Re[2]: dotnetrocks о Nemerle
От: VladD2 Российская Империя www.nemerle.org
Дата: 06.10.11 12:22
Оценка:
Здравствуйте, WolfHound, Вы писали:

WH>Здравствуйте, Ziaw, Вы писали:


WH>Думаю можно попробовать завербовать Филипа для того чтобы он помог решить проблемы с бекендом.


Да. Я уже думал об этом. Он в твитере ответил, что эксперт по MSIL.

Но Хардкейс, в общем-то, на финишной прямой. Да и в самих бэкэндах не особо нужны знания по MSIL.
Так что его помощь именно в области бэкэндов не очень то и нужна.

Но мне категорически не нравится текущая реализация. Ее нужно переписывать. Вместо ручной работы с MSIL нужен ДСЛ который бы позволял бы описывать кодогенерацию более декларативно.

Кроме того меня просто удручает то что творится на стадиях T2-T4. Это грязный и не внятный код. Буквально позавчера убил более 10 часов чтобы найти одну маленькую ошибочку. Поляки переписывают вызов локальной функции в вызов статического метода и при этом информацию о новом методе помещают в старую функцию! То есть, вместо нормальной, обособленной реализации трарсформирующей одно аст в другое, они тупо смешали все в одну кучу и получили просто клубок непонятного кода. В итоге я исправил всего пару строк кода, но убил на это 10 часов .

Вот тут его помощь могла бы быть очень полезной. Не знаю только возьмется ли он и потянет ли он такую работу.

Но, спросить стоит.
Есть логика намерений и логика обстоятельств, последняя всегда сильнее.
Re: dotnetrocks о Nemerle
От: Don Reba Канада https://stackoverflow.com/users/49329/don-reba
Дата: 06.10.11 12:38
Оценка: 113 (8)
And this brings us to "Nemérle". Is that how you pronounce it?

It's "Némerlee".

"Némerlee"?

Yeah. Nemerle is not my work. It's actually this very very obscure programming language that runs on .NET. And the thing about Nemerle that makes it so fascinating is that it has language features that aren't even available in C# 5 or even the next versions of C#, simply because of how it is built.

And is it a C-ish language? Does it look like C#?

Yeah, it has a lot of improvements from C#, so for the most part the code is interoperable with C#, and these guys that wrote this compiler are even crazier than I am and they actually used the language itself to create a compiler for C#, so you can add a C# file to a Nemerle project and it would just compile C# as if it was part of the language.

Wow! I'm afraid. I'm very afraid. Well, so you're saying somebody wrote a C# compiler on the side. Right?

No, this is actually crazy, because to prove the power of the language, they used their own language to define the grammar of C# and then compile it using the grammar.

Awesome!! This is like macaroni and cheese dinner. Did you mention being broke before?

Well... I'm still broke!

You spend all your time writing compilers! What's the matter with you? Oh, my God. So, these guys who wrote this compiler, who are they, the Nemerle people?

I'm sorry, I never remembered their full names. I remember their usernames, so they are, like, "VladD2", or something.

So these are the guys that just do this in their spare time? Is this an open-source language?

Yes. I think the license is BSD, and these guys just keep hacking it like crazy. And, if you were to line Nemerle up with the reset of .NET languages, Nemerle is the equivalent of a bunch of Russian guys building a nuclear reactor in their basements, on their spare time.

Yeah, this is what this sounds like. What could possibly go wrong?

Yeah, what could possibly go wrong with a nuclear reactor in your basement? But some of the stuff that they are actually doing with Nemerle is crazy, because one of the big features in Nemerle is this idea that the compiler is a service and it is extendible, the pipeline for the compiler is extendible. So, it's not like C# 5, where you got these immutable trees that you can only read. You can actually have these things, called "macros", which allow you to build language features into the compiler, as it's running. So, you can do things like: add keywords, new operators, you could change classes by inspecting the compiler's internal DOM, so that there are certain conventions that you can follow. So, for example, if I have an NUnit project and I have a class that ends with the word "Test", then it should decorate this class with the NUnit attributes and all public methods on that class should have the NUnit test attribute. So, what's interesting about this, is that when you look at the source code, you don't see any NUnit attributes there, you don't see anything. You just see this class as a "public class FooTest", and you got all these public methods that, when you compile it and look at the source code with ILSpy, what happens is that, all of a sudden, you have all these NUnit attributes on there. And this is something that is not built into the language, and it goes deep enough that language features, such as "if/else", "for", even "while" statements are not a part of the language — they're just macros.

Yeah... That's cra... That is awesome, awesomely crazy. So, I'm thinking now that you would use Nemerle not for, you know, the language features of Nemerle, such as they are, but as a C# programmer to make these conventions, like you're saying, with your testing. You mention that in theory you can make the async/await features as macros.

Yeah, actually, all you would need to do to implement the async or await features is to figure out how exactly they are done in C# and then throw a macro together. And these macros are so powerful that you could actually take somebody else's code, find the exact location where this code is and then put it into these async/await expansions, basically, as you would write it yourself. And when you look at your code, you don't see it there. You just see the keywords. But when it compiles, the compiler just bakes it in and throws your macros out. The thing about Nemerle that really got my attention is that it does the same kind of transformations that you normally have to do with IL, but does it natively with the language.

Wow, powerful.

It has features that C# has only been talking about. We've been talking about them for years, but for one reason or the other, they never made it into the language. Like, for example, design by contract — that's a macro, AOP is also a macro, non-nullable types are, again, they're macros. And the thing is just that the language itself doesn't support these. It just shows up by adding references by these assemblies. And the compiler extensibility is so tight that, if you add a keyword to Nemerle, as soon as you import a reference to that compiler extension, Intellisense actually shows the new keyword as if it was part of the language.

Wow! What are you working on in Nemerle?

Oh, of course, it's IL, but, what I'm doing is that I'm writing my own version of Cecil.

Of Cecil? Ok. Remind us that that is.

Cecil is this library for manipulating assemblies in .NET. It's basically reflection from scratch. The difference between Cecil and your standard run-of-the-mill standard reflection is that System.Reflection is read-only. Cecil, or this thing I'm working on, which is called Tao, is that you can change anything about an assembly. Like, for example, you can change the types, you can add new classes, you can add new methods — anything is, pretty much, open for extension in Cecil. You can do anything you need to do with it that normally would not be allowed in System.Reflection, because they never built it in there.

Ok. So, tell us about Tao.

Well Tao is this project that I've been working on for quite a while now. I think it has been a year. It's, basically, short for "Tao of metaprogramming in .NET" — it's this ability to change not only programs that you write, but programmers that you don't own. And I'm pretty confident that with Nemerle that what I'm going to do is to use Tao to do something that's, pretty much, unheard of, which is to have a decompiler as a service.

A "de"-compiler as a service?

A decompiler as a service. It is this idea that, if you got something like Nemerle, and it has this ability to natively create these extensions, these DSLs, then I should be able to use something like Cecil or Tao to take any given assembly and decompile it up to Nemerle, and then change it and write it back. So, in theory, I should be able to take any sealed or normally inaccessible assembly, like the base class library and change it to do whatever I need it to do.

Now, is an obfuscator powerless in front of you? In other words, do you care if something has been obfuscated?

Well, not really, because there's got to be some entry point, where you actually now what it's going to do. If you could black-box it, then obfuscation is quite moot.

So, we should be afraid of you, basically. If we were to deploy our assemblies to not have people look at them, we should not let them know about you.

Well, in general, I use my powers for good. I haven't killed anybody yet. You know, it's a Spiderman thing: with great power comes great responsibility. Fortunately, I haven't killed anyone yet.

Absolutely. And you believe that users of Tao will be as responsible?

Well, I subscribe to the IAYP ideology, which is "I ain't your pa". Basically, if you are smart enough to figure out what these features do, then you should also be responsible for what you do with them. So, there might be some edge cases, in which it might blow up, but you have this nice thing, called "reality", then tells you what works and what doesn't. So, I'm not restricting what other people can or can't do. So, even if I were to restrict them with whatever language I'm working on, they are going to find a way to work around that and indeed they have. And that's always the case: if you don't provide something in the language, someone, like me, is going to come along and throw it in there, because we actually do need it.

Now, do you thing Nemerle is suitable for use by mere mortals, or do you have to be one of you aliens to get full use out of it?

Well, it's, pretty much, usable by anybody, because it looks like C#, but has a mix of functional features that looks a lot like ML, without the pain of having switched to a functional language. One of the reasons that I chose Nemerle over a more awesome language, which would probably be Closure, is that I can still read the syntax without having to make such a large shift. I don't have to bury myself in parentheses. But for demigod, or for lesser mortals, Nemerle is, pretty much, usable, because it does resemble C#. You could use it just like you would C# without the macros, and it would still be just as useful, but not as powerful, given you could, pretty much, make your own domain-specific language by creating your own keywords, which would automatically be picked up by Intellisense. And the thing you can't do with C#, at least not in near future. Because, fundamentally, Nemerle has this idea that I don't need to wait for the language authors to create something. Because, chances are there has already been a macro for that language feature and it has already been written. And if I go back to that example that I gave, where I have the NUnit tests, what's interesting about that is that I came up with this extension, called "expects", which is this idea that whenever you write an NUnit test, you always have to have this "expected exception" keyword. But what if you could actually extend the language, so that when you declare a method, say "public FooTest expects <this type of exception>", and then, all of a sudden the language is smart enough to throw in the attribute and be able to do these things for you that would be a huge burden on you, if you had to type yourself by hand. So, with Nemerle, you no longer have to work around that language — the language works for you. And that's one thing that I have not seen in any other language right now. Pretty much, we have to wait for Microsoft or whatever the vendor is to extend the language. You, pretty much, are the person that decides what language changes need to be done. There are no longer these syntax hacks that you do in C#. You actually create keywords that make it easier to read your program without having these long statements. It can be, pretty much, anything you want, and that's the power — it's inverting the responsibility, so that you can do what you want and have it just get out of the way.

In some ways, I think the question of what comes next is kind of moot. Once you have this capability, there is not a whole lot of "next". It's up to you what comes next.

Yeah, and I think that's the ultimate goal. Our goal, as programmers, as developers, is to be able to get the computer to do what we want. It's not, necessarily, to throw up obstacles, because we think people might screw up. And sometimes they do, yes, I admit that, but for people who actually have to get the job done, then you definitely need something to reduce the friction. And something like this definitely reduces the friction, because it follows you, and you don't have to necessarily work around it.
Ce n'est que pour vous dire ce que je vous dis.
Re[3]: dotnetrocks о Nemerle
От: Ziaw Россия  
Дата: 06.10.11 15:40
Оценка:
Здравствуйте, VladD2, Вы писали:

VD>Но мне категорически не нравится текущая реализация. Ее нужно переписывать. Вместо ручной работы с MSIL нужен ДСЛ который бы позволял бы описывать кодогенерацию более декларативно.


Я с Филипом изредка общаюсь, как я понял, его Тао и планируется как этот самый DSL. Только умеющий работать со сборками в режиме RW (его идеал, это декомпиляция в nemerle ast и dsl для его анализа и трансформации). Так что не стоит ему мешать доделать Tao.

VD>Кроме того меня просто удручает то что творится на стадиях T2-T4. Это грязный и не внятный код. Буквально позавчера убил более 10 часов чтобы найти одну маленькую ошибочку. Поляки переписывают вызов локальной функции в вызов статического метода и при этом информацию о новом методе помещают в старую функцию! То есть, вместо нормальной, обособленной реализации трарсформирующей одно аст в другое, они тупо смешали все в одну кучу и получили просто клубок непонятного кода. В итоге я исправил всего пару строк кода, но убил на это 10 часов .


VD>Вот тут его помощь могла бы быть очень полезной. Не знаю только возьмется ли он и потянет ли он такую работу.


Врядли. Тем более, по большому счету, она не является жизненно необходимой. Как минимум, надо взглянуть на CTP Roslyn.
Re: dotnetrocks о Nemerle
От: Rival Таиланд
Дата: 06.10.11 21:44
Оценка:
Здравствуйте, Ziaw, Вы писали:

Z>http://www.dotnetrocks.com/default.aspx?showNum=704


Ведущие отличные! Стебутся как надо.
«История жизни – это, по существу, развитие сознания, которое завуалировано морфологией.» Пьер Тейяр де Шарден
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.