Overloading short-circuit

Pages: 1234
closed account (iw0XoG1T)
I am so tired of this loser (xorebxebx), I write programs everyday and I am not a programmer (I did not go to school for it) but my office has data that comes the way it comes, and this data needs to be analyzed in a reasonable amount of time and I can solve those problems.

Sometimes people look at my work and say it could have been done easier this way or that way, but they did not solve the problem, I did.

Any loser can learn a language and copy someone else's code, the guys that get paid get the work done. That's right I get paid and I am not a programmer I am a total beginner.

What is your point that someone smart somewhere solved a problem using scala—who cares. Every days uncountable problems are solved with the C++ tool.

Show us one real problem you solved—or admit to being one of those language lawyer loser that can't find work.

C and C++ were written by the type of people who solve problems.
I've already made someone at this forum take a closer look at Scala, so there **is** a point in posting critical posts on C++ on C++ forum.
But you did not convince them C++ sucks. I could right now go and give Scala or any other language a try, after a few months conclude that it's a better designed language than C++, and still insist that C++ outperforms it in certain domains.
If you just wanted people to try out something different, there are much more efficient ways of doing it. A simple "hey guys, have any of you tried out X? It has such and such features and performs reasonably well in such and such situations" would have gotten you much better results than antagonizing half the forum.
But that wasn't your goal. Your goal was either to troll or to simply bitch about C++. I'm inclined to the former.

By using this personal argument you have definitely lost the discussion.
So, someone asks you for credentials and your response is not to give them, but to first say something stupid about logic, then pretend there's been an ad hominem when they call you out on your bullshit.
PROTIP: in a debate, it's more important to convince your opponent that your reasoning is sound than to actually have a sound reasoning. With this brilliant stratagem, you have utterly destroyed any chances of doing that. Well done. I couldn't have done it better if I had access to your account.
Last edited on
It wasn't the posts being critical of C++, it was more that Scala looks like an interesting language and I want to learn lots of languages.
closed account (EzwRko23)
C and C++ were written by the type of people who solve problems.

So is any other language.


Show us one real problem you solved—or admit to being one of those language lawyer loser that can't find work.


Just this one among many others:
http://www.springerlink.com/content/gg21605m7k348476/

For this to be tested we had to implement about 50% of the RDBMS, with the query optimizer much more advanced then the ones found in open source database systems like PostgreSQL or MySQL. We also reimplemented some algorithms used in IBM DB/2 and MS SQL Server (in a tight cooperation with people from IBM and Microsoft) as reference algorithms to compare to our method:

http://portal.acm.org/citation.cfm?id=847390
http://portal.acm.org/citation.cfm?id=1731357

Ok, now your turn. Show me a paper of yours in a **reviewed** journal or proceedings, describing that you solved or improved solution of some important hot problem.
Answering noob's questions on forum or writing programs "on your own" doesn't count.


It's not, overloaded operators are meant to behave as functions


C++ operators are not functions. So this is another inconsistency or at least violation of the least astonishment rule. Operators are functions in Scala, C# and Haskell. And they work consistently there - there are no special or exceptional rules.


Almost no programming languages can be described by an unambiguos LL context-free grammar


Huh? Languages with LL grammar: Java, C#, Scala, LISP, Pascal, Basic, Haskell (list is not complete). C and C++ are the only I know that disallow the compiler writer to separate syntactic and semantic analysis passes.


The two things are not related and 'compatible compilers' really means nothing, the produced object code may not be compatible but I can't see if this is an issue


2 weeks ago I compared performance of some Scala code to some C++ code posted on this forum. Guess what? The C++ code snippets copied from the forum **did not compile** on my computer. Why? Because I had probably a newer / more strict version of the compiler. I had to add "typename" here and ther. So, after more than a decade from the last standard release, compilers still interpret things differently. Forget binary compatibility - it is not even theoretically possible under assumptions that were made in the C++ standard.
Last edited on
Link 1 wrote:
Authors: Piotr Kołaczkowski and Henryk Rybiński
Link 2 wrote:
Author: Alan Skelley
Link 3 wrote:
Authors: Nicolas Bruno and Surajit Chaudhuri

I'm confused. You had a part in these books, yes? Then why is/are the author/s different for each one?
closed account (EzwRko23)
No. I have part in the first one, although I know some of the coauthors of 2. and 3. personally. The 2. and 3. are examples of algorithms we reimplemented on our own to compare with our approach in link 1. These are not algorithms as simple as QuickSort. You wouldn't be able to touch the topic without having at least some basic infrastructure for evaluating query plans, compiling SQL, managing index metadata etc.
Last edited on
http://www.springerlink.com/content/gg21605m7k348476/
For this to be tested we had to implement about 50% of the RDBMS, with the query optimizer much more advanced then the ones found in open source database systems like PostgreSQL or MySQL. We also reimplemented some algorithms used in IBM DB/2 and MS SQL Server (in a tight cooperation with people from IBM and Microsoft) as reference algorithms to compare to our method:

http://portal.acm.org/citation.cfm?id=847390
http://portal.acm.org/citation.cfm?id=1731357



COOL, that's really great you did that, here's my achievement.

http://www2.research.att.com/~bs/

welcome to the anonymous world of the internet nimrod, copying some link and saying you achieved what it entails is about as factual as me claiming to be a challupa. It sounds neat, but in no way is remotely true.
closed account (EzwRko23)
The last two links are links to **reference** algorithms we **reimplemented** (and confirmed the results of Bruno and Zilio, by the way). Can't you read? I stated it in the first post. I gave these links because our research is competitive and to illustrate the complexity of the problem - e.g. the evolutionary approach we used is several times faster than the MS SQL method but also achieves sometimes worse results (actually from 30% worse to 20% better in some cases). This is not a research just for the purpose of doing research.
Last edited on
xorebxebx wrote:
You wouldn't be able to touch the topic without having at least some basic infrastructure for evaluating query plans, compiling SQL, managing index metadata etc.

I don't know if this was intentional, but it just sounds like this:
I came up with a new theory of how particles gain mass, but YOU wouldn't understand so there's no point in me explaining it
closed account (EzwRko23)
No, I didn't mean this. I just want to show how large amount of work it was and how complex the problem is. If someone ever bother to read these articles ofc. I can explain if you wish, but it would be extremely off-topic.


welcome to the anonymous world of the internet nimrod, copying some link and saying you achieved what it entails is about as factual as me claiming to be a challupa. It sounds neat, but in no way is remotely true


So please ask any question on any of these articles and I will prove you are wrong. ;)
Last edited on
That is entirely irrelevant to what I just stated. you posting a link with no way of proving that it was indeed you who developed it, is in no way a rebuttal to "What problems have you solved"

and I apologize for the slow internet, I over shot my bandwidth allocation last night at University and have dialup till monday.
Last edited on
I hate when that happens; luckily I have unlimited now.
Edit: Subject to fair use, of course
Last edited on
No you will prove you have studied them. and their sources. See in the real world, (unlike the fantasy world you live in), the one true way to prove you are who you say you are is with documentation. And even then there is the whole identity theft thing.
closed account (EzwRko23)

That is entirely irrelevant to what I just stated. you posting a link with no way of proving that it was indeed you who developed it, is in no way a rebuttal to "What problems have you solved"


If links are not sufficient, maybe some source code?
You cannot google it anywhere. This is the first time I post this part of code on the Internet (it is just a submodule of the whole 100+ kloc system, so don't try to compile this)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
package pl.pk.dbtuner.query.optimizer.dynamic

import pl.pk.dbtuner.query.algebra.scalar.Predicate
import pl.pk.dbtuner.util.SetUtil._
import pl.pk.dbtuner.util.Skyline

import scala.math.max


/**
 * Rule telling, that some tables can be joined.
 * Implementations may contain some additional data like join predicates, to actually
 * perform the joining. However those details are not used by the optimizer.
 */
trait AbstractJoin[Table] {
  val tables: Set[Table]
}


/**
 * An abstract query plan tree providing data required for the optimizer.
 */
trait AbstractTree[Table, Predicate] {

  /** Tables used by this tree */
  val tables: Set[Table]

  /**
   * Join predicates used in this tree.
   * If two trees have different predicates, they are considered different.
   */
  val predicates: Set[Predicate]

  /**
   * Lower bound cost estimate for this node.
   * Usually the cost of returning the first tuple.
   */
  val minCost: Float

  /**
   * Upper bound cost estimate for this node. Usually the cost of
   * returning all of the tuples.
   */
  val maxCost: Float

  /** Hidden cost is a possible cost that using this node can cause for its parents. May be negative. */
  val hiddenCost: Float

  /** Number of rows that the root of this tree is going to return */
  val rows: Float
}


/**
 * Date: 2010-01-31
 * Time: 16:33:44
 *
 * Implements a query plan generator based on dynamic programming approach (Selinger, 1979)
 */
trait AbstractJoinOptimizer[Table] {

  protected type Order
  protected type Tree <: AbstractTree[Table, Predicate]
  protected type Join <: AbstractJoin[Table]

  /** Plan leaves */
  protected val leaves: List[Tree]

  /** AbstractJoin specifications telling which node can be joined with which one */
  protected val joins: List[Join]


  def levels = leaves.groupBy(t => t.tables).size

  def optimize: List[Tree] = forest(levels)(prune _).last

  def optimizeMax: List[Tree] = forest(levels)(pruneMax _).last


  /**
   * Generates a forest of trees:
   * starting from the one-table plans and finishing at n-table joins.
   */
  private def forest(n: Int)(implicit prune: (List[Tree], Int) => List[Tree]): List[List[Tree]] = {
    if (n <= 1) {
      val p = prune(leaves, Int.MaxValue)
      List(p)
    }
    else {
      val f = forest(n - 1)
      val p1 = products(f)
      val p2 = prune(p1, 500)
      f ::: List(p2)
    }
  }


  

  private def negativeOrZero(x: Double): Double =
    if (x < 0.0) x else 0.0

  private def positiveOrZero(x: Double): Double =
    if (x > 0.0) x else 0.0


  private def prune(trees: List[Tree], limit: Int): List[Tree] =
    prune(trees, Skyline.weakParetoMax[Tree, Double, Double](_,
      x => -(x.minCost + negativeOrZero(x.hiddenCost)),
      x => -(x.maxCost + positiveOrZero(x.hiddenCost))), limit)


  private def pruneMax(trees: List[Tree], limit: Int): List[Tree] =
    prune(trees, Skyline.weakParetoMax[Tree, Double, Double](_,
      x => -(x.maxCost + negativeOrZero(x.hiddenCost)),
      x => -(x.maxCost + positiveOrZero(x.hiddenCost))), limit)


  /**
   * Removes suboptimal trees from the list.
   * AbstractTree is considered suboptimal if its minCost and maxCost are
   * both higher than any other tree with the same set of result tables.
   *
   * @arg trees list of trees to be pruned
   * @arg df domination function that prunes semantically equivalent trees
   */
  private def prune(trees: List[Tree], df: Iterable[Tree] => List[Tree], limit: Int): List[Tree] = {
    val groups: List[List[Tree]] =
        trees.groupBy(t => (t.tables, t.predicates)).values.toList
    val pruned: List[Tree] = groups.flatMap(df)
    val byPredicate: List[List[Tree]] =
        pruned.groupBy(_.predicates).values.toList
    byPredicate.flatMap(_.toList.sortBy(_.maxCost).take(max(1, limit / byPredicate.length)))
  }



  /**
   * Join trees in such a way that they produce trees with exactly n leaves.
   * For example, given 3 lists of trees:
   * 1. a, b, c
   * 2. (a,b), (b,c)
   * 3. (d,e,f)
   * calling it with n = 4 yields:
   * (a,b,c), (c,a,b)
   * calling it with n = 5 yields:
   * (a,b,d,e,f), (b,c,d,e,f)
   */
  private def products(forest: List[List[Tree]]): List[Tree] = {
    val p =
      for ((i1, i2) <- forest.zip(forest.reverse).take((forest.length + 1) / 2))
        yield product(i1, i2)
    p.flatten
  }


  /**
   * Returns all valid join combinations that can be
   * created from two lists of trees.
   */
  private def product(t1: List[Tree], t2: List[Tree]): List[Tree] = {

    def matchingJoins(s1: Tree, s2: Tree): List[Join] =
      joins.filter(j => {
          val left = j.tables intersect s1.tables
          val right = j.tables intersect s2.tables
          !left.isEmpty && !right.isEmpty && left.size + right.size == j.tables.size
      })

    def simpleJoins(s1: Tree, s2: Tree): List[Tree] = {
      val m = matchingJoins(s1, s2)
      if (!m.isEmpty)
        join(s1, s2, m)
      else
        Nil
    }

    def cartesianJoins(s1: Tree, s2: Tree, rowLimit: Float): List[Tree] = {
      if (s1.rows * s2.rows > rowLimit)
        Nil
      else {
        val m = matchingJoins(s1, s2)
        if (m.isEmpty)
          join(s1, s2, m)
        else
          Nil
      }
    }

    def joinUsing(joinGenerator: (Tree, Tree) => List[Tree]): List[Tree] = {
      for (s1 <- t1;
           s2 <- t2 if !(s1.tables containsAny s2.tables);
           j <- joinGenerator(s1, s2))
      yield j
    }

    val joins1 = joinUsing(simpleJoins)
    val rowLimit = (List(Float.MaxValue) ++ (joins1 map (_.rows))) min
    val joins2 = joinUsing(cartesianJoins(_, _, rowLimit))
    joins1 ::: joins2
  }
      

  /**
   * Joins two trees using various join algorithms.
   * The implementation need not check for correctness of the input parameters.
   * @param t1: left tree
   * @param t2: right tree
   * @param joins: joins that should be all used to produce every tree returned by the result
   * @return list of possible results
   */
  protected def join(t1: Tree, t2: Tree, joins: List[Join]): List[Tree]


}
Last edited on
1) I still dont know that you wrote that.
2) it could be open source
3) if not you just violated the contract for what ever company you MIGHT work for and if/when they find out you WILL be sued.
closed account (EzwRko23)
1) so can be said about any code posted on this forum
2) so google for it, good luck ;)
3) don't worry, I have full copyright to it because I'm the only author of this piece of code; anyway it will be published on BSD or MIT license soon
Last edited on
don't worry, I have full copyright to it because I'm the only author of this piece of code; anyway it will be published on BSD or MIT license soon
You posted it without copyright notice...

BTW I want to say this:
OK xorebxebx, you convinced me. C++ sucks and Scala will be the most popular language in the future.
But... who cares anyway? This is cplusplus.com, not scala.com
I thought everything you create is automatically "All rights reserved"?

Also he said "I have full copyright to [the code I just posted]". I don't know if that counts.

Also
xorebxebx wrote:
it is just a submodule of the whole 100+ kloc system
closed account (EzwRko23)
Posting a 215 loc code snippet from a 100+ kloc system can be viewed as a "citation". There is nothing novel in this piece of code, it is just an implementation of Selinger's paper from 1979 with some minor changes like the ability to consider cartesian joins in some cases. So, you can use it as you wish (e.g. for your homework from database system implementation theory course, if you attend one).


C++ sucks


C++ does not suck, unless you try to "boost" it to a language it is not (by adding short-circuit behaviour to && using internal interpreter, trying to do multithreaded programming or doing a 20 man-years project in it). It was designed with some requirements in mind, which were IMHO good for that times, but are outdated now (really, outside of embedded software niche noone cares if runtime for language requires 50 kB or 20 MB). I think it could have been quite a good language if BS had not agreed to include so many conflicting features in it and did not require strict source compatibility with C.
Last edited on
>Implying there's any point continuing this argument when it's going no-where and no-one's opinions have been changed.
Pages: 1234