« first day (2851 days earlier)      last day (2314 days later) » 

13:00
Server will be updated. Will test locally tomorrow but the server had to be updated anyway.
abr
abr
@AMDG did you check the screenshot that I've sent you? :o
gtg :) cya and thanks for the tips and ideas and time o/
bye geis
@abr no sorry, I'll look at it now :)
Uh, can you repost it here.
I can't scroll up that far
nvm I found it
abr
abr
found it? okay
I don't see where your lib is not on there. All I see is that you don't have Apache Commons on the classpath
@abr what library are you trying to export?
abr
abr
13:10
I'm trying to debug and it's giving that. It's opencsv 4.2
Apache Commons has nothing to do with OpenCSV as far as I know. If you press run, it works fine, but if you debug, it gives this NoClassDefFoundError, correct?
Oh wait
I see you are using CSVReader which requires Apache Commons
If your OpenCSV distribution does not come with Apache Commons, you can just download it and add it to the classpath manually and that will fix the problem altogether.
abr
abr
will take a look, thank you! I'll give u feedback in a few moments
"Apache commons" represents a great many libraries. This page lists the four specific dependencies that are mandatory: opencsv.sourceforge.net/dependencies.html
Alright, so back to my question I guess then. I should definitely create a class for each kind of Production in the JLS to enforce strong typing for the API of JCLA. However, I'm not sure how I should go about Production inheritance.
If you look here
You'll see the structure of Productions.
When I say "Production inheritance", I do not mean the OOP concept of inheritance.
However, the OOP inheritance may also be a consideration.
what question?
@Gimby i find the apache commons to be rather... annoying
same with apache io and the others
13:23
The question I need to answer is whether or not, for example the first Production in Chapter 19 is Type, what should I store from what I pass to the constructor for public class Type extends JavaProduction? Should I store everything as a giant list of Tokens (get all the tokens for PrimitiveType and ReferenceType and merge into one list of Tokens), or do I simply preserve the Production and store that instead of the Tokens of the Production?
I should also note that every single one of these Production objects needs a constructor for making the Production from an arbitrary array of Tokens.
i would make each class have one responsibility
Meant to say PrimitiveType or ReferenceType there.
not using the same class for different things
@Wietlol what do you mean in this case?
make a class for a set of tokens that is meant to represent the PrimitiveType
then make another class which is the compiled/parsed version of the PrimitivaType
13:28
I don't follow...
Are you saying I should have a class that defines PrimitiveType, and a class that stores PrimitiveType?
That's double the classes and double the work! Then again... everything is 64-bit :P
I had the idea of something like class PrimitiveType and class PrimitiveTypeDefinition as a factory for PrimitiveType, but it feels too bulky to have two classes for every kind of Production
And the fact that Productions are so lightweight is where I start complaining, "Tuples WHEN!!?!?!?!"
so what you want to do is take a sequence of tokens, then split up that sequence in smaller sets that represent a specific thing, and then compile those sets?
yes
Also, there's no room for trying to make flyweights, and when I said flyweights before, I was incorrectly terming what I was trying to do
Each Production will be unique.
(obvi)
unique and immutable really.
are you able to compile all tokens on the spot?
or do you have to do this in multiple stages?
All Tokens were created first. This is the second pass: creating productions in one pass.
As it is, it's probably as simple as this pseudo-example of what my parsing algorithm is (much like your boole parser really):
my boole parser?
13:33
dang it, I didn't mean to press enter
one sec, lemme create a gist of the parser algorithm
way too much text
i cant read that
I'm not giving a TL;DR. This is the summarized documentation of my parsing algorithm.
summarized
only 36 lines of text. If you can't stand to read that, I don't know how you stand to read something like "Effective Java", let alone the first paragraph of a book.
i cant read books either
I never read EJ
@michael help
but I know everything that is in there
14:17
Yes, well you certainly don't know everything in my parsing algorithm, and if you don't want to help me, that is fine; I can take my cookies and cream to another santa.
Any volunteers?
also, is lifo an actual thing?
afaik, its either fifo or filo
(because fulo and lifo are the same)
Last in First out stack? You haven't heard it called that way?
i never heard a version that starts with "last in"
everything there says "LIFO"
Could also just be an anagram for \n I/O :P
I can give a basic example with this here: gist.github.com/marlonyao/6b171f489e659bf3b919c06008d1fb55
It's the Java HelloWorld demo that everyone knows
According to the algorithm, we would check if this first Token "public" is its own complete Production, and is if it is, if it is the largest possible Production (greatest number of non-terminals before a right-hand terminal). The Algorithm would then stop at the class opening bracket which is a block because there are inadequate Productions to create the current Production which is the class Production. (That is, after it has already checked "class" and "HelloWorld" in the same manner)
We get the next Token, which is the start of another Production (representing a method), so we push the current incomplete Production on the working stack onto the waiting stack, and push this (and the subsequent Tokens up to the first ( [left parenthesis]) onto the working stack.
i still have javax.persistence.noclue why explaining the algorithm is going to be useful
14:32
Ah, yes, well if you understand my parser's algorithm, then you can help me to understand how I should design the Production objects by the nature of the algorithm and the data it expects.
Also, I asked you this question some months ago
I probably still had the username "ltp" or "linktheprogrammer"
and i still have no idea why it is called a production
A context-free grammar consists of a number of productions.
i still think that having a separate class for every item in the code for every stage of your compiler is the way to go
that is how I wrote my compiler... except mine is slightly more complex
I can totally understand if everyone in here (including myself) is not James Gosling, Bill Joy, Guy Steele, Gilad Bracha, Alex Buckley, or Daniel Smith.
@Wietlol are you saying you understand how my parsing algorithm works?
Are there any guys from Oracle ever on here?
nope
14:41
is there a place any of those guys are ever on the web daily?
why would someone from oracle be here?
(in terms of interacting with the Java devs)
i think not
Zoe
Zoe
I doubt the Java devs ask questions about their own language anyways xD
Well, I mean even C++'s Bjarne Stroustrup is on stackoverflow!
14:42
@Zoe surveys :D
customer experience
@Zoe I'm thinking in terms of answers
Zoe
Zoe
@AMDG Meh, they're probably too busy to fix the language to answer SO questions
oh, sure, they can have a stackoverflow account, but they arent commonly seen around places like the chatrooms
Zoe
Zoe
Very few high-rep users are
usually, I give the answers in here
14:43
I would expect not, but they must have a public email hiding somewhere...
when im not here, geister, mibael and zoobot do the work
"josh.bloch@oracle.com"
wonderb0lt and nicktar are here sometimes as well
and it seems we have a new one named gimli
midget
:P
Wields an axe. I suppose it'll be good for getting rid of the trolls here.
i probably missed like 10 other people but whatever
Zoe
Zoe
14:46
@AMDG Axes are too heavy to get rid of trolls. It slows you down enough to get hit by them.
You're probably right;SELECT 10 FROM "Users"
select top 10 username from user where isActiveInJabaRoom = true
yeah that
sql i n j e c t i o n
nosql-injection
So @Wietlol you're saying I should just store a Set of Tokens in the Production objects instead of the Production(s) passed in to the constructor directly?
14:49
i think
at the very least, make your classes that are responsible for storing data not responsible for anything else
But then I'll have a defensive copy of all the Tokens in two different places... unless I use a reference.
so if you pass tokens to a constructor, that class stores tokens, nothing else
you can use sub-lists
Well, a Production, as you should have read in Chapter 2 of the Java 10 Language Specification, stores Productions. Tokens subclass Production.
I think then that we can both agree it would be more space-efficient, more performant, and easier to maintain (while being less error-prone) if we don't use sub-lists or copy the whole Token Set from the given Productions but just store them in the Production, and retrieve the Tokens when we need them.
Tell me what you think
Production.getTokens() is overridden in Token to return itself, so there's no chance of a StackOverflowError there.
abr
abr
@AMDG just came to say thank you, adding the apache commons worked!
@abr you're welcome!
15:01
@AMDG sub-lists are more space-efficient, more performant and easier to maintain
/javadoc java.util.collections.List
@Wietlol Sorry, I never heard of that class. :(
/help javadoc
@Wietlol Sorry, I never heard of that class. :(
Displays class documentation from the Javadocs. If more than one class or method matches the query, then a list of choices is displayed. Queries are case-insensitive.
Usage: /javadoc CLASS_NAME[#METHOD_NAME[(METHOD_PARAMS)]] [PARAGRAPH_NUM] [[@]TARGET_USER]
Examples:
/javadoc String
/javadoc java.lang.String#indexOf
/javadoc java.lang.String#indexOf 2
/javadoc java.lang.String#indexOf NoobUser
/javadoc java.lang.String#substring(int)
/javadoc java.util.List
15:03
/javadoc java.util.List#subList
there you are
Storing just PrimitiveType is a single int in Type. Much more lightweight than creating a sublist object as a view of a set of Token objects. I also don't need all of the Tokens until I construct a new Production in the parser.
but that is something different
you pass the tokens to a parser, which returns you the PrimitiveType
the constructor is not a parser
the parser uses the constructor of the PrimitiveType which takes the int
No, my parser is a Production generator.
I said "a single int" because a reference is 32-bit (unless you explicitly make references 64-bit, or you use more than 4GiB of memory)
putfield vs putfield; new(...);
15:08
but you shouldnt make a constructor take in a list of tokens and reads out the data from that list
that is what you use a parser for
a parser can be a factory method
a parser can be a singleton lying around somewhere that does it
Hm. I should change my username to Gimli.
a parser can be a visitor
etc
but a constructor is just asking for issues later on
@Wietlol the idea was to make a package-private constructor taking an arbitrary array of Productions assuming that the Productions correctly represent the Production, and this constructor would be the factory used by the ProductionLookupTable to construct and build new Productions from, but since the last time I was here, I mentioned, "I don't like instance factory methods." I still don't.
instance factory methods?
factory methods are static
if they are not static, they should be a member of a factory class
Hi, I am kinda inexperienced in Java. I was trying to parse to JSON string (just for trying it out) and I got to know about JSONTokener (library org.json). I saw the example here: developer.android.com/reference/org/json/JSONTokener but I am not sure what's the use of .nextValue() method call. Can someone help me?
15:15
otherwise, they arent factory methods
Yes, I originally had it where you called production.build(List<Token>); from the ProductionLookupTable so that I had a programmatic way of constructing that specific Production without knowing the class type to construct it.
and of what type would production be?
a ProductionBuilder?
(Hence why it would be very great and wonderfully convenient if there was actual FP in Java, as I could simply construct a Production of arbitrary type without knowing the type of class)
fp? floating point?
The type would be whatever the Production is
15:18
@AMDG this is what the parser is doing
the parser looks at the data and creates productions based on what the data represents
I have a commons lib that contains a Parser<In, Out> interface which is basically doing Out parse(In input)
If I have a Production class Type, I want to create a Type Production without knowing the class name. Hence, it would be convenient if I could just do something like production::new(Set)() to invoke the constructor anonymously without knowing the type of the class.
renamed room from Java to Room for AMDG and Wietlol
@geisterfurz007 ty
lol
@AMDG calling constructors anonymously is not really nice
calling a constructor means "give me an instance of X class"
if you dont do that, you basically say "give me an instance of Any class"
15:21
No, but it would be the most efficient and readable means of constructing a new object based on the meta-data of the object.
but how would the program know of which class it should create the instance?
@Wietlol exactly, so basically, I just want to do something like: new (production.getTypeName())(tokens)
wait, you want to create an instance of a class based on the class of an instance?
that is horribru
it would have so many possibilities to be broken
and you are solidly coupling your classes
i would rather suggest a map where the class could be the key and the value the appropriate constructor
and the returned instance, when calling production.getClass() would return the actual type (in this case we want to construct a new Type production), which in this case would mean that we would have a new object that satisfies the condition newProduction instanceof Type.
using the class as key, you keep the same issue of the coupling though
there are subtle ways to solve that issue, but they are not really clear for maintenance
15:26
@Wietlol you're making the idea too subjective. I could care less how I get the constructor, I just want to make the implementation decoupled by anonymously getting and invoking the correct constructor, which would best be done by having an object that is passed to ProductionLookupTable which gives the correct constructor to invoke.
Basically, it would then be like someMethod(Provider<T extends Production> constructor); where we only have the erased type T, and no other information, and the Provider is just the constructor object instead of the very versatile interface Provider.
You can't specify a constructor in an interface.
Map<Class<? extends Production>, Function<List<String>, Production>> constructorMap = new HashMap<>();

constructorMap.put(Production1.class, Production1::new);
constructorMap.put(Production2.class, Production2::new);
constructorMap.put(Production3.class, Production3::new);
constructorMap.put(Production4.class, Production4::new);

val tokens = new ArrayList<String>();
val production = new Production1(tokens);
val constructor = constructorMap.get(production.getClass());
val newProduction = constructor.apply(tokens);
(see full text)
like this
you fill the map with class -> constructor links
I create a list of tokens (strings in my example)
then, I create a new production
That's assuming every constructor has the same paramteres.
` public <T> T someMethod(Provider<T extends Production> constructor) {
// ... perform lookup search (snipped)
T production = (constructor)();
return production;
}
`
is effectively your pseudo-code.
@Michael not really
that is assuming that there is a method for those productions available
it can be the constructor, maybe it is not the constructor
15:30
dang it, ctrl-k won't work here
@AMDG It should.
Effectively, I'm asking for dependency injection for the constructor in order to be able to return the correct object.
map.put(Production4.class, stuff) stuff here doesnt even have to return a Production4 instance
as long as it is an instance
@AMDG ` characters don't work for code blocks here
A map is really slow
15:31
@AMDG try the code above
a map is not slow :D
a map is faster than anything you and i can come up with
Not in a real-time method trying to compile on the fly
Wiedol admitting he cannot do something better? Dang.
@geisterfurz007 everytime I look at the HashMap implementation, I am like "dang it, this boi really knows what he did"
it is not even fair how well designed it is
I can't have 100 mods loaded for minecraft, all of which need to be hackily injected, while invoking modifications on class files (in a Java Agent) and end up taking 100 minutes for each one.
A bit extreme, but even 100 seconds (1 second for each) is a long time to initialize a program
15:34
that was random
No, it's the purpose of JCLA
but not caused by slow ass hashmap
try my code, it will do exactly what you want
I'm making it for Quantum API, which is another project I'm working on which requires an esoteric build solution. JCLA is the solution, but I wanted it to be robust, unlike the other libraries I tried to use which fail to meet my requirements.
without most of the downsides I mentioned earlier
@Wietlol a hashmap is very slow in a loop with hundreds of Tokens being processed.
15:35
its not
try it
A giant switch statement is at least one order of magnitude faster than a hashmap (using String, and even better if we use integers in order)
Why would it?
Try a giant hashmap to identify a token, vs. creating a large switch for every kind of Token. I timed both of them. The switch was faster.
It's because you don't have the overhead of bins, even if, under the hood, String switch requires hashCode()
That's inherent to String since it is immutable, but it is something about the implementation of HashMap that makes it slower than a large switch of String objects.
@AMDG I'd like to see that code. :P
err I mean "inherent to string since every string is unique"
well, you can check out my tokenizer and look there and you'll see the giant method containing the switch. Feel free to replace it with a HashMap lookup and initialize the hashmap during class initialization. You'll see the difference.
15:41
A Map would be easier to maintain because, if you need to add a new entry, all you have to do is add an entry to the map. As opposed to adding X number of lines of code somewhere in your program.
see #identify (the method I tested the HashMap vs. switch)
Stopwatch stopwatch = Stopwatch.createStarted();

List<String> input = Stream.iterate(0, (i) -> i + 1)
	.limit(100_000)
	.map(Object::toString)
	.collect(toList());


Map<String, Integer> lengths = input
	.stream()
	.collect(toMap(Function.identity(), String::length));

input
	.stream()
	.map(lengths::get)
	.forEach(System.out::println);

System.out.println(stopwatch);
user8622974
@wietlol Please use a paste site when pasting long code snippets and stacktraces
@Michael yes, but you're only adding a line of code and compiling it to bytecode, vs. the overhead of an object on the heap which uses method calls. If I were making a parser generator, then I would make a state machine which registers all the tokens to a HashMap, but this is Java, and the only language I am compiling for, and the switch was found to be faster, and the maintenance cost is no more than adding 2 lines of code (the case "symbol" followed by return THE_TOKEN;)
Zoe
Zoe
@Michael They don't work for code blocks anywhere on SE
15:45
create a list of numbers from 0 to 99.999 as a string,
put the strings in a map, storing their lengths, using the string as key,
loop through the input (100k elements),
    lookup the length in the map
    print the length
Zoe
Zoe
There's no markdown blocks, just indentation blocks
took, 700ms
slow ass hashmap
with the enums, it should be 4 times faster at least
15:47
from the perspective of making a very fast tokenizer/parser/compiler, 700ms is slow compared to the couple hundred thousand nanoseconds it took to run my Tokenizer. When I added the Hashmap, it jumped from 0.5ms on average (sometimes better, depends on the Tokens), to 1ms.
private static boolean isHexDigit(char c) {
  return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F');
}
@AMDG on a side note, 90% of that time is sout
@Wietlol sout?
system out println
@Michael assertTrue(isHexDigit('a'));
15:48
@Wietlol I didn't include println in the timings, just the algorithm
10 million hashmap lookups for strings on a hashmap with 10 million elements takes 400ms in total
otherwise it is biased
if you think that is slow, then you can go and write your own implementation
also you aren't using the exact data set that I used to calculate the performance of HashMap vs switch in my case.
i dont really care about the data set
15:50
Well if you don't care about the data set, then you don't care about the results. You are not very scientific then...
but I know that you wont be needing 10 million entries in the hashmap
and you probably wont be doing 10 million lookups per second
@Wietlol it can easily add up to that many
it took 200ms for a map with 10 elements
i still think you should just use a hashmap
if there is something that provides the behavior you want to achieve, use it!
there is no reason not to use it
posted on August 13, 2018 by CommitStrip

you can optimize later
15:52
You know it can take like 2 seconds to compile a ton of Java source files? It could be faster... but if they used HashMap to do it, that might be why.
The idea of "optimize later" sounds like procrastination, not DesignForPerformance.
not building anything is considered... nothing at all I think
also, if it takes 2 seconds, let it be 2 seconds
i think 2 seconds for compiling a jon of source code files is pretty good
also, the hashmap lookups will probably be max 10% of the operation of the parsing for each production
not worth optimizing that
2 seconds, or however long it takes, doesn't matter in a development environment. It does matter, however, when you are launching a program and you want to play Minecraft with 100 mods loaded and not end up waiting a whole minute for initialization.
that is why you dont use source code as the product
You don't want to have the compile time of a C++ program at runtime... or boot for that matter... you'll close the program before 10 seconds are done.
15:57
jvm bytecode might not be the best either, but you dont have to compile it when your application starts
@Wietlol alright, you try: 1) deobfuscating minecraft classes, fields, and methods using a map at runtime for 2) modifying the game to do exactly what you want when the Java Agent for Quantum API loads without using something weird like this Mixin framework or you want an organized, central place for quickly modifying bytecode while 3) working for any version of Minecraft (that I support) regardless of underlying bytecode.
I consider minecraft to be boring and sad...
You need a highly abstract means of modifying bytecode dynamically as cleanly as possible without getting too messy in such a scenario.
also, I dont have to do all that
I simply ask a classloader to load all that mess and run it
@Wietlol yes, Minecraft is boring and sad, but I'm doing this for the profits that I know I can and will make from it.
Except that the Minecraft classes cannot be modified at runtime (or any of them for that matter) unless you have a way to modify them as they are loaded (such as a Java Agent). Furthermore, the API will have the ability to load and unload mods (i.e. class files in JARs) on their own ClassLoaders.
16:03
i try not to be curious what productions have to do with minecraft though
Uh, nothing?
its not like you write the classloader in minecraft
I'm writing a classloader for Minecraft so to speak
This is just the library for it
But it's also for everyone else to use
but the productions are about the source code
a classloader is forbidden to use the source code
it is supposed to use the jvm bytecode classes
yes, of course, and we minecraft mod developers commonly use source code that gets compiled to bytecode and injected at loadtime. The JCLA library has a decompiler to decompile Java bytecode to source code if you want, and then you could modify that source code (which is necessary because of the Minecraft bytecode names being obfuscated) and then compiled again after injecting the modifications. That or just the class struct is loaded from the bytecode and put into a ClassBuilder to modify there
16:06
that sounds horrible
It is, and I'm doing it so that they don't have to
so something is compiled, decompiled, modified, compiled, loaded, ran
Mojang doesn't provide us a public Minecraft API, so this is the solution for modifying Minecraft.
i would remove the decompiled, modified, compiled part
because it really shouldnt be that way
you shouldnt modify the source code
at all
Well the option for a dedicated Minecraft JAR that does all of those steps ahead of time will be available.
16:08
no, you dont decompile code, modify and recompile it
it is just plain wrong
Alright, then Minecraft dies because there is no way to modify it otherwise.
Modding and multiplayer are at least 90% of the community, and Microsoft would be at a big loss.
it would cause so many more problems than it would solve while it would easily be solvable without changing the source code
in any case, im off
@Wietlol Mojang gives poor excuses. These aren't my decisions.
Alright, take care.
@AMDG While Minecraft does not have an official "Modding API", it does have Add-ons
Add-ons don't actually add anything to the game, they just let you change aesthetics and effectively script Minecraft, but only existing blocks, entities, etc.; you can't define new ones without modding.
You can see my project page on the minecraftforum: minecraftforum.net/forums/mapping-and-modding-java-edition/…
16:56
It's 62 F in the building where I work right now.
Nice and chilly
yes plz
Freezing cold :(
Management won't tell us why
Get your winter weights out
/shrug
¯\_(ツ)_/¯
I need gloves, but I can't wear gloves while using a computer.
17:00
Oh hey it actually works here
@JennaSloan You know, the names for Add-ons make me wonder if there's also a .McNuggets and .McChicken file too
They have a McWorld and a McPack... funny naming convention
It's been this way all summer.
Meanwhile in Europe we had 2 weeks where you could use your office as sauna.
 
2 hours later…
18:48
@geisterfurz007 Yeah Europe isn't fond of air conditioning, is it? xD
Well my office sure isn't.
Fortunately they put most of the windows towards south so it isn't that dark during the day as well
Don't look at that edit history.
@gei, I told you, you have to cut back on the caffeine.
All of the 0 caffeine I consume?
Don't lie to me, I know you down Red Bulls like they're water.
I do? Huh...
Must be so much, I don't even remember it.
 
1 hour later…
20:17
@Michael oh?
at our office, it could get about 16-18 degrees
while outside, it is around 35
@Wietlol American, please.
@Wietlol Yeah, that's about how cold it is here.
It's been that way ever since our air conditioning went out. When they "fixed" it, it's like they just put it on full blast.
@geisterfurz007 you must have javax.persistence.noclue :)
at our office, the hotter it is outside, the colder it is inside
so while everyone is worried about the earth being heated up, we are worried about getting frozen at work
Sounds like my life. xD
my life is worse
PHP
need to make a website in pure php
no js, no nothing
20:38
Studies have shown that pure PHP causes cancer in lab rats.
Zoe
Zoe
20:50
My code works owo
@Zoe \o/
 
2 hours later…
22:47
Effectively, a HashMap is slower because it is, informally, a heavy-weight lookupswitch, whereas String gets converted to hashes to determine which case to enter. If you conveniently use Strings initialized and interned one after the other such as during class init for Tokens.class, the hashCode, since it usually is the internal reference (on HotSpot), can use a tableswitch rather than lookupswitch.
23:11
Also there you go @Michael. But I'm done ranting for today about performance. I should try being productive, but first I need food; brain is dead.
i still think you are overthinking this
overthinking what?
the lookups of the factories
I've decided to use Provider. I don't know why I didn't think of it before. Then again, I didn't know about it in the first place until recently when I looked it up.
provider?
23:21
The Provider interface in java.util.function
/javadoc java.util.function.Provider
@AMDG Sorry, I never heard of that class. :(
I must be close but not quite
/javadoc java.util.function.Supplier
meant that
im not sure how you use a supplier though
you want to get an object based on a list of tokens and another object
that is a Function, not a Supplier
23:27
No, I mean for the ProductionLookupTable
I'm going to use the method I sampled to everyone earlier
I meant Supplier then, and I mean it now
I can use a Supplier that creates a Production, or just use Function<Set<Token>, Production>.

« first day (2851 days earlier)      last day (2314 days later) »