Better HN
topnewbestaskshowjobs
Log inSign up

scriptkiddy

559 karma · joined Aug 26, 2016 (10y ago) · 276 submissions

Submissions

comment 9y ago · link · parent

Just so you know, you can launch an executable and it's icon will pop up in the launcher. If you right-click the icon, you can select `Lock to Launcher` and the icon will persist after the application is closed. Still not ideal, but it may hep you.

Ideally a user should be able to simply drag and drop an application or file directory to the launcher.

It would also be cool to have folders in the launcher for quick access to certain directories where hovering over the icon opens a miniature browser. Sort of like the Android launcher.

comment 9y ago · link · parent

You may live in a country where the government subsidizes the laying of communications infrastructure. Laying fiber or even just coaxial cable is extremely expensive.

comment 9y ago · link · parent

Oh, you were asking about inheritance, not objects. My bad. I'd say composition is almost always preferable.

That said, single level inheritance can be useful if you need to have multiple different objects that require very similar business logic but contain vastly different data.

A good example of this is Django's class based `View` class. I'm not talking about all the mixin views Django offers, just the simple generic `View` class. It handles routing to specific methods based on HTTP request METHOD. That eliminates the need to write the same ~100loc over and over. The alternative would be to use function based views. However, with function based views you end up basically recreating what the class does anyways after checking for each HTTP request method.

comment 9y ago · link · parent

When modeling objects that need to encapsulate mutable data and pass messages between one another.

comment 9y ago · link · parent

Here's a couple I watch regularly with some great content:

- Computerphile: Interesting stuff about computer hardware and software: https://www.youtube.com/channel/UC9-y-6csu5WGm29I7JiwpnA

- Deep Astronomy: Space stuff: https://www.youtube.com/channel/UCQkLvACGWo8IlY1-WKfPp6g

- Deep sky videos: more space stuff: https://www.youtube.com/channel/UCo-3ThNQmPmQSQL_L6Lx1_w

- Grant Thompson: Expiriments, building things, explosions: https://www.youtube.com/channel/UC1zZE_kJ8rQHgLTVfobLi_g

- Numberphile: math stuff: https://www.youtube.com/channel/UCoxcjq-8xIDTYp3uz647V5A

- Nurdrage: chemistry experiments: https://www.youtube.com/channel/UCIgKGGJkt1MrNmhq3vRibYA

- Retro game mechanics: implementation of retro gaming software and hardware: https://www.youtube.com/channel/UCwRqWnW5ZkVaP_lZF7caZ-g

- Sixty symbols: general physics stuff: https://www.youtube.com/channel/UCvBqzzvUBLCs8Y7Axb-jZew

- Stuff they don't want you to know: conspiracies:https://www.youtube.com/channel/UCrrOic-og4HzhleZqOq4L-A

- Vsauce: Thought experiments, interesting facts, etc: https://www.youtube.com/channel/UC6nSFpj9HTCZ5t-N3Rm3-HA

I don't know if you're into gaming or inane comedy, but I also watch a lot of Funhaus: https://www.youtube.com/channel/UCboMX_UNgaPBsUOIgasn3-Q. dfinitely not for everyone.

comment 9y ago · link · parent

Inheritance is a useful tool when used sparingly. Ideally it should be used to encapsulate logic that is going to be re-used multiple times. I don't really think there are pros and cons as much as there are trade-offs between the 2 paradigms.

comment 9y ago · link · parent

I can think of a couple.

Write a small toy document database with an integrated ORM. Tables/documents can be modeled as objects and the query API can be built using a functional paradigm. Doesn't need to be fancy. Could be a simple key/value store really.

Or how about an HTML generation library?

Or how about a toy web server?

How about a command line argument parser for your favorite language?

How about a small library for geometric calculations?

There are many languages that have multi-paradigm support. One of my favorite multi-paradigm languages in still in it's growing phase, but it's fun to learn: https://nim-lang.org/

comment 9y ago · link · parent

I agree that all programs can benefit from lower-level concepts. That said, that's not how I understood the article.

comment 9y ago · link · parent

As I said above, I believe a mixture of paradigms tends to be the best approach for most software.

I think OOP is a better way to build an ORM. That said, the query constructors might benefit from a FP approach.

I think FP is a better way to build a mathematics library. That said, data structures might be better represented as objects.

It really depends on the specific application.

I also want to clarify that OOP does not necessarily require inheritance and such.

comment 9y ago · link · parent

I wouldn't have any problem with those abbreviations, I just wouldn't use them myself.

comment 9y ago · link · parent

Agreed. I use PyCharm for my day job, so I don't really have a problem with long variable names.

comment 9y ago · link · parent

Arguably, A person who is familiar with the operation of a cart would be at least somewhat familiar with the operation of a car in that they both roll in a specific direction based on user input.

That said, the complexity of operation in a car arises from increasing the number of controls from 1 to, at minimum, 10. I would say the cart to car analogy is more akin to learning a complex API.

I would say that a better analogy for traditional languages vs. Haskell is that of a car to a fighter jet. The fighter jet is faster and really really good at certain things like movement on 2 planes and firing missiles. However, the fighter jet is orders of magnitude more difficult to operate and requires much more maintenance. For real world concerns such as getting groceries or transporting furniture, a car is the much more practical choice. I mean, we'd all love to own a fighter jet, but would any of us really have a use for it other than screwing around?

comment 9y ago · link · parent

I've always taken the approach of making variable/function/class names as verbose as they need to be. I do not use any sort of abbreviation in function or class names. However, I will sometimes use abbreviated variable names or function arguments. For instance, if I had a function that searched for and returned an object that has a specific property from a list, I might use the name 'find_object_with_property'. The arguments might be 'list' and 'prop'.

It's been said many times that naming things is the hardest problem in programming.

comment 9y ago · link · parent

While there are some parts of this matrix I agree with, I have to say that it seems rather "old school". The matrix seems to assume that all programmers are systems-level programmers working with compiled languages. Dynamic languages are only listed in the "scripting" knowledge section. There are tons of huge projects written entirely in dynamic languages. Assuming that dynamic languages are only for writing small scripts is disingenuous.

The next improvement I can suggest is to remove the implications that knowing the FP paradigm somehow makes you a better developer, or that only a good developer can use FP. FP is a useful tool just like OOP or imperative programming. Generally speaking, a good developer should be able to compose multiple paradigms together where they fit in the problem space. Maybe if this section of the matrix were reworded to say something along the lines of "Able to use multiple paradigms in their equivalent problem space including OOP, FP, and imperitive programming to create quality software." it would be better.

I do like how the author included a section for communication skills. Too often we, as developers, forget that we are ultimately only as good as the team around us is. We should work our hardest to improve our team in order to increase the quality of our work. That starts with effective communication.

comment 9y ago · link · parent

Here's the logic:

Scenario A: We spend a ton of money and resources on combating climate change. Energy and fuel become more expensive. There is economic crisis in some areas of the word. There is large scale refugee migration. Some small proxy wars break out. We manage to stem climate change and even slightly reverse it back to a natural level. We keep our modern technology. We keep most of the cultural status quo. Maybe a couple hundred million people lose their lives due to indirect consequences. The Earth still spins. Coastal cities aren't underwater. There is no global famine. Climate change skeptics will complain that combating climate change was a bad idea because they didn't see the worst of it.

Scenario B: We decide to not try and combat climate change. We don't spend any money on it. We think "everything will work out". Everything goes on just like normal for a few decades. Climate change skeptics are saying "I told you so." The economy prospers. Technology improves. We continue our dependence on fossil fuels, continuously pumping carbon into the atmosphere. We continue dumping waste into the ocean. The permafrost continues to melt more and more every year. It's all so gradual that barely anyone notices. Coastal cliff faces in California start eroding and taking beach front property with them as the sea level rises. Farms at lower latitudes start having more and more of a difficult time producing good yields. There is less snow falling in the mountains meaning that come spring time there is less melt. This causes droughts in many parts of the world. This drought starts to impact farmers. The global food supply dwindles. We are noticing massive numbers of oceanic lifeforms start to die off. Fisheries are not able to keep up with the demand. There isn't enough feed for livestock. The global food supply falls even lower. The drought is getting worse over the years due to less snow melt. Smaller countries with sub-par infrastructure start seeing a massive exodus of their population. These refugees migrate to large developed nations causing cultural strife and putting a strain on their economy and food supply. This cultural and economic strain leads to warfare. This warfare leads to even larger migrations. Soon we have world war 3 in the midst of the greatest global famine and drought the world has ever seen. Billions of people die. Human civilization as we know it is destroyed. We regress culturally and technologically.

This is just one set of possible scenarios. So, I ask you; Why not spend a little bit of money now and avoid what is essentially the apocalypse later? Let's say I'm wrong. Let's say scenario B could never happen and climate change isn't as bad as we think it is. Well, you have insurance on your house, don't you? Your car? Think of combating climate change like car insurance. Even if an accident is unlikely, it's still nice to know that you have it covered if it does happen.

comment 9y ago · link · parent

> It's not that it's confusing, rather it's unnecesarrely cumbersome because it's explicit and because you have to put it as an argument.

I don't feel the same way. To each their own I guess.

Regarding your example, I don't see anything wrong with the second version. Anyone who reads the code will easily be able to tell what it does and where the variables come from. In your third example, how is anyone supposed to know whether or not `x`, `y`, and `z` are class variables or global variables? Kind of defeats the purpose of namespacing, I think.

> What I find worse than that is that you have to specify self in the parameter list.

This is really one of Python's implementation details. Methods can be bound or unbound. Without going into to much detail, just know that a bound method can be used as a regular function. Here is some code to illustrate what I mean:

    >>> class A():
    ...     def a(self):
    ...         print('hello')
    ... 
    >>> A
    <class '__main__.A'>
    >>> A.a
    <function A.a at 0x7fc4009381e0>
    >>> A.a()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: a() missing 1 required positional argument: 'self'
    >>> A().a()
    hello
    >>> b = A()
    >>> A.a(b)
    hello
    >>> class B():  
    ...     pass
    ... 
    >>> b = B()
    >>> A.a(b)
    hello
    >>> class B():
    ...     def a(self):
    ...       print('goodbye')       
    ... 
    >>> b = B()
    >>> A.a(b)
    hello
    >>> c = A()
    >>> B.a(c)
    goodbye


Self does not have to be the same class it's called on. It can be any class. However, if you try to access a class attribute that doesn't exist, you get an attribute error.

    >>> class C():
    ...     x = 10
    ...     def a(self):
    ...         print(self.x)
    ...
    >>> C.a()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: a() missing 1 required positional argument: 'self'
    >>> C().a()
    10
    >>> a = A()
    >>> a.a()
    hello
    >>> C.a(a)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "<stdin>", line 4, in a
    AttributeError: 'A' object has no attribute 'x'
Since bound methods need to behave like regular functions, it is improper to not pass the object instance to the function.

comment 9y ago · link · parent

I'm aware. The `self` vs `cls` thing is convention. You can call either argument whatever you want.

comment 9y ago · link · parent

Could you please explain? It's always very clear in Python what `self` refers to. Self is always an instance of the parent object of a method. Some classes can also have static class methods that can be called from the class itself instead of one of it's instances. Maybe that is where your confusion is arising?

comment 9y ago · link · parent

Let me put it to you this way:

There is no place to live that is totally safe from bad weather. It is in the best interest of every citizen of the United States to pay for climate and weather modeling as disastrous weather can have massive impact on the economy. Also, from a moral standpoint, I personally don't mind shelling out some money to try and keep people safe.

As to your point about people living in areas where weather tends to be statistically more dangerous: If the government came to your house and forced you to leave, how would you feel about that?

comment 9y ago · link · parent

I think I may have misunderstood your point after re-reading.

I thought you were implying that compiled binaries do not have dependencies. Now I can see that is not the case.

comment 9y ago · link · parent

>Could you give an example of what "system libraries" would pose a problem in my example of using Rust with cargo?

Specifically things like xorg libs, libmpeg, libsdl, and such. Not that Rust would have a problem interfacing with them, just that they would need to be present regardless of whether or not someone was just trying to run a distributed binary.

Agreed that you wouldn't need a VM like CPython or the JVM. However, Rust isn't unique in that department. Almost all languages that compile to binary executables have this advantage.

comment 9y ago · link · parent

I guess this is true if you don't need to interact with any system libraries.

comment 9y ago · link · parent

I'm sorry, but I need to question the validity of this claim. People have been living in very warm climates for a very long time.

I myself have been camping in the Mojave for several days at a time with temperatures high above 100 degrees Fahrenheit.

Are you implying that the combination of heat and humidity is the deadly combination? If so, can you provide some evidence?

comment 9y ago · link · parent

In the case of the Json module, I totally agree. I'm not really concerned with Performance either. It's mostly API flexibility that I care about. I mean, urllib is always such a great example of an overcomplicated and inflexible API with bad naming conventions. The Json module really did a good job in learning from previous mistakes. `json.loads()` and `json.dumps()` couldn't be any easier to use. Though, I would argue that the json module's ease of use is owed more to the fact that Python dictionaries map pretty much 1-to-1 with JSON already.

comment 9y ago · link · parent

Python has a history of treating standard library modules as a sort of reference implementation. Look at urllib and urllib2 for example. No self respecting Python dev will use either of those two packages if they can help it. They'll use requests instead. Other examples include Python's standard library json/xml parsers. Nobody really uses them out of the box. In my work, the only standard library module I really use extensively is the collections module.

comment 9y ago · link · parent

>There are cases where you could justify writing "except Exception as e" and having it return a value

I actually use this pattern quite frequently in one very specific place. I use marshmallow to handle schemas for my API. On endpoints that require creating or updating a model, it's often difficult to write an exception for every single possible error type. Therefore, I usually try to catch ValueErrors, IndexErrors, etc explicitly. However, as a last line of defense I do have an except Exception as e. This is to catch and document any exception that I may not know of. Ideally, this ends up catching library defined exceptions that do not inherit from a standard defined exception or inherit from Exception directly. I haven't hit this line yet on any of my views, but when I do I'll know exactly what exception I need to catch.

comment 9y ago · link · parent

This is great info! Definitely gave me some stuff to think about.

I think I'll check out thesquatrack.com for some ideas.

Regarding your point about native vs web apps: I have never built a native app before. That said, I'm sure it can't be all that difficult. I have built my back end to be fully decoupled from the front end and work entirely through an API. Shouldn't be too difficult to get the data onto a mobile device. Something new to learn I guess. I have also heard about "native" apps; where the app is "installed" on the device, but it really just opens up a windowless browser.

Thank you!

comment 9y ago · link · parent

I'm working on an open source fitness platform. Think Github/Gitlab, but for fitness enthusiasts.

Basically, a training program is kind of like a repository that can be edited and improved by the community. Same with individual exercises.

Now, this ends up being much more difficult to implement than you would think at first glance. I already have the basic application structure laid out in what I believe to be a maintainable and extensible manner.

My mission statement is as follows:

"To create a self-curating community that demystifies physical fitness and makes information on fitness freely available."

One of the use cases I have envisioned is a user being able to declare that they are following a program. The user can then record their numbers for each individual set/session. The user can then view their progress in the form of various graphs and other visualizations. I believe this feature is important because I believe that many fitness beginners have a difficult time taking notice of their progress and become discouraged.

I don't necessarily have any technical questions. I would just like some feedback from fitness beginners and long time fitness enthusiasts. specifically:

- Have you used a fitness tracking app before? What did you like about it? Where could it have been improved?

- Does it matter to you if an app is browser only with a good mobile ui? Do you prefer web apps or native apps for tracking fitness/calories/etc?

- Have you tried to improve your fitness before and failed? If so, what was the reason you became discouraged?

- What kind of search/filtering functionality do you think would be most helpful for you to find a fitness program that suits your needs?

- The application itself is open source. There is no subscription/membership fee. No monthly subscriptions. Do you think an application like this one could subsist off of donations alone?

- Any other feedback?

Thanks for reading this, and if anyone wants to help, you can view the repository here: https://github.com/FFX01/fithub2

comment 9y ago · link · parent

I for one applaud Dropbox's devotion to Python. They are really helping to move the Python community forward.

I also think Kevin hits the nail on the head regarding what makes speeding up Python difficult. It's the same thing that makes writing Python so enjoyable: the object model.

240.

Nim Lang is getting a podcast(forum.nim-lang.org ↗)

17 points · by scriptkiddy · 9y ago · discuss

1
678910