« first day (786 days earlier)      last day (107 days later) » 

user1804599
10:17 AM
@FredOverflow last time I checked the standard library was tens of MBs of JS code you had to send to the client.
 
user1804599
Though I heard they implemented tree shaking.
 
@райтфолд In recent demos I've seen, it's like 200 kb.
 
user1804599
That's still a shitload of code.
 
user1804599
I'm gonna implement nested comments.
 
user1804599
Which is very easy because Perl allows recursive regular expressions!
 
10:26 AM
@райтфолд How common is that in programming languages? For example, does Haskell do it?
 
user1804599
@FredOverflow No idea, but D has it.
 
user1804599
I don't see why it shouldn't be there.
 
/* string s = "/*"; */ Am I still in a comment or not?
 
user1804599
This matches nested comments: (#\(((?-2)|.)*?\))!
 
user1804599
@FredOverflow Absolutely.
 
10:36 AM
not sure if I like this
 
user1804599
?-2 recurses to the second group before (?-2).
 
user1804599
Which is (#\(((?-2)|.)*?\)).
 
If that's what normal Perl code looks like, I want nothing to do with it.
 
user1804599
11:34 AM
 
@райтфолд Regex diffs... gotta love it or hate it.
 
user1804599
@FredOverflow You can implement diff in Perl as a regex-based substitution. :)
 
user1804599
Perl regular expressions are Turing-complete.
 
user1804599
Here's a JSON parser as a single regex: perlmonks.org/?node_id=995856
 
4427
A: RegEx match open tags except XHTML self-contained tags

bobinceYou can't parse [X]HTML with regex. Because HTML can't be parsed by regex. Regex is not a tool that can be used to correctly parse HTML. As I have answered in HTML-and-regex questions here so many times before, the use of regex will not allow you to consume HTML. Regular expressions are a tool th...

 
user1804599
11:37 AM
You can parse HTML with a Perl regex.
 
user1804599
Even considering the context-sensitivity of HTML!
 
user1804599
<form><form>a</form></form> is the same as <form>a</form> because nested forms are not allowed.
 
user1804599
And "not allowed" in HTML pretty much means "ignore it."
 
user1804599
Here's a quote from WebKit's parser:
 
user1804599
bool HTMLParser::formCreateErrorCheck(Token* t, RefPtr<Node>& result)
{
    // Only create a new form if we're not already inside one.
    // This is consistent with other browsers' behavior.
    if (!m_currentFormElement) {
        m_currentFormElement = new HTMLFormElement(formTag, m_document);
        result = m_currentFormElement;
        pCloserCreateErrorCheck(t, result);
    }
    return false;
}
 
11:40 AM
Do you think we'll ever live in a world where web programming isn't terrible?
 
user1804599
No.
 
@райтфолд Did you start out with imperative git commit messages ("implement" instead of "implemented"), or did you have to learn it?
 
user1804599
I always did it like this.
 
user1804599
It's consistent with the generated commit messages such as "Merge branch X into Y"
 
user1804599
Capitalised, imperative and without full stop.
 
user1804599
11:53 AM
@FredOverflow I'm going to implement function parameters!
 
@райтфолд I always had those. How can you even speak about functions without parameters? :)
 
user1804599
Or rather, procedure parameters.
 
user1804599
I haven't implemented functions yet.
 
Also, by "implement", I only mean static analysis. Nothing runs yet.
 
user1804599
Run it on the Mill VM!
 
user1804599
12:00 PM
 
user1804599
I recently wrote a parser generator, by the way.
 
user1804599
This program reads that file and generates a parser for the instructions: github.com/mill-lang/mill/blob/develop/mill/tools/…
 
2:21 PM
0
Q: Creating only 1 instance or a Singleton

user3328660I used a class called 'City' & there will only be 1 city in the entire game; will it be beneficial to create an instance, if only 1 or a singleton. The class itself will contain methods that won't all be static, & I've read that the singletons themselves consist of static attributes and methods ...

 
 
5 hours later…
7:10 PM
-1
Q: Singleton bewteen many classes

chatteVerteI've got quite disturbing problem with singleton in my project. I created a class called Singleton (how creative) with a variable String name; Then I created another class called Player where I take a name of user. And main class where I want to save the data kept in Singleton. The problem is,...

0
Q: Singleton networking object gives error on second call

fermeriusCommunication class of which singleton object will be created: import java.net.*; import java.io.*; import java.util.Scanner; public class Communication { private static Communication mInstance = null; private static final String REQUEST_LOGIN = "Login"; private BufferedOutpu...

 
 
1 hour later…
8:19 PM
@райтфолд Have you heard of miniboxing yet?
 
user1804599
Nope.
 
It's pretty cool.
It's a middle ground between specialization and boxing.
Basically, it treats all primitive types as longs in boxing contexts.
 
user1804599
Nice.
 
user1804599
func itoa(x: Int = %_) { … }
proc writeln(s: String = %_) { … }

func prime?(n: Int): Boolean {
    if n < 2 {
        return false
    }
    2.^n *> &(n %% &1) |> none()
}

for filter(0..inf, prime?) {
    writeln(itoa())
}
 
Quite a waste for boolean, byte, char and short, but who cares :)
 
user1804599
8:21 PM
By the end of April I want to have this work.
 
Having goals is always good.
Maybe I should set some goals for my project instead of merely sailing along :)
 
user1804599
@FredOverflow Are you saying I should program in a logic programming library?
 
user1804599
@FredOverflow Here are my goals: github.com/mill-lang/mill/milestones
 
:-P
36
Q: Why are `private val` and `private final val` different?

user955091I used to think that private val and private final val are same, until I saw section 4.1 in Scala Reference: A constant value definition is of the form final val x = e where e is a constant expression (§6.24). The final modifier must be present and no type annotation may be given. Refe...

TIL about final val
 
user1804599
private[this] is useful as well.
 
user1804599
8:26 PM
class T[U] // invariant in U!
class V[+W] { // covariant in W!
    private val x: T[W] // error
    private[this] val x: T[W] // OK
}
 
user1804599
> Perl 6 is a sister language of Perl 5 similar to how C# is a sister language of Java. And I also mean that in terms of quality.
 
user1804599
LOL!
 
Who said that?
 
user1804599
Some Perl 6 guy.
 
user1804599
> subset NonEmptyList of List where *.elems > 0
> sub f(NonEmptyList $xs) { }
sub f (List $xs where { ... }) { #`(Sub|140200819584320) ... }
> f((1, 2, 3).list)
> f(().list)
Constraint type check failed for parameter '$xs'
 
user1804599
8:29 PM
This is cool!
 
user1804599
have to login
 
You can do it via Google.
 
user1804599
don't wanna
 
Do you like to watch adult movies?
 
user1804599
8:42 PM
Yes. :P
 
user1804599
But I'm already watching something else now.
 
user1804599
So I'll watch that later.
 
@райтфолд Hm, nothing I haven't seen before in some of his other talks so far...
 
user1804599
What's it about?
 
8:52 PM
Where does OOP come from, why do we need FP, Space vs. Time etc.
I bet you know it all.
 
user1804599
I don't like to compare FP to OOP.
 
user1804599
I like to compare OOP to PP and FP to IP.
 
What is PP? Parallel Programming?
 
user1804599
Procedural programming.
 
user1804599
So you use free functions instead of methods or gotos.
 
8:54 PM
Ah, you mean structured programming.
 
user1804599
No idea what that is.
 
Control structures instead of goto Spaghetti.
 
user1804599
I mean like, what you typically do in C and Go.
 
user1804599
No, I mean functions instead of methods or global gotos.
 
Structured programming is a programming paradigm aimed at improving the clarity, quality, and development time of a computer program by making extensive use of subroutines, block structures and for and while loops—in contrast to using simple tests and jumps such as the goto statement which could lead to "spaghetti code" which is difficult both to follow and to maintain. It emerged in the 1960s—particularly from a famous letter, Go To Statement Considered Harmful.— and was bolstered theoretically by the structured program theorem, and practically by the emergence of languages such as ALGOL with...
 
user1804599
8:55 PM
SP is in the FP/IP like set.
 
user1804599
It's about the implementation of subroutines.
 
SJD
Can someone give me an advice to a C related question?
 
Did you know not all imperative languages supported recursion back then? :)
 
user1804599
No.
 
17
Q: What imperative programming languages do not support recursion?

FredOverflowTo my knowledge, all modern imperative programming languages support recursion in the sense that a procedure can call itself. This was not always the case, but I cannot find any hard facts with a quick Google search. So my question is: Which languages did not support recursion right from the sta...

 
user1804599
8:58 PM
 
user1804599
hehehe
 
no.
 
@райтфолд I can't see anything. Can you make it bigger?
 
user1804599
Java Sucks!
 
SJD
@Puppy that doesn't mean that nobody can help me :-"
 
user1804599
9:02 PM
@FredOverflow Zoom in.
 
@райтфолд Where is equals and hashCode?
 
user1804599
They're not there in Perl 6 either by default.
 
Perl has a die keyword? :)
 
user1804599
Yeah it throws an exception.
 
3 messages moved from Lounge<C++>
@SJD Sure, fire away. What is your C question?
 
9:05 PM
maybe the singleton mess should be moved here :)
 
I'm not gonna click on hundreds of messages, tyvm :)
 
I regret it
Now I'll look like a singleton fanboi in public transcript
 
You have basically rendered yourself unemployable.
 
user1804599
# Here's the Mill equivalent:
struct Point {
    $x: Double;
    $y: Double;
    invariant list($x, $y) |> all(&(-10d <= &1 <= 10d))
}
 
is the all a precondition?
 
user1804599
9:08 PM
list($x, $y) |> all(&(-10d <= &1 <= 10d)) must always be true for all points.
 
not for x & y? nvm
 
user1804599
It translates roughly to all(list($x, $y), &(-10d <= &1 <= 10d)).
 
why do you need the ds? 10 is the same as 10d no?
 
user1804599
10 is an Int and 10d is a Double.
 
user1804599
-10 <= &1 would be a type error since &1 is a Double and -10 is an Int.
 
9:11 PM
you can't compare int with double?
 
user1804599
No, of course not.
 
user1804599
They're completely different types.
 
Oh god that reminds me, some day I will have to implement the C implicit conversions...
 
I think being able to compare them makes sense at least for greater than & less than
 
user1804599
You can define your own operator <~= that casts. :)
 
9:13 PM
Was playing with a logo a while ago.
Thinking about starting a company sometimes.
 
user1804599
Nice.
 
Got some good feedback from a designer friend that it is a bit thin
Might render poorly in small sizes.
 
9:32 PM
@JohanLarsson If the company doesn't work out, you can rename it to PROBLEMATIC.
 
SJD
@FredOverflow is there a way of copying a file into another using threads but not using mutex? I tried several scenarios... and I just can't find a solution.. or idea?. I know for each thread the block size and the position in file coresponding to each thread.
 
@SJD What does that even mean? Does the destination file exist already?
 
SJD
@FredOverflow yeap. Before creating threads I open both files. Source file and destination file.
Also, I store globally file descriptors for each of them.. so the only issue appears when I try to lseek on specific position..
 
So you want multiple threads to write to the same file?
 
SJD
yea
but, each thread shall copy -> paste a specific part from the file.
 
9:43 PM
Why do you want to do this?
You won't gain any performance, IO will be the bottleneck.
 
SJD
like:
Thread 0 : size:20 starting offset: 0
Thread 1: size 25: starting offset: 21
Thread 2: size 2 :starting offset 47.. and so on
that's a homework.. and It is mentioned that I shall not use mutex..
so.. just asking if there is any way of doing it..
 
I don't know. You may want to ask on SO proper.
 
SJD
fine:D thanks for your time.
 
You're welcome.
 
@FredOverflow maybe even start with it?
 
9:51 PM
Start with OPTIMISTIC.
 
progmatic is a bit lame but I still like it
usually don't love puns & wordgames
 
10:13 PM
What will your company be about?
 
consulting is the most realistic
gonna try to fish around for some gigs
maybe :)
pretty likely that it will stay null cos lazy
 
Are you gonna become the next Scott Meyers?
 
What did he do?
The reason I'm thinking about it is that I work too much. Think I averaged 12h per day last year.
Might as well do it for myself.
 
@JohanLarsson He teaches people the intricacies of C++.
 
oh, I'll be grinding not teaching :)
 
maybe consulting is the wrong word
 
Oh you mean freelancing?
 
depending on what it means :)
 
> A freelancer or freelance worker is a term commonly used for a person who is self-employed and is not necessarily committed to a particular employer long-term.
 
you are a teacher right?
 
user1804599
10:39 PM
@FredOverflow The last thing D needs is indeed somebody as silly as Scott Meyers.
 
@JohanLarsson depending on what it means ;)
 
10:57 PM
@райтфолд If I need an immutable array, can't I simply "cast" an Array[T] to a Seq[T]?
 
user1804599
No.
 
user1804599
That's like C++ const.
 
It comes from a factory, and nobody else knows it's an array.
 
user1804599
If you want D's immutable you either need to have a unique reference to the array or copy it.
 
Oh wait, could I just use Product maybe? :)
 
user1804599
10:59 PM
It's also not a cast, but an implicit conversion.
 
user1804599
No, Product isn't for sequences.
 
I'm wondering what the best data structure for "parameter list" would be.
 
user1804599
You should use Seq or IndexedSeq.
 
user1804599
@FredOverflow Perl 6 has a data type for that.
 
user1804599
Yes.
 
user1804599
11:00 PM
It has a type for parameter lists.
 
user1804599
It also has a type for argument lists: doc.perl6.org/type/Capture
 
I started out using Vector, but that takes at least 32 references, doesn't it? :)
 
user1804599
@FredOverflow What are you trying to do?
 
user1804599
You should most likely not use arrays in Scala.
 
user1804599
11:04 PM
Vector is what you use in Scala when you'd use std::vector or std::deque in C++.
 
0
Q: Can a Field class from Java reflection work on any object?

WaterI am curious if I can store an instance of a Field object and use that on any object I pass to it. I'm doing a ton of reflection work, and I recall reading somewhere that it is unsafe to store a Field object and use that as a singleton (more or less) to quickly access the field from the class. I...

 
private def parseParameterList(): Seq[Parameter] = {
  val parameters = new VectorBuilder[Parameter]
  // ...
  parameters.result()
}
When the parse is done, I never need to change the parameter list again.
 
user1804599
@FredOverflow Use an array.
 
That's what I thought.
 
user1804599
Arrays have more efficient lookup and iteration.
 
11:07 PM
I can't just swap VectorBuilder for ArrayBuilder. Nice.
 
user1804599
You can say new Array[Parameter](n).
 
But I don't know the size at the beginning of the parse.
 
user1804599
Or just new ArrayList[Parameter].
 
The Java version?
 
user1804599
Yes.
 
user1804599
11:08 PM
Then call toArray to get the result.
 
user1804599
11:21 PM
@FredOverflow what is an efficient algorithm to check whether a number is a power of two?
 
user1804599
Currently I do this:
 
user1804599
sub power-of-two(Int $x) {
    $x.base(2).subst(/0/, '', :g).codes == 1;
}
 
user1804599
Ah, here's a nicer one:
 
user1804599
sub power-of-two(Int $x) {
    $x.lsb == $x.msb;
}
 
user1804599
Breaks for negative inputs though.
 
user1804599
11:32 PM
sub power-of-two(Int $x) {
    $_ && !($_ +& $_.pred);
}
 
user1804599
Wonderful. :)
 
@райтфолд (x & (x-1)) == 0
 
user1804599
sub power-of-two(Int $x) {
    $x && !($x +& $x.pred);
}
 
user1804599
That's what this does.
 
user1804599
It also checks for $x == 0.
 
11:39 PM
oh ok :)
 
user1804599
Is 0 a power of two?
 
user1804599
No, of course not.
 
user1804599
∄ n ∈ ℝ: n^0 = 0
 
user1804599
Everything is terrible.
 

« first day (786 days earlier)      last day (107 days later) »