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.
 
  • Post
  • Reply
tef
May 30, 2004

-> some l-system crap ->

b0lt posted:

"sufficiently smart jit" is just as handwavey as "sufficiently smart compiler"

(strongtalk, hotspot, luajit, spring to mind)

Adbot
ADBOT LOVES YOU

Notorious b.s.d.
Jan 25, 2003

by Reene

tef posted:

scala is fiendishly complex, and performant scala is closer to java than idiomatic scala.

scala is fiendishly complex if you want it to be. in daily use it's java with a repl and a compiler that's not stupid.

if complexity is really the enemy, there is also groovy

hepatizon
Oct 27, 2010

MALE SHOEGAZE posted:

the thing i hate the most about ruby atm is that it strongly encourages you to just use a hash as your only argument, and people will call it the options hash, and then the entire method is built out of options that maybe arent actually optional anymore. but good luck looking at the method signature to figure that out because it's just foo(opt={}).

then that options hash gets merged and passed to another method which also specifies foo(opt={}) and so now maybe your options are also a requirement of that method. but you'll never know until it breaks 10 calls up that stack.


i guess that's more of an indiom because there's nothing stopping people from doing that in other dynamic languages except ruby encourages you to do it by letting you omit the braces entirely ughh

they fixed this in 2.0 with keyword arguments http://brainspec.com/blog/2012/10/08/keyword-arguments-ruby-2-0/

Notorious b.s.d.
Jan 25, 2003

by Reene

Subjunctive posted:

I don't know why you couldn't JIT ruby like you do JS and Lua and PHP -- what parts would be worse? and if you can JIT you can do AOT. you'll have a support runtime, but so do Java and C#.

people haven't done a compiler because nobody has cared enough about performance of ruby to put in the work, not afaict because it's an open research problem.

js and lua are not germane. i know for sure that js is a much more consistent, streamlined language than ruby or python. it was consciously designed by one person. the semantics are difficult to grasp (because it's nuts) but it's less difficult to implement.

php is a more apt comparison. existing compilers for php either a.) produce really loving slow output, just like php (e.g. caucho/resin, facebook's first attempt) or b.) abandon 100% php compatibility as a goal (facebook's second attempt)

people have put a shitton of work into ruby performance, but they've put it into interpreters, where actual gains can be made. jruby and mri 2.x are both much faster than old school ruby. still slow, but half as slow :q:

Damiya
Jul 3, 2012

Notorious b.s.d. posted:

in daily use it's java with a repl and a compiler that's not stupid

also some nice semantics around pattern matching/partial functions amongst others.

I don't get super deep into the type system stuff with Scala and I'll say there's a lot of conveniences to it that feel nice.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Notorious b.s.d. posted:

js and lua are not germane. i know for sure that js is a much more consistent, streamlined language than ruby or python. it was consciously designed by one person. the semantics are difficult to grasp (because it's nuts) but it's less difficult to implement.

Can you give an example of something in Ruby that's not amenable to JIT? I can imagine things like mutable caller frames making certain optimizations harder, but I can't figure out why "emit machine code that operates on the same representations" as a baseline compiler isn't feasible, especially for a JIT that can punt back to the interpreter if someone touches the stupid.

the HHVM team has committed to complete Zend compatibility now, and there are a lot of relevant fixes going in, but I'm sure there'll be some adventures. none of them seem to think that there are pieces that are impossible, though, just annoying. of course Zend PHP isn't completely compatible with itself version to version, so...

JewKiller 3000
Nov 28, 2006

by Lowtax

GrumpyDoctor posted:

i like f# because using it is like looking into the future of c# and vb.net

that's because you're looking at ocaml

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

GrumpyDoctor posted:

i like f# because using it is like looking into the future of c# and vb.net
i like f# because its the closest i can get to haskell while still having a decent ecosystem to play with

and also the closest i can get to haskell while still being able to use it for work

coffeetable fucked around with this message at 07:56 on Aug 26, 2014

Damiya
Jul 3, 2012
just use Scala

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY
i don't know much about scala. java is in many ways a better thought-out language than c#, and there're more than a few bits of f# that just seem to have been nailed on for shits and giggles. thing is, there's some pretty convincing arguments to stay in the .net ecosystem:
  • wpf

ShadowHawk
Jun 25, 2000

CERTIFIED PRE OWNED TESLA OWNER

Shaggar posted:

java is great because it forces everyone to use those standards or leave and go back to their lovely p-langs. all the poo poo p-langers hate about java is what makes it the best language.
Python forces people to use more or less the same formatting standard which is pretty nice

cowboy beepboop
Feb 24, 2001

ShadowHawk posted:

Python forces people to use more or less the same formatting standard which is pretty nice

gofmt was a pretty good idea too

Workaday Wizard
Oct 23, 2009

by Pragmatica
go isnt dead yet?

Sapozhnik
Jan 2, 2005

Nap Ghost

fleshweasel posted:

otoh you could be using c# which is basically java but better in literally every aspect

same, except worse.

Mr Dog posted:

e: bbcode sux

also ugh, never use c#. it is literally strictly worse than java. examples i've found so far:

c# visibility rules are bureaucratic and annoying so i just declare everything public (or equivalently "internal" with a small handful of publics). java's default accesibility is package-scoped, but c# lacks a concept of packages

c# blindly ripped off Java's monitors mechanism without improving on it, but lacks the ability to declare methods synchronized, which is a convenient shorthand just as long as you remember not to lock objects that are not `this' or a freestanding instance of Object that you've created for that purpose

c# doesn't have final fields, it has readonly fields. the difference being that the compiler doesn't guarantee initialisation of readonly fields in your constructors. wtf is the point of using a statically typed language if it doesn't check dumb poo poo like that? oh also c# has const fields for gently caress knows what reason. you can't declare final variables inside methods either.

java enums are classes with a finite number of statically declared instances. c# enums are sugar for various kinds of int. no the type system does not check whether a given variable with enum type actually contains a valid value from that enum, you have to do it yourself, constantly. again, why the gently caress do i have to do this in a statically typed language? if i didn't give a gently caress whether my program was valid or not i'd write it in python.

java has == and .equals(). The latter is verbose, but at least the difference between the two is clear. c# blurs the two by allowing you to override operator== and operator!=, and then you have to watch out for all sorts of gotchas when you implement it in terms of Equals().

in fact operator overloading is dumb in general and idiot fuckers are just going to abuse it. yes i know it's nice to have clean syntax for bignums. programming isn't math, the things going on behind the scenes are important.

c# extension methods are an over-reach and just begging for abuse. java 8's default interface methods are a more constrained solution to the problem that still fulfil the specific use case (i.e. retroactively adding stream operation methods to collections) that this language feature was introduced for.

java 8 has a cleaner and more orthogonal version of delegates now. What it does not have are c# style events; why do these have to be a language feature instead of a library feature? and why on earth do i have to check for null every time i want to fire one? the library conventions around them are idiotic too, but then this is microsoft so expecting a comprehensible and useful api for anything is like expecting insightful commentary on the human condition from an eight year old (mandatory dynamic casts everywhere, seriously?).

c# doesn't have proxy objects, instead you're supposed to use code generation. this is crap, proxy objects are really nice for transparent marshalling. i use them in Java to interact with db stored procs by just declaring an interface that has the same names and it's lovely.

c# and .net's capitalisation conventions are not only ugly, they are poorly designed and introduce grammatical ambiguities quite frequently, e.g. ambiguities between class and namespace names, ambiguities between class and property names.

c# does not enforce java's rule that public class names have to match their source unit's filename. it also does not enforce any particular correspondence between directory structures and namespaces. combine this with the fact that visual studio's refactoring is a turd that has two ways to rename a class (rename the class, rename the file) and only the latter actually changed both the filename and the class name, and all of a sudden you find yourself wishing for java's "bureaucratic" rules back.

c#'s System.DateTime class struct and its partner TimeSpan are a tremendous improvement on the wtf that is java.util.Calendar and friends. However, it's still not that great because DateTime has three different "kinds": utc, local time, and "unspecified". this is stupid, timezones should be completely separate from times. Also java has java.time now, which is a considerable improvement again on c#'s offering.

c# doesn't have checked exceptions. properly applied these are a good thing imo but that's a flamewar that'd been fought to death.

there is precisely one thing that c# does better than java: it has unsigned types. a lot of things in java are really obnoxious in the absence of unsigned types (e.g. always having to remember to promote byte b to int i with an expression of the form i = b & 0xFF, because b is always sign-extended instead of being zero-extended). alright, two things: "ref"/"out" parameters are also nice and i see nothing wrong with those.

i'd say reified generics too but that's more of an under-the-cover slowness issue introduced by compiler-generated dynamic casts. you can always pass a Class object to the generic's constructor if it's really that important, i've not found it to be that big of a deal.

syntaxrigger
Jul 7, 2011

Actually you owe me 6! But who's countin?

Shinku ABOOKEN posted:

go isnt dead yet?

Go looks neat to my scrub eyes. It seems more accessible than C++ but that is prolly just the hype

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

syntaxrigger posted:

more accessible than C++

Brain Candy
May 18, 2006

Damiya posted:

also some nice semantics around pattern matching/partial functions amongst others.

I don't get super deep into the type system stuff with Scala and I'll say there's a lot of conveniences to it that feel nice.

it feels like c++ all over again

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

MALE SHOEGAZE posted:

how much would you need to sacrifice from a language like ruby to make it a useful language?

your children, at the altar of bha'al

raminasi
Jan 25, 2005

a last drink with no ice

Mr Dog posted:

same, except worse.

what about properties

ahmeni
May 1, 2005

It's one continuous form where hardware and software function in perfect unison, creating a new generation of iPhone that's better by any measure.
Grimey Drawer

Mr Dog posted:

same, except worse.

valid criticisms except for base class matching a file name, that's a grognardy clown complaint

ahmeni
May 1, 2005

It's one continuous form where hardware and software function in perfect unison, creating a new generation of iPhone that's better by any measure.
Grimey Drawer
python was good at 2.7 and is sweet at 3.4 and will continue to become better in the future and it makes me happy

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

Notorious b.s.d. posted:

i know for sure that js is a much more consistent, streamlined language than ruby or python.

:frog:

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

Mr Dog posted:

same, except worse.

thanks for this post -- most people seem to say that c# has the better language and java has the better standard library, and i'm interested in understanding why people prefer one or the other :tipshat:

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
I'll play the tbc and say that static typing is way overrated when it comes about catching errors. I'm p sure any kind of trivial testing will catch most of these errors


dynamic typing is great, here's what's wrong in other p-langs:

- in javascript (and php I guess) the combination of weak + dynamic typing brings you a long list of stupid gotchas
- in ruby people hate exceptions or something and like to return nil instead

I guess this is why stuff like tdd is such a big deal in javascript and ruby. yes, in both of these cases I feel like a static typed lang would be more adequate.

but not with python or racket, I swear to god I'll never use this type annotations bullshit once or typed racket again :argh:

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
dynamic4lyfe

Shaggar
Apr 26, 2006
dynamic typing is garbage for garbage people.

Notorious b.s.d.
Jan 25, 2003

by Reene

Symbolic Butt posted:

I'll play the tbc and say that static typing is way overrated when it comes about catching errors. I'm p sure any kind of trivial testing will catch most of these errors

why the gently caress do i want to write hundreds of trivial tests in a separate file instead of expressing my invariants directly, inside the code?

that is the most rear end-backwards thing

qntm
Jun 17, 2009

Symbolic Butt posted:

I'll play the tbc and say that static typing is way overrated when it comes about catching errors. I'm p sure any kind of trivial testing will catch most of these errors

trivial testing that, maybe, the compiler could carry out for you?

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
when I say trivial test, I mean any kind of test

like you'll need to check if factorial(5) == 120 anyway, if you messed something that static typing would catch then just this test would immediately catch the error because it'd return something really stupid instead

I'm not writing asserts around the functions or something

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
if you have a function with the signature void foo(filtered_input bar) and call it with an argument of type string or of type unfiltered_input, the compiler gives you an error and prevents a potentially bad bug

good luck catching that with typical unit testing

hepatizon
Oct 27, 2010

Symbolic Butt posted:

- in ruby people hate exceptions or something and like to return nil instead

would people like to post some examples of ruby core doing this? i write ruby for a living and i don't encounter this much

Notorious b.s.d.
Jan 25, 2003

by Reene

Subjunctive posted:

Can you give an example of something in Ruby that's not amenable to JIT? I can imagine things like mutable caller frames making certain optimizations harder, but I can't figure out why "emit machine code that operates on the same representations" as a baseline compiler isn't feasible, especially for a JIT that can punt back to the interpreter if someone touches the stupid.
i started working on an effort post about this but then found someone else did a better job. mutable caller frames are a recurring complaint in this guy's essay.

and it's worse than you think. e.g. closures retain the ability to edit their enclosing frame for as long as they exist.

Subjunctive posted:

the HHVM team has committed to complete Zend compatibility now, and there are a lot of relevant fixes going in, but I'm sure there'll be some adventures. none of them seem to think that there are pieces that are impossible, though, just annoying. of course Zend PHP isn't completely compatible with itself version to version, so...

well "not impossible but annoying" includes all the cases that are hilariously slow, or require it to stop the world while it compiles and loads a new module on the fly.

common lisp always had the problem that while it was very possible to write a fast CL compiler, people once expected to be able to load/generate new code at runtime on a regular basis, not as a rare event. 80s and 90s CL implementations solved this by including a bytecoded interpreter IN ADDITION TO the compiler

modern CL systems omit the bytecode interpreters, because codebases that abuse code generation have become rare. CL implementors have concluded that it's better to implement that case in an incredibly slow way (compile poo poo on the spot) in order to keep their implementation simple

in ruby, generated and runtime-modified code is 100% completely normal. method_missing and refinements are as bad as perl's autoload and BEGIN blocks.

gonadic io
Feb 16, 2011

>>=

Symbolic Butt posted:

I'll play the tbc and say that static typing is way overrated when it comes about catching errors. I'm p sure any kind of trivial testing will catch most of these errors

yes, some kind of way to test your code...statically...all at once

MononcQc
May 29, 2007

Static type systems are way more helpful in helping you design your software around them. And you must embrace the types if you want to benefit from it. They let you express the broad ideas about the data that your app operates on, and makes sure you didn't make any mistake in how the different pieces fit together.

If you get into the case where you decided that Distance is an int, you still run into the issue that you're going to eventually plug in imperial units with metric units and explode a shuttle. You really have to be careful about building a type zoo rich enough to actually represent the problems you're working on and the data you're using in order to prevent errors with types at a higher level than the primitives given to you by the language.

If you go lazy on your usage or whatever, you don't necessarily cover the most important type errors, you'll just cover the most obvious ones, along with the same false confidence you'd get from tests.

FamDav
Mar 29, 2008

hepatizon posted:

would people like to post some examples of ruby core doing this? i write ruby for a living and i don't encounter this much

Array#first

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

MononcQc posted:

Static type systems are way more helpful in helping you design your software around them. And you must embrace the types if you want to benefit from it. They let you express the broad ideas about the data that your app operates on, and makes sure you didn't make any mistake in how the different pieces fit together.

If you get into the case where you decided that Distance is an int, you still run into the issue that you're going to eventually plug in imperial units with metric units and explode a shuttle. You really have to be careful about building a type zoo rich enough to actually represent the problems you're working on and the data you're using in order to prevent errors with types at a higher level than the primitives given to you by the language.

If you go lazy on your usage or whatever, you don't necessarily cover the most important type errors, you'll just cover the most obvious ones, along with the same false confidence you'd get from tests.

what are your thoughts on passing a tag+data tuple to a process/task/whatever and letting the process/task/whatever crash when it encounters a tag it doesn't recognize vs sending the message without a tag and pattern matching on the type of the data? (if what i just said makes sense)

hepatizon
Oct 27, 2010

FamDav posted:

Array#first

sure, array indexing and hash lookups count as an example, although i personally find this convention works great for me. any others?

hepatizon fucked around with this message at 16:41 on Aug 26, 2014

MononcQc
May 29, 2007

Otto Skorzeny posted:

what are your thoughts on passing a tag+data tuple to a process/task/whatever and letting the process/task/whatever crash when it encounters a tag it doesn't recognize vs sending the message without a tag and pattern matching on the type of the data? (if what i just said makes sense)

I prefer to wrap that stuff in a function call that sends the data to the process (but is owned in the process' module). Do the verification and assertions there, outside of the more critical/stateful process, and if something is wrong, you crash the caller, not the process. If the process crashes, then you know you've forgotten an important assertion, but hopefully it doesn't need to ever crash on type stuff.

Move all dynamic type verifications, assertions, etc. to the edge of the system (so for a process, to the caller) and assume that what makes it inside is safe. This makes poo poo easier to test (whether through unit tests, integration tests, property-based tests, etc.), and will also make it much easier to play with type checkers like Dialyzer, which can't really track types over an untyped mailbox, but will do it fine otherwise.

Doing that also makes it much easier to reason about your system. Once you've cleared all the thinking about "am I getting the right kind of data?" out of the way, you're free to reason about the task to actually accomplish and that lets you keep far less stuff inside your head that's not directly relevant to the problem.

At this point, tags are useful to have because they more or less represent types themselves (except they're just enacted at runtime) and make it easy to crash early, and Dialyzer will have an even easier time figuring that poo poo out that way.

E: I make heavy assumptions of Erlang due to using processes, message passing, pattern matching, tag/tuples, etc. Maybe that was wrong?

MononcQc fucked around with this message at 16:51 on Aug 26, 2014

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

yeah, using types to represent narrower classes of data state rather than just representation can be really valuable, but you don't see it very often. Java doesn't have a different type for UnvalidatedCertificate vs ValidatedCertificate, AFAIK. so you're writing tests, and those tests will catch string-vs-int representation mismatch as well. there's a good paper I'll try to dig up.

I like type systems as compiler-enforced documentation, but they're pretty underused from the perspective of actually preventing bugs statically.

Adbot
ADBOT LOVES YOU

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

FamDav posted:

Array#first

wait what does Array#first [Nil] return then

or whatever the syntax is

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply