Open Side Menu Go to the Top
Register
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

04-16-2018 , 12:16 AM
Quote:
Originally Posted by blacklab
#!/usr/bin/perl
$e="the it";
$d="the quick brown fox quick fox fox brown it jumped";
while($d=~/(\w+)/g){if($e!~/$1/){$c{$1}++}}
foreach$n(sort{$c{$b}<=>$c{$a}}keys%c){print"$n $c{$n}\n"}

fox 3
quick 2
brown 2
jumped 1
even perl is rather verbose for golfing. java golf is straight masochism.

J fares better, but not as well as the pure golf langs like Jelly, which could likely solve this problem in 10 chars or so. Here's a not even particularly golfed J version in 31 chars:

Code:
NB. sample data
w=.;:'the quick brown fox quick fox fox brown it jumped'
e=.;:'the it'

NB. the solution is f
NB. using 3 instead of 25 for demo purposes

f=. ([:3&{.[:(\:{:"1)~.,.<@#/.~)@-.
Try it online!

Ungolfed version:

Code:
([: 3&{. [: (\: {:"1) ~. ,. <@#/.~)@-.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-16-2018 , 12:21 AM
Quote:
Originally Posted by Sholar
Code:
cat source.txt | tr ' ' '\n' | sort | uniq -c | sort -nr | head -25
seems halfway there (not handling stopwords) and easy enough to slot in punctuation and whatever other refinements.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-16-2018 , 12:44 PM
Quote:
Originally Posted by ChrisV
My favourite piece of Java hate, which I've posted before ITT, is that there's an Arrays.toList() method, which takes an array and produces an ArrayList. Easy! Except that this ArrayList is not a java.util.ArrayList, but a java.arrays.ArrayList, which looks and acts exactly the same unless you try to mutate it, in which case it will compile and then throw an exception at runtime. I consider this proof that the programmers of Java actually were trolling us.
But typescript >>>> javascript.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-16-2018 , 12:46 PM
Quote:
Originally Posted by jmakin
Chris - i may mess around with it later but I had to be extremely careful with how I decided to do things because the file we're parsing is pride and prejudice which is an extremely large book and has about ~11,000 unique words.
Use perl. It would probably be 20x less code and 100x faster.

Last edited by suzzer99; 04-16-2018 at 12:47 PM. Reason: nm my pony got parsed by blacklab
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-16-2018 , 01:16 PM
I use java because it’s easy to turn in and for the TA to compile and run on his machine, plus I don’t know perl
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-16-2018 , 02:03 PM
Quote:
Originally Posted by suzzer99
But typescript >>>> javascript.
not sure how this applies in any way
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-16-2018 , 02:11 PM
Quote:
Originally Posted by suzzer99
But typescript >>>> javascript.
I'm not sure why this is a response to Chris's post, but yes, this is a true statement.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-16-2018 , 02:23 PM
Chris's post shows the weird pain that can come with casting types and similar built in types - which you never have to worry about in regular JS. I've had similar hassles trying to feed http headers to an HTTP service in angular 2 and had to jump through all kinds of hoops to cast a simple hash into an HttpInputParamaters object (or w/e it was called). I had tons of Java flashbacks.

There's reason why Javascript chose dynamic typing to begin with. Can you name anything significant that's changed so much about the browser (or node which was built on dynamic typing) that static typing with a klugey add on is now superior? Certainly the option was available to bake in static typing from the beginning if that was deemed superior.

I agree static typing makes people more comfortable who come over from Java or C#. Also auto-complete of 3rd party libs is sweet. But I don't think those outweigh the extra cruft and slowdown. For sure not in node. Obviously with angular 2+ you need it so that's fine.

I can be crusty about learning new things - so I force myself to use important new technology even if I don't think it's superior. IE - I didn't use a linter for a long time, then finally forced myself. Within a few hours I immediately realized I was an idiot for not using it from the beginning. I feel pretty confident that if a technology is superior I will pick up on that after using it for a while.

I used typescript in node for months and never saw any kind of advantage as far as sniffing out run time issues at compile time (that a linter wouldn't also catch). The extra compile step slows node down. Debugging is a mess. And other than auto-complete, which is awesome - in every other way development is slowed down considerably.

The whole key to node imo is to quickly spin up new components and expand scope in a modular way. Stuff like factories and rigid types slow that down imo. Composition over inheritance. Yes you can do static typing w/o inheritance but what's the point?

Typescript is turning node into weblogic imo. The java devs at my old corporate job don't feel comfortable without compile-checking, so they love it. And if it grinds node reboot, debug and dev time down to where you lose half the advantage over Weblogic - they're fine with that because they have no concept how to do node right - and would rather just stick to Java anyway.

Last edited by suzzer99; 04-16-2018 at 02:38 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-16-2018 , 02:50 PM
We had a "notable JS expert" do a 2 day training thing with us last week and he more or less said the above re: Typescript. It solves a problem I don't have. I guess if it makes C# people happy go nuts otherwise its a giant waste of time.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-16-2018 , 04:30 PM
Quote:
Originally Posted by suzzer99
Stuff like factories and rigid types slow that down imo. Composition over inheritance.
...
Typescript is turning node into weblogic imo.
There's a difference between a language and how people choose to use it - you might as well blame JS dynamic typing for people writing poorly documented libraries that rely on objects having magic properties or something. Type safety doesn't mean you have to write factory classes.

I think it's pretty ****ing magical in TS when I can write complex array operations with map/reduce/whatever and the compiler can verify without me even running my code that it's doing what I wanted and generating the result I expected (usually without me even having to specify types, because it correctly infers types based on the existing vars I use and the code that I write to modify them).
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-16-2018 , 05:30 PM
We use typescript and I don't think it's a waste of time, although I agree there are cases where I prefer not to be encumbered with typing. But with typescript I can do that, when I want.

I could imagine even agreeing with the "notable JS expert", it may be a problem he doesn't have. For me, I want typing mostly in large code bases with many authors where it makes it a lot easier to understand how the public interfaces between different parts of the system work together, how to consume those interfaces and what to expect as output, and also a lot easier to do certain kinds of refactoring where the compiler is going to help me know all the places in the code that have to be changed. I find those benefits pretty compelling and have actually relied on them in practice, but I can imagine lots of projects where I wouldn't be as worried about them also.

It's at least possible that we could have gotten some of those benefits with a different linter, I'm not 100% sure. We implemented typescript as part of a plan to upgrade to newer versions of Angular, so we didn't bother evaluating some of those alternatives. So I wouldn't necessarily argue that everyone should adopt it but I don't think it's been worthless.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-16-2018 , 07:52 PM
Oh God are we seriously doing this AGAIN?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-16-2018 , 07:55 PM
Lol I'm done sorry
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-16-2018 , 08:18 PM
I'm agnostic about TypeScript. I've used it a little and it just seemed kind of annoying, but I probably didn't get to the point where I was seeing the benefits.

Java sucks because Java sucks. The functional stuff in it sucks because, like TypeScript, it's a new feature awkwardly nailed on to an existing language. (So is LINQ in C#, but they somehow made that good). I think complaints about static typing generally come from people who have never used a modern statically typed language, with good support for functional programming, anonymous types, etc. As of C# 4.0, you can even ignore static typing if you want to, by using the "dynamic" keyword for everything, but nobody does because it provides no benefit.

The difference is just not as great as people make out anymore. Linters in JavaScript provide many of the benefits of static typing. Modern statically typed languages allow you to write much as you would in a dynamic language. I don't find writing in C# or writing in JavaScript to be hugely different experiences. Writing in Java, I feel like the language is constantly getting in my way.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-17-2018 , 06:26 AM
(yes, we're doing this again)
Quote:
Originally Posted by suzzer99
The whole key to node imo is to quickly spin up new components and expand scope in a modular way. Stuff like factories and rigid types slow that down imo. Composition over inheritance. Yes you can do static typing w/o inheritance but what's the point?
Static typing has nothing to do with oop methodologies (inheritance, factories etc). You can do oop without static types and vice versa. And you can easily do composition with static types.

I'd also like to second that Typescript is not the best example to judge static types by, because it is an afterthought and not core to the language. My personal experience with dynamic vs static (js vs java/c++) is that dynamic makes it easier to develop quickly, while static makes it easier to develop robustly. Depending on the domain, one can be preferable over the other, e.g. front-end vs back-end.

Last edited by Wolfram; 04-17-2018 at 06:32 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-17-2018 , 04:20 PM
I learned PHP in my web apps class today and realized I could do that golf problem in like ~100 chars.

i like php arrays but man that language looks so ugly
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-17-2018 , 06:29 PM
PHP is a really prime example of how a reasonable piece of technology can also be a piece of **** if you don't actually try to design it, but instead just wing everything.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-17-2018 , 07:14 PM
Anyone know if you can multi account aws or is that free tier abuse?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-17-2018 , 08:39 PM
Quote:
Originally Posted by PJo336
Anyone know if you can multi account aws or is that free tier abuse?
I dunno man, define "can"

Like, is it possible to do so? Probably. Do they want you to? No.

The free tier stuff is like.. a few tens of dollars/month at most? Call me old/jaded but I moved from a hosted environment to AWS a long time go, going from $120/mo to like $20-30/mo for very similar results.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-17-2018 , 08:51 PM
Quote:
Originally Posted by RustyBrooks
I dunno man, define "can"

Like, is it possible to do so? Probably. Do they want you to? No.

The free tier stuff is like.. a few tens of dollars/month at most? Call me old/jaded but I moved from a hosted environment to AWS a long time go, going from $120/mo to like $20-30/mo for very similar results.
My team makes fun of me because I drop like 30 bucks on food delivery for one dinner and then nitpick a 5 dollar difference on a month of server costs. Ill get over it someday...probably not


That said, im gonna give Firebase a spin
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-18-2018 , 10:31 AM
getting much stronger at bash/vim/gdb, classmates remark at how quickly I do things in the lab lol. also, this is my first heavy exposure to C and I'm really enjoying it. IMO everyone should start out by learning C, I have no idea why they start with java/python.

one small irritating thing, I can't quite figure out how to yank an entire file in putty and paste it into windows.

ggVG will select an entire file, but multiple different methods of yanking doesn't yield anything. copy pasting from windows into putty is fine.

Last edited by jmakin; 04-18-2018 at 10:45 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-18-2018 , 10:53 AM
I personally think people should start with C (not C++!) also. My first class was Pascal but they replaced it with C++ the next year. I actually don't think Java is a very good first choice because it has a lot of complicated and verbose syntax that makes the whole thing look more complicated than it is. C is very bare-bones syntax wise.

I wonder how many CS grads even learn C any more? It's still heavily used in kernel development and probably will be for some time.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-18-2018 , 11:03 AM
C should probably be taught at some level at some point in a CS curriculum. But when/where depends on the goals/courses. First course? Definitely not. I think usually you want to be starting off with something that teaches more core/common/conceptual topics, maybe either Python or C#, and start to learn some basic patterns/algorithms. C is great for an OS course or something later on.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-18-2018 , 11:12 AM
Quote:
Originally Posted by jmakin
one small irritating thing, I can't quite figure out how to yank an entire file in putty and paste it into windows.

ggVG will select an entire file, but multiple different methods of yanking doesn't yield anything. copy pasting from windows into putty is fine.
The yank buffer only exists inside vim. It's probably easiest to just copy the file using winscp.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-18-2018 , 11:19 AM
I think learning java/python is far more complicated than learning C. I mean the C syntax is super easy, the library's pretty small and easy to understand, and doesn't require some super complicated and annoying IDE like java/C++ frequently do (early on in programming classes).

It's more prone to user error but that's why I think it'd be a good language to start with. The first time you seg fault on an array because of an off by 1 error in a loop and spend an hour looking for it will make you way more careful.

in java you get some meaningless (to the beginner) exception (what's an exception?) and it'll tell you exactly where and how you went wrong. and don't even get me started on trying to explain the JVM to a newbie, i'm 5 years into this and i still barely understand it. I accidentally registered for a compiler project course and the project was literally "implement the JVM" and i never clicked "drop" so fast in my life.

This is by far the most enjoyable language I've programmed in for some reason. I did some C programming last quarter for a microprocessor but I just donked my way through the course and had no idea what I was doing.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m