Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Notorious b.s.d.
Jan 25, 2003

by Reene

Shaggar posted:

I meant use java or c# to replace swift. they used objc cause steve made them cause it was nextstep

they already tried java and it didn't work. no uptake. apple was actively pushing java on devs to no avail.

also, times change. java is now owned by an extremely hostile vendor who would want a huge cut of mobile revenues. even if they wanted to bring back java as an option, it wouldn't be viable from a business perspective.

Adbot
ADBOT LOVES YOU

FamDav
Mar 29, 2008

Notorious b.s.d. posted:

they already tried java and it didn't work. no uptake. apple was actively pushing java on devs to no avail.

also, times change. java is now owned by an extremely hostile vendor who would want a huge cut of mobile revenues. even if they wanted to bring back java as an option, it wouldn't be viable from a business perspective.

why do you think oracle is being actively hostile

Notorious b.s.d.
Jan 25, 2003

by Reene

FamDav posted:

why do you think oracle is being actively hostile

oracle is competently managed, and they want to make money off their assets. aggressive rent-seeking is the obvious way to make money off java

sun lost a lot of money on nearly everything they did, in no small part because sun didn't do things like sue their prospective customers over java.

pushing java was a much safer choice in the 1990s

compuserved
Mar 20, 2006

Nap Ghost
i'm trying to implement some other team's artisanal hash function in java, but have never used java before so I have no idea what I'm doing (as usual)

i can express the function fine in python:

code:
>>> from hashlib import md5
>>> def hash(string):
...     trunc_digest = md5(string).hexdigest()[0:4]
...
...     # this should always return an integer in [0, 65535]
...     return int(trunc_digest, 16)
...
>>> hash('yosposbirch')
2243
>>> hash('yosposeurborch')
53620
but am stuck in java:

code:
[...]

import java.security.MessageDigest;

[...]

public short hash(byte[] input)
{
    MessageDigest md = MessageDigest.getInstance("MD5");
    md.update(input);
    digest_bytes = md.digest();

    [...]

    return ???
}
i've tried using java.util.Arrays.copyOf to create a new byte array with only the first two bytes of digest_bytes (that should correspond to getting the first four characters of the digest in the python example, right?), but i get totally stumped there.

any help would be appreciated :)

Shaggar
Apr 26, 2006
idk maybe this. java shorts are signed so max val is 32767
Java code:
ByteBuffer.wrap(digest_bytes,0,4).getInt() 

Zaxxon
Feb 14, 2004

Wir Tanzen Mekanik

compuserved posted:

i've tried using java.util.Arrays.copyOf to create a new byte array with only the first two bytes of digest_bytes (that should correspond to getting the first four characters of the digest in the python example, right?), but i get totally stumped there.

any help would be appreciated :)

I think you want copyOfRange to get a copy of the first 2 bytes, and then I think ByteBuffer has all the stuff to extract unsigned ints and poo poo from it.

CPColin
Sep 9, 2003

Big ol' smile.
Just now, I wrote this:

code:
      int startId = loadStartId();
      int endId = processRows(startId);
      
      saveId(endId);
I could have written this:

code:
   saveId(processRows(loadStartId()));
I'm happy that I didn't.

Zaxxon
Feb 14, 2004

Wir Tanzen Mekanik

CPColin posted:

Just now, I wrote this:

code:
      int startId = loadStartId();
      int endId = processRows(startId);
      
      saveId(endId);
I could have written this:

code:
   saveId(processRows(loadStartId()));
I'm happy that I didn't.

:thumbsup:

Bloody
Mar 3, 2013

CPColin posted:

Just now, I wrote this:

code:
      int startId = loadStartId();
      int endId = processRows(startId);
      
      saveId(endId);
I could have written this:

code:
   saveId(processRows(loadStartId()));
I'm happy that I didn't.

ok

comedyblissoption
Mar 15, 2006

Bloody posted:

i continue to be displeased that c# numeric value types don't implement some IAddable and IMultiplyable or whatever interfaces it would be so much more convenient to be able to define genericized higher-level math that way but nope gotta have a FirFilter.Process(float) and FirFilter.Process(double) and FirFilter.Process(decimal)

or a FirFilter.Process(BespokeArtisanalNumericTypeWrapper) lmao
An ideal programming language should let you orthogonally say that type Foo implements interface IBar without having to make modifications to the source of type Foo. This method of indicating interface implementation should extend to primitive types.

Haskell typeclasses meet this criteria. I think typeclasses don't play that nicely with subtyping inheritance hierarchies, but if you have typeclasses the use cases for subtyping through inheritance probably become vanishingly small.

This is why people like dynamic duck typing because mainstream statically typed languages suck at making generic code like this. C++ can kind of do this, but it uses compile-time duck typing.

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


i spent half of today getting 80% of my save methods working using a single stored proc and then in the process of getting the other 20% to work hosed it all up and now only like 10% works

i should have created separate procs

Bloody
Mar 3, 2013

yeah duck typing is a means to an end there but i'd rather be able to enforce it with an interface or some extensionmethods-style fuckery or something

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

CPColin posted:

Just now, I wrote this:

code:

      int startId = loadStartId();
      int endId = processRows(startId);
      
      saveId(endId);

I could have written this:

code:

   saveId(processRows(loadStartId()));

I'm happy that I didn't.

me too

FlapYoJacks
Feb 12, 2009

CPColin posted:

Just now, I wrote this:

code:
      int startId = loadStartId();
      int endId = processRows(startId);
      
      saveId(endId);
I could have written this:

code:
   saveId(processRows(loadStartId()));
I'm happy that I didn't.

Did you really not check any return values? Shameful.

CPColin
Sep 9, 2003

Big ol' smile.
Pass 'em all, let the code in the methods sort 'em out, I say.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

comedyblissoption posted:

An ideal programming language should let you orthogonally say that type Foo implements interface IBar without having to make modifications to the source of type Foo. This method of indicating interface implementation should extend to primitive types.

Honestly, I would be happy if it just extended to like, collections classes, so that immutable collections could show up without being absolutely horrible.

craisins
May 17, 2004

A DRIIIIIIIIIIIIVE!
JSON technically isn't valid if you use single quotes for strings. time to sperg out and rewrite all of my JS objects with double quotes.

abraham linksys
Sep 6, 2010

:darksouls:
have any of y'all used this phoenix thing? http://www.phoenixframework.org/

thinking about building a little threaded chat app to play around with react/redux some more and I think I want to make the backend in something I haven't used before. phoenix looks like it has a bunch of asset management poo poo I would completely ignore but the channel stuff seems neat?

of course i'd have to learn erlang and elixr on the way to using this and idk how hard that is but it seems more fun than making yet another node or python backend

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
elixir owns bones and so does erlang. i haven't messed with phoenix but it's supposed to be fine or whatever. like rails or something idk.

phoenix could be worse than cobol on cogs and it wouldn't matter because any time in the erlang (and elixir) eco system is going to make you happy and blow your mind.

abraham linksys
Sep 6, 2010

:darksouls:
phoenix kinda just seems like rails re-implemented in a far more confusing language, not really digging it

the hell are y'all in this thread using for building web applications with realtime (re: i want a websocket) communication and a decent model layer? i wish python's async story wasn't still messy as gently caress, and i wish node had an orm and migration library worth a drat

is it naive to think that in two thousand and loving sixteen i shouldn't have to build authentication endpoints and a user model from scratch for the 30000th time

abraham linksys fucked around with this message at 08:12 on Jan 23, 2016

9-Volt Assault
Jan 27, 2007

Beter twee tetten in de hand dan tien op de vlucht.

abraham linksys posted:

phoenix kinda just seems like rails re-implemented in a far more confusing language, not really digging it

the hell are y'all in this thread using for building web applications with realtime (re: i want a websocket) communication and a decent model layer? i wish python's async story wasn't still messy as gently caress, and i wish node had an orm and migration library worth a drat

is it naive to think that in two thousand and loving sixteen i shouldn't have to build authentication endpoints and a user model from scratch for the 30000th time

Its creators claims it is in fact not rails: https://dockyard.com/blog/2015/11/18/phoenix-is-not-rails

aardvaard
Mar 4, 2013

you belong in the bog of eternal stench

abraham linksys posted:

phoenix kinda just seems like rails re-implemented in a far more confusing language, not really digging it

the hell are y'all in this thread using for building web applications with realtime (re: i want a websocket) communication and a decent model layer? i wish python's async story wasn't still messy as gently caress, and i wish node had an orm and migration library worth a drat

is it naive to think that in two thousand and loving sixteen i shouldn't have to build authentication endpoints and a user model from scratch for the 30000th time

ruby is a far more confusing language than erlang or elixir could ever be, even if they tried

aardvaard
Mar 4, 2013

you belong in the bog of eternal stench

dehumanize yrself and face to functional programming

abraham linksys
Sep 6, 2010

:darksouls:
yeah tbh i'm kind of being a baby about elixir because, much like how you're not gonna learn ruby from the rails DSLs, the phoenix DSLs sorta hide what's really going on and making it a little extra confusing. also annoyed that i'm learning how to build stuff from poorly-written blog posts because the official guide is pretty limited but that's just web development in 2016 i guess

i think i generally Get functional programming thanks to javascript (outside of pattern matching but i get the concept) so i'm interested to see how it works in elixir if nothing else

aardvaard
Mar 4, 2013

you belong in the bog of eternal stench

javascript is not a functional programming language in either sense of the word

9-Volt Assault
Jan 27, 2007

Beter twee tetten in de hand dan tien op de vlucht.

abraham linksys posted:

yeah tbh i'm kind of being a baby about elixir because, much like how you're not gonna learn ruby from the rails DSLs, the phoenix DSLs sorta hide what's really going on and making it a little extra confusing. also annoyed that i'm learning how to build stuff from poorly-written blog posts because the official guide is pretty limited but that's just web development in 2016 i guess

i think i generally Get functional programming thanks to javascript (outside of pattern matching but i get the concept) so i'm interested to see how it works in elixir if nothing else

If you dont mind spending some money, pragmatic programmers has a book on Phoenix in early acces.

And also a good book on Elixir.

my homie dhall
Dec 9, 2010

honey, oh please, it's just a machine

abraham linksys posted:

i think i generally Get functional programming thanks to javascript (outside of pattern matching but i get the concept) so i'm interested to see how it works in elixir if nothing else

haha

~Coxy
Dec 9, 2003

R.I.P. Inter-OS Sass - b.2000AD d.2003AD

Zemyla posted:

When OSX came out in 1999, Java was still poo poo from a butt and Microsoft was still trying to ritualisticaly murder Apple (and C# didn't even publically exist yet), and Apple wanted to use NeXTSTEP which they'd acquired along with reacquiring Steve Jobs.

I know fellating big business doesn't leave you with time for stuff like "the bare minimum of checking facts" but come on son.

FAKE EDIT: "arguing with shaggar lol"

when OS X came out Java was a first class language for it

E:F;B

~Coxy fucked around with this message at 10:41 on Jan 23, 2016

jesus WEP
Oct 17, 2004


abraham linksys posted:

phoenix kinda just seems like rails re-implemented in a far more confusing language, not really digging it

the hell are y'all in this thread using for building web applications with realtime (re: i want a websocket) communication and a decent model layer? i wish python's async story wasn't still messy as gently caress, and i wish node had an orm and migration library worth a drat

is it naive to think that in two thousand and loving sixteen i shouldn't have to build authentication endpoints and a user model from scratch for the 30000th time
use signalr

distortion park
Apr 25, 2011


why do people always claim that JavaScript is a functional language.

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

because they havent actually used a functional language before and maybe theyre coming from java?

abraham linksys
Sep 6, 2010

:darksouls:
idk if javascript is a functional language but you can do a thing that looks and feels like functional programming in javascript so w/e

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av

comedyblissoption posted:

C++ can kind of do this, but it uses compile-time duck typing.

C++17 is going to finally make it formal. maybe. possibly. well, almost certainly. I think

gonadic io
Feb 16, 2011

>>=

abraham linksys posted:

idk if javascript is a functional language but you can do a thing that looks and feels like functional programming in javascript so w/e

you mean map a function over a list right?

Shaggar
Apr 26, 2006

suffix
Jul 27, 2013

Wheeee!

CommunistPancake posted:

javascript is not a functional programming language in either sense of the word

it has closures and first-class functions, which wasn't a given at the time

compare to vbscript for a taste of what could have been

triple sulk
Sep 17, 2014



elixir world is gonna become a dsl hell for the same sort of reasons that the ruby/rails world did

triple sulk
Sep 17, 2014



asp.net development is going to basically be at 100% on osx/linux by the end of the year and it's gonna be great because real companies use java and c# and those kinds of jobs will still be around when the tech bubble pops

Notorious b.s.d.
Jan 25, 2003

by Reene
people are probably not going to start hosting their poo poo with asp.net on linux

asp.net has worked just fine on mono for y'know 10 years and it didn't start a revolution.

and before that, sun used to sell a 100% compatible asp classic on solaris/linux. that didn't exactly set the world on fire either

Adbot
ADBOT LOVES YOU

Bloody
Mar 3, 2013

lol "mono is fine"

  • Locked thread