You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@devicemap.apache.org by Bertrand Delacretaz <bd...@apache.org> on 2013/05/06 18:11:04 UTC

Porting dClass to other languages?

Hi,

I'm still chasing the idea of a multi-language device identification
implementation that uses the exact same data files and gives the exact
same results on various platforms.

Reza, do you think dClass [1] [2] would be a good candidate for that?

As it's written in C, the PHP variant might just need a wrapper.

A JNI wrapper for Java is already available, but for my use cases I'd
prefer a real Java version which would require porting. The C code is
not huge, but we'll need to check for any constructs that might be
problematic in Java.

We can test 100% of the results by comparing to the C implementation,
so validating the various implementations would probably be easier
than using different algorithms in different languages.

WDYT?

-Bertrand

[1] https://github.com/TheWeatherChannel/dClass
[2] http://www.rezsoft.org/device_detection/

Re: Porting dClass to other languages?

Posted by Reza <re...@yahoo.com>.
I agree, I think automated tests and community submissions will be critical for this project.


________________________________
 From: Bertrand Delacretaz <bd...@apache.org>
To: devicemap-dev@incubator.apache.org; Reza <re...@yahoo.com> 
Sent: Tuesday, May 7, 2013 11:30 AM
Subject: Re: Porting dClass to other languages?
 

On Tue, May 7, 2013 at 4:46 PM, Bertrand Delacretaz
<bd...@apache.org> wrote:
> ...IMO the critical element in doing that is having reproducible tests
> for both implementations, which we can easily achieve with a text file
> that lists User-Agent values and the expected device properties....

Like
https://svn.apache.org/repos/asf/incubator/devicemap/trunk/openddr/test-data/src/main/resources/test-data/ua-to-properties.txt
for example, which is used by the TestDataFileEntries

-Bertrand

Re: Porting dClass to other languages?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Tue, May 7, 2013 at 4:46 PM, Bertrand Delacretaz
<bd...@apache.org> wrote:
> ...IMO the critical element in doing that is having reproducible tests
> for both implementations, which we can easily achieve with a text file
> that lists User-Agent values and the expected device properties....

Like
https://svn.apache.org/repos/asf/incubator/devicemap/trunk/openddr/test-data/src/main/resources/test-data/ua-to-properties.txt
for example, which is used by the TestDataFileEntries

-Bertrand

Re: Porting dClass to other languages?

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,

On Mon, May 6, 2013 at 6:31 PM, Reza <re...@yahoo.com> wrote:
> ...maintaining an API in multiple languages can be a burden. For example, simply maintaining dClass in Java and C is a
> lot of work which is why I opted for JNI. I would have prefered pure Java but did not want to maintain a single
> algorithm in 2 codebases...

Of course - but if the burden can be shared that's easier.

IMO the critical element in doing that is having reproducible tests
for both implementations, which we can easily achieve with a text file
that lists User-Agent values and the expected device properties.

> ...So right now DeviceMap uses a small subset of dClass functionality. So it might be a good idea to just take that subset and port it over..

Agreed.

> ...I also think porting this subset over to other languages is a very doable task and im open to have someone take this as their own task...

Cool - I'll try that in my Copious Free Time (which means not right now...)

-Bertrand

Re: Porting dClass to other languages?

Posted by Reza <re...@yahoo.com>.
I think its a good idea and I have given it some thought, but I had some concerns which everyone should probably consider:

-maintaining an API in multiple languages can be a burden. For example, simply maintaining dClass in Java and C is a lot of work which is why I opted for JNI. I would have prefered pure Java but did not want to maintain a single algorithm in 2 codebases...
-dClass has some wider use cases and is currently and will continue to evolve towards to a more powerful and generic pattern database/engine

So right now DeviceMap uses a small subset of dClass functionality. So it might be a good idea to just take that subset and port it over. That subset is basically an in memory search tree (but be linear in respect to number of patterns being searched), a tokenizer, a few regex (I found them to be optional in the DDR), ranking, CHAIN, WEAK, and STRONG patterns. The reason im focusing on this subset is that currently dClass supports *a lot* more than this which would be overkill for this project. I also think porting this subset over to other languages is a very doable task and im open to have someone take this as their own task.


________________________________
 From: Bertrand Delacretaz <bd...@apache.org>
To: devicemap-dev@incubator.apache.org 
Sent: Monday, May 6, 2013 12:11 PM
Subject: Porting dClass to other languages?
 

Hi,

I'm still chasing the idea of a multi-language device identification
implementation that uses the exact same data files and gives the exact
same results on various platforms.

Reza, do you think dClass [1] [2] would be a good candidate for that?

As it's written in C, the PHP variant might just need a wrapper.

A JNI wrapper for Java is already available, but for my use cases I'd
prefer a real Java version which would require porting. The C code is
not huge, but we'll need to check for any constructs that might be
problematic in Java.

We can test 100% of the results by comparing to the C implementation,
so validating the various implementations would probably be easier
than using different algorithms in different languages.

WDYT?

-Bertrand

[1] https://github.com/TheWeatherChannel/dClass
[2] http://www.rezsoft.org/device_detection/