169 похожих чатов

Representation at compile time. C compilers view arrays as continous

blocks of memory. Such a representation while producing the expected assembly will reduce the transformations we have at hand for optimizing said strucuture. An example would be slicing arrays where we would have to do thing manually in C/C++ and either rely on templates to abstract it away of be very careful in operating on the array. Higher level languages which view arrays as objects would simply produce two new array objects for us to operate on. This would deal with copying in case we need the original array, in-place modification if we do not reference the original since we can simply treat the new array objects as regular arrays even when they are just "views" of a much larger array. Again in C/C++ you would have to do all of the work manually which is very error prone and is usually avoided as reliable software has a higher value than efficiency of certain operations. We lose a possible optimization simply by C/C++'s representation of arrays not being abstract enough. This is one possible out of many more such as loop fusion which is done but not a guarantee as it is in haskell with folds (if it's an explicit fold we can remove all immediate representations and fuse loops). This is why in haskell we gain performance by using a higher level representation and operations rather than lose it as the compiler has much more to work with. Catamorphisms and Anamorphisms used for mergesort comes into mind as they seem to be inefficient as ana builds structures only for cata to reduce them again directly after. However, given that cata is an explicit fold and ana is an explicit unfold the compiler (GHC) is able to detect this and erase all immediate structures and transform the algorithm to a near hand optimized core representation. Why? Haskell is aware of folds. Could C do such things? No, unless you make C aware of more it is simply not possible to take advantage of such things. Can Java do this? Yes for anything relying on higher level abstract types since the compiler is aware of it.

1 ответов

10 просмотров

Source?

Похожие вопросы

Обсуждают сегодня

а вот интересный вопрос появляется: допустим у нас есть приложение с системой модулей. Будет ли считаться система модуль+прога ассемблерной программой если: а) Прога на Си, м...
Mixail Frolov
29
Может кто встречал такое? Один набор данных, но в одном столбце кодировка нормальная, а в другом ироглифы. Как такое может быть?
Alexander
23
коллеги, добрый вечер! А никто не знает как модальная форма может себя закрыть? Ну допустим модальная форма определила, что смысла ей работать нет и хочет вернуть modalResult...
Михаил
83
И к какой архитектуре привязана Java?
Dmitry Olshansky
17
@Aiwan что такое база образца?
Alexey
27
Всем привет. Подскажите, пожалуйста, почему не ищет русскую букву а? А английскую ищет. Полагаю что-то с кодировкой. Но как исправить это? procedure TfrmMain.btnOpenFileClic...
Евгений
7
Не многие знают, а кто знает, тот уже успел забыть, что в далёком 2004 году эта игра произвела настоящий фурор, настолько революционной была технология, применяемая для её соз...
ICCID
4
Добрый день Хочу начать обучение языку, не являюсь представителем it, буду благодарна за помощь, совсем пока не понимаю ничего) Подскажите, пожалуйста, где можно начать первы...
Sara Lala
30
если не секрет какую?
Mikhail Tchervonenko
7
Хотя у меня сейчас есть более сложная задача, вот её думаю: как объяснить челу переходного возраста противоположного полу, обучающегося в польском колледже (а-ля наш техникум)...
Вячеслав Кузьменко
15
Карта сайта